14.05.2026 rip
This commit is contained in:
@@ -151,3 +151,39 @@ export async function getPortfolio(): Promise<PortfolioData> {
|
||||
const res = await walletGet<{ success: boolean; data: PortfolioData }>('/api/wallets/portfolio')
|
||||
return res.data
|
||||
}
|
||||
|
||||
export interface TokenInfo {
|
||||
chain: string
|
||||
symbol: string
|
||||
name: string
|
||||
contract: string | null
|
||||
}
|
||||
|
||||
export interface RelayQuotePayload {
|
||||
user: string
|
||||
recipient: string
|
||||
originChainId: number
|
||||
destinationChainId: number
|
||||
originCurrency: string
|
||||
destinationCurrency: string
|
||||
amount: string
|
||||
tradeType: 'EXACT_INPUT'
|
||||
}
|
||||
|
||||
export interface RelayQuoteResponse {
|
||||
details: {
|
||||
currencyOut: {
|
||||
amountFormatted: string
|
||||
amountUsd: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTokensList(): Promise<TokenInfo[]> {
|
||||
const res = await walletGet<{ success: boolean; data: TokenInfo[] }>('/api/tokens')
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function getRelayQuote(payload: RelayQuotePayload): Promise<RelayQuoteResponse> {
|
||||
return walletPost<RelayQuoteResponse>('/api/relay/quote', payload)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export { useAllWalletBalances, usePrices, useSendWallet, useWalletAddresses, useWalletBalance, usePortfolio } from './model/useWalletData'
|
||||
export type { Chain, FormattedAmount, WalletBalanceData, PriceEntry, SendWalletPayload, SendWalletResponse, WalletAddress, PortfolioData, PortfolioChain, PortfolioNative, PortfolioToken } from './api/walletApi'
|
||||
export { useAllWalletBalances, usePrices, useSendWallet, useWalletAddresses, useWalletBalance, usePortfolio, useTokensList, useRelayQuote } from './model/useWalletData'
|
||||
export type { Chain, FormattedAmount, WalletBalanceData, PriceEntry, SendWalletPayload, SendWalletResponse, WalletAddress, PortfolioData, PortfolioChain, PortfolioNative, PortfolioToken, TokenInfo, RelayQuotePayload, RelayQuoteResponse } from './api/walletApi'
|
||||
export { CHAINS } from './api/walletApi'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery, useQueries, useMutation } from '@tanstack/react-query'
|
||||
import { getWalletBalance, getPrices, sendWallet, getWalletAddresses, getPortfolio, CHAINS, type Chain, type SendWalletPayload } from '../api/walletApi'
|
||||
import { getWalletBalance, getPrices, sendWallet, getWalletAddresses, getPortfolio, getTokensList, getRelayQuote, CHAINS, type Chain, type SendWalletPayload, type RelayQuotePayload } from '../api/walletApi'
|
||||
|
||||
export function useWalletBalance(chain: Chain) {
|
||||
return useQuery({
|
||||
@@ -49,3 +49,23 @@ export function usePortfolio() {
|
||||
staleTime: 30_000,
|
||||
})
|
||||
}
|
||||
|
||||
export function useTokensList() {
|
||||
return useQuery({
|
||||
queryKey: ['wallet', 'tokens'],
|
||||
queryFn: getTokensList,
|
||||
staleTime: 10 * 60 * 1000,
|
||||
})
|
||||
}
|
||||
|
||||
export function useRelayQuote(payload: RelayQuotePayload | null) {
|
||||
return useQuery({
|
||||
queryKey: ['relay', 'quote',
|
||||
payload?.originChainId, payload?.originCurrency,
|
||||
payload?.destinationCurrency, payload?.amount,
|
||||
],
|
||||
queryFn: () => getRelayQuote(payload!),
|
||||
enabled: !!payload,
|
||||
staleTime: 10_000,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user