0xtrails 0.2.5 → 0.3.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/aave.d.ts +2 -0
- package/dist/aave.d.ts.map +1 -1
- package/dist/abortController.d.ts +8 -0
- package/dist/abortController.d.ts.map +1 -0
- package/dist/{ccip-CXlshvBY.js → ccip-BMB3uDZt.js} +1 -1
- package/dist/config.d.ts +0 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +4 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/fees.d.ts +19 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/{index-_QuyGrjU.js → index-QXPUrZVv.js} +48719 -50852
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +811 -784
- package/dist/intentReceiptMonitor.d.ts +24 -0
- package/dist/intentReceiptMonitor.d.ts.map +1 -0
- package/dist/intentReceiptPoller.d.ts +69 -0
- package/dist/intentReceiptPoller.d.ts.map +1 -0
- package/dist/intents.d.ts +15 -11
- package/dist/intents.d.ts.map +1 -1
- package/dist/morpho.d.ts +6 -5
- package/dist/morpho.d.ts.map +1 -1
- package/dist/mutations.d.ts +16 -0
- package/dist/mutations.d.ts.map +1 -0
- package/dist/preconditions.d.ts +5 -4
- package/dist/preconditions.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +7 -258
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +9 -6
- package/dist/prices.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -16
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +17 -13
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/trails.d.ts +24 -40
- package/dist/trails.d.ts.map +1 -1
- package/dist/transactionIntent/constants.d.ts +7 -0
- package/dist/transactionIntent/constants.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +44 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/index.d.ts +4 -0
- package/dist/transactionIntent/deposits/index.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/execution/index.d.ts +2 -0
- package/dist/transactionIntent/execution/index.d.ts.map +1 -0
- package/dist/transactionIntent/execution/transactionState.d.ts +5 -0
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts +82 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/index.d.ts +4 -0
- package/dist/transactionIntent/handlers/index.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +62 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +72 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -0
- package/dist/transactionIntent/index.d.ts +9 -0
- package/dist/transactionIntent/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts +17 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -0
- package/dist/transactionIntent/quote/index.d.ts +4 -0
- package/dist/transactionIntent/quote/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts +34 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +5 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/types.d.ts +131 -0
- package/dist/transactionIntent/types.d.ts.map +1 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts +18 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts.map +1 -0
- package/dist/transactionIntent/utils/index.d.ts +4 -0
- package/dist/transactionIntent/utils/index.d.ts.map +1 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts +10 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts +3 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/validators.d.ts +6 -0
- package/dist/transactionIntent/validators.d.ts.map +1 -0
- package/dist/transactions.d.ts +6 -3
- package/dist/transactions.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts +4 -0
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts.map +1 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +2 -3
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DynamicInputStyles.d.ts +18 -0
- package/dist/widget/components/DynamicInputStyles.d.ts.map +1 -0
- package/dist/widget/components/DynamicSizeInputField.d.ts +13 -0
- package/dist/widget/components/DynamicSizeInputField.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts +2 -3
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/ErrorAnimationIcon.d.ts +2 -0
- package/dist/widget/components/ErrorAnimationIcon.d.ts.map +1 -0
- package/dist/widget/components/FeeBreakdown.d.ts +9 -0
- package/dist/widget/components/FeeBreakdown.d.ts.map +1 -0
- package/dist/widget/components/FeeOptions.d.ts +5 -13
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +2 -3
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSwap.d.ts +2 -3
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Identicon.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -3
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +2 -3
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +3 -3
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +3 -20
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts +2 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +2 -3
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts +11 -0
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts.map +1 -0
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Tooltip.d.ts +9 -0
- package/dist/widget/components/Tooltip.d.ts.map +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +1 -0
- package/dist/widget/components/WaasFeeOptions.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/css/compiled.css +2 -2
- package/dist/widget/hooks/useCheckout.d.ts +17 -4
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +82 -0
- package/dist/widget/hooks/useQuote.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +5 -6
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts +25 -0
- package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +1 -0
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +17 -7
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +19 -21
- package/src/aave.ts +54 -1
- package/src/abortController.ts +35 -0
- package/src/config.ts +57 -58
- package/src/constants.ts +11 -9
- package/src/error.ts +21 -3
- package/src/fees.ts +210 -0
- package/src/index.ts +35 -13
- package/src/intentReceiptMonitor.ts +102 -0
- package/src/intentReceiptPoller.ts +299 -0
- package/src/intents.ts +205 -171
- package/src/morpho.ts +58 -9
- package/src/mutations.ts +129 -0
- package/src/preconditions.ts +16 -21
- package/src/prepareSend.ts +92 -4699
- package/src/prices.ts +26 -22
- package/src/relaySdk.ts +2 -2
- package/src/sequenceWallet.ts +6 -73
- package/src/tokenBalances.ts +175 -69
- package/src/trails.ts +230 -722
- package/src/transactionIntent/constants.ts +11 -0
- package/src/transactionIntent/deposits/depositOrchestrator.ts +210 -0
- package/src/transactionIntent/deposits/gaslessDeposit.ts +588 -0
- package/src/transactionIntent/deposits/index.ts +3 -0
- package/src/transactionIntent/deposits/standardDeposit.ts +379 -0
- package/src/transactionIntent/execution/index.ts +1 -0
- package/src/transactionIntent/execution/transactionState.ts +35 -0
- package/src/transactionIntent/handlers/crossChain.ts +1707 -0
- package/src/transactionIntent/handlers/index.ts +3 -0
- package/src/transactionIntent/handlers/sameChainDifferentToken.ts +323 -0
- package/src/transactionIntent/handlers/sameChainSameToken.ts +712 -0
- package/src/transactionIntent/index.ts +9 -0
- package/src/transactionIntent/quote/feeExtractors.ts +81 -0
- package/src/transactionIntent/quote/index.ts +3 -0
- package/src/transactionIntent/quote/normalizeQuote.ts +367 -0
- package/src/transactionIntent/quote/quoteHelpers.ts +53 -0
- package/src/transactionIntent/types.ts +157 -0
- package/src/transactionIntent/utils/balanceChecker.ts +96 -0
- package/src/transactionIntent/utils/index.ts +3 -0
- package/src/transactionIntent/utils/lifiHelpers.ts +68 -0
- package/src/transactionIntent/utils/testnetHelpers.ts +10 -0
- package/src/transactionIntent/validators.ts +57 -0
- package/src/transactions.ts +98 -71
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountIntentTransactionHistory.tsx +36 -36
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
- package/src/widget/components/AccountSettings.tsx +70 -41
- package/src/widget/components/ChainFilterDropdown.tsx +24 -3
- package/src/widget/components/ClassicSwap.tsx +44 -107
- package/src/widget/components/ConfigDisplay.tsx +0 -11
- package/src/widget/components/ConnectWallet.tsx +4 -1
- package/src/widget/components/ConnectedWallets.tsx +51 -25
- package/src/widget/components/DynamicInputStyles.tsx +76 -0
- package/src/widget/components/DynamicSizeInputField.tsx +109 -0
- package/src/widget/components/Earn.tsx +34 -45
- package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
- package/src/widget/components/FeeBreakdown.tsx +155 -0
- package/src/widget/components/FeeOption.tsx +2 -2
- package/src/widget/components/FeeOptions.tsx +151 -112
- package/src/widget/components/Fund.tsx +10 -29
- package/src/widget/components/FundMethods.tsx +4 -3
- package/src/widget/components/FundSwap.tsx +2 -3
- package/src/widget/components/FundingMethodSelectorButton.tsx +24 -14
- package/src/widget/components/Identicon.tsx +164 -95
- package/src/widget/components/MeshConnectExchanges.tsx +2 -15
- package/src/widget/components/Modal.tsx +0 -12
- package/src/widget/components/Pay.tsx +72 -75
- package/src/widget/components/PoolDeposit.tsx +221 -242
- package/src/widget/components/PoolWithdraw.tsx +347 -469
- package/src/widget/components/PriceImpactWarning.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +906 -484
- package/src/widget/components/Receipt.tsx +16 -2
- package/src/widget/components/RecipientSelectorButton.tsx +7 -5
- package/src/widget/components/Recipients.tsx +1 -1
- package/src/widget/components/ScreenHeader.tsx +60 -36
- package/src/widget/components/Swap.tsx +2 -3
- package/src/widget/components/ThemeProvider.tsx +2 -1
- package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
- package/src/widget/components/TokenImage.tsx +1 -1
- package/src/widget/components/TokenSelector.tsx +62 -53
- package/src/widget/components/TokenSelectorButton.tsx +38 -15
- package/src/widget/components/Tooltip.tsx +51 -0
- package/src/widget/components/TransferPendingVertical.tsx +12 -8
- package/src/widget/components/WaasFeeOptions.tsx +139 -4
- package/src/widget/components/WalletConfirmation.tsx +23 -13
- package/src/widget/components/WalletConnect.tsx +93 -29
- package/src/widget/hooks/useAmountUsd.ts +9 -9
- package/src/widget/hooks/useCheckout.ts +97 -9
- package/src/widget/hooks/useDefaultTokenSelection.tsx +27 -21
- package/src/widget/hooks/useQuote.ts +466 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +32 -37
- package/src/widget/hooks/useSendForm.ts +45 -51
- package/src/widget/hooks/useTokenList.ts +34 -26
- package/src/widget/hooks/useWalletConnectionContext.tsx +128 -0
- package/src/widget/widget.tsx +365 -390
- package/dist/apiClient.d.ts +0 -9
- package/dist/apiClient.d.ts.map +0 -1
- package/dist/intentEntrypoint.d.ts +0 -114
- package/dist/intentEntrypoint.d.ts.map +0 -1
- package/dist/metaTxnMonitor.d.ts +0 -15
- package/dist/metaTxnMonitor.d.ts.map +0 -1
- package/dist/metaTxns.d.ts +0 -11
- package/dist/metaTxns.d.ts.map +0 -1
- package/dist/relayer.d.ts +0 -43
- package/dist/relayer.d.ts.map +0 -1
- package/src/apiClient.ts +0 -35
- package/src/intentEntrypoint.ts +0 -203
- package/src/metaTxnMonitor.ts +0 -171
- package/src/metaTxns.ts +0 -45
- package/src/relayer.ts +0 -289
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Polling intervals for different operations
|
|
2
|
+
export const POLLING_INTERVALS = {
|
|
3
|
+
// Consistent interval for transaction history polling (3 seconds)
|
|
4
|
+
TRANSACTION_HISTORY: 3000,
|
|
5
|
+
// Consistent interval for meta transaction polling (2 seconds)
|
|
6
|
+
META_TRANSACTION: 2000,
|
|
7
|
+
// Consistent interval for CCTP queue polling (5 seconds)
|
|
8
|
+
CCTP_QUEUE: 5000,
|
|
9
|
+
// Consistent interval for failure polling (2 seconds)
|
|
10
|
+
FAILURE_POLLING: 2000,
|
|
11
|
+
} as const
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Account,
|
|
3
|
+
Chain,
|
|
4
|
+
PublicClient,
|
|
5
|
+
WalletClient,
|
|
6
|
+
TransactionReceipt,
|
|
7
|
+
} from "viem"
|
|
8
|
+
import { zeroAddress } from "viem"
|
|
9
|
+
import type { TrailsAPIClient } from "@0xsequence/trails-api"
|
|
10
|
+
import type { TransactionState } from "../../transactions.js"
|
|
11
|
+
import type { CheckoutOnHandlers } from "../../widget/hooks/useCheckout.js"
|
|
12
|
+
import type {
|
|
13
|
+
DepositSignature,
|
|
14
|
+
GasFeeOptions,
|
|
15
|
+
ExecuteIntentResponse,
|
|
16
|
+
} from "@0xsequence/trails-api"
|
|
17
|
+
import type { SelectedFeeToken } from "../types.js"
|
|
18
|
+
import { logger } from "../../logger.js"
|
|
19
|
+
import { attemptGaslessDeposit, getDoGasless } from "./gaslessDeposit.js"
|
|
20
|
+
import { attemptStandardDeposit } from "./standardDeposit.js"
|
|
21
|
+
|
|
22
|
+
export async function attemptUserDepositTx({
|
|
23
|
+
originTokenAddress,
|
|
24
|
+
paymasterUrl,
|
|
25
|
+
chain,
|
|
26
|
+
account,
|
|
27
|
+
firstPreconditionMin,
|
|
28
|
+
originIntentAddress,
|
|
29
|
+
onOriginSend,
|
|
30
|
+
publicClient,
|
|
31
|
+
walletClient,
|
|
32
|
+
destinationTokenDecimals,
|
|
33
|
+
sourceTokenDecimals,
|
|
34
|
+
fee,
|
|
35
|
+
dryMode,
|
|
36
|
+
sourceTokenPriceUsd,
|
|
37
|
+
destinationTokenPriceUsd,
|
|
38
|
+
swapAmount,
|
|
39
|
+
onTransactionStateChange,
|
|
40
|
+
transactionStates,
|
|
41
|
+
fundMethod,
|
|
42
|
+
originTokenSymbol,
|
|
43
|
+
destinationTokenSymbol,
|
|
44
|
+
depositAmountUsd,
|
|
45
|
+
feeOptions,
|
|
46
|
+
trailsClient,
|
|
47
|
+
selectedFeeToken,
|
|
48
|
+
walletId,
|
|
49
|
+
abortSignal,
|
|
50
|
+
checkoutOnHandlers,
|
|
51
|
+
intentId,
|
|
52
|
+
executeIntentFn,
|
|
53
|
+
depositRecipientOverride,
|
|
54
|
+
isSameChainSameToken,
|
|
55
|
+
}: {
|
|
56
|
+
originTokenAddress: string
|
|
57
|
+
paymasterUrl?: string
|
|
58
|
+
chain: Chain
|
|
59
|
+
account: Account
|
|
60
|
+
firstPreconditionMin: string
|
|
61
|
+
originIntentAddress: string
|
|
62
|
+
onOriginSend?: () => void
|
|
63
|
+
publicClient: PublicClient
|
|
64
|
+
walletClient: WalletClient
|
|
65
|
+
destinationTokenDecimals: number
|
|
66
|
+
sourceTokenDecimals: number
|
|
67
|
+
swapAmount: string
|
|
68
|
+
dryMode: boolean
|
|
69
|
+
sourceTokenPriceUsd: number | null
|
|
70
|
+
destinationTokenPriceUsd: number | null
|
|
71
|
+
fee: string
|
|
72
|
+
onTransactionStateChange: (transactionStates: TransactionState[]) => void
|
|
73
|
+
transactionStates: TransactionState[]
|
|
74
|
+
fundMethod?: string
|
|
75
|
+
originTokenSymbol: string
|
|
76
|
+
destinationTokenSymbol: string
|
|
77
|
+
depositAmountUsd: number
|
|
78
|
+
feeOptions?: GasFeeOptions
|
|
79
|
+
trailsClient: TrailsAPIClient
|
|
80
|
+
selectedFeeToken?: SelectedFeeToken
|
|
81
|
+
walletId?: string
|
|
82
|
+
abortSignal?: AbortSignal
|
|
83
|
+
checkoutOnHandlers?: CheckoutOnHandlers
|
|
84
|
+
intentId?: string
|
|
85
|
+
executeIntentFn?: (params: {
|
|
86
|
+
intentId: string
|
|
87
|
+
depositTransactionHash?: string
|
|
88
|
+
depositSignature?: DepositSignature
|
|
89
|
+
}) => Promise<ExecuteIntentResponse>
|
|
90
|
+
depositRecipientOverride?: string
|
|
91
|
+
isSameChainSameToken?: boolean
|
|
92
|
+
}): Promise<TransactionReceipt | null> {
|
|
93
|
+
let depositUserTxnReceipt: TransactionReceipt | null = null
|
|
94
|
+
const originChainId = chain.id
|
|
95
|
+
|
|
96
|
+
// Use override recipient if provided (for same-chain same-token non-gasless transfers)
|
|
97
|
+
// Otherwise use originIntentAddress
|
|
98
|
+
const effectiveDepositRecipient =
|
|
99
|
+
depositRecipientOverride || originIntentAddress
|
|
100
|
+
|
|
101
|
+
logger.console.log("[trails-sdk] attemptUserDepositTx called with:", {
|
|
102
|
+
fundMethod,
|
|
103
|
+
intentId,
|
|
104
|
+
hasPaymasterUrl: !!paymasterUrl,
|
|
105
|
+
depositRecipientOverride,
|
|
106
|
+
effectiveDepositRecipient,
|
|
107
|
+
isSameChainSameToken,
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
// Skip wallet deposit if fund method is qr-code
|
|
111
|
+
if (fundMethod === "qr-code" || fundMethod === "exchange") {
|
|
112
|
+
logger.console.log(
|
|
113
|
+
"[trails-sdk] Skipping wallet deposit for QR code mode - fundMethod is:",
|
|
114
|
+
fundMethod,
|
|
115
|
+
)
|
|
116
|
+
return null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const doGasless = getDoGasless(
|
|
120
|
+
originTokenAddress,
|
|
121
|
+
feeOptions,
|
|
122
|
+
selectedFeeToken,
|
|
123
|
+
walletId,
|
|
124
|
+
)
|
|
125
|
+
logger.console.log(
|
|
126
|
+
"[trails-sdk] [GASLESS-FLOW] [FEE-SELECT] doGasless check results:",
|
|
127
|
+
{
|
|
128
|
+
doGasless,
|
|
129
|
+
paymasterUrl,
|
|
130
|
+
hasFeeOptions: !!feeOptions,
|
|
131
|
+
feeOptionsCount: feeOptions?.feeOptions?.length || 0,
|
|
132
|
+
selectedFeeToken,
|
|
133
|
+
selectedFeeTokenSet:
|
|
134
|
+
selectedFeeToken !== null && selectedFeeToken !== undefined,
|
|
135
|
+
originTokenAddress,
|
|
136
|
+
isNotNative: originTokenAddress !== zeroAddress,
|
|
137
|
+
},
|
|
138
|
+
)
|
|
139
|
+
if (doGasless || paymasterUrl) {
|
|
140
|
+
logger.console.log(
|
|
141
|
+
"[trails-sdk] [GASLESS-FLOW] Entering gasless deposit flow",
|
|
142
|
+
{
|
|
143
|
+
doGasless,
|
|
144
|
+
hasPaymasterUrl: !!paymasterUrl,
|
|
145
|
+
paymasterUrl,
|
|
146
|
+
},
|
|
147
|
+
)
|
|
148
|
+
try {
|
|
149
|
+
await attemptGaslessDeposit({
|
|
150
|
+
paymasterUrl,
|
|
151
|
+
depositTokenAddress: originTokenAddress,
|
|
152
|
+
depositTokenAmount: firstPreconditionMin,
|
|
153
|
+
depositRecipient: originIntentAddress,
|
|
154
|
+
onOriginSend,
|
|
155
|
+
walletClient,
|
|
156
|
+
chain,
|
|
157
|
+
account,
|
|
158
|
+
trailsClient,
|
|
159
|
+
feeOptions: feeOptions,
|
|
160
|
+
selectedFeeToken: selectedFeeToken,
|
|
161
|
+
abortSignal,
|
|
162
|
+
checkoutOnHandlers,
|
|
163
|
+
intentId,
|
|
164
|
+
onTransactionStateChange,
|
|
165
|
+
transactionStates,
|
|
166
|
+
executeIntentFn,
|
|
167
|
+
})
|
|
168
|
+
// Gasless deposit submitted to backend, monitoring happens separately
|
|
169
|
+
depositUserTxnReceipt = null
|
|
170
|
+
} catch (error) {
|
|
171
|
+
logger.console.log("[trails-sdk] gassless attempt failed", error)
|
|
172
|
+
// If doGasless is true (ERC20 fee selected), re-throw error since we must use gasless
|
|
173
|
+
if (doGasless) {
|
|
174
|
+
throw error
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// If gasless attempt failed, try to send a regular transaction
|
|
180
|
+
if (!depositUserTxnReceipt && !doGasless) {
|
|
181
|
+
depositUserTxnReceipt = await attemptStandardDeposit({
|
|
182
|
+
originTokenAddress,
|
|
183
|
+
firstPreconditionMin,
|
|
184
|
+
originIntentAddress,
|
|
185
|
+
onOriginSend,
|
|
186
|
+
publicClient,
|
|
187
|
+
walletClient,
|
|
188
|
+
originChainId,
|
|
189
|
+
chain,
|
|
190
|
+
account,
|
|
191
|
+
fee,
|
|
192
|
+
dryMode,
|
|
193
|
+
sourceTokenPriceUsd,
|
|
194
|
+
destinationTokenPriceUsd,
|
|
195
|
+
swapAmount,
|
|
196
|
+
destinationTokenDecimals,
|
|
197
|
+
sourceTokenDecimals,
|
|
198
|
+
onTransactionStateChange,
|
|
199
|
+
transactionStates,
|
|
200
|
+
originTokenSymbol,
|
|
201
|
+
destinationTokenSymbol,
|
|
202
|
+
depositAmountUsd,
|
|
203
|
+
checkoutOnHandlers,
|
|
204
|
+
isSameChainSameToken,
|
|
205
|
+
recipient: effectiveDepositRecipient,
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return depositUserTxnReceipt
|
|
210
|
+
}
|