-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add token-logo fix, and use latest jupiter code * wip token logo and prices * update the deprecated signatures method (#33) * removed unverifiedTokens, add dynamicComputeUnits, removed 0 priorityFees, add discussion on priorityFees * fix comment * Revert "fix comment" This reverts commit ec2fa55. * Reapply "fix comment" This reverts commit 154922e. * Revert "Reapply "fix comment"" This reverts commit 34b037b. * remove priorityfees and dynamic fee changes --------- Co-authored-by: Utkarsh <[email protected]>
- Loading branch information
1 parent
2c42e76
commit b962c4c
Showing
18 changed files
with
878 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,70 @@ | ||
import useGovernanceAssets from '@hooks/useGovernanceAssets' | ||
import { getTreasuryAccountItemInfoV2 } from '@utils/treasuryTools' | ||
import React from 'react' | ||
import { getTreasuryAccountItemInfoV2Async } from '@utils/treasuryTools' | ||
import React, { useEffect, useState } from 'react' | ||
import AccountItem from './AccountItem' | ||
import { AssetAccount } from '@utils/uiTypes/assets' | ||
import Loading from '@components/Loading' | ||
|
||
const AccountsItems = () => { | ||
const { | ||
governedTokenAccountsWithoutNfts, | ||
auxiliaryTokenAccounts, | ||
} = useGovernanceAssets() | ||
const accounts = [ | ||
...governedTokenAccountsWithoutNfts, | ||
...auxiliaryTokenAccounts, | ||
] | ||
const accountsSorted = accounts | ||
.sort((a, b) => { | ||
const infoA = getTreasuryAccountItemInfoV2(a) | ||
const infoB = getTreasuryAccountItemInfoV2(b) | ||
return infoB.totalPrice - infoA.totalPrice | ||
}) | ||
.splice( | ||
0, | ||
Number(process?.env?.MAIN_VIEW_SHOW_MAX_TOP_TOKENS_NUM || accounts.length) | ||
) | ||
|
||
const [sortedAccounts, setSortedAccounts] = useState<AssetAccount[]>([]) | ||
const [isLoading, setIsLoading] = useState(true) | ||
|
||
useEffect(() => { | ||
const sortAccounts = async () => { | ||
try { | ||
setIsLoading(true) | ||
const accounts = [ | ||
...governedTokenAccountsWithoutNfts, | ||
...auxiliaryTokenAccounts, | ||
] | ||
|
||
// Get all account info in parallel | ||
const accountsWithInfo = await Promise.all( | ||
accounts.map(async (account) => ({ | ||
account, | ||
info: await getTreasuryAccountItemInfoV2Async(account) | ||
})) | ||
) | ||
|
||
// Sort based on the fetched info | ||
const sorted = accountsWithInfo | ||
.sort((a, b) => b.info.totalPrice - a.info.totalPrice) | ||
.map(({ account }) => account) | ||
.splice( | ||
0, | ||
Number(process?.env?.MAIN_VIEW_SHOW_MAX_TOP_TOKENS_NUM || accounts.length) | ||
) | ||
|
||
setSortedAccounts(sorted) | ||
} catch (error) { | ||
console.error('Error sorting accounts:', error) | ||
} finally { | ||
setIsLoading(false) | ||
} | ||
} | ||
|
||
sortAccounts() | ||
}, []) | ||
|
||
if (isLoading) { | ||
return <div className="space-y-3"><Loading></Loading></div> | ||
} | ||
|
||
return ( | ||
<div className="space-y-3"> | ||
{accountsSorted.map((account) => { | ||
return ( | ||
<AccountItem | ||
governedAccountTokenAccount={account} | ||
key={account?.extensions.transferAddress?.toBase58()} | ||
/> | ||
) | ||
})} | ||
{sortedAccounts.map((account) => ( | ||
<AccountItem | ||
governedAccountTokenAccount={account} | ||
key={account?.extensions.transferAddress?.toBase58()} | ||
/> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export default AccountsItems | ||
export default AccountsItems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
type UseStorageReturnValue = { | ||
getItem: (key: string) => string; | ||
setItem: (key: string, value: string) => boolean; | ||
removeItem: (key: string) => void; | ||
}; | ||
|
||
export const useLocalStorage = (): UseStorageReturnValue => { | ||
const isBrowser: boolean = ((): boolean => typeof window !== "undefined")(); | ||
|
||
const getItem = (key: string): string => { | ||
return isBrowser ? window.localStorage[key] : ""; | ||
}; | ||
|
||
const setItem = (key: string, value: string): boolean => { | ||
if (isBrowser) { | ||
window.localStorage.setItem(key, value); | ||
return true; | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
const removeItem = (key: string): void => { | ||
window.localStorage.removeItem(key); | ||
}; | ||
|
||
return { | ||
getItem, | ||
setItem, | ||
removeItem, | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.