remove admin
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
import { useQuery, useQueries, useMutation } from '@tanstack/react-query'
|
||||
import { getWalletBalance, getPrices, sendWallet, getWalletAddresses, getPortfolio, getTokensList, getRelayQuote, executeRelaySwap, signRawEvmTx, signSolTx, getTrxSwapQuote, executeTrxSwap, getJumperTokens, getJumperQuote, executeBridge, createWallet, revealMnemonic, CHAINS, type Chain, type SendWalletPayload, type RelayQuotePayload, type RelaySwapStep, type TrxSwapQuotePayload, type JumperQuotePayload, type BridgeExecutePayload } from '../api/walletApi'
|
||||
import { useMe } from '@features/auth'
|
||||
import { getWalletBalance, getPrices, sendWallet, getWalletAddresses, getPortfolio, getOrgPortfolio, getOrgWalletBalance, getOrgWalletAddresses, getTokensList, getRelayQuote, executeRelaySwap, signRawEvmTx, signSolTx, getTrxSwapQuote, executeTrxSwap, getJumperTokens, getJumperQuote, executeBridge, createWallet, revealMnemonic, CHAINS, type Chain, type SendWalletPayload, type RelayQuotePayload, type RelaySwapStep, type TrxSwapQuotePayload, type JumperQuotePayload, type BridgeExecutePayload } from '../api/walletApi'
|
||||
|
||||
/** Legal-entity accounts read wallet data from b2b instead of cryptowallet. */
|
||||
function useIsLegalAccount() {
|
||||
const { data: me } = useMe()
|
||||
return { isLegal: me?.account_type === 'legal_entity', ready: !!me }
|
||||
}
|
||||
|
||||
export function useWalletBalance(chain: Chain) {
|
||||
const { isLegal, ready } = useIsLegalAccount()
|
||||
return useQuery({
|
||||
queryKey: ['wallet', 'balance', chain],
|
||||
queryFn: () => getWalletBalance(chain),
|
||||
queryKey: ['wallet', 'balance', chain, isLegal ? 'org' : 'self'],
|
||||
queryFn: isLegal ? () => getOrgWalletBalance(chain) : () => getWalletBalance(chain),
|
||||
enabled: isLegal ? ready : true,
|
||||
staleTime: 30_000,
|
||||
})
|
||||
}
|
||||
@@ -35,17 +44,21 @@ export function useSendWallet() {
|
||||
}
|
||||
|
||||
export function useWalletAddresses() {
|
||||
const { isLegal, ready } = useIsLegalAccount()
|
||||
return useQuery({
|
||||
queryKey: ['wallet', 'addresses'],
|
||||
queryFn: getWalletAddresses,
|
||||
queryKey: ['wallet', 'addresses', isLegal ? 'org' : 'self'],
|
||||
queryFn: isLegal ? getOrgWalletAddresses : getWalletAddresses,
|
||||
enabled: isLegal ? ready : true,
|
||||
staleTime: 10 * 60 * 1000,
|
||||
})
|
||||
}
|
||||
|
||||
export function usePortfolio() {
|
||||
const { isLegal, ready } = useIsLegalAccount()
|
||||
return useQuery({
|
||||
queryKey: ['wallet', 'portfolio'],
|
||||
queryFn: getPortfolio,
|
||||
queryKey: ['wallet', 'portfolio', isLegal ? 'org' : 'self'],
|
||||
queryFn: isLegal ? getOrgPortfolio : getPortfolio,
|
||||
enabled: isLegal ? ready : true,
|
||||
staleTime: 30_000,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user