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