0xtrails 0.12.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abis/trailsHydrate.d.ts.map +1 -1
- package/dist/analytics.d.ts +41 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-62W6LwH2.js → ccip-Cg9-lJ6K.js} +16 -16
- package/dist/chainSwitch.d.ts.map +1 -1
- package/dist/chains.d.ts +9 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/{index-C0QTNYIA.js → index-DEojZg7b.js} +50431 -50424
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +377 -421
- package/dist/intentReceiptPoller.d.ts.map +1 -1
- package/dist/intents.d.ts +1 -3
- package/dist/intents.d.ts.map +1 -1
- package/dist/mutations.d.ts +1 -4
- package/dist/mutations.d.ts.map +1 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/query/balance.hooks.d.ts.map +1 -1
- package/dist/query/chains.hooks.d.ts.map +1 -1
- package/dist/query/chains.queries.d.ts +4 -1
- package/dist/query/chains.queries.d.ts.map +1 -1
- package/dist/queryParams.d.ts.map +1 -1
- package/dist/recover.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +1 -7
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
- package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts +10 -1
- package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +3 -6
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactionIntent/utils/resilientDepositTracker.d.ts +3 -3
- package/dist/transactionIntent/utils/resilientDepositTracker.d.ts.map +1 -1
- package/dist/transactions.d.ts +2 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/umd/trails.min.js +200 -200
- package/dist/walletUtils.d.ts +4 -0
- package/dist/walletUtils.d.ts.map +1 -1
- package/dist/wallets.d.ts +2 -1
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts +5 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DepositTracker.d.ts +1 -1
- package/dist/widget/components/DepositTracker.d.ts.map +1 -1
- package/dist/widget/components/DirectTransfer.d.ts +0 -8
- package/dist/widget/components/DirectTransfer.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +1 -1
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundWalletSelection.d.ts +0 -8
- package/dist/widget/components/FundWalletSelection.d.ts.map +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/MeldStepsFlow.d.ts.map +1 -1
- package/dist/widget/components/OnrampErrorScreen.d.ts.map +1 -1
- package/dist/widget/components/OnrampPaymentMethods.d.ts.map +1 -1
- package/dist/widget/components/OnrampProviderConfirmation.d.ts +0 -6
- package/dist/widget/components/OnrampProviderConfirmation.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/QrCode.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/ReceiptRecoverableFunds.d.ts +25 -0
- package/dist/widget/components/ReceiptRecoverableFunds.d.ts.map +1 -0
- package/dist/widget/components/RecipientSelectorButton.d.ts +3 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +2 -16
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
- package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/TruncatedTransactionHash.d.ts.map +1 -1
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WidgetProviders.d.ts.map +1 -1
- package/dist/widget/components/Withdraw.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useClickTracking.d.ts.map +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts +1 -10
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
- package/dist/widget/hooks/useDepositMonitor.d.ts +2 -4
- package/dist/widget/hooks/useDepositMonitor.d.ts.map +1 -1
- package/dist/widget/hooks/useExternalFundingReceiptSync.d.ts +11 -0
- package/dist/widget/hooks/useExternalFundingReceiptSync.d.ts.map +1 -0
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts +16 -0
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +1 -0
- package/dist/widget/hooks/useQuote.d.ts +0 -4
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useScreenTracking.d.ts +2 -0
- package/dist/widget/hooks/useScreenTracking.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +0 -2
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +0 -4
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +1 -1
- package/dist/widget/hooks/useViewManager.d.ts +89 -0
- package/dist/widget/hooks/useViewManager.d.ts.map +1 -0
- package/dist/widget/hooks/useWalletConnectUri.d.ts.map +1 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts +1 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +1 -1
- package/dist/widget/index.d.ts +1 -1
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +7 -6
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/types/commonProps.d.ts +1 -6
- package/dist/widget/types/commonProps.d.ts.map +1 -1
- package/dist/widget/utils/forexRateStore.d.ts.map +1 -1
- package/dist/widget/utils/fundMethodSwitchState.d.ts +10 -0
- package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -0
- package/dist/widget/utils/localeStore.d.ts.map +1 -1
- package/dist/widget/utils/viewManagerGuards.d.ts +5 -0
- package/dist/widget/utils/viewManagerGuards.d.ts.map +1 -0
- package/dist/widget/widget.d.ts +23 -2
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/abis/trailsHydrate.ts +2 -1
- package/src/analytics.ts +60 -0
- package/src/chainSwitch.ts +11 -8
- package/src/chains.ts +82 -37
- package/src/constants.ts +2 -2
- package/src/error.ts +8 -0
- package/src/index.ts +1 -12
- package/src/intentReceiptPoller.ts +27 -0
- package/src/intents.ts +36 -87
- package/src/mutations.ts +11 -102
- package/src/onramp-client/index.ts +3 -3
- package/src/prepareSend.ts +6 -2
- package/src/query/balance.hooks.ts +31 -10
- package/src/query/chains.hooks.ts +7 -1
- package/src/query/chains.queries.ts +8 -5
- package/src/queryParams.ts +8 -6
- package/src/recover.ts +9 -9
- package/src/tokens.ts +4 -2
- package/src/transactionIntent/deposits/depositOrchestrator.ts +0 -2
- package/src/transactionIntent/deposits/gaslessDeposit.ts +8 -0
- package/src/transactionIntent/deposits/standardDeposit.ts +25 -35
- package/src/transactionIntent/handlers/intentHandler.ts +234 -138
- package/src/transactionIntent/helpers/transactionStateHelpers.ts +108 -1
- package/src/transactionIntent/types.ts +14 -8
- package/src/transactionIntent/utils/resilientDepositTracker.ts +72 -183
- package/src/transactions.ts +16 -0
- package/src/walletUtils.ts +188 -1
- package/src/wallets.ts +50 -15
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountActionsDropdown.tsx +4 -6
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +4 -6
- package/src/widget/components/AccountSettings.tsx +36 -22
- package/src/widget/components/ClassicSwap.tsx +67 -9
- package/src/widget/components/ConnectWallet.tsx +5 -7
- package/src/widget/components/ConnectedWallets.tsx +143 -82
- package/src/widget/components/DepositTracker.tsx +4 -5
- package/src/widget/components/DirectTransfer.tsx +85 -84
- package/src/widget/components/Earn.tsx +3 -3
- package/src/widget/components/Fund.tsx +90 -17
- package/src/widget/components/FundMethods.tsx +77 -43
- package/src/widget/components/FundWalletSelection.tsx +13 -397
- package/src/widget/components/FundingMethodSelectorButton.tsx +11 -10
- package/src/widget/components/MeldStepsFlow.tsx +64 -30
- package/src/widget/components/OnrampErrorScreen.tsx +2 -18
- package/src/widget/components/OnrampPaymentMethods.tsx +4 -6
- package/src/widget/components/OnrampProviderConfirmation.tsx +91 -110
- package/src/widget/components/OriginTransferInformation.tsx +2 -2
- package/src/widget/components/Pay.tsx +27 -7
- package/src/widget/components/PaymentMethods.tsx +10 -10
- package/src/widget/components/PoolDeposit.tsx +2 -2
- package/src/widget/components/QrCode.tsx +13 -11
- package/src/widget/components/QuoteDetails.tsx +16 -6
- package/src/widget/components/Receipt.tsx +66 -6
- package/src/widget/components/ReceiptRecoverableFunds.tsx +135 -0
- package/src/widget/components/RecipientSelectorButton.tsx +6 -17
- package/src/widget/components/Recipients.tsx +38 -29
- package/src/widget/components/Swap.tsx +2 -25
- package/src/widget/components/TokenList.tsx +2 -2
- package/src/widget/components/TokenSelector.tsx +11 -11
- package/src/widget/components/TokenSelectorButton.tsx +3 -3
- package/src/widget/components/TrailsHookModal.tsx +1 -1
- package/src/widget/components/TransactionDetails.tsx +43 -37
- package/src/widget/components/TransactionHistoryItem.tsx +1 -42
- package/src/widget/components/TransferPendingVertical.tsx +11 -4
- package/src/widget/components/TruncatedTransactionHash.tsx +5 -0
- package/src/widget/components/WalletConfirmation.tsx +5 -8
- package/src/widget/components/WalletConnect.tsx +6 -2
- package/src/widget/components/WidgetProviders.tsx +34 -43
- package/src/widget/components/Withdraw.tsx +25 -11
- package/src/widget/hooks/useClickTracking.ts +5 -0
- package/src/widget/hooks/useDebugScreens.ts +40 -86
- package/src/widget/hooks/useDepositMonitor.ts +14 -149
- package/src/widget/hooks/useExternalFundingReceiptSync.ts +79 -0
- package/src/widget/hooks/useIntentReceiptBalances.ts +141 -0
- package/src/widget/hooks/useQuote.ts +7 -16
- package/src/widget/hooks/useScreenTracking.ts +14 -0
- package/src/widget/hooks/useSelectedFundMethod.tsx +0 -5
- package/src/widget/hooks/useSendForm.ts +5 -14
- package/src/widget/hooks/useTokenList.ts +3 -16
- package/src/widget/hooks/useTrailsSendTransaction.ts +1 -5
- package/src/widget/hooks/useViewManager.tsx +505 -0
- package/src/widget/hooks/useWalletConnectUri.tsx +77 -18
- package/src/widget/hooks/useWalletConnectionContext.tsx +1 -1
- package/src/widget/index.tsx +1 -0
- package/src/widget/providers/TrailsProvider.tsx +0 -41
- package/src/widget/styles.ts +1 -1
- package/src/widget/types/commonProps.ts +0 -8
- package/src/widget/utils/forexRateStore.ts +0 -2
- package/src/widget/utils/fundMethodSwitchState.ts +25 -0
- package/src/widget/utils/localeStore.ts +0 -1
- package/src/widget/utils/viewManagerGuards.ts +49 -0
- package/src/widget/widget.tsx +405 -316
- package/dist/intentStorage.d.ts +0 -24
- package/dist/intentStorage.d.ts.map +0 -1
- package/dist/mode.d.ts +0 -2
- package/dist/mode.d.ts.map +0 -1
- package/dist/widget/hooks/useBack.d.ts +0 -22
- package/dist/widget/hooks/useBack.d.ts.map +0 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts +0 -13
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +0 -1
- package/dist/widget/hooks/useInitialRedirect.d.ts +0 -7
- package/dist/widget/hooks/useInitialRedirect.d.ts.map +0 -1
- package/dist/widget/hooks/useMode.d.ts +0 -20
- package/dist/widget/hooks/useMode.d.ts.map +0 -1
- package/dist/widget/hooks/usePreviousScreen.d.ts +0 -12
- package/dist/widget/hooks/usePreviousScreen.d.ts.map +0 -1
- package/dist/widget/workers/intentExecutionWorker.d.ts +0 -73
- package/dist/widget/workers/intentExecutionWorker.d.ts.map +0 -1
- package/src/intentStorage.ts +0 -106
- package/src/mode.ts +0 -1
- package/src/widget/hooks/useBack.tsx +0 -210
- package/src/widget/hooks/useCurrentScreen.tsx +0 -73
- package/src/widget/hooks/useInitialRedirect.tsx +0 -70
- package/src/widget/hooks/useMode.tsx +0 -51
- package/src/widget/hooks/usePreviousScreen.ts +0 -36
- package/src/widget/workers/intentExecutionWorker.ts +0 -502
package/dist/index.js
CHANGED
|
@@ -1,64 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { I as
|
|
4
|
-
import {
|
|
5
|
-
import { useRef as
|
|
6
|
-
import { useWalletClient as
|
|
7
|
-
import { zeroAddress as
|
|
8
|
-
|
|
9
|
-
const I =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
const T = await A.waitIntentReceipt({
|
|
18
|
-
intentId: s
|
|
19
|
-
});
|
|
20
|
-
return d.console.log(
|
|
21
|
-
`[trails-sdk] 📊 Intent ${s} status: ${T.intentReceipt.status}, done: ${T.done}`
|
|
22
|
-
), T;
|
|
23
|
-
},
|
|
24
|
-
enabled: !!s,
|
|
25
|
-
refetchIntervalInBackground: !0,
|
|
26
|
-
refetchInterval: (T) => {
|
|
27
|
-
const C = T.state.data;
|
|
28
|
-
return C && C.done ? (d.console.log(
|
|
29
|
-
`[trails-sdk] ✅ Intent monitoring complete for ${s}`
|
|
30
|
-
), !1) : ae;
|
|
31
|
-
},
|
|
32
|
-
retry: (T, C) => T >= 30 ? (d.console.error(
|
|
33
|
-
`[trails-sdk] ❌ Giving up on intent ${s} after 30 failed API attempts:`,
|
|
34
|
-
C
|
|
35
|
-
), !1) : !0
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
intentReceipt: I.data?.intentReceipt ?? null,
|
|
39
|
-
done: I.data?.done ?? !1,
|
|
40
|
-
isLoading: I.isLoading,
|
|
41
|
-
isError: I.isError,
|
|
42
|
-
error: I.error
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
function Je(s) {
|
|
46
|
-
const { data: A } = We(), { chainId: I } = qe(), T = Fe(), C = pe(), { trailsApiKey: ie, sequenceIndexerUrl: ce, sequenceMetadataUrl: de } = we(), P = Be(), {
|
|
47
|
-
openModal: X,
|
|
48
|
-
setPendingSelection: le,
|
|
49
|
-
setHostTransactionState: Y,
|
|
50
|
-
setHostTransactionQuote: q,
|
|
51
|
-
setHostTransactionStates: F,
|
|
52
|
-
setHostTransactionTimestamp: Q,
|
|
2
|
+
import { u as ye, a as we, b as pe, c as Pe, d as Re, e as Ue, f as He, l as T, g as M, h as G, i as se, j as N, k as X, T as H, m as oe, n as ae, o as xe, p as Oe, q as W } from "./index-DEojZg7b.js";
|
|
3
|
+
import { I as Ze, M as be, S as et, r as tt, s as nt, t as st, v as ot, w as at, x as rt, y as it, U as ct, W as dt, z as lt, A as ut, B as Tt, C as ft, D as mt, E as gt, F as kt, G as ht, H as At, J as Ct, K as It, L as Et, N as St, O as yt, P as wt, Q as pt, R as Pt, V as Rt, X as Ut, Y as Ht, Z as xt, _ as Ot, $ as Dt, a0 as Bt, a1 as Mt, a2 as Nt, a3 as Wt, a4 as Ft, a5 as Lt, a6 as Qt, a7 as qt, a8 as _t, a9 as Kt, aa as jt, ab as Vt, ac as Gt, ad as Xt, ae as Yt, af as $t, ag as zt, ah as Jt, ai as vt, aj as Zt, ak as bt, al as en, am as tn, an as nn, ao as sn, ap as on, aq as an, ar as rn, as as cn, at as dn, au as ln, av as un, aw as Tn, ax as fn, ay as mn, az as gn, aA as kn, aB as hn, aC as An, aD as Cn, aE as In, aF as En, aG as Sn, aH as yn, aI as wn, aJ as pn, aK as Pn, aL as Rn, aM as Un, aN as Hn, aO as xn, aP as On, aQ as Dn, aR as Bn, aS as Mn, aT as Nn, aU as Wn, aV as Fn, aW as Ln, aX as Qn, aY as qn } from "./index-DEojZg7b.js";
|
|
4
|
+
import { useQueryClient as De, useMutation as Be } from "@tanstack/react-query";
|
|
5
|
+
import { useRef as Me, useCallback as F } from "react";
|
|
6
|
+
import { useWalletClient as Ne, useAccount as We, useChainId as Fe } from "wagmi";
|
|
7
|
+
import { zeroAddress as y, erc20Abi as Le } from "viem";
|
|
8
|
+
function $e(i) {
|
|
9
|
+
const { data: I } = Ne(), { chainId: x } = We(), O = Fe(), w = ye(), { trailsApiKey: re, sequenceIndexerUrl: ie, sequenceMetadataUrl: ce } = we(), p = De(), {
|
|
10
|
+
openModal: Y,
|
|
11
|
+
setPendingSelection: de,
|
|
12
|
+
setHostTransactionState: $,
|
|
13
|
+
setHostTransactionQuote: L,
|
|
14
|
+
setHostTransactionStates: Q,
|
|
15
|
+
setHostTransactionTimestamp: q,
|
|
53
16
|
hostTransactionState: D,
|
|
54
|
-
setReceiptActionButtonText:
|
|
55
|
-
setOnReceiptAction:
|
|
17
|
+
setReceiptActionButtonText: le,
|
|
18
|
+
setOnReceiptAction: ue,
|
|
56
19
|
retryTransactionRef: Te,
|
|
57
|
-
repeatTransactionRef:
|
|
58
|
-
setLastOriginSelection:
|
|
59
|
-
} =
|
|
20
|
+
repeatTransactionRef: fe,
|
|
21
|
+
setLastOriginSelection: me
|
|
22
|
+
} = pe(), _ = Pe(), { supportedTokens: P } = Re(), ge = Ue(), ke = He(), B = Me(null), f = F(
|
|
60
23
|
(e) => {
|
|
61
|
-
|
|
24
|
+
$((n) => ({
|
|
62
25
|
status: e.status ?? n.status,
|
|
63
26
|
details: e.details === null ? void 0 : e.details ? { ...n.details, ...e.details } : n.details,
|
|
64
27
|
error: e.error === null ? void 0 : e.error !== void 0 ? e.error : n.error,
|
|
@@ -66,457 +29,454 @@ function Je(s) {
|
|
|
66
29
|
retryEnabled: e.retryEnabled !== void 0 ? e.retryEnabled : n.retryEnabled
|
|
67
30
|
}));
|
|
68
31
|
},
|
|
69
|
-
[
|
|
70
|
-
),
|
|
71
|
-
if (
|
|
32
|
+
[$]
|
|
33
|
+
), z = async (e, n, s) => {
|
|
34
|
+
if (T.console.log(
|
|
72
35
|
"[trails-sdk] [useTrailsSendTransaction] Executing transaction",
|
|
73
36
|
{ variables: e, originSelection: n }
|
|
74
|
-
), !
|
|
37
|
+
), !I || !I.account)
|
|
75
38
|
throw new Error(
|
|
76
39
|
"Wallet client not available. Please connect your wallet."
|
|
77
40
|
);
|
|
78
41
|
if (!e.to)
|
|
79
42
|
throw new Error("Transaction 'to' address is required.");
|
|
80
|
-
let a,
|
|
43
|
+
let a, o, m;
|
|
81
44
|
if (n)
|
|
82
|
-
a = n.fromTokenAddress,
|
|
45
|
+
a = n.fromTokenAddress, o = n.fromChainId, m = n.fromAmount;
|
|
83
46
|
else if (e.fromTokenAddress && e.fromChainId && e.fromAmount)
|
|
84
|
-
a = e.fromTokenAddress,
|
|
47
|
+
a = e.fromTokenAddress, o = e.fromChainId, m = e.fromAmount;
|
|
85
48
|
else if (e.to && e.value !== void 0) {
|
|
86
|
-
const t =
|
|
49
|
+
const t = x || O;
|
|
87
50
|
if (!t)
|
|
88
51
|
throw new Error("Chain ID not available. Please connect your wallet.");
|
|
89
|
-
|
|
52
|
+
o = t, a = y, m = e.value.toString();
|
|
90
53
|
} else
|
|
91
54
|
throw new Error(
|
|
92
55
|
"Origin token parameters are required. Please provide 'value' (native token), or 'fromTokenAddress'/'fromChainId'/'fromAmount' (ERC20 token), or select via modal."
|
|
93
56
|
);
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
57
|
+
const A = x || O;
|
|
58
|
+
if (!A)
|
|
96
59
|
throw new Error("Chain ID not available. Please connect your wallet.");
|
|
97
|
-
let
|
|
60
|
+
let h, g, r, k;
|
|
98
61
|
if (e.tokenAddress && e.tokenAmount)
|
|
99
|
-
|
|
100
|
-
|
|
62
|
+
h = e.tokenAddress, g = M(
|
|
63
|
+
P,
|
|
101
64
|
e.tokenAddress
|
|
102
|
-
)?.chainId ??
|
|
65
|
+
)?.chainId ?? A, r = e.tokenAmount, k = e.to;
|
|
103
66
|
else if (e.to && e.value !== void 0)
|
|
104
|
-
|
|
67
|
+
h = y, g = A, r = e.value.toString(), k = e.to;
|
|
105
68
|
else
|
|
106
69
|
throw new Error(
|
|
107
70
|
"Either 'value' or 'tokenAddress'/'tokenAmount' must be provided."
|
|
108
71
|
);
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
72
|
+
const u = e.tokenAddress && e.tokenAmount ? H.EXACT_OUTPUT : H.EXACT_INPUT;
|
|
73
|
+
if (u === H.EXACT_INPUT && !m)
|
|
111
74
|
throw new Error(
|
|
112
75
|
"Origin amount is required for this transaction. Please provide 'value' or 'fromAmount'."
|
|
113
76
|
);
|
|
114
|
-
const
|
|
115
|
-
let
|
|
77
|
+
const S = u === H.EXACT_OUTPUT ? r : m;
|
|
78
|
+
let d = [];
|
|
116
79
|
try {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
80
|
+
d = (await p.ensureQueryData(
|
|
81
|
+
G.withPrices(
|
|
82
|
+
I.account.address,
|
|
120
83
|
_,
|
|
121
|
-
|
|
84
|
+
w
|
|
122
85
|
)
|
|
123
86
|
)).balances;
|
|
124
87
|
} catch (t) {
|
|
125
|
-
|
|
88
|
+
T.console.warn(
|
|
126
89
|
"[trails-sdk] [useTrailsSendTransaction] Error fetching balances, proceeding with zero balance",
|
|
127
90
|
t
|
|
128
|
-
),
|
|
91
|
+
), d = [];
|
|
129
92
|
}
|
|
130
|
-
const
|
|
131
|
-
(t) => t.chainId ===
|
|
93
|
+
const J = d.find(
|
|
94
|
+
(t) => t.chainId === o && (oe(t.contractAddress, a) || !t.contractAddress && a === y)
|
|
132
95
|
)?.balance ?? "0";
|
|
133
|
-
let
|
|
96
|
+
let v = 0;
|
|
134
97
|
try {
|
|
135
|
-
const c =
|
|
136
|
-
c && (
|
|
98
|
+
const c = ae(o)?.nativeCurrency?.symbol ?? "";
|
|
99
|
+
c && (v = (await xe(w, {
|
|
137
100
|
tokenSymbol: c,
|
|
138
|
-
tokenAddress:
|
|
139
|
-
chainId:
|
|
101
|
+
tokenAddress: y,
|
|
102
|
+
chainId: o
|
|
140
103
|
}))?.priceUsd ?? 0);
|
|
141
104
|
} catch (t) {
|
|
142
|
-
|
|
105
|
+
T.console.warn(
|
|
143
106
|
"[trails-sdk] [useTrailsSendTransaction] Error getting native token price",
|
|
144
107
|
t
|
|
145
108
|
);
|
|
146
109
|
}
|
|
147
|
-
const Z =
|
|
148
|
-
|
|
110
|
+
const Z = M(
|
|
111
|
+
P,
|
|
149
112
|
a,
|
|
150
|
-
|
|
151
|
-
), b =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
), { getChainRpcClient:
|
|
113
|
+
o
|
|
114
|
+
), b = M(
|
|
115
|
+
P,
|
|
116
|
+
h,
|
|
117
|
+
g
|
|
118
|
+
), { getChainRpcClient: V } = await import("./index-DEojZg7b.js").then((t) => t.bl), ee = V(o), te = V(g), ne = async (t, c) => {
|
|
156
119
|
try {
|
|
157
|
-
const
|
|
158
|
-
return
|
|
120
|
+
const E = c === o ? ee : c === g ? te : V(c);
|
|
121
|
+
return E ? oe(t, y) ? ae(c)?.nativeCurrency.decimals ?? 18 : await E.readContract({
|
|
159
122
|
address: t,
|
|
160
|
-
abi:
|
|
123
|
+
abi: Le,
|
|
161
124
|
functionName: "decimals"
|
|
162
125
|
}) : null;
|
|
163
|
-
} catch (
|
|
164
|
-
return
|
|
126
|
+
} catch (E) {
|
|
127
|
+
return T.console.error(
|
|
165
128
|
`[trails-sdk] Error fetching decimals on-chain for token ${t} on chain ${c}:`,
|
|
166
|
-
|
|
129
|
+
E
|
|
167
130
|
), null;
|
|
168
131
|
}
|
|
169
132
|
};
|
|
170
|
-
let
|
|
171
|
-
if (!
|
|
133
|
+
let R = Z?.decimals;
|
|
134
|
+
if (!R && a) {
|
|
172
135
|
const t = await ne(
|
|
173
136
|
a,
|
|
174
|
-
|
|
137
|
+
o
|
|
175
138
|
);
|
|
176
|
-
t !== null && (
|
|
139
|
+
t !== null && (R = t);
|
|
177
140
|
}
|
|
178
|
-
|
|
179
|
-
let
|
|
180
|
-
if (!
|
|
141
|
+
R || (R = 18);
|
|
142
|
+
let U = b?.decimals;
|
|
143
|
+
if (!U && h) {
|
|
181
144
|
const t = await ne(
|
|
182
|
-
|
|
183
|
-
|
|
145
|
+
h,
|
|
146
|
+
g
|
|
184
147
|
);
|
|
185
|
-
t !== null && (
|
|
148
|
+
t !== null && (U = t);
|
|
186
149
|
}
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
}, { send:
|
|
191
|
-
queryClient:
|
|
192
|
-
account:
|
|
150
|
+
U || (U = 18);
|
|
151
|
+
const Ae = b?.symbol ?? "", Ce = Z?.symbol ?? "", Ie = (t) => {
|
|
152
|
+
s?.trackInWidget && Q(t), i?.onStatusUpdate?.(t);
|
|
153
|
+
}, { send: Ee, quote: Se } = await Oe({
|
|
154
|
+
queryClient: p,
|
|
155
|
+
account: I.account,
|
|
193
156
|
originTokenAddress: a,
|
|
194
|
-
originChainId:
|
|
195
|
-
originTokenBalance:
|
|
196
|
-
destinationChainId:
|
|
197
|
-
recipient:
|
|
198
|
-
destinationTokenAddress:
|
|
199
|
-
swapAmount:
|
|
200
|
-
tradeType:
|
|
157
|
+
originChainId: o,
|
|
158
|
+
originTokenBalance: J,
|
|
159
|
+
destinationChainId: g,
|
|
160
|
+
recipient: k,
|
|
161
|
+
destinationTokenAddress: h,
|
|
162
|
+
swapAmount: S,
|
|
163
|
+
tradeType: u,
|
|
201
164
|
originTokenSymbol: Ce,
|
|
202
|
-
destinationTokenSymbol:
|
|
203
|
-
client:
|
|
204
|
-
trailsClient:
|
|
165
|
+
destinationTokenSymbol: Ae,
|
|
166
|
+
client: I,
|
|
167
|
+
trailsClient: w,
|
|
205
168
|
destinationCalldata: e.data ? e.data.toString() : void 0,
|
|
206
|
-
onTransactionStateChange:
|
|
207
|
-
sourceTokenDecimals:
|
|
208
|
-
destinationTokenDecimals:
|
|
209
|
-
paymasterUrl:
|
|
210
|
-
slippageTolerance:
|
|
211
|
-
originNativeTokenPriceUsd:
|
|
212
|
-
swapProvider:
|
|
213
|
-
bridgeProvider:
|
|
214
|
-
commitIntentFn: (t
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
sequenceIndexerUrl: ce,
|
|
221
|
-
sequenceMetadataUrl: de,
|
|
222
|
-
sequenceProjectAccessKey: ie,
|
|
169
|
+
onTransactionStateChange: Ie,
|
|
170
|
+
sourceTokenDecimals: R,
|
|
171
|
+
destinationTokenDecimals: U,
|
|
172
|
+
paymasterUrl: i?.paymasterUrl,
|
|
173
|
+
slippageTolerance: i?.slippageTolerance?.toString(),
|
|
174
|
+
originNativeTokenPriceUsd: v,
|
|
175
|
+
swapProvider: i?.swapProvider,
|
|
176
|
+
bridgeProvider: i?.bridgeProvider,
|
|
177
|
+
commitIntentFn: (t) => ge.mutateAsync(t),
|
|
178
|
+
executeIntentFn: ke.mutateAsync,
|
|
179
|
+
checkoutOnHandlers: i?.checkoutOnHandlers,
|
|
180
|
+
sequenceIndexerUrl: ie,
|
|
181
|
+
sequenceMetadataUrl: ce,
|
|
182
|
+
sequenceProjectAccessKey: re,
|
|
223
183
|
originPublicClient: ee ?? void 0,
|
|
224
184
|
destinationPublicClient: te ?? void 0,
|
|
225
|
-
isSmartWallet:
|
|
226
|
-
mode:
|
|
185
|
+
isSmartWallet: i?.isSmartWallet ?? void 0,
|
|
186
|
+
mode: i?.mode ?? void 0
|
|
227
187
|
});
|
|
228
|
-
|
|
188
|
+
s?.trackInWidget && (L(Se ?? null), D.details || f({
|
|
229
189
|
details: {
|
|
230
|
-
to:
|
|
231
|
-
tokenAddress:
|
|
232
|
-
tokenAmount:
|
|
233
|
-
toChainId:
|
|
190
|
+
to: k,
|
|
191
|
+
tokenAddress: h,
|
|
192
|
+
tokenAmount: u === H.EXACT_OUTPUT ? r : void 0,
|
|
193
|
+
toChainId: g,
|
|
234
194
|
data: e.data
|
|
235
195
|
}
|
|
236
|
-
}), (!D.status || D.status === "idle") &&
|
|
196
|
+
}), (!D.status || D.status === "idle") && q(Date.now()));
|
|
237
197
|
try {
|
|
238
|
-
|
|
198
|
+
s?.trackInWidget && f({ retryEnabled: !1 });
|
|
239
199
|
const {
|
|
240
200
|
depositUserTxnReceipt: t,
|
|
241
201
|
destinationIntentTransaction: c,
|
|
242
|
-
totalCompletionSeconds:
|
|
243
|
-
} = await
|
|
202
|
+
totalCompletionSeconds: E
|
|
203
|
+
} = await Ee({
|
|
244
204
|
selectedFeeOption: null,
|
|
245
205
|
// Transition to "pending" when wallet signature is complete
|
|
246
206
|
onOriginSend: () => {
|
|
247
|
-
|
|
207
|
+
s?.trackInWidget && f({ status: "pending", error: null });
|
|
248
208
|
}
|
|
249
209
|
});
|
|
250
|
-
return
|
|
210
|
+
return s?.trackInWidget && f({
|
|
251
211
|
status: "success",
|
|
252
212
|
result: {
|
|
253
213
|
originTxHash: t?.transactionHash,
|
|
254
|
-
originExplorerUrl: t?.transactionHash ?
|
|
214
|
+
originExplorerUrl: t?.transactionHash ? W({
|
|
255
215
|
txHash: t.transactionHash,
|
|
256
|
-
chainId:
|
|
216
|
+
chainId: o
|
|
257
217
|
}) : void 0,
|
|
258
218
|
destinationTxHash: c?.txnHash,
|
|
259
|
-
destinationExplorerUrl: c?.txnHash ?
|
|
219
|
+
destinationExplorerUrl: c?.txnHash ? W({
|
|
260
220
|
txHash: c.txnHash,
|
|
261
|
-
chainId:
|
|
221
|
+
chainId: g
|
|
262
222
|
}) : void 0
|
|
263
223
|
}
|
|
264
224
|
}), {
|
|
265
225
|
originTransaction: {
|
|
266
226
|
transactionHash: t?.transactionHash,
|
|
267
|
-
explorerUrl:
|
|
227
|
+
explorerUrl: W({
|
|
268
228
|
txHash: t?.transactionHash,
|
|
269
|
-
chainId:
|
|
229
|
+
chainId: o
|
|
270
230
|
}),
|
|
271
231
|
receipt: t
|
|
272
232
|
},
|
|
273
233
|
destinationTransaction: {
|
|
274
234
|
transactionHash: c?.txnHash,
|
|
275
|
-
explorerUrl:
|
|
235
|
+
explorerUrl: W({
|
|
276
236
|
txHash: c?.txnHash,
|
|
277
|
-
chainId:
|
|
237
|
+
chainId: g
|
|
278
238
|
}),
|
|
279
239
|
receipt: c
|
|
280
240
|
},
|
|
281
|
-
totalCompletionSeconds:
|
|
241
|
+
totalCompletionSeconds: E
|
|
282
242
|
};
|
|
283
243
|
} catch (t) {
|
|
284
|
-
if (
|
|
285
|
-
const c =
|
|
286
|
-
|
|
244
|
+
if (s?.trackInWidget) {
|
|
245
|
+
const c = X(t);
|
|
246
|
+
f(c ? {
|
|
287
247
|
status: "confirmation",
|
|
288
248
|
error: null,
|
|
289
249
|
retryEnabled: !0
|
|
290
250
|
} : {
|
|
291
251
|
status: "error",
|
|
292
|
-
error:
|
|
252
|
+
error: N(t),
|
|
293
253
|
retryEnabled: !1
|
|
294
254
|
});
|
|
295
255
|
}
|
|
296
256
|
throw t;
|
|
297
257
|
}
|
|
298
|
-
},
|
|
258
|
+
}, l = Be({
|
|
299
259
|
mutationFn: async (e) => {
|
|
300
|
-
|
|
260
|
+
T.console.log(
|
|
301
261
|
"[trails-sdk] [useTrailsSendTransaction] Starting transaction",
|
|
302
262
|
e
|
|
303
|
-
),
|
|
304
|
-
|
|
305
|
-
),
|
|
306
|
-
const n = e.value !== void 0,
|
|
307
|
-
let
|
|
308
|
-
if (e.tokenAddress &&
|
|
309
|
-
const
|
|
310
|
-
|
|
263
|
+
), B.current = e, le(
|
|
264
|
+
i?.receiptActionButtonText ?? "Transact Again"
|
|
265
|
+
), ue(i?.onReceiptAction ?? null);
|
|
266
|
+
const n = e.value !== void 0, s = e.fromTokenAddress !== void 0 && e.fromChainId !== void 0, a = n || s;
|
|
267
|
+
let o;
|
|
268
|
+
if (e.tokenAddress && P) {
|
|
269
|
+
const r = M(
|
|
270
|
+
P,
|
|
311
271
|
e.tokenAddress
|
|
312
272
|
);
|
|
313
|
-
|
|
273
|
+
r && (o = r.chainId);
|
|
314
274
|
}
|
|
315
|
-
|
|
316
|
-
let
|
|
317
|
-
if (
|
|
275
|
+
o || (o = x || O);
|
|
276
|
+
let m = !0, A = !0;
|
|
277
|
+
if (I?.account)
|
|
318
278
|
try {
|
|
319
279
|
if (a) {
|
|
320
|
-
let
|
|
321
|
-
if (e.value !== void 0 ? (
|
|
322
|
-
const { balances:
|
|
323
|
-
|
|
324
|
-
|
|
280
|
+
let r, k, u;
|
|
281
|
+
if (e.value !== void 0 ? (r = y, k = x || O || 1, u = e.value.toString()) : e.fromTokenAddress && e.fromChainId && (r = e.fromTokenAddress, k = e.fromChainId, u = e.fromAmount), r && k && u && u !== "0") {
|
|
282
|
+
const { balances: S } = await p.ensureQueryData(
|
|
283
|
+
G.withPrices(
|
|
284
|
+
I.account.address,
|
|
325
285
|
_,
|
|
326
|
-
|
|
286
|
+
w
|
|
327
287
|
)
|
|
328
288
|
);
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
),
|
|
289
|
+
m = se(
|
|
290
|
+
S,
|
|
291
|
+
r,
|
|
292
|
+
u,
|
|
293
|
+
k
|
|
294
|
+
), T.console.log(
|
|
335
295
|
"[trails-sdk] [useTrailsSendTransaction] Origin token balance check:",
|
|
336
296
|
{
|
|
337
|
-
tokenAddress:
|
|
338
|
-
amount:
|
|
339
|
-
chainId:
|
|
340
|
-
hasSufficientBalance:
|
|
297
|
+
tokenAddress: r,
|
|
298
|
+
amount: u,
|
|
299
|
+
chainId: k,
|
|
300
|
+
hasSufficientBalance: m
|
|
341
301
|
}
|
|
342
302
|
);
|
|
343
303
|
}
|
|
344
304
|
}
|
|
345
|
-
if (
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
305
|
+
if (m && e.tokenAddress && e.tokenAmount) {
|
|
306
|
+
const r = await p.ensureQueryData(
|
|
307
|
+
G.withPrices(
|
|
308
|
+
I.account.address,
|
|
349
309
|
_,
|
|
350
|
-
|
|
310
|
+
w
|
|
351
311
|
)
|
|
352
312
|
);
|
|
353
|
-
|
|
354
|
-
|
|
313
|
+
A = se(
|
|
314
|
+
r.balances,
|
|
355
315
|
e.tokenAddress,
|
|
356
316
|
e.tokenAmount,
|
|
357
|
-
|
|
358
|
-
),
|
|
317
|
+
o
|
|
318
|
+
), T.console.log(
|
|
359
319
|
"[trails-sdk] [useTrailsSendTransaction] Destination token balance check:",
|
|
360
320
|
{
|
|
361
321
|
tokenAddress: e.tokenAddress,
|
|
362
322
|
tokenAmount: e.tokenAmount,
|
|
363
|
-
chainId:
|
|
364
|
-
hasSufficientBalance:
|
|
323
|
+
chainId: o,
|
|
324
|
+
hasSufficientBalance: A
|
|
365
325
|
}
|
|
366
326
|
);
|
|
367
327
|
}
|
|
368
|
-
} catch (
|
|
369
|
-
|
|
328
|
+
} catch (r) {
|
|
329
|
+
T.console.warn(
|
|
370
330
|
"[trails-sdk] [useTrailsSendTransaction] Error checking balances, defaulting to origin selection:",
|
|
371
|
-
|
|
372
|
-
),
|
|
331
|
+
r
|
|
332
|
+
), m = !1, A = !1;
|
|
373
333
|
}
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
334
|
+
const h = !a || !m || !A;
|
|
335
|
+
if (T.console.log(
|
|
376
336
|
"[trails-sdk] [useTrailsSendTransaction] Origin selection decision:",
|
|
377
337
|
{
|
|
378
338
|
hasOriginParams: a,
|
|
379
|
-
hasSufficientOriginBalance:
|
|
380
|
-
hasSufficientDestinationTokenBalance:
|
|
381
|
-
needsOriginSelection:
|
|
339
|
+
hasSufficientOriginBalance: m,
|
|
340
|
+
hasSufficientDestinationTokenBalance: A,
|
|
341
|
+
needsOriginSelection: h
|
|
382
342
|
}
|
|
383
|
-
),
|
|
384
|
-
const
|
|
343
|
+
), h) {
|
|
344
|
+
const r = !(e.tokenAddress && e.tokenAmount), k = {
|
|
385
345
|
to: e.to,
|
|
386
346
|
tokenAddress: e.tokenAddress,
|
|
387
347
|
tokenAmount: e.tokenAmount,
|
|
388
|
-
toChainId:
|
|
348
|
+
toChainId: o,
|
|
389
349
|
data: e.data
|
|
390
350
|
};
|
|
391
|
-
return
|
|
351
|
+
return f({
|
|
392
352
|
status: "awaiting-origin",
|
|
393
|
-
details:
|
|
353
|
+
details: k,
|
|
394
354
|
error: null,
|
|
395
355
|
result: null
|
|
396
|
-
}),
|
|
397
|
-
|
|
398
|
-
resolve: async (
|
|
356
|
+
}), L(null), Q([]), q(Date.now()), new Promise((u, S) => {
|
|
357
|
+
de({
|
|
358
|
+
resolve: async (d) => {
|
|
399
359
|
try {
|
|
400
|
-
|
|
360
|
+
B.current = {
|
|
401
361
|
...e,
|
|
402
|
-
fromTokenAddress:
|
|
403
|
-
fromChainId:
|
|
404
|
-
fromAmount:
|
|
405
|
-
},
|
|
406
|
-
tokenAddress:
|
|
407
|
-
chainId:
|
|
408
|
-
amount:
|
|
409
|
-
}),
|
|
410
|
-
const
|
|
362
|
+
fromTokenAddress: d.fromTokenAddress,
|
|
363
|
+
fromChainId: d.fromChainId,
|
|
364
|
+
fromAmount: d.fromAmount
|
|
365
|
+
}, me({
|
|
366
|
+
tokenAddress: d.fromTokenAddress,
|
|
367
|
+
chainId: d.fromChainId,
|
|
368
|
+
amount: d.fromAmount
|
|
369
|
+
}), f({ status: "confirmation" });
|
|
370
|
+
const C = await z(e, d, {
|
|
411
371
|
trackInWidget: !0
|
|
412
372
|
});
|
|
413
|
-
|
|
414
|
-
} catch (
|
|
415
|
-
|
|
373
|
+
u(C);
|
|
374
|
+
} catch (C) {
|
|
375
|
+
X(C) || f({
|
|
416
376
|
status: "error",
|
|
417
|
-
error:
|
|
418
|
-
}),
|
|
377
|
+
error: N(C)
|
|
378
|
+
}), S(C);
|
|
419
379
|
}
|
|
420
380
|
},
|
|
421
|
-
reject: (
|
|
422
|
-
const
|
|
423
|
-
|
|
381
|
+
reject: (d) => {
|
|
382
|
+
const C = d instanceof Error ? d : new Error(String(d));
|
|
383
|
+
f({
|
|
424
384
|
status: "error",
|
|
425
|
-
error:
|
|
426
|
-
}),
|
|
385
|
+
error: N(C)
|
|
386
|
+
}), S(C);
|
|
427
387
|
},
|
|
428
|
-
requireAmountInput:
|
|
388
|
+
requireAmountInput: r
|
|
429
389
|
}), setTimeout(() => {
|
|
430
|
-
|
|
390
|
+
T.console.log(
|
|
431
391
|
"[trails-sdk] [useTrailsSendTransaction] Calling openModal()"
|
|
432
|
-
),
|
|
392
|
+
), Y();
|
|
433
393
|
}, 0);
|
|
434
394
|
});
|
|
435
395
|
}
|
|
436
|
-
const
|
|
396
|
+
const g = {
|
|
437
397
|
to: e.to,
|
|
438
398
|
tokenAddress: e.tokenAddress,
|
|
439
399
|
tokenAmount: e.tokenAmount,
|
|
440
|
-
toChainId:
|
|
400
|
+
toChainId: o,
|
|
441
401
|
data: e.data
|
|
442
402
|
};
|
|
443
|
-
return
|
|
403
|
+
return f({
|
|
444
404
|
status: "confirmation",
|
|
445
|
-
details:
|
|
405
|
+
details: g,
|
|
446
406
|
error: null,
|
|
447
407
|
result: null
|
|
448
|
-
}),
|
|
408
|
+
}), L(null), Q([]), q(Date.now()), Y(), z(e, void 0, { trackInWidget: !0 });
|
|
449
409
|
},
|
|
450
410
|
onSuccess: (e, n) => {
|
|
451
|
-
|
|
411
|
+
T.console.log(
|
|
452
412
|
"[trails-sdk] [useTrailsSendTransaction] Transaction successful",
|
|
453
413
|
{ data: e, variables: n }
|
|
454
|
-
),
|
|
414
|
+
), p.invalidateQueries({ queryKey: ["prepareSend"] }), i?.onSuccess?.(e, n);
|
|
455
415
|
},
|
|
456
416
|
onError: (e, n) => {
|
|
457
|
-
|
|
417
|
+
T.console.error(
|
|
458
418
|
"[trails-sdk] [useTrailsSendTransaction] Transaction error",
|
|
459
419
|
{ error: e, variables: n }
|
|
460
420
|
);
|
|
461
|
-
const
|
|
462
|
-
D.status !== "idle" && !a &&
|
|
421
|
+
const s = N(e), a = X(e);
|
|
422
|
+
D.status !== "idle" && !a && f({
|
|
463
423
|
status: "error",
|
|
464
|
-
error:
|
|
465
|
-
}),
|
|
424
|
+
error: s
|
|
425
|
+
}), i?.onError?.(new Error(s), n);
|
|
466
426
|
},
|
|
467
|
-
onSettled: (e, n,
|
|
468
|
-
|
|
427
|
+
onSettled: (e, n, s) => {
|
|
428
|
+
T.console.log(
|
|
469
429
|
"[trails-sdk] [useTrailsSendTransaction] Transaction settled",
|
|
470
|
-
{ data: e, error: n, variables:
|
|
471
|
-
),
|
|
430
|
+
{ data: e, error: n, variables: s }
|
|
431
|
+
), i?.onSettled?.(e, n, s);
|
|
472
432
|
}
|
|
473
|
-
}), K =
|
|
433
|
+
}), K = F(
|
|
474
434
|
(e, n) => {
|
|
475
|
-
|
|
476
|
-
onSuccess: (
|
|
477
|
-
n?.onSuccess?.(
|
|
435
|
+
l.mutate(e, {
|
|
436
|
+
onSuccess: (s) => {
|
|
437
|
+
n?.onSuccess?.(s);
|
|
478
438
|
},
|
|
479
|
-
onError: (
|
|
480
|
-
n?.onError?.(
|
|
439
|
+
onError: (s) => {
|
|
440
|
+
n?.onError?.(s);
|
|
481
441
|
},
|
|
482
|
-
onSettled: (
|
|
483
|
-
n?.onSettled?.(
|
|
442
|
+
onSettled: (s, a) => {
|
|
443
|
+
n?.onSettled?.(s, a);
|
|
484
444
|
}
|
|
485
445
|
});
|
|
486
446
|
},
|
|
487
|
-
[
|
|
488
|
-
),
|
|
489
|
-
async (e, n) =>
|
|
490
|
-
onSuccess: (
|
|
491
|
-
n?.onSuccess?.(
|
|
447
|
+
[l]
|
|
448
|
+
), he = F(
|
|
449
|
+
async (e, n) => l.mutateAsync(e, {
|
|
450
|
+
onSuccess: (s) => {
|
|
451
|
+
n?.onSuccess?.(s);
|
|
492
452
|
},
|
|
493
|
-
onError: (
|
|
494
|
-
n?.onError?.(
|
|
453
|
+
onError: (s) => {
|
|
454
|
+
n?.onError?.(s);
|
|
495
455
|
},
|
|
496
|
-
onSettled: (
|
|
497
|
-
n?.onSettled?.(
|
|
456
|
+
onSettled: (s, a) => {
|
|
457
|
+
n?.onSettled?.(s, a);
|
|
498
458
|
}
|
|
499
459
|
}),
|
|
500
|
-
[
|
|
501
|
-
),
|
|
502
|
-
|
|
460
|
+
[l]
|
|
461
|
+
), j = F(() => {
|
|
462
|
+
B.current && K(B.current);
|
|
503
463
|
}, [K]);
|
|
504
|
-
return Te.current =
|
|
464
|
+
return Te.current = j, fe.current = j, {
|
|
505
465
|
sendTransaction: K,
|
|
506
|
-
sendTransactionAsync:
|
|
507
|
-
retry:
|
|
508
|
-
data:
|
|
509
|
-
error:
|
|
510
|
-
isPending:
|
|
511
|
-
isSuccess:
|
|
512
|
-
isError:
|
|
513
|
-
isIdle:
|
|
514
|
-
status:
|
|
515
|
-
reset:
|
|
516
|
-
variables:
|
|
466
|
+
sendTransactionAsync: he,
|
|
467
|
+
retry: j,
|
|
468
|
+
data: l.data,
|
|
469
|
+
error: l.error,
|
|
470
|
+
isPending: l.isPending,
|
|
471
|
+
isSuccess: l.isSuccess,
|
|
472
|
+
isError: l.isError,
|
|
473
|
+
isIdle: l.isIdle,
|
|
474
|
+
status: l.status,
|
|
475
|
+
reset: l.reset,
|
|
476
|
+
variables: l.variables
|
|
517
477
|
};
|
|
518
478
|
}
|
|
519
|
-
const
|
|
479
|
+
const Qe = ["JPY", "KRW", "VND", "CLP", "ISK"], qe = {
|
|
520
480
|
USD: "$",
|
|
521
481
|
EUR: "€",
|
|
522
482
|
GBP: "£",
|
|
@@ -531,127 +491,123 @@ const _e = ["JPY", "KRW", "VND", "CLP", "ISK"], Ke = {
|
|
|
531
491
|
NOK: "kr",
|
|
532
492
|
DKK: "kr"
|
|
533
493
|
};
|
|
534
|
-
function
|
|
494
|
+
function ze(i) {
|
|
535
495
|
return {
|
|
536
|
-
decimals:
|
|
537
|
-
symbol:
|
|
496
|
+
decimals: Qe.includes(i) ? 0 : 2,
|
|
497
|
+
symbol: qe[i] || i
|
|
538
498
|
};
|
|
539
499
|
}
|
|
540
500
|
export {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
He as
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
Un as useGetIntent,
|
|
632
|
-
Hn as useGetTokenImageUrl,
|
|
633
|
-
xn as useHasSufficientBalanceToken,
|
|
634
|
-
On as useHasSufficientBalanceUsd,
|
|
501
|
+
Ze as InsufficientBalanceError,
|
|
502
|
+
be as MIN_REFETCH_INTERVAL,
|
|
503
|
+
et as SDK_VERSION,
|
|
504
|
+
tt as TRAILS_ROUTER_PLACEHOLDER_AMOUNT,
|
|
505
|
+
H as TradeType,
|
|
506
|
+
nt as TrailsClient,
|
|
507
|
+
st as TrailsHookModal,
|
|
508
|
+
ot as TrailsModalProvider,
|
|
509
|
+
at as TrailsOnramp,
|
|
510
|
+
rt as TrailsProvider,
|
|
511
|
+
it as TrailsWidget,
|
|
512
|
+
ct as UserRejectionError,
|
|
513
|
+
dt as WidgetFundMethod,
|
|
514
|
+
lt as attemptSwitchChain,
|
|
515
|
+
G as balanceQueries,
|
|
516
|
+
ut as buildRefundTransactionWithSignature,
|
|
517
|
+
Tt as calcAmountUsdPrice,
|
|
518
|
+
ft as calculateOriginAndDestinationIntentAddresses,
|
|
519
|
+
mt as chainQueries,
|
|
520
|
+
gt as commitIntent,
|
|
521
|
+
kt as convertApiTokenInfoToToken,
|
|
522
|
+
ht as createModalController,
|
|
523
|
+
At as determineRefundCall,
|
|
524
|
+
Ct as fetchCountryCode,
|
|
525
|
+
It as fiatQueries,
|
|
526
|
+
Et as formatBalanceFields,
|
|
527
|
+
St as formatPriceFields,
|
|
528
|
+
yt as formatTvl,
|
|
529
|
+
wt as formatUsdAmountFormatted,
|
|
530
|
+
pt as formatUsdAmountLocaleDisplay,
|
|
531
|
+
Pt as formatUsdFields,
|
|
532
|
+
Rt as geoQueries,
|
|
533
|
+
Ut as getAccountTotalBalanceUsd,
|
|
534
|
+
Ht as getAccountTransactionHistory,
|
|
535
|
+
xt as getAllChains,
|
|
536
|
+
ae as getChainInfo,
|
|
537
|
+
Ot as getChainRpcClient,
|
|
538
|
+
ze as getCurrencyInfo,
|
|
539
|
+
Dt as getERC20TransferData,
|
|
540
|
+
Bt as getHasSufficientBalanceToken,
|
|
541
|
+
Mt as getHasSufficientBalanceUsd,
|
|
542
|
+
Nt as getIntent,
|
|
543
|
+
Wt as getIntentConfigurationFromCalls,
|
|
544
|
+
Ft as getIsApiError,
|
|
545
|
+
Lt as getIsBalanceTooLowError,
|
|
546
|
+
Qt as getIsInsufficientLiquidityError,
|
|
547
|
+
qt as getIsNoAvailableQuoteError,
|
|
548
|
+
_t as getIsQuoteFailedError,
|
|
549
|
+
Kt as getIsQuoteInputError,
|
|
550
|
+
jt as getIsQuoteTokenError,
|
|
551
|
+
Vt as getIsRateLimitedError,
|
|
552
|
+
Gt as getIsRequiredAmountNotMetError,
|
|
553
|
+
X as getIsUserRejectionError,
|
|
554
|
+
Xt as getIsWalletAlreadyConnectedError,
|
|
555
|
+
Yt as getMinLogLevel,
|
|
556
|
+
$t as getOnrampClient,
|
|
557
|
+
zt as getPrettifiedErrorMessage,
|
|
558
|
+
Jt as getRpcUrl,
|
|
559
|
+
vt as getSupportedChains,
|
|
560
|
+
Zt as getSupportedTokens,
|
|
561
|
+
xe as getTokenPrice,
|
|
562
|
+
bt as getTokenPrices,
|
|
563
|
+
en as getTrailsClient,
|
|
564
|
+
tn as getTxTimeDiff,
|
|
565
|
+
nn as getVersion,
|
|
566
|
+
sn as invalidateTokenBalancesCache,
|
|
567
|
+
on as invalidateTokenPricesCache,
|
|
568
|
+
an as isValidInteger,
|
|
569
|
+
rn as isValidNumeric,
|
|
570
|
+
T as logger,
|
|
571
|
+
cn as meldQueries,
|
|
572
|
+
dn as normalizeNumber,
|
|
573
|
+
ln as pollIntentReceipt,
|
|
574
|
+
Oe as prepareSend,
|
|
575
|
+
un as quoteIntent,
|
|
576
|
+
Tn as sendOriginTransaction,
|
|
577
|
+
fn as signPayload,
|
|
578
|
+
mn as useAccountTotalBalanceUsd,
|
|
579
|
+
gn as useAccountTransactionHistory,
|
|
580
|
+
kn as useChainRpcClient,
|
|
581
|
+
Ue as useCommitIntent,
|
|
582
|
+
hn as useCountryCode,
|
|
583
|
+
An as useCountryList,
|
|
584
|
+
Cn as useExchangeRate,
|
|
585
|
+
He as useExecuteIntent,
|
|
586
|
+
In as useFiatCurrencyList,
|
|
587
|
+
En as useGetIntent,
|
|
588
|
+
Sn as useGetTokenImageUrl,
|
|
589
|
+
yn as useHasSufficientBalanceToken,
|
|
590
|
+
wn as useHasSufficientBalanceUsd,
|
|
635
591
|
Pe as useIndexerGatewayClient,
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
592
|
+
pn as useIntentReceiptMonitor,
|
|
593
|
+
Pn as useIntentRecover,
|
|
594
|
+
Rn as useIntentRecoverWithAddress,
|
|
595
|
+
Un as useIntentTransactionHistory,
|
|
596
|
+
Hn as useMeldPaymentMethods,
|
|
597
|
+
xn as useMeldServiceProviders,
|
|
598
|
+
On as useOnrampClient,
|
|
599
|
+
Dn as useQuote,
|
|
600
|
+
Bn as useSupportedChains,
|
|
601
|
+
Re as useSupportedTokens,
|
|
602
|
+
Mn as useTokenAddress,
|
|
603
|
+
Nn as useTokenBalances,
|
|
604
|
+
Wn as useTokenBalancesForMultipleAccounts,
|
|
605
|
+
Fn as useTokenInfo,
|
|
606
|
+
Ln as useTokenList,
|
|
607
|
+
Qn as useTokenPrice,
|
|
608
|
+
qn as useTokenPrices,
|
|
653
609
|
we as useTrails,
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
610
|
+
ye as useTrailsClient,
|
|
611
|
+
pe as useTrailsModal,
|
|
612
|
+
$e as useTrailsSendTransaction
|
|
657
613
|
};
|