14.05.2026 rip
This commit is contained in:
@@ -74,8 +74,8 @@ export function useRevealMnemonic() {
|
||||
export function useRelayQuote(payload: RelayQuotePayload | null) {
|
||||
return useQuery({
|
||||
queryKey: ['relay', 'quote',
|
||||
payload?.originChainId, payload?.originCurrency,
|
||||
payload?.destinationCurrency, payload?.amount,
|
||||
payload?.originChainId, payload?.destinationChainId,
|
||||
payload?.originCurrency, payload?.destinationCurrency, payload?.amount,
|
||||
],
|
||||
queryFn: () => getRelayQuote(payload!),
|
||||
enabled: !!payload,
|
||||
|
||||
@@ -40,14 +40,21 @@ export function BridgeForm() {
|
||||
|
||||
const isTrxNetwork = fromNetwork === 'TRX'
|
||||
|
||||
const { data: walletData } = useWalletBalance(fromNetwork as Chain)
|
||||
const tokenOptions = walletData ? buildTokensFromBalance(walletData) : TOKENS_LIST
|
||||
const { data: fromWalletData } = useWalletBalance(fromNetwork as Chain)
|
||||
const { data: toWalletData } = useWalletBalance(toNetwork as Chain)
|
||||
|
||||
const fromTokenOptions = fromWalletData ? buildTokensFromBalance(fromWalletData) : TOKENS_LIST
|
||||
const toTokenOptions = toWalletData ? buildTokensFromBalance(toWalletData) : TOKENS_LIST
|
||||
|
||||
useEffect(() => {
|
||||
if (tokenOptions.length === 0) return
|
||||
setFromToken(t => tokenOptions.find(o => o.symbol === t.symbol) ?? tokenOptions[0])
|
||||
setToToken(t => tokenOptions.find(o => o.symbol === t.symbol) ?? (tokenOptions[1] ?? tokenOptions[0]))
|
||||
}, [walletData, fromNetwork])
|
||||
if (fromTokenOptions.length === 0) return
|
||||
setFromToken(t => fromTokenOptions.find(o => o.symbol === t.symbol) ?? fromTokenOptions[0])
|
||||
}, [fromWalletData, fromNetwork])
|
||||
|
||||
useEffect(() => {
|
||||
if (toTokenOptions.length === 0) return
|
||||
setToToken(t => toTokenOptions.find(o => o.symbol === t.symbol) ?? toTokenOptions[0])
|
||||
}, [toWalletData, toNetwork])
|
||||
|
||||
const debouncedAmount = useDebounce(fromAmount, 500)
|
||||
const { data: addresses } = useWalletAddresses()
|
||||
@@ -55,17 +62,19 @@ export function BridgeForm() {
|
||||
|
||||
const parsedAmount = parseFloat(debouncedAmount)
|
||||
|
||||
const chainId = CHAIN_ID[fromNetwork]
|
||||
const walletAddress = addresses?.find(a => a.chain === fromNetwork)?.address
|
||||
const fromChainId = CHAIN_ID[fromNetwork]
|
||||
const toChainId = CHAIN_ID[toNetwork]
|
||||
const fromAddress = addresses?.find(a => a.chain === fromNetwork)?.address
|
||||
const toAddress = addresses?.find(a => a.chain === toNetwork)?.address
|
||||
const fromContract = tokensList?.find(t => t.chain === fromNetwork && t.symbol === fromToken.symbol)?.contract ?? nativeAddr(fromNetwork)
|
||||
const toContract = tokensList?.find(t => t.chain === fromNetwork && t.symbol === toToken.symbol)?.contract ?? nativeAddr(fromNetwork)
|
||||
const toContract = tokensList?.find(t => t.chain === toNetwork && t.symbol === toToken.symbol)?.contract ?? nativeAddr(toNetwork)
|
||||
|
||||
const quotePayload = !isTrxNetwork && chainId && walletAddress && parsedAmount > 0
|
||||
const quotePayload = !isTrxNetwork && fromChainId && toChainId && fromAddress && parsedAmount > 0
|
||||
? {
|
||||
user: walletAddress,
|
||||
recipient: walletAddress,
|
||||
originChainId: chainId,
|
||||
destinationChainId: chainId,
|
||||
user: fromAddress,
|
||||
recipient: toAddress ?? fromAddress,
|
||||
originChainId: fromChainId,
|
||||
destinationChainId: toChainId,
|
||||
originCurrency: fromContract,
|
||||
destinationCurrency: toContract,
|
||||
amount: Math.round(parsedAmount * Math.pow(10, fromToken.decimals)).toString(),
|
||||
@@ -121,7 +130,7 @@ export function BridgeForm() {
|
||||
<SwapCard
|
||||
mode="from"
|
||||
token={fromToken}
|
||||
tokenOptions={tokenOptions}
|
||||
tokenOptions={fromTokenOptions}
|
||||
amount={fromAmount}
|
||||
usd={fromUsd}
|
||||
onAmountChange={setFromAmount}
|
||||
@@ -136,7 +145,7 @@ export function BridgeForm() {
|
||||
<SwapCard
|
||||
mode="to"
|
||||
token={toToken}
|
||||
tokenOptions={tokenOptions}
|
||||
tokenOptions={toTokenOptions}
|
||||
amount={displayToAmount}
|
||||
usd={displayToUsd}
|
||||
onTokenChange={setToToken}
|
||||
@@ -145,7 +154,7 @@ export function BridgeForm() {
|
||||
|
||||
<SwapInfoPanel gasFee={gasFee} />
|
||||
|
||||
<PrimaryButton onClick={handleSwap} disabled={isButtonDisabled} />
|
||||
<PrimaryButton label="Подтвердить бридж" onClick={handleSwap} disabled={isButtonDisabled} />
|
||||
|
||||
{modalData && (
|
||||
<SwapConfirmModal
|
||||
|
||||
Reference in New Issue
Block a user