14.05.2026 rip
This commit is contained in:
@@ -35,6 +35,12 @@ export interface SendWalletResponse {
|
||||
data: { txid: string; chain: Chain }
|
||||
}
|
||||
|
||||
export interface WalletAddress {
|
||||
chain: Chain
|
||||
address: string
|
||||
derivationPath: string
|
||||
}
|
||||
|
||||
export const CHAINS: Chain[] = ['ETH', 'BSC', 'BTC', 'TRX', 'SOL']
|
||||
|
||||
async function walletGet<T>(path: string, allowRetry: boolean = true): Promise<T> {
|
||||
@@ -94,6 +100,11 @@ async function walletPost<T>(path: string, body: unknown, allowRetry: boolean =
|
||||
return data as T
|
||||
}
|
||||
|
||||
export async function getWalletAddresses(): Promise<WalletAddress[]> {
|
||||
const res = await walletGet<{ success: boolean; data: WalletAddress[] }>('/api/wallets')
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function getWalletBalance(chain: Chain): Promise<WalletBalanceData> {
|
||||
const res = await walletGet<{ success: boolean; data: WalletBalanceData }>(`/api/wallets/${chain}/balance`)
|
||||
return res.data
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export { useAllWalletBalances, usePrices, useSendWallet } from './model/useWalletData'
|
||||
export type { Chain, FormattedAmount, WalletBalanceData, PriceEntry, SendWalletPayload, SendWalletResponse } from './api/walletApi'
|
||||
export { useAllWalletBalances, usePrices, useSendWallet, useWalletAddresses } from './model/useWalletData'
|
||||
export type { Chain, FormattedAmount, WalletBalanceData, PriceEntry, SendWalletPayload, SendWalletResponse, WalletAddress } from './api/walletApi'
|
||||
export { CHAINS } from './api/walletApi'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery, useQueries, useMutation } from '@tanstack/react-query'
|
||||
import { getWalletBalance, getPrices, sendWallet, CHAINS, type Chain, type SendWalletPayload } from '../api/walletApi'
|
||||
import { getWalletBalance, getPrices, sendWallet, getWalletAddresses, CHAINS, type Chain, type SendWalletPayload } from '../api/walletApi'
|
||||
|
||||
export function useAllWalletBalances() {
|
||||
return useQueries({
|
||||
@@ -25,3 +25,11 @@ export function useSendWallet() {
|
||||
sendWallet(chain, payload),
|
||||
})
|
||||
}
|
||||
|
||||
export function useWalletAddresses() {
|
||||
return useQuery({
|
||||
queryKey: ['wallet', 'addresses'],
|
||||
queryFn: getWalletAddresses,
|
||||
staleTime: 10 * 60 * 1000,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user