14.05.2026 rip
This commit is contained in:
@@ -255,6 +255,39 @@ export async function signSolTx(txData: unknown): Promise<unknown> {
|
||||
return walletPost('/api/wallets/SOL/sign-and-broadcast-tx', txData)
|
||||
}
|
||||
|
||||
export interface TrxSwapQuotePayload {
|
||||
from: string
|
||||
to: string
|
||||
amountHuman: string
|
||||
}
|
||||
|
||||
export interface TrxSwapQuoteData {
|
||||
quoteId: string
|
||||
expiresIn: number
|
||||
expectedOutFormatted: string
|
||||
minOutFormatted: string
|
||||
fees: {
|
||||
network: { amountFormatted: string; asset: string; amountUsd: number }
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTrxSwapQuote(payload: TrxSwapQuotePayload): Promise<TrxSwapQuoteData> {
|
||||
const res = await walletPost<{ success: boolean; data: TrxSwapQuoteData }>(
|
||||
'/api/wallets/TRX/swap/quote',
|
||||
payload
|
||||
)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function executeTrxSwap(quoteId: string): Promise<unknown> {
|
||||
return walletPost(
|
||||
'/api/wallets/TRX/swap',
|
||||
{ quoteId },
|
||||
true,
|
||||
{ 'Idempotency-Key': `trx-${Date.now()}` }
|
||||
)
|
||||
}
|
||||
|
||||
export async function createWallet(): Promise<void> {
|
||||
await walletPost<unknown>('/api/wallets/create', {})
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export { useAllWalletBalances, usePrices, useSendWallet, useWalletAddresses, useWalletBalance, usePortfolio, useTokensList, useRelayQuote, useExecuteRelaySwap, useSignSwap, useCreateWallet, useRevealMnemonic } from './model/useWalletData'
|
||||
export type { Chain, FormattedAmount, WalletBalanceData, PriceEntry, SendWalletPayload, SendWalletResponse, WalletAddress, PortfolioData, PortfolioChain, PortfolioNative, PortfolioToken, TokenInfo, RelayQuotePayload, RelayQuoteResponse, RelaySwapResponse, RelaySwapStep } from './api/walletApi'
|
||||
export { useAllWalletBalances, usePrices, useSendWallet, useWalletAddresses, useWalletBalance, usePortfolio, useTokensList, useRelayQuote, useExecuteRelaySwap, useSignSwap, useTrxSwapQuote, useFetchTrxQuote, useExecuteTrxSwap, useCreateWallet, useRevealMnemonic } from './model/useWalletData'
|
||||
export type { Chain, FormattedAmount, WalletBalanceData, PriceEntry, SendWalletPayload, SendWalletResponse, WalletAddress, PortfolioData, PortfolioChain, PortfolioNative, PortfolioToken, TokenInfo, RelayQuotePayload, RelayQuoteResponse, RelaySwapResponse, RelaySwapStep, TrxSwapQuotePayload, TrxSwapQuoteData } 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, getTokensList, getRelayQuote, executeRelaySwap, signRawEvmTx, signSolTx, createWallet, revealMnemonic, CHAINS, type Chain, type SendWalletPayload, type RelayQuotePayload, type RelaySwapStep } from '../api/walletApi'
|
||||
import { getWalletBalance, getPrices, sendWallet, getWalletAddresses, getPortfolio, getTokensList, getRelayQuote, executeRelaySwap, signRawEvmTx, signSolTx, getTrxSwapQuote, executeTrxSwap, createWallet, revealMnemonic, CHAINS, type Chain, type SendWalletPayload, type RelayQuotePayload, type RelaySwapStep, type TrxSwapQuotePayload } from '../api/walletApi'
|
||||
|
||||
export function useWalletBalance(chain: Chain) {
|
||||
return useQuery({
|
||||
@@ -97,3 +97,20 @@ export function useSignSwap() {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useTrxSwapQuote(payload: TrxSwapQuotePayload | null) {
|
||||
return useQuery({
|
||||
queryKey: ['trx', 'quote', payload?.from, payload?.to, payload?.amountHuman],
|
||||
queryFn: () => getTrxSwapQuote(payload!),
|
||||
enabled: !!payload,
|
||||
staleTime: 10_000,
|
||||
})
|
||||
}
|
||||
|
||||
export function useFetchTrxQuote() {
|
||||
return useMutation({ mutationFn: getTrxSwapQuote })
|
||||
}
|
||||
|
||||
export function useExecuteTrxSwap() {
|
||||
return useMutation({ mutationFn: (quoteId: string) => executeTrxSwap(quoteId) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user