0xtrails 0.13.2 → 0.14.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 +5 -42
- package/dist/abis/trailsHydrate.d.ts.map +1 -1
- package/dist/abis/trailsRouter.d.ts +1 -1
- package/dist/abis/trailsRouter.d.ts.map +1 -1
- package/dist/{widget/analytics → analytics/hooks}/useWidgetAnalytics.d.ts +2 -4
- package/dist/analytics/hooks/useWidgetAnalytics.d.ts.map +1 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/chainSwitch.d.ts.map +1 -1
- package/dist/chains-C1NhDLF_.js +4 -0
- package/dist/chains-CcoarGia.js +658 -0
- package/dist/chains.d.ts +0 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/committedIntentStore.d.ts +5 -0
- package/dist/committedIntentStore.d.ts.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +73 -4
- package/dist/error.d.ts.map +1 -1
- package/dist/hooks/useAddressWalletIcon.d.ts.map +1 -0
- package/dist/hooks/useAmountUsd.d.ts.map +1 -0
- package/dist/hooks/useBalanceVisible.d.ts.map +1 -0
- package/dist/hooks/useChainFilter.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useCheckout.d.ts +15 -15
- package/dist/hooks/useCheckout.d.ts.map +1 -0
- package/dist/hooks/useClickTracking.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useCombinedHistory.d.ts +3 -2
- package/dist/hooks/useCombinedHistory.d.ts.map +1 -0
- package/dist/hooks/useConnector.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useCustomTokenSearch.d.ts +1 -1
- package/dist/hooks/useCustomTokenSearch.d.ts.map +1 -0
- package/dist/hooks/useDebounce.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useDebugScreens.d.ts +2 -2
- package/dist/hooks/useDebugScreens.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useDefaultDestinationToken.d.ts +1 -1
- package/dist/hooks/useDefaultDestinationToken.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useDefaultOriginToken.d.ts +1 -1
- package/dist/hooks/useDefaultOriginToken.d.ts.map +1 -0
- package/dist/hooks/useDepositMonitor.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useDestinationSelectedToken.d.ts +2 -2
- package/dist/hooks/useDestinationSelectedToken.d.ts.map +1 -0
- package/dist/hooks/useDisplayCurrencyPreference.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useEarnPool.d.ts +1 -1
- package/dist/hooks/useEarnPool.d.ts.map +1 -0
- package/dist/hooks/useEffectiveFundBalance.d.ts +28 -0
- package/dist/hooks/useEffectiveFundBalance.d.ts.map +1 -0
- package/dist/hooks/useExecutingIntentsCount.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useExternalFundingReceiptSync.d.ts +1 -1
- package/dist/hooks/useExternalFundingReceiptSync.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useFiatOnRampCurrencies.d.ts +1 -1
- package/dist/hooks/useFiatOnRampCurrencies.d.ts.map +1 -0
- package/dist/hooks/useFiatSelectedCurrency.d.ts.map +1 -0
- package/dist/hooks/useGetIntent.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useIntentReceiptBalances.d.ts +1 -1
- package/dist/hooks/useIntentReceiptBalances.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useIntentTransactionHistory.d.ts +2 -1
- package/dist/hooks/useIntentTransactionHistory.d.ts.map +1 -0
- package/dist/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/hooks/useIsSequenceWallet.d.ts.map +1 -0
- package/dist/hooks/useLocalePreference.d.ts.map +1 -0
- package/dist/hooks/useMeldTransactionHistory.d.ts.map +1 -0
- package/dist/hooks/useMeldTransactionStatus.d.ts.map +1 -0
- package/dist/hooks/useOnRampCountryDefaults.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOnRampPaymentMethods.d.ts +2 -2
- package/dist/hooks/useOnRampPaymentMethods.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOnRampProviderWidget.d.ts +1 -1
- package/dist/hooks/useOnRampProviderWidget.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOnRampQuote.d.ts +3 -3
- package/dist/hooks/useOnRampQuote.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOnRampTransactionStatus.d.ts +1 -1
- package/dist/hooks/useOnRampTransactionStatus.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOriginSelectedToken.d.ts +1 -1
- package/dist/hooks/useOriginSelectedToken.d.ts.map +1 -0
- package/dist/hooks/usePayMessage.d.ts.map +1 -0
- package/dist/hooks/usePriceImpactWarning.d.ts.map +1 -0
- package/dist/hooks/useQuote.d.ts +439 -0
- package/dist/hooks/useQuote.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useRecentTokens.d.ts +1 -1
- package/dist/hooks/useRecentTokens.d.ts.map +1 -0
- package/dist/hooks/useRecipients.d.ts.map +1 -0
- package/dist/hooks/useSelectedFeeOption.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useSelectedFundMethod.d.ts +11 -1
- package/dist/hooks/useSelectedFundMethod.d.ts.map +1 -0
- package/dist/hooks/useSelectedRecipient.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useSendForm.d.ts +6 -11
- package/dist/hooks/useSendForm.d.ts.map +1 -0
- package/dist/hooks/useSwapAmount.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useSwapState.d.ts +1 -1
- package/dist/hooks/useSwapState.d.ts.map +1 -0
- package/dist/hooks/useTargetAmount.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useTokenList.d.ts +2 -2
- package/dist/hooks/useTokenList.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useTrailsSendTransaction.d.ts +1 -1
- package/dist/hooks/useTrailsSendTransaction.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useViewManager.d.ts +1 -1
- package/dist/hooks/useViewManager.d.ts.map +1 -0
- package/dist/hooks/useWalletConnectUri.d.ts +19 -0
- package/dist/hooks/useWalletConnectUri.d.ts.map +1 -0
- package/dist/hooks/useWalletConnectionContext.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useWidgetProps.d.ts +1 -1
- package/dist/hooks/useWidgetProps.d.ts.map +1 -0
- package/dist/hydrate/builder.d.ts +131 -0
- package/dist/hydrate/builder.d.ts.map +1 -0
- package/dist/hydrate/constants.d.ts +13 -0
- package/dist/hydrate/constants.d.ts.map +1 -0
- package/dist/hydrate/encodeExecute.d.ts +73 -0
- package/dist/hydrate/encodeExecute.d.ts.map +1 -0
- package/dist/hydrate/index.d.ts +6 -0
- package/dist/hydrate/index.d.ts.map +1 -0
- package/dist/hydrate/index.js +11 -0
- package/dist/hydrate/payload.d.ts +38 -0
- package/dist/hydrate/payload.d.ts.map +1 -0
- package/dist/hydrate/selectors.d.ts +28 -0
- package/dist/hydrate/selectors.d.ts.map +1 -0
- package/dist/hydrate/types.d.ts +19 -0
- package/dist/hydrate/types.d.ts.map +1 -0
- package/dist/hydrate/utils.d.ts +8 -0
- package/dist/hydrate/utils.d.ts.map +1 -0
- package/dist/hydrate-Cr9eaeDK.js +654 -0
- package/dist/index.d.ts +19 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +157 -662
- package/dist/intentConfigStore.d.ts +8 -0
- package/dist/intentConfigStore.d.ts.map +1 -0
- package/dist/intentProtocolApi.d.ts +11 -0
- package/dist/intentProtocolApi.d.ts.map +1 -0
- package/dist/intentProtocolEncoding.d.ts +25 -0
- package/dist/intentProtocolEncoding.d.ts.map +1 -0
- package/dist/intentProtocolResolver.d.ts +28 -0
- package/dist/intentProtocolResolver.d.ts.map +1 -0
- package/dist/intentReceiptPoller.d.ts.map +1 -1
- package/dist/intentValidation.d.ts +5 -0
- package/dist/intentValidation.d.ts.map +1 -0
- package/dist/intents.d.ts.map +1 -1
- package/dist/keymachine/index.d.ts +20 -0
- package/dist/keymachine/index.d.ts.map +1 -1
- package/dist/mutations.d.ts.map +1 -1
- package/dist/offlineRecovery.d.ts +24 -0
- package/dist/offlineRecovery.d.ts.map +1 -0
- package/dist/onramp/MeshConnectFlow.d.ts +9 -0
- package/dist/onramp/MeshConnectFlow.d.ts.map +1 -1
- package/dist/onramp/MeshConnectIframe.d.ts +9 -0
- package/dist/onramp/MeshConnectIframe.d.ts.map +1 -1
- package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -1
- package/dist/onramp/mesh/components/MeshExchangeConfirmation.d.ts +10 -0
- package/dist/onramp/mesh/components/MeshExchangeConfirmation.d.ts.map +1 -0
- package/dist/onramp/mesh/components/MeshExchangeIcon.d.ts +13 -0
- package/dist/onramp/mesh/components/MeshExchangeIcon.d.ts.map +1 -0
- package/dist/{widget → onramp/mesh}/components/MeshExchangeSelection.d.ts +1 -0
- package/dist/onramp/mesh/components/MeshExchangeSelection.d.ts.map +1 -0
- package/dist/onramp/mesh/components/MeshSessionOptions.d.ts +15 -0
- package/dist/onramp/mesh/components/MeshSessionOptions.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshAccessTokens.d.ts +9 -0
- package/dist/onramp/mesh/hooks/useMeshAccessTokens.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshFundingSelection.d.ts +11 -0
- package/dist/onramp/mesh/hooks/useMeshFundingSelection.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshOnrampFlow.d.ts +71 -0
- package/dist/onramp/mesh/hooks/useMeshOnrampFlow.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshOnrampSessionState.d.ts +32 -0
- package/dist/onramp/mesh/hooks/useMeshOnrampSessionState.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshSelectedTokenBalance.d.ts +19 -0
- package/dist/onramp/mesh/hooks/useMeshSelectedTokenBalance.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshSessionAccountBalance.d.ts +15 -0
- package/dist/onramp/mesh/hooks/useMeshSessionAccountBalance.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshSessionStorage.d.ts +7 -0
- package/dist/onramp/mesh/hooks/useMeshSessionStorage.d.ts.map +1 -0
- package/dist/onramp/meshSessionStorage.d.ts +13 -0
- package/dist/onramp/meshSessionStorage.d.ts.map +1 -0
- package/dist/onramp/meshconnect.d.ts +6 -4
- package/dist/onramp/meshconnect.d.ts.map +1 -1
- package/dist/onramp/trailsOnramp.d.ts +8 -0
- package/dist/onramp/trailsOnramp.d.ts.map +1 -1
- package/dist/onrampClient.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +3 -2
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/query/intentProtocol.queries.d.ts +32 -0
- package/dist/query/intentProtocol.queries.d.ts.map +1 -0
- package/dist/recover.d.ts +70 -24
- package/dist/recover.d.ts.map +1 -1
- package/dist/src-4HYDQv2T.js +48798 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +2 -3
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -3
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +2 -5
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/intentHandler.d.ts +4 -4
- package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +2 -2
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +3 -3
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactions.d.ts +1 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/umd/trails.min.js +1370 -410
- package/dist/utils/localStorageGc.d.ts +22 -0
- package/dist/utils/localStorageGc.d.ts.map +1 -0
- package/dist/walletUtils.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/Earn.d.ts +2 -6
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +1 -1
- package/dist/widget/components/FeeOption.d.ts.map +1 -1
- package/dist/widget/components/FeeOptions.d.ts +1 -1
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/FiatSelector.d.ts +1 -1
- package/dist/widget/components/FiatSelector.d.ts.map +1 -1
- package/dist/widget/components/FiatSelectorButton.d.ts +1 -1
- package/dist/widget/components/FiatSelectorButton.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/FundingMethodSelectorButton.d.ts +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/MeldHistory.d.ts +1 -1
- package/dist/widget/components/MeldHistory.d.ts.map +1 -1
- package/dist/widget/components/MeldTransactionStatus.d.ts +1 -1
- package/dist/widget/components/MeldTransactionStatus.d.ts.map +1 -1
- package/dist/widget/components/MeshExchangeAccountHeader.d.ts +9 -0
- package/dist/widget/components/MeshExchangeAccountHeader.d.ts.map +1 -0
- package/dist/widget/components/OnrampHistoryRow.d.ts +1 -1
- package/dist/widget/components/OnrampHistoryRow.d.ts.map +1 -1
- package/dist/widget/components/OnrampProviderConfirmation.d.ts +1 -1
- package/dist/widget/components/OnrampProviderConfirmation.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +2 -6
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +2 -2
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/PulsatingButton.d.ts +9 -0
- package/dist/widget/components/PulsatingButton.d.ts.map +1 -0
- package/dist/widget/components/Receipt.d.ts +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/Recipients.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +2 -6
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts +1 -0
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts +1 -2
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TransactionDetails.d.ts +1 -0
- package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
- package/dist/widget/components/TransactionHistoryItem.d.ts +1 -0
- package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WalletAccountHeader.d.ts +7 -0
- package/dist/widget/components/WalletAccountHeader.d.ts.map +1 -0
- package/dist/widget/components/WalletConfirmation.d.ts +2 -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/index.d.ts +13 -0
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +16 -8
- package/dist/widget/modes/EarnWidget.d.ts +83 -0
- package/dist/widget/modes/EarnWidget.d.ts.map +1 -0
- package/dist/widget/modes/FundWidget.d.ts +103 -0
- package/dist/widget/modes/FundWidget.d.ts.map +1 -0
- package/dist/widget/modes/PayWidget.d.ts +86 -0
- package/dist/widget/modes/PayWidget.d.ts.map +1 -0
- package/dist/widget/modes/SwapWidget.d.ts +82 -0
- package/dist/widget/modes/SwapWidget.d.ts.map +1 -0
- package/dist/widget/modes/WithdrawWidget.d.ts +71 -0
- package/dist/widget/modes/WithdrawWidget.d.ts.map +1 -0
- package/dist/widget/providers/TrailsProvider.d.ts +3 -0
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/shared/mapSharedProps.d.ts +9 -0
- package/dist/widget/shared/mapSharedProps.d.ts.map +1 -0
- package/dist/widget/shared/methodMap.d.ts +18 -0
- package/dist/widget/shared/methodMap.d.ts.map +1 -0
- package/dist/widget/shared/resolution.d.ts +22 -0
- package/dist/widget/shared/resolution.d.ts.map +1 -0
- package/dist/widget/shared/resolvePaymentSource.d.ts +34 -0
- package/dist/widget/shared/resolvePaymentSource.d.ts.map +1 -0
- package/dist/widget/shared/types.d.ts +94 -0
- package/dist/widget/shared/types.d.ts.map +1 -0
- package/dist/widget/types/commonProps.d.ts +3 -7
- package/dist/widget/types/commonProps.d.ts.map +1 -1
- package/dist/widget/utils/fundMethodSwitchState.d.ts +1 -0
- package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -1
- package/dist/widget/utils/viewManagerGuards.d.ts +1 -1
- package/dist/widget/utils/viewManagerGuards.d.ts.map +1 -1
- package/dist/widget/widget.d.ts +21 -16
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +17 -23
- package/dist/buffer.d.ts +0 -3
- package/dist/buffer.d.ts.map +0 -1
- package/dist/ccip-CT_An6eM.js +0 -230
- package/dist/index-RfqL5Foz.js +0 -114567
- package/dist/paymasterSend.d.ts +0 -90
- package/dist/paymasterSend.d.ts.map +0 -1
- package/dist/sendUserOp.d.ts +0 -122
- package/dist/sendUserOp.d.ts.map +0 -1
- package/dist/toSimpleSmartAccount.d.ts +0 -95
- package/dist/toSimpleSmartAccount.d.ts.map +0 -1
- package/dist/transactionIntent/utils/erc20Approval.d.ts +0 -34
- package/dist/transactionIntent/utils/erc20Approval.d.ts.map +0 -1
- package/dist/utils/allowance.d.ts +0 -19
- package/dist/utils/allowance.d.ts.map +0 -1
- package/dist/widget/analytics/useWidgetAnalytics.d.ts.map +0 -1
- package/dist/widget/components/FeeBreakdown.d.ts +0 -9
- package/dist/widget/components/FeeBreakdown.d.ts.map +0 -1
- package/dist/widget/components/HideBalances.d.ts +0 -4
- package/dist/widget/components/HideBalances.d.ts.map +0 -1
- package/dist/widget/components/MeshExchangeSelection.d.ts.map +0 -1
- package/dist/widget/components/OnrampDeposit.d.ts +0 -10
- package/dist/widget/components/OnrampDeposit.d.ts.map +0 -1
- package/dist/widget/components/SwapSettings.d.ts +0 -4
- package/dist/widget/components/SwapSettings.d.ts.map +0 -1
- package/dist/widget/components/TruncatedAddress.d.ts +0 -12
- package/dist/widget/components/TruncatedAddress.d.ts.map +0 -1
- package/dist/widget/components/WalletImage.d.ts +0 -8
- package/dist/widget/components/WalletImage.d.ts.map +0 -1
- package/dist/widget/css/compiled.css +0 -26
- package/dist/widget/css/index.css +0 -686
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +0 -1
- package/dist/widget/hooks/useAmountUsd.d.ts.map +0 -1
- package/dist/widget/hooks/useBalanceVisible.d.ts.map +0 -1
- package/dist/widget/hooks/useChainFilter.d.ts.map +0 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +0 -1
- package/dist/widget/hooks/useClickTracking.d.ts.map +0 -1
- package/dist/widget/hooks/useCombinedHistory.d.ts.map +0 -1
- package/dist/widget/hooks/useConnector.d.ts.map +0 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +0 -1
- package/dist/widget/hooks/useDebounce.d.ts.map +0 -1
- package/dist/widget/hooks/useDebugScreens.d.ts.map +0 -1
- package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +0 -1
- package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +0 -1
- package/dist/widget/hooks/useDepositMonitor.d.ts.map +0 -1
- package/dist/widget/hooks/useDestinationSelectedToken.d.ts.map +0 -1
- package/dist/widget/hooks/useDisplayCurrencyPreference.d.ts.map +0 -1
- package/dist/widget/hooks/useEarnPool.d.ts.map +0 -1
- package/dist/widget/hooks/useExecutingIntentsCount.d.ts.map +0 -1
- package/dist/widget/hooks/useExternalFundingReceiptSync.d.ts.map +0 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +0 -1
- package/dist/widget/hooks/useFiatSelectedCurrency.d.ts.map +0 -1
- package/dist/widget/hooks/useGetIntent.d.ts.map +0 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +0 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +0 -1
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts +0 -7
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts.map +0 -1
- package/dist/widget/hooks/useIsMobile.d.ts.map +0 -1
- package/dist/widget/hooks/useIsSequenceWallet.d.ts.map +0 -1
- package/dist/widget/hooks/useLocalePreference.d.ts.map +0 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +0 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampCountryDefaults.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampPaymentMethods.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampProviderWidget.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +0 -1
- package/dist/widget/hooks/useOriginSelectedToken.d.ts.map +0 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +0 -1
- package/dist/widget/hooks/usePriceImpactWarning.d.ts.map +0 -1
- package/dist/widget/hooks/useQuote.d.ts +0 -378
- package/dist/widget/hooks/useQuote.d.ts.map +0 -1
- package/dist/widget/hooks/useRecentTokens.d.ts.map +0 -1
- package/dist/widget/hooks/useRecipients.d.ts.map +0 -1
- package/dist/widget/hooks/useScreenTracking.d.ts +0 -2
- package/dist/widget/hooks/useScreenTracking.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +0 -1
- package/dist/widget/hooks/useSendForm.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapAmount.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapState.d.ts.map +0 -1
- package/dist/widget/hooks/useTargetAmount.d.ts.map +0 -1
- package/dist/widget/hooks/useTheme.d.ts.map +0 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +0 -1
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +0 -1
- package/dist/widget/hooks/useViewManager.d.ts.map +0 -1
- package/dist/widget/hooks/useWalletConnectUri.d.ts +0 -11
- package/dist/widget/hooks/useWalletConnectUri.d.ts.map +0 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +0 -1
- package/dist/widget/hooks/useWidgetProps.d.ts.map +0 -1
- package/dist/widget/types.d.ts +0 -44
- package/dist/widget/types.d.ts.map +0 -1
- package/dist/widget/utils/historyUtils.d.ts +0 -18
- package/dist/widget/utils/historyUtils.d.ts.map +0 -1
- package/src/abi.ts +0 -38
- package/src/abis/erc20.ts +0 -60
- package/src/abis/trailsHydrate.ts +0 -185
- package/src/abis/trailsRouter.ts +0 -121
- package/src/abis/trailsSweep.ts +0 -32
- package/src/abortController.ts +0 -35
- package/src/analytics.ts +0 -2029
- package/src/buffer.ts +0 -10
- package/src/chainSwitch.ts +0 -95
- package/src/chains.ts +0 -570
- package/src/config.ts +0 -118
- package/src/constants.ts +0 -239
- package/src/contractUtils.ts +0 -46
- package/src/cssUtils.ts +0 -5
- package/src/customChains.ts +0 -24
- package/src/customTokens.ts +0 -168
- package/src/decoders.ts +0 -365
- package/src/ens.ts +0 -74
- package/src/error.ts +0 -268
- package/src/estimate.ts +0 -480
- package/src/explorer.ts +0 -38
- package/src/fees.ts +0 -362
- package/src/gasless.ts +0 -638
- package/src/index.ts +0 -205
- package/src/indexerClient.ts +0 -118
- package/src/intentReceiptMonitor.ts +0 -99
- package/src/intentReceiptPoller.ts +0 -327
- package/src/intents.ts +0 -1133
- package/src/keyMachineClient.ts +0 -29
- package/src/keymachine/index.ts +0 -175
- package/src/keymachine/key-machine.gen.ts +0 -993
- package/src/localeUtils.ts +0 -244
- package/src/logger/index.ts +0 -95
- package/src/logger/useSyncLoggerDebug.ts +0 -11
- package/src/logger.ts +0 -1
- package/src/meld/components/MeldCountriesList.tsx +0 -237
- package/src/meld/components/MeldFundMethods.tsx +0 -265
- package/src/meld/components/MeldProvidersList.tsx +0 -187
- package/src/meld/components/MeldTokensList.tsx +0 -321
- package/src/meld/components/SimpleHeader.tsx +0 -35
- package/src/meld/utils/meld.ts +0 -77
- package/src/mutations.ts +0 -166
- package/src/onramp/MeshConnectFlow.tsx +0 -86
- package/src/onramp/MeshConnectIframe.tsx +0 -661
- package/src/onramp/SendFromExchangeButton.tsx +0 -81
- package/src/onramp/TrailsOnRampProvider.tsx +0 -59
- package/src/onramp/index.ts +0 -31
- package/src/onramp/meshconnect.ts +0 -277
- package/src/onramp/trailsOnramp.tsx +0 -130
- package/src/onramp-client/index.ts +0 -52
- package/src/onrampClient.ts +0 -46
- package/src/paymasterSend.ts +0 -521
- package/src/placeholder.ts +0 -92
- package/src/poolUtils.ts +0 -222
- package/src/pools.ts +0 -120
- package/src/prepareSend.ts +0 -553
- package/src/query/balance.fetchers.ts +0 -753
- package/src/query/balance.hooks.ts +0 -357
- package/src/query/balance.queries.ts +0 -307
- package/src/query/chains.hooks.ts +0 -45
- package/src/query/chains.queries.ts +0 -17
- package/src/query/client.ts +0 -20
- package/src/query/fiat.fetchers.ts +0 -33
- package/src/query/fiat.hooks.ts +0 -71
- package/src/query/fiat.queries.ts +0 -67
- package/src/query/geo.fetchers.ts +0 -100
- package/src/query/geo.hooks.ts +0 -16
- package/src/query/geo.queries.ts +0 -36
- package/src/query/helpers.ts +0 -81
- package/src/query/meld.fetchers.ts +0 -97
- package/src/query/meld.hooks.ts +0 -18
- package/src/query/meld.queries.ts +0 -184
- package/src/query/persister.ts +0 -11
- package/src/query/price.fetchers.ts +0 -53
- package/src/query/price.hooks.ts +0 -46
- package/src/query/price.queries.ts +0 -364
- package/src/query/tokenList.queries.ts +0 -118
- package/src/queryParams.ts +0 -100
- package/src/recover.ts +0 -1728
- package/src/sendUserOp.ts +0 -512
- package/src/theme.ts +0 -2
- package/src/toSimpleSmartAccount.ts +0 -567
- package/src/toast.ts +0 -110
- package/src/tokens.ts +0 -1862
- package/src/trailsClient.ts +0 -40
- package/src/transactionIntent/constants.ts +0 -15
- package/src/transactionIntent/deposits/depositOrchestrator.ts +0 -243
- package/src/transactionIntent/deposits/gaslessDeposit.ts +0 -705
- package/src/transactionIntent/deposits/index.ts +0 -3
- package/src/transactionIntent/deposits/standardDeposit.ts +0 -590
- package/src/transactionIntent/execution/index.ts +0 -1
- package/src/transactionIntent/execution/transactionState.ts +0 -38
- package/src/transactionIntent/handlers/index.ts +0 -1
- package/src/transactionIntent/handlers/intentHandler.ts +0 -1613
- package/src/transactionIntent/helpers/index.ts +0 -1
- package/src/transactionIntent/helpers/transactionStateHelpers.ts +0 -440
- package/src/transactionIntent/index.ts +0 -10
- package/src/transactionIntent/quote/feeExtractors.ts +0 -61
- package/src/transactionIntent/quote/index.ts +0 -3
- package/src/transactionIntent/quote/normalizeQuote.ts +0 -559
- package/src/transactionIntent/quote/quoteHelpers.ts +0 -117
- package/src/transactionIntent/types.ts +0 -241
- package/src/transactionIntent/utils/balanceChecker.ts +0 -103
- package/src/transactionIntent/utils/erc20Approval.ts +0 -171
- package/src/transactionIntent/utils/index.ts +0 -2
- package/src/transactionIntent/utils/resilientDepositTracker.ts +0 -171
- package/src/transactionIntent/utils/testnetHelpers.ts +0 -5
- package/src/transactionIntent/validators.ts +0 -27
- package/src/transactions.ts +0 -429
- package/src/types.d.ts +0 -16
- package/src/umd.tsx +0 -33
- package/src/utils/address.ts +0 -78
- package/src/utils/allowance.ts +0 -47
- package/src/utils/fiat.ts +0 -32
- package/src/utils/format.ts +0 -625
- package/src/utils/passthrough.ts +0 -93
- package/src/utils/time.ts +0 -118
- package/src/utils/validation.ts +0 -104
- package/src/utils.ts +0 -112
- package/src/version.ts +0 -8
- package/src/vite-env.d.ts +0 -4
- package/src/walletUtils.ts +0 -293
- package/src/wallets.ts +0 -544
- package/src/widget/analytics/useWidgetAnalytics.ts +0 -56
- package/src/widget/assets/Exchange-icon-black.svg +0 -5
- package/src/widget/assets/MetaMask-icon-fox-with-margins.svg +0 -31
- package/src/widget/assets/MetaMask-icon-fox.svg +0 -26
- package/src/widget/assets/MetaMask-logo-black.svg +0 -3
- package/src/widget/assets/MetaMask-logo-white.svg +0 -16
- package/src/widget/assets/Trails-logo-black.svg +0 -13
- package/src/widget/assets/Trails-logo-white.svg +0 -13
- package/src/widget/assets/WalletChange-black.svg +0 -5
- package/src/widget/assets/WalletConnect-logo-black.svg +0 -14
- package/src/widget/assets/WalletConnect-logo-blue.svg +0 -14
- package/src/widget/assets/WalletConnect-logo-white.svg +0 -14
- package/src/widget/assets/WalletConnect-logo.svg +0 -40
- package/src/widget/assets/aave.svg +0 -14
- package/src/widget/assets/morpho.svg +0 -14
- package/src/widget/compiled.css +0 -26
- package/src/widget/components/AccountActionsDropdown.tsx +0 -31
- package/src/widget/components/AccountIntentTransactionHistory.tsx +0 -756
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +0 -34
- package/src/widget/components/AccountSettings.tsx +0 -168
- package/src/widget/components/AddressOrEnsName.tsx +0 -24
- package/src/widget/components/AddressWalletIcon.tsx +0 -49
- package/src/widget/components/AllChainsIcon.tsx +0 -54
- package/src/widget/components/ChainFilterDropdown.tsx +0 -220
- package/src/widget/components/ChainImage.tsx +0 -40
- package/src/widget/components/ChainList.tsx +0 -158
- package/src/widget/components/ClassicSwap.tsx +0 -1761
- package/src/widget/components/ConfigDisplay.tsx +0 -158
- package/src/widget/components/ConnectWallet.tsx +0 -566
- package/src/widget/components/ConnectedWallets.tsx +0 -414
- package/src/widget/components/CopyButton.tsx +0 -108
- package/src/widget/components/CountryFilterDropdown.tsx +0 -179
- package/src/widget/components/DebugMenu.tsx +0 -50
- package/src/widget/components/DebugScreensList.tsx +0 -70
- package/src/widget/components/DebugToast.tsx +0 -63
- package/src/widget/components/DepositTracker.tsx +0 -326
- package/src/widget/components/DirectTransfer.tsx +0 -305
- package/src/widget/components/Disconnect.tsx +0 -68
- package/src/widget/components/DynamicInputStyles.tsx +0 -121
- package/src/widget/components/DynamicSizeInputField.tsx +0 -245
- package/src/widget/components/ENSAvatar.tsx +0 -33
- package/src/widget/components/Earn.tsx +0 -160
- package/src/widget/components/EarnPools.tsx +0 -417
- package/src/widget/components/EarnPoolsFilters.tsx +0 -165
- package/src/widget/components/ErrorAnimationIcon.tsx +0 -130
- package/src/widget/components/ErrorDisplay.tsx +0 -152
- package/src/widget/components/ExecutingIntentsBadge.tsx +0 -24
- package/src/widget/components/ExecutionStatusBadge.tsx +0 -53
- package/src/widget/components/FeeBreakdown.tsx +0 -155
- package/src/widget/components/FeeOption.tsx +0 -170
- package/src/widget/components/FeeOptions.tsx +0 -247
- package/src/widget/components/FiatSelector.tsx +0 -308
- package/src/widget/components/FiatSelectorButton.tsx +0 -68
- package/src/widget/components/Footer.tsx +0 -67
- package/src/widget/components/Fund.tsx +0 -2463
- package/src/widget/components/FundMethods.tsx +0 -423
- package/src/widget/components/FundWalletSelection.tsx +0 -60
- package/src/widget/components/FundingMethodSelectorButton.tsx +0 -106
- package/src/widget/components/GreenCheckAnimation.tsx +0 -119
- package/src/widget/components/HideBalances.tsx +0 -24
- package/src/widget/components/HighPriceImpactBlock.tsx +0 -44
- package/src/widget/components/HookModalContent.tsx +0 -377
- package/src/widget/components/Identicon.tsx +0 -228
- package/src/widget/components/LoadingSpinner.tsx +0 -9
- package/src/widget/components/MeldForm.tsx +0 -780
- package/src/widget/components/MeldHistory.tsx +0 -433
- package/src/widget/components/MeldStepsFlow.tsx +0 -1651
- package/src/widget/components/MeldTransactionStatus.tsx +0 -255
- package/src/widget/components/MeshExchangeSelection.tsx +0 -218
- package/src/widget/components/Modal.tsx +0 -86
- package/src/widget/components/OFTProgressBar.tsx +0 -89
- package/src/widget/components/OnRampProviderSelector.tsx +0 -263
- package/src/widget/components/OnrampDeposit.tsx +0 -122
- package/src/widget/components/OnrampErrorScreen.tsx +0 -163
- package/src/widget/components/OnrampHistoryRow.tsx +0 -321
- package/src/widget/components/OnrampPaymentMethods.tsx +0 -81
- package/src/widget/components/OnrampProviderConfirmation.tsx +0 -1060
- package/src/widget/components/OriginSelectionAmount.tsx +0 -144
- package/src/widget/components/OriginTransferInformation.tsx +0 -59
- package/src/widget/components/Pay.tsx +0 -1165
- package/src/widget/components/PaymentMethods.tsx +0 -198
- package/src/widget/components/PercentageMaxButtons.tsx +0 -112
- package/src/widget/components/PoolDeposit.tsx +0 -642
- package/src/widget/components/PoolWithdraw.tsx +0 -761
- package/src/widget/components/PriceImpactWarning.tsx +0 -87
- package/src/widget/components/QRCodeOptions.tsx +0 -65
- package/src/widget/components/QRCodeWalletSelect.tsx +0 -80
- package/src/widget/components/QrCode.tsx +0 -216
- package/src/widget/components/QuoteDetails.tsx +0 -1275
- package/src/widget/components/Receipt.tsx +0 -673
- package/src/widget/components/ReceiptRecoverableFunds.tsx +0 -135
- package/src/widget/components/RecentTokens.tsx +0 -66
- package/src/widget/components/RecipientSelectorButton.tsx +0 -50
- package/src/widget/components/Recipients.tsx +0 -413
- package/src/widget/components/RefundWarning.tsx +0 -61
- package/src/widget/components/RequiredPropsError.tsx +0 -33
- package/src/widget/components/ScreenHeader.tsx +0 -123
- package/src/widget/components/SearchInputField.tsx +0 -99
- package/src/widget/components/SessionTimeoutScreen.tsx +0 -103
- package/src/widget/components/ShadowPortal.tsx +0 -99
- package/src/widget/components/ShadowRootContext.tsx +0 -17
- package/src/widget/components/SimpleRecipientInputScreen.tsx +0 -91
- package/src/widget/components/SlippageToleranceSettings.tsx +0 -279
- package/src/widget/components/Swap.tsx +0 -50
- package/src/widget/components/SwapDisplay.tsx +0 -68
- package/src/widget/components/SwapSettings.tsx +0 -52
- package/src/widget/components/ThemeProvider.tsx +0 -115
- package/src/widget/components/ThemeSyncer.tsx +0 -47
- package/src/widget/components/Toast.tsx +0 -336
- package/src/widget/components/TokenDisplayNonSelectable.tsx +0 -40
- package/src/widget/components/TokenImage.tsx +0 -156
- package/src/widget/components/TokenList.tsx +0 -107
- package/src/widget/components/TokenSelector.tsx +0 -807
- package/src/widget/components/TokenSelectorButton.tsx +0 -123
- package/src/widget/components/TokenSkeleton.tsx +0 -53
- package/src/widget/components/Tooltip.tsx +0 -64
- package/src/widget/components/TrailsHookModal.tsx +0 -107
- package/src/widget/components/TransactionDetails.tsx +0 -534
- package/src/widget/components/TransactionHistoryItem.tsx +0 -767
- package/src/widget/components/TransferPendingVertical.tsx +0 -591
- package/src/widget/components/TruncatedAddress.tsx +0 -68
- package/src/widget/components/TruncatedTransactionHash.tsx +0 -74
- package/src/widget/components/UserPreferences.tsx +0 -570
- package/src/widget/components/WaasFeeOptions.tsx +0 -588
- package/src/widget/components/WalletConfirmation.tsx +0 -220
- package/src/widget/components/WalletConnect.tsx +0 -348
- package/src/widget/components/WalletConnectionPending.tsx +0 -178
- package/src/widget/components/WalletImage.tsx +0 -52
- package/src/widget/components/WalletList.tsx +0 -125
- package/src/widget/components/WidgetProviders.tsx +0 -82
- package/src/widget/components/Withdraw.tsx +0 -1106
- package/src/widget/components/YellowWarningAnimation.tsx +0 -146
- package/src/widget/hooks/useAddressWalletIcon.ts +0 -55
- package/src/widget/hooks/useAmountUsd.ts +0 -44
- package/src/widget/hooks/useBalanceVisible.tsx +0 -95
- package/src/widget/hooks/useChainFilter.tsx +0 -56
- package/src/widget/hooks/useCheckout.ts +0 -361
- package/src/widget/hooks/useClickTracking.ts +0 -74
- package/src/widget/hooks/useCombinedHistory.ts +0 -420
- package/src/widget/hooks/useConnector.tsx +0 -24
- package/src/widget/hooks/useCustomTokenSearch.tsx +0 -369
- package/src/widget/hooks/useDebounce.ts +0 -25
- package/src/widget/hooks/useDebugScreens.ts +0 -600
- package/src/widget/hooks/useDefaultDestinationToken.tsx +0 -179
- package/src/widget/hooks/useDefaultOriginToken.tsx +0 -407
- package/src/widget/hooks/useDepositMonitor.ts +0 -118
- package/src/widget/hooks/useDestinationSelectedToken.tsx +0 -310
- package/src/widget/hooks/useDisplayCurrencyPreference.tsx +0 -145
- package/src/widget/hooks/useEarnPool.tsx +0 -36
- package/src/widget/hooks/useExecutingIntentsCount.ts +0 -78
- package/src/widget/hooks/useExternalFundingReceiptSync.ts +0 -79
- package/src/widget/hooks/useFiatOnRampCurrencies.ts +0 -46
- package/src/widget/hooks/useFiatSelectedCurrency.tsx +0 -123
- package/src/widget/hooks/useGetIntent.ts +0 -54
- package/src/widget/hooks/useIntentReceiptBalances.ts +0 -141
- package/src/widget/hooks/useIntentTransactionHistory.ts +0 -790
- package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +0 -43
- package/src/widget/hooks/useIsMobile.tsx +0 -50
- package/src/widget/hooks/useIsSequenceWallet.ts +0 -17
- package/src/widget/hooks/useLocalePreference.tsx +0 -187
- package/src/widget/hooks/useMeldTransactionHistory.ts +0 -184
- package/src/widget/hooks/useMeldTransactionStatus.ts +0 -707
- package/src/widget/hooks/useOnRampCountryDefaults.ts +0 -57
- package/src/widget/hooks/useOnRampPaymentMethods.ts +0 -72
- package/src/widget/hooks/useOnRampProviderWidget.ts +0 -184
- package/src/widget/hooks/useOnRampQuote.ts +0 -340
- package/src/widget/hooks/useOnRampTransactionStatus.ts +0 -196
- package/src/widget/hooks/useOriginSelectedToken.tsx +0 -253
- package/src/widget/hooks/usePayMessage.tsx +0 -496
- package/src/widget/hooks/usePriceImpactWarning.ts +0 -17
- package/src/widget/hooks/useQuote.ts +0 -1239
- package/src/widget/hooks/useRecentTokens.ts +0 -159
- package/src/widget/hooks/useRecipients.ts +0 -167
- package/src/widget/hooks/useScreenTracking.ts +0 -14
- package/src/widget/hooks/useSelectedFeeOption.tsx +0 -323
- package/src/widget/hooks/useSelectedFundMethod.tsx +0 -93
- package/src/widget/hooks/useSelectedRecipient.tsx +0 -75
- package/src/widget/hooks/useSendForm.ts +0 -1389
- package/src/widget/hooks/useSwapAmount.tsx +0 -50
- package/src/widget/hooks/useSwapState.tsx +0 -121
- package/src/widget/hooks/useTargetAmount.ts +0 -26
- package/src/widget/hooks/useTheme.tsx +0 -80
- package/src/widget/hooks/useTokenList.ts +0 -1168
- package/src/widget/hooks/useTrailsSendTransaction.ts +0 -987
- package/src/widget/hooks/useViewManager.tsx +0 -506
- package/src/widget/hooks/useWalletConnectUri.tsx +0 -307
- package/src/widget/hooks/useWalletConnectionContext.tsx +0 -128
- package/src/widget/hooks/useWidgetProps.tsx +0 -33
- package/src/widget/index.css +0 -686
- package/src/widget/index.tsx +0 -28
- package/src/widget/providers/TrailsModalProvider.tsx +0 -238
- package/src/widget/providers/TrailsProvider.tsx +0 -155
- package/src/widget/providers/UserActivityProvider.tsx +0 -78
- package/src/widget/providers/WidgetProviderTree.tsx +0 -90
- package/src/widget/styles.ts +0 -26
- package/src/widget/types/analytics.ts +0 -22
- package/src/widget/types/commonProps.ts +0 -56
- package/src/widget/types/svg.d.ts +0 -8
- package/src/widget/types.ts +0 -51
- package/src/widget/utils/countryUtils.ts +0 -89
- package/src/widget/utils/createWagmiConfig.ts +0 -43
- package/src/widget/utils/forexRateStore.ts +0 -120
- package/src/widget/utils/fundMethodSwitchState.ts +0 -27
- package/src/widget/utils/historyFilters.ts +0 -157
- package/src/widget/utils/historyUtils.ts +0 -101
- package/src/widget/utils/localeStore.ts +0 -68
- package/src/widget/utils/meldProviderUtils.ts +0 -26
- package/src/widget/utils/meshSupportedTokens.ts +0 -28
- package/src/widget/utils/onrampConfig.ts +0 -15
- package/src/widget/utils/statusLabel.ts +0 -3
- package/src/widget/utils/tokens.ts +0 -138
- package/src/widget/utils/trailsOnrampConfig.ts +0 -39
- package/src/widget/utils/transactionFailure.ts +0 -52
- package/src/widget/utils/viewManagerGuards.ts +0 -49
- package/src/widget/utils/windowUtils.ts +0 -138
- package/src/widget/widget.tsx +0 -3400
- /package/dist/{widget/hooks → hooks}/useAddressWalletIcon.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useAmountUsd.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useBalanceVisible.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useChainFilter.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useClickTracking.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useConnector.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useDebounce.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useDepositMonitor.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useDisplayCurrencyPreference.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useExecutingIntentsCount.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useFiatSelectedCurrency.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useGetIntent.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useIsMobile.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useIsSequenceWallet.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useLocalePreference.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useMeldTransactionHistory.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useMeldTransactionStatus.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useOnRampCountryDefaults.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/usePayMessage.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/usePriceImpactWarning.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useRecipients.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useSelectedFeeOption.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useSelectedRecipient.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useSwapAmount.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useTargetAmount.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useTheme.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useWalletConnectionContext.d.ts +0 -0
|
@@ -1,1613 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Account,
|
|
3
|
-
Chain,
|
|
4
|
-
PublicClient,
|
|
5
|
-
WalletClient,
|
|
6
|
-
TransactionReceipt,
|
|
7
|
-
} from "viem"
|
|
8
|
-
import { formatUnits } from "viem"
|
|
9
|
-
import {
|
|
10
|
-
type FeeOption,
|
|
11
|
-
type TrailsApi,
|
|
12
|
-
type RouteProvider,
|
|
13
|
-
type Intent,
|
|
14
|
-
type CommitIntentResponse,
|
|
15
|
-
type DepositSignature,
|
|
16
|
-
type ExecuteIntentResponse,
|
|
17
|
-
type GasFeeOptions,
|
|
18
|
-
type DepositTransaction,
|
|
19
|
-
type IntentTransaction,
|
|
20
|
-
type TrailsContracts,
|
|
21
|
-
IntentProtocolVersion,
|
|
22
|
-
IntentStatus,
|
|
23
|
-
} from "@0xtrails/api"
|
|
24
|
-
import type { PrepareSendReturn, SendReturn, FundMethod } from "../types.js"
|
|
25
|
-
import {
|
|
26
|
-
isExternalFundingMethod,
|
|
27
|
-
TradeType,
|
|
28
|
-
toApiFundMethod,
|
|
29
|
-
} from "../types.js"
|
|
30
|
-
import type { QueryClient } from "@tanstack/react-query"
|
|
31
|
-
import type { TransactionState } from "../../transactions.js"
|
|
32
|
-
import type { CheckoutOnHandlers } from "../../widget/hooks/useCheckout.js"
|
|
33
|
-
import { logger } from "../../logger.js"
|
|
34
|
-
import { getNormalizedQuoteObject } from "../quote/normalizeQuote.js"
|
|
35
|
-
import { getChainInfo, getChainRpcClient } from "../../chains.js"
|
|
36
|
-
import { getTransactionStateFromReceipt } from "../execution/transactionState.js"
|
|
37
|
-
import { getIntentArgs } from "../quote/quoteHelpers.js"
|
|
38
|
-
import {
|
|
39
|
-
quoteIntent,
|
|
40
|
-
commitIntent,
|
|
41
|
-
sendOriginTransaction,
|
|
42
|
-
executeIntent as executeIntentRequest,
|
|
43
|
-
} from "../../intents.js"
|
|
44
|
-
import {
|
|
45
|
-
decodeTokenSweeperEvents,
|
|
46
|
-
decodeGuestModuleEvents,
|
|
47
|
-
} from "../../decoders.js"
|
|
48
|
-
import { updatePersistentToast } from "../../toast.js"
|
|
49
|
-
import { formatRawAmount, rawAmountToNumber } from "../../utils/format.js"
|
|
50
|
-
import { invalidateTokenBalancesCache } from "../../query/balance.queries.js"
|
|
51
|
-
import { calcAmountUsdPrice } from "../../utils/format.js"
|
|
52
|
-
import { checkAccountBalance } from "../utils/balanceChecker.js"
|
|
53
|
-
import { queryClient as defaultQueryClient } from "../../query/client.js"
|
|
54
|
-
import {
|
|
55
|
-
getFeesFromIntent,
|
|
56
|
-
getPriceImpactFromIntent,
|
|
57
|
-
getPriceImpactUsdFromIntent,
|
|
58
|
-
} from "../quote/feeExtractors.js"
|
|
59
|
-
import { attemptUserDepositTx } from "../deposits/depositOrchestrator.js"
|
|
60
|
-
import { getTxTimeDiff } from "../../transactions.js"
|
|
61
|
-
import { pollIntentReceipt } from "../../intentReceiptPoller.js"
|
|
62
|
-
import {
|
|
63
|
-
trackPaymentCompleted,
|
|
64
|
-
trackPaymentError,
|
|
65
|
-
trackTransactionConfirmed,
|
|
66
|
-
} from "../../analytics.js"
|
|
67
|
-
import { getFullErrorMessage, getIsAlreadyExecutingError } from "../../error.js"
|
|
68
|
-
import { getIsCustomCalldata } from "../../contractUtils.js"
|
|
69
|
-
import { isNativeToken } from "../../utils/address.js"
|
|
70
|
-
import { ensureErc20Approval } from "../utils/erc20Approval.js"
|
|
71
|
-
import { HOUR_MS } from "../../utils/time.js"
|
|
72
|
-
import { attemptSwitchChain } from "../../chainSwitch.js"
|
|
73
|
-
import { getDoGasless } from "../deposits/gaslessDeposit.js"
|
|
74
|
-
import {
|
|
75
|
-
applyIntentReceiptToTransactionStates,
|
|
76
|
-
getNormalizedTransactionStates,
|
|
77
|
-
insertRefundTransactionState,
|
|
78
|
-
updateTransactionStateWithDecodedEvents,
|
|
79
|
-
} from "../helpers/transactionStateHelpers.js"
|
|
80
|
-
import { isSameChain, isSameToken } from "../validators.js"
|
|
81
|
-
import {
|
|
82
|
-
isSyntheticTransactionHash,
|
|
83
|
-
isDisplayableTransactionHash,
|
|
84
|
-
} from "../../transactions.js"
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Parameters for the unified intent handler.
|
|
88
|
-
*/
|
|
89
|
-
export interface IntentHandlerParams {
|
|
90
|
-
queryClient?: QueryClient
|
|
91
|
-
mainSignerAddress: string
|
|
92
|
-
originChainId: number
|
|
93
|
-
originTokenAddress: string
|
|
94
|
-
originTokenBalance: string
|
|
95
|
-
originTokenDecimals: number
|
|
96
|
-
originTokenSymbol: string
|
|
97
|
-
destinationChainId: number
|
|
98
|
-
destinationTokenAddress: string
|
|
99
|
-
destinationTokenSymbol: string
|
|
100
|
-
destinationTokenDecimals: number
|
|
101
|
-
swapAmount: string
|
|
102
|
-
recipient: string
|
|
103
|
-
destinationApproveAddress?: string
|
|
104
|
-
destinationCalldata?: string
|
|
105
|
-
walletClient: WalletClient
|
|
106
|
-
publicClient: PublicClient
|
|
107
|
-
account: Account
|
|
108
|
-
chain: Chain
|
|
109
|
-
onTransactionStateChange: (transactionStates: TransactionState[]) => void
|
|
110
|
-
transactionStates: TransactionState[]
|
|
111
|
-
trailsClient: TrailsApi
|
|
112
|
-
sourceTokenPriceUsd?: number | null
|
|
113
|
-
destinationTokenPriceUsd?: number | null
|
|
114
|
-
originNativeTokenPriceUsd?: number | null
|
|
115
|
-
slippageTolerance: string | null
|
|
116
|
-
tradeType?: TradeType
|
|
117
|
-
swapProvider?: RouteProvider | null
|
|
118
|
-
bridgeProvider?: RouteProvider | null
|
|
119
|
-
swapProviderFallback?: boolean
|
|
120
|
-
bridgeProviderFallback?: boolean
|
|
121
|
-
fundMethod?: FundMethod
|
|
122
|
-
mode?: "pay" | "fund" | "earn" | "swap" | "withdraw"
|
|
123
|
-
checkoutOnHandlers?: Partial<CheckoutOnHandlers>
|
|
124
|
-
paymasterUrl?: string
|
|
125
|
-
selectedFeeOption?: FeeOption | null
|
|
126
|
-
walletId?: string
|
|
127
|
-
abortSignal?: AbortSignal
|
|
128
|
-
commitIntentFn?: (intent: Intent) => Promise<CommitIntentResponse>
|
|
129
|
-
executeIntentFn?: (params: {
|
|
130
|
-
intentId: string
|
|
131
|
-
depositTransactionHash?: string
|
|
132
|
-
depositSignature?: DepositSignature
|
|
133
|
-
}) => Promise<ExecuteIntentResponse>
|
|
134
|
-
sequenceProjectAccessKey?: string
|
|
135
|
-
sequenceIndexerUrl?: string
|
|
136
|
-
isSmartWallet?: boolean
|
|
137
|
-
isSenderContractOnOrigin?: boolean | null
|
|
138
|
-
trailsApiKey?: string
|
|
139
|
-
trailsApiUrl?: string
|
|
140
|
-
sequenceMetadataUrl?: string
|
|
141
|
-
refundAddress?: string
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function isFeeSelectionPassthroughEligible(params: {
|
|
145
|
-
selectedFeeOption: FeeOption | null | undefined
|
|
146
|
-
gasFeeOptions: GasFeeOptions | undefined
|
|
147
|
-
}): boolean {
|
|
148
|
-
const { selectedFeeOption, gasFeeOptions } = params
|
|
149
|
-
|
|
150
|
-
// Undefined means no explicit user selection yet: stay conservative and use intent flow.
|
|
151
|
-
if (selectedFeeOption === undefined) {
|
|
152
|
-
return false
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Null means "native fee selected". This is only passthrough-safe if the native fee option
|
|
156
|
-
// advertised by backend is explicitly marked passthrough-eligible.
|
|
157
|
-
if (selectedFeeOption === null) {
|
|
158
|
-
const nativeFeeOption = gasFeeOptions?.feeOptions?.find((option) =>
|
|
159
|
-
isNativeToken(option.tokenAddress),
|
|
160
|
-
)
|
|
161
|
-
return nativeFeeOption?.isPassthroughEligible === true
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return selectedFeeOption.isPassthroughEligible === true
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Execute a passthrough transaction (direct transfer, no intents).
|
|
169
|
-
*
|
|
170
|
-
* Used when backend marks quote passthrough-eligible and client-side fee gating allows it.
|
|
171
|
-
* Handles ERC20 approval if needed for custom calldata scenarios (S4c).
|
|
172
|
-
* See SPEC.md for flow decision details.
|
|
173
|
-
*/
|
|
174
|
-
async function executePassthrough(
|
|
175
|
-
params: IntentHandlerParams,
|
|
176
|
-
depositTransaction: DepositTransaction,
|
|
177
|
-
transactionStates: TransactionState[],
|
|
178
|
-
options: {
|
|
179
|
-
onOriginSend?: () => void
|
|
180
|
-
depositTransactionHash?: string
|
|
181
|
-
},
|
|
182
|
-
): Promise<SendReturn> {
|
|
183
|
-
const {
|
|
184
|
-
queryClient: paramQueryClient,
|
|
185
|
-
account,
|
|
186
|
-
walletClient,
|
|
187
|
-
onTransactionStateChange,
|
|
188
|
-
originTokenDecimals,
|
|
189
|
-
originTokenSymbol,
|
|
190
|
-
destinationTokenSymbol,
|
|
191
|
-
swapAmount,
|
|
192
|
-
destinationCalldata,
|
|
193
|
-
sourceTokenPriceUsd,
|
|
194
|
-
mode,
|
|
195
|
-
fundMethod = "wallet",
|
|
196
|
-
checkoutOnHandlers,
|
|
197
|
-
walletId,
|
|
198
|
-
} = params
|
|
199
|
-
|
|
200
|
-
const effectiveQueryClient = paramQueryClient ?? defaultQueryClient
|
|
201
|
-
|
|
202
|
-
const { onOriginSend, depositTransactionHash } = options
|
|
203
|
-
|
|
204
|
-
const effectiveOriginChain = params.chain
|
|
205
|
-
const effectiveOriginChainId = effectiveOriginChain.id
|
|
206
|
-
const effectivePublicClient =
|
|
207
|
-
params.publicClient ?? getChainRpcClient(effectiveOriginChain.id)
|
|
208
|
-
|
|
209
|
-
const depositAmountFormatted = Number(
|
|
210
|
-
formatUnits(BigInt(swapAmount), originTokenDecimals),
|
|
211
|
-
)
|
|
212
|
-
const depositAmountUsd = calcAmountUsdPrice({
|
|
213
|
-
amount: depositAmountFormatted,
|
|
214
|
-
usdPrice: sourceTokenPriceUsd,
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
// Update transaction state to pending
|
|
218
|
-
if (transactionStates[0]) {
|
|
219
|
-
transactionStates[0].state = "pending"
|
|
220
|
-
try {
|
|
221
|
-
onTransactionStateChange(transactionStates)
|
|
222
|
-
} catch (error) {
|
|
223
|
-
logger.console.error(
|
|
224
|
-
"[trails-sdk] Error calling onTransactionStateChange:",
|
|
225
|
-
error,
|
|
226
|
-
)
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Show persistent toast
|
|
231
|
-
updatePersistentToast(
|
|
232
|
-
"Payment Started",
|
|
233
|
-
"Waiting for wallet confirmation...",
|
|
234
|
-
"info",
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
// Validate chainId before sending
|
|
238
|
-
if (depositTransaction.chainId !== effectiveOriginChainId) {
|
|
239
|
-
throw new Error(
|
|
240
|
-
`Chain ID mismatch: expected ${effectiveOriginChainId}, got ${depositTransaction.chainId}`,
|
|
241
|
-
)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Read ALL fields from passthrough depositTransaction
|
|
245
|
-
const { to, data, value, chainId } = depositTransaction
|
|
246
|
-
|
|
247
|
-
logger.console.log(
|
|
248
|
-
"[trails-sdk] Executing passthrough with depositTransaction:",
|
|
249
|
-
{
|
|
250
|
-
to,
|
|
251
|
-
data,
|
|
252
|
-
value,
|
|
253
|
-
chainId,
|
|
254
|
-
},
|
|
255
|
-
)
|
|
256
|
-
|
|
257
|
-
// Handle ERC20 approval for passthrough transactions with custom calldata.
|
|
258
|
-
// This is needed when the passthrough target contract (e.g., Aave) needs to
|
|
259
|
-
// transferFrom the user's tokens.
|
|
260
|
-
const originTokenAddress = params.originTokenAddress
|
|
261
|
-
const hasCustomCalldata = getIsCustomCalldata(destinationCalldata)
|
|
262
|
-
const isErc20Token = !isNativeToken(originTokenAddress)
|
|
263
|
-
|
|
264
|
-
if (isErc20Token && hasCustomCalldata) {
|
|
265
|
-
await ensureErc20Approval({
|
|
266
|
-
tokenAddress: originTokenAddress,
|
|
267
|
-
spender: to,
|
|
268
|
-
requiredAmount: BigInt(swapAmount),
|
|
269
|
-
account,
|
|
270
|
-
publicClient: effectivePublicClient,
|
|
271
|
-
walletClient,
|
|
272
|
-
chain: effectiveOriginChain,
|
|
273
|
-
depositAmountUsd,
|
|
274
|
-
checkoutOnHandlers,
|
|
275
|
-
logPrefix: "[trails-sdk] [passthrough]",
|
|
276
|
-
})
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
let effectiveDepositTransactionHash = depositTransactionHash
|
|
280
|
-
|
|
281
|
-
if (!effectiveDepositTransactionHash) {
|
|
282
|
-
effectiveDepositTransactionHash = await sendOriginTransaction(
|
|
283
|
-
account,
|
|
284
|
-
walletClient,
|
|
285
|
-
{
|
|
286
|
-
to,
|
|
287
|
-
data: data as `0x${string}`,
|
|
288
|
-
value: BigInt(value),
|
|
289
|
-
chain: effectiveOriginChain,
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
transactionType: "origin_call",
|
|
293
|
-
depositTokenAmountUsd: depositAmountUsd?.toString(),
|
|
294
|
-
},
|
|
295
|
-
)
|
|
296
|
-
}
|
|
297
|
-
const finalDepositTransactionHash =
|
|
298
|
-
effectiveDepositTransactionHash as `0x${string}`
|
|
299
|
-
|
|
300
|
-
if (onOriginSend) {
|
|
301
|
-
onOriginSend()
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Wait for transaction receipt
|
|
305
|
-
const receipt = await effectivePublicClient.waitForTransactionReceipt({
|
|
306
|
-
hash: finalDepositTransactionHash,
|
|
307
|
-
onReplaced: (replacement) => {
|
|
308
|
-
logger.console.log(
|
|
309
|
-
"[trails-sdk] Passthrough deposit transaction replaced",
|
|
310
|
-
{
|
|
311
|
-
reason: replacement.reason,
|
|
312
|
-
replacedHash: replacement.replacedTransaction.hash,
|
|
313
|
-
replacementHash: replacement.transaction.hash,
|
|
314
|
-
},
|
|
315
|
-
)
|
|
316
|
-
},
|
|
317
|
-
})
|
|
318
|
-
logger.console.log("[trails-sdk] Passthrough receipt:", receipt)
|
|
319
|
-
|
|
320
|
-
// Track transaction confirmation
|
|
321
|
-
trackTransactionConfirmed({
|
|
322
|
-
transactionHash: finalDepositTransactionHash,
|
|
323
|
-
chainId: effectiveOriginChainId,
|
|
324
|
-
userAddress: account.address,
|
|
325
|
-
blockNumber: Number(receipt.blockNumber),
|
|
326
|
-
originTokenAddress: params.originTokenAddress,
|
|
327
|
-
depositTokenAmountUsd: depositAmountUsd,
|
|
328
|
-
})
|
|
329
|
-
|
|
330
|
-
// Update toast
|
|
331
|
-
const chainInfo = getChainInfo(effectiveOriginChainId)
|
|
332
|
-
updatePersistentToast(
|
|
333
|
-
"Transfer Confirmed",
|
|
334
|
-
`Your transaction on ${chainInfo?.name || "chain"} has been confirmed`,
|
|
335
|
-
"info",
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
// Update transaction state to completed with decoded events
|
|
339
|
-
const updatedStates = updateTransactionStateWithDecodedEvents(
|
|
340
|
-
transactionStates,
|
|
341
|
-
transactionStates[0]?.label || "Execute",
|
|
342
|
-
receipt,
|
|
343
|
-
effectiveOriginChainId,
|
|
344
|
-
)
|
|
345
|
-
onTransactionStateChange(updatedStates)
|
|
346
|
-
|
|
347
|
-
// Track payment completion
|
|
348
|
-
if (receipt.status === "success") {
|
|
349
|
-
trackPaymentCompleted({
|
|
350
|
-
userAddress: account.address,
|
|
351
|
-
originTxHash: receipt.transactionHash,
|
|
352
|
-
originChainId: effectiveOriginChainId,
|
|
353
|
-
mode,
|
|
354
|
-
fundMethod,
|
|
355
|
-
originTokenAddress: params.originTokenAddress,
|
|
356
|
-
originTokenSymbol,
|
|
357
|
-
originTokenAmount: swapAmount,
|
|
358
|
-
originTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
359
|
-
destinationTokenAddress: params.originTokenAddress,
|
|
360
|
-
destinationTokenSymbol,
|
|
361
|
-
depositTokenAmount: swapAmount,
|
|
362
|
-
depositTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
363
|
-
depositTokenAmountUsd: depositAmountUsd,
|
|
364
|
-
destinationTokenAmount: swapAmount,
|
|
365
|
-
destinationTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
366
|
-
destinationTokenAmountUsd: depositAmountUsd,
|
|
367
|
-
originTokenDecimals,
|
|
368
|
-
destinationTokenDecimals: originTokenDecimals,
|
|
369
|
-
walletId,
|
|
370
|
-
destinationCalldata,
|
|
371
|
-
})
|
|
372
|
-
|
|
373
|
-
invalidateTokenBalancesCache(undefined, effectiveQueryClient)
|
|
374
|
-
|
|
375
|
-
if (checkoutOnHandlers?.triggerCheckoutComplete) {
|
|
376
|
-
checkoutOnHandlers.triggerCheckoutComplete("success", account.address)
|
|
377
|
-
}
|
|
378
|
-
} else {
|
|
379
|
-
trackPaymentError({
|
|
380
|
-
error: "Transaction failed",
|
|
381
|
-
userAddress: account.address,
|
|
382
|
-
mode,
|
|
383
|
-
fundMethod,
|
|
384
|
-
originTokenAddress: params.originTokenAddress,
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
invalidateTokenBalancesCache(undefined, effectiveQueryClient)
|
|
388
|
-
|
|
389
|
-
if (checkoutOnHandlers?.triggerCheckoutError) {
|
|
390
|
-
checkoutOnHandlers.triggerCheckoutError("Transaction failed")
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return {
|
|
395
|
-
depositUserTxnReceipt: receipt,
|
|
396
|
-
originIntentTransaction: null,
|
|
397
|
-
destinationIntentTransaction: null,
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Execute an intent flow (commit, deposit, poll).
|
|
403
|
-
*/
|
|
404
|
-
async function executeIntent(
|
|
405
|
-
params: IntentHandlerParams,
|
|
406
|
-
intent: Intent,
|
|
407
|
-
localTransactionStates: TransactionState[],
|
|
408
|
-
gasFeeOptions: GasFeeOptions | undefined,
|
|
409
|
-
trailsContracts: TrailsContracts,
|
|
410
|
-
options: {
|
|
411
|
-
onOriginSend?: () => void
|
|
412
|
-
selectedFeeOption?: FeeOption | null
|
|
413
|
-
depositTransactionHash?: string
|
|
414
|
-
skipCommit?: boolean
|
|
415
|
-
},
|
|
416
|
-
): Promise<SendReturn> {
|
|
417
|
-
const {
|
|
418
|
-
queryClient: paramQueryClient,
|
|
419
|
-
account,
|
|
420
|
-
walletClient,
|
|
421
|
-
onTransactionStateChange,
|
|
422
|
-
originTokenDecimals,
|
|
423
|
-
originTokenSymbol,
|
|
424
|
-
destinationTokenSymbol,
|
|
425
|
-
swapAmount,
|
|
426
|
-
destinationCalldata,
|
|
427
|
-
sourceTokenPriceUsd,
|
|
428
|
-
destinationTokenPriceUsd,
|
|
429
|
-
mode,
|
|
430
|
-
fundMethod = "wallet",
|
|
431
|
-
checkoutOnHandlers,
|
|
432
|
-
walletId,
|
|
433
|
-
trailsClient,
|
|
434
|
-
paymasterUrl,
|
|
435
|
-
abortSignal,
|
|
436
|
-
executeIntentFn,
|
|
437
|
-
destinationTokenDecimals,
|
|
438
|
-
swapProvider,
|
|
439
|
-
bridgeProvider,
|
|
440
|
-
tradeType,
|
|
441
|
-
} = params
|
|
442
|
-
|
|
443
|
-
const effectiveQueryClient = paramQueryClient ?? defaultQueryClient
|
|
444
|
-
|
|
445
|
-
const {
|
|
446
|
-
onOriginSend,
|
|
447
|
-
selectedFeeOption: runtimeSelectedFeeOption,
|
|
448
|
-
depositTransactionHash,
|
|
449
|
-
} = options
|
|
450
|
-
|
|
451
|
-
const effectiveSelectedFeeOption = runtimeSelectedFeeOption
|
|
452
|
-
|
|
453
|
-
const effectiveOriginChain = params.chain
|
|
454
|
-
const effectiveOriginChainId = effectiveOriginChain.id
|
|
455
|
-
const effectivePublicClient = getChainRpcClient(effectiveOriginChain.id)
|
|
456
|
-
const effectiveOriginTokenAddress = params.originTokenAddress
|
|
457
|
-
|
|
458
|
-
const isToSameChain = isSameChain(
|
|
459
|
-
params.originChainId,
|
|
460
|
-
params.destinationChainId,
|
|
461
|
-
)
|
|
462
|
-
const isToSameToken = isSameToken(
|
|
463
|
-
params.originTokenAddress,
|
|
464
|
-
params.destinationTokenAddress,
|
|
465
|
-
)
|
|
466
|
-
const isSameChainSameToken = isToSameChain && isToSameToken
|
|
467
|
-
|
|
468
|
-
// API is source of truth for deposit amount
|
|
469
|
-
const depositAmount = intent.depositTransaction.amount.toString()
|
|
470
|
-
|
|
471
|
-
const depositAmountFormatted = formatRawAmount(
|
|
472
|
-
depositAmount,
|
|
473
|
-
originTokenDecimals,
|
|
474
|
-
)
|
|
475
|
-
const depositAmountNumeric = rawAmountToNumber(
|
|
476
|
-
depositAmount,
|
|
477
|
-
originTokenDecimals,
|
|
478
|
-
)
|
|
479
|
-
const depositAmountUsd = calcAmountUsdPrice({
|
|
480
|
-
amount: depositAmountNumeric,
|
|
481
|
-
usdPrice: sourceTokenPriceUsd,
|
|
482
|
-
})
|
|
483
|
-
|
|
484
|
-
let depositUserTxnReceipt: TransactionReceipt | null = null
|
|
485
|
-
let originIntentTransaction: IntentTransaction | null = null
|
|
486
|
-
let destinationIntentTransaction: IntentTransaction | null = null
|
|
487
|
-
let hasExecutedIntentEarly = false
|
|
488
|
-
|
|
489
|
-
// Create destination public client for cross-chain polling
|
|
490
|
-
const destinationPublicClient = getChainRpcClient(params.destinationChainId)
|
|
491
|
-
|
|
492
|
-
const shouldUseGaslessFlow =
|
|
493
|
-
fundMethod === "wallet" &&
|
|
494
|
-
(getDoGasless(
|
|
495
|
-
effectiveOriginTokenAddress,
|
|
496
|
-
gasFeeOptions,
|
|
497
|
-
effectiveSelectedFeeOption,
|
|
498
|
-
walletId,
|
|
499
|
-
) ||
|
|
500
|
-
Boolean(paymasterUrl))
|
|
501
|
-
|
|
502
|
-
// Signal executeIntent immediately after commit for all funding flows.
|
|
503
|
-
if (intent.intentId && !shouldUseGaslessFlow) {
|
|
504
|
-
try {
|
|
505
|
-
if (executeIntentFn) {
|
|
506
|
-
await executeIntentFn({
|
|
507
|
-
intentId: intent.intentId,
|
|
508
|
-
})
|
|
509
|
-
} else {
|
|
510
|
-
await executeIntentRequest(trailsClient, intent.intentId, undefined)
|
|
511
|
-
}
|
|
512
|
-
hasExecutedIntentEarly = true
|
|
513
|
-
logger.console.log(
|
|
514
|
-
"[trails-sdk] executeIntent called immediately after commit",
|
|
515
|
-
{
|
|
516
|
-
intentId: intent.intentId,
|
|
517
|
-
fundMethod,
|
|
518
|
-
depositTransactionHash,
|
|
519
|
-
},
|
|
520
|
-
)
|
|
521
|
-
} catch (executeError: unknown) {
|
|
522
|
-
if (getIsAlreadyExecutingError(executeError)) {
|
|
523
|
-
hasExecutedIntentEarly = true
|
|
524
|
-
logger.console.log(
|
|
525
|
-
"[trails-sdk] Intent already executing after early executeIntent call",
|
|
526
|
-
)
|
|
527
|
-
} else {
|
|
528
|
-
throw executeError
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
} else if (intent.intentId && shouldUseGaslessFlow) {
|
|
532
|
-
logger.console.log(
|
|
533
|
-
"[trails-sdk] Skipping early executeIntent for gasless flow, waiting for deposit signature",
|
|
534
|
-
{
|
|
535
|
-
intentId: intent.intentId,
|
|
536
|
-
fundMethod,
|
|
537
|
-
hasPaymasterUrl: Boolean(paymasterUrl),
|
|
538
|
-
hasSelectedFeeOption: effectiveSelectedFeeOption !== undefined,
|
|
539
|
-
},
|
|
540
|
-
)
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
// External funding flows without a client-provided deposit hash should return
|
|
544
|
-
// immediately after commit/early execute. Their UI will monitor balance at the
|
|
545
|
-
// origin intent address and continue independently of this send() call.
|
|
546
|
-
const publishTransactionStates = (states: TransactionState[]) => {
|
|
547
|
-
onTransactionStateChange(states)
|
|
548
|
-
if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
|
|
549
|
-
checkoutOnHandlers.triggerCheckoutStatusUpdate(states)
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
if (isExternalFundingMethod(fundMethod) && !depositTransactionHash) {
|
|
554
|
-
publishTransactionStates(localTransactionStates)
|
|
555
|
-
|
|
556
|
-
logger.console.log(
|
|
557
|
-
"[trails-sdk] External funding flow: intent committed, returning early",
|
|
558
|
-
{
|
|
559
|
-
fundMethod,
|
|
560
|
-
intentId: intent.intentId,
|
|
561
|
-
},
|
|
562
|
-
)
|
|
563
|
-
return {
|
|
564
|
-
depositUserTxnReceipt: null,
|
|
565
|
-
originIntentTransaction: null,
|
|
566
|
-
destinationIntentTransaction: null,
|
|
567
|
-
totalCompletionSeconds: 0,
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
// Balance check for wallet fund method
|
|
572
|
-
if (fundMethod === "wallet") {
|
|
573
|
-
const { hasEnoughBalance, balanceError } = await checkAccountBalance({
|
|
574
|
-
account,
|
|
575
|
-
tokenAddress: effectiveOriginTokenAddress,
|
|
576
|
-
depositAmount,
|
|
577
|
-
publicClient: effectivePublicClient,
|
|
578
|
-
})
|
|
579
|
-
|
|
580
|
-
if (!hasEnoughBalance) {
|
|
581
|
-
throw balanceError
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
// Switch chain if needed
|
|
586
|
-
await attemptSwitchChain({
|
|
587
|
-
walletClient,
|
|
588
|
-
desiredChainId: effectiveOriginChainId,
|
|
589
|
-
})
|
|
590
|
-
|
|
591
|
-
// Set up transaction state tracking
|
|
592
|
-
publishTransactionStates(localTransactionStates)
|
|
593
|
-
|
|
594
|
-
const rawIntentProtocol = (intent as { intentProtocol?: string })
|
|
595
|
-
.intentProtocol
|
|
596
|
-
|
|
597
|
-
if (!rawIntentProtocol) {
|
|
598
|
-
logger.console.log(
|
|
599
|
-
"[trails-sdk] [intent-protocol] Intent protocol version not found in response, defaulting to v1",
|
|
600
|
-
)
|
|
601
|
-
}
|
|
602
|
-
const intentProtocol =
|
|
603
|
-
rawIntentProtocol === "v1.5"
|
|
604
|
-
? IntentProtocolVersion.v1_5
|
|
605
|
-
: IntentProtocolVersion.v1
|
|
606
|
-
|
|
607
|
-
logger.console.log(
|
|
608
|
-
"[trails-sdk] [intent-protocol] === Intent Protocol Version ===",
|
|
609
|
-
{
|
|
610
|
-
version: intentProtocol,
|
|
611
|
-
isV1: intentProtocol === IntentProtocolVersion.v1,
|
|
612
|
-
isV1_5: intentProtocol === IntentProtocolVersion.v1_5,
|
|
613
|
-
intentId: intent.intentId,
|
|
614
|
-
fundMethod,
|
|
615
|
-
},
|
|
616
|
-
)
|
|
617
|
-
|
|
618
|
-
// Execute deposit transaction
|
|
619
|
-
if (depositTransactionHash && fundMethod !== "wallet") {
|
|
620
|
-
// External deposit with provided hash (onramp-meld, direct-transfer, etc.)
|
|
621
|
-
let resolvedDepositTransactionHash = depositTransactionHash as `0x${string}`
|
|
622
|
-
depositUserTxnReceipt =
|
|
623
|
-
await effectivePublicClient.waitForTransactionReceipt({
|
|
624
|
-
hash: depositTransactionHash as `0x${string}`,
|
|
625
|
-
onReplaced: (replacement) => {
|
|
626
|
-
resolvedDepositTransactionHash = replacement.transaction.hash
|
|
627
|
-
logger.console.log(
|
|
628
|
-
"[trails-sdk] External deposit transaction replaced",
|
|
629
|
-
{
|
|
630
|
-
reason: replacement.reason,
|
|
631
|
-
replacedHash: replacement.replacedTransaction.hash,
|
|
632
|
-
replacementHash: replacement.transaction.hash,
|
|
633
|
-
},
|
|
634
|
-
)
|
|
635
|
-
},
|
|
636
|
-
})
|
|
637
|
-
|
|
638
|
-
if (depositUserTxnReceipt?.transactionHash) {
|
|
639
|
-
resolvedDepositTransactionHash =
|
|
640
|
-
depositUserTxnReceipt.transactionHash as `0x${string}`
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
logger.console.log("[trails-sdk] External deposit receipt resolved", {
|
|
644
|
-
providedHash: depositTransactionHash,
|
|
645
|
-
resolvedHash: resolvedDepositTransactionHash,
|
|
646
|
-
status: depositUserTxnReceipt.status,
|
|
647
|
-
})
|
|
648
|
-
|
|
649
|
-
// Update transaction state with receipt
|
|
650
|
-
if (depositUserTxnReceipt) {
|
|
651
|
-
localTransactionStates[0] = getTransactionStateFromReceipt(
|
|
652
|
-
depositUserTxnReceipt,
|
|
653
|
-
effectiveOriginChainId,
|
|
654
|
-
localTransactionStates[0]?.label,
|
|
655
|
-
)
|
|
656
|
-
publishTransactionStates(localTransactionStates)
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
if (depositUserTxnReceipt.status === "success" && intent.intentId) {
|
|
660
|
-
// Always signal external deposit success so UI can navigate to pending.
|
|
661
|
-
if (onOriginSend) {
|
|
662
|
-
logger.console.log(
|
|
663
|
-
"[trails-sdk] Calling onOriginSend for external deposit",
|
|
664
|
-
)
|
|
665
|
-
onOriginSend()
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
if (hasExecutedIntentEarly) {
|
|
669
|
-
// Intent execution was already triggered immediately after commit.
|
|
670
|
-
// Skip the duplicate executeIntent call, but continue into receipt polling.
|
|
671
|
-
} else {
|
|
672
|
-
// Try to execute the intent if early execution didn't run.
|
|
673
|
-
try {
|
|
674
|
-
if (executeIntentFn) {
|
|
675
|
-
await executeIntentFn({
|
|
676
|
-
intentId: intent.intentId,
|
|
677
|
-
})
|
|
678
|
-
} else {
|
|
679
|
-
await executeIntentRequest(trailsClient, intent.intentId, undefined)
|
|
680
|
-
}
|
|
681
|
-
} catch (executeError: unknown) {
|
|
682
|
-
// If intent is already executing, that's fine - it means the system picked it up
|
|
683
|
-
if (getIsAlreadyExecutingError(executeError)) {
|
|
684
|
-
logger.console.log(
|
|
685
|
-
"[trails-sdk] Intent already executing, continuing...",
|
|
686
|
-
)
|
|
687
|
-
} else {
|
|
688
|
-
throw executeError
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
} else if (fundMethod === "wallet") {
|
|
694
|
-
// Wallet deposit
|
|
695
|
-
depositUserTxnReceipt = await attemptUserDepositTx({
|
|
696
|
-
queryClient: effectiveQueryClient,
|
|
697
|
-
originTokenAddress: effectiveOriginTokenAddress,
|
|
698
|
-
paymasterUrl,
|
|
699
|
-
chain: effectiveOriginChain,
|
|
700
|
-
account,
|
|
701
|
-
depositAmount,
|
|
702
|
-
originIntentAddress: intent.originIntentAddress,
|
|
703
|
-
onOriginSend,
|
|
704
|
-
publicClient: effectivePublicClient,
|
|
705
|
-
walletClient,
|
|
706
|
-
destinationTokenDecimals,
|
|
707
|
-
sourceTokenDecimals: originTokenDecimals,
|
|
708
|
-
sourceTokenPriceUsd: sourceTokenPriceUsd ?? null,
|
|
709
|
-
destinationTokenPriceUsd: destinationTokenPriceUsd ?? null,
|
|
710
|
-
swapAmount,
|
|
711
|
-
onTransactionStateChange,
|
|
712
|
-
transactionStates: localTransactionStates,
|
|
713
|
-
fundMethod,
|
|
714
|
-
originTokenSymbol,
|
|
715
|
-
destinationTokenSymbol,
|
|
716
|
-
depositAmountUsd,
|
|
717
|
-
feeOptions: gasFeeOptions,
|
|
718
|
-
trailsContracts,
|
|
719
|
-
trailsClient,
|
|
720
|
-
selectedFeeOption: effectiveSelectedFeeOption,
|
|
721
|
-
walletId,
|
|
722
|
-
abortSignal,
|
|
723
|
-
checkoutOnHandlers,
|
|
724
|
-
intentId: intent.intentId,
|
|
725
|
-
executeIntentFn,
|
|
726
|
-
isSameChainSameToken,
|
|
727
|
-
destinationCalldata,
|
|
728
|
-
depositTransaction: intent.depositTransaction,
|
|
729
|
-
intentProtocol,
|
|
730
|
-
})
|
|
731
|
-
|
|
732
|
-
// Update state and call executeIntent
|
|
733
|
-
if (depositUserTxnReceipt) {
|
|
734
|
-
localTransactionStates[0] = getTransactionStateFromReceipt(
|
|
735
|
-
depositUserTxnReceipt,
|
|
736
|
-
effectiveOriginChainId,
|
|
737
|
-
localTransactionStates[0]?.label,
|
|
738
|
-
)
|
|
739
|
-
|
|
740
|
-
// Decode events
|
|
741
|
-
try {
|
|
742
|
-
localTransactionStates[0].decodedTokenSweeperEvents =
|
|
743
|
-
decodeTokenSweeperEvents(depositUserTxnReceipt)
|
|
744
|
-
localTransactionStates[0].decodedGuestModuleEvents =
|
|
745
|
-
decodeGuestModuleEvents(depositUserTxnReceipt)
|
|
746
|
-
localTransactionStates[0].refunded =
|
|
747
|
-
localTransactionStates[0].decodedTokenSweeperEvents.findIndex(
|
|
748
|
-
(event) =>
|
|
749
|
-
event.type === "Refund" || event.type === "RefundAndSweep",
|
|
750
|
-
) !== -1
|
|
751
|
-
} catch (error) {
|
|
752
|
-
logger.console.error(
|
|
753
|
-
"[trails-sdk] Error decoding deposit events",
|
|
754
|
-
error,
|
|
755
|
-
)
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
publishTransactionStates(localTransactionStates)
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
// Start polling for intent completion to update transaction states
|
|
762
|
-
let finalReceipt: Awaited<ReturnType<typeof pollIntentReceipt>> = null
|
|
763
|
-
let pollStartMs = 0
|
|
764
|
-
if (intent.intentId) {
|
|
765
|
-
// Determine max wait time based on route provider.
|
|
766
|
-
// OFT routes (LayerZero OFT) can take 5-10+ minutes to complete.
|
|
767
|
-
const isOFTRoute = intent.quote?.routeProviders?.some((p) => p === "LZ_OFT")
|
|
768
|
-
const maxWaitTime = isOFTRoute ? HOUR_MS : 10 * 60 * 1000 // 1 hour for OFT, 10 min for others
|
|
769
|
-
|
|
770
|
-
logger.console.log("[trails-sdk] Intent polling configuration:", {
|
|
771
|
-
isOFTRoute,
|
|
772
|
-
maxWaitTime,
|
|
773
|
-
routeProviders: intent.quote?.routeProviders,
|
|
774
|
-
})
|
|
775
|
-
try {
|
|
776
|
-
pollStartMs = Date.now()
|
|
777
|
-
finalReceipt = await pollIntentReceipt({
|
|
778
|
-
intentId: intent.intentId,
|
|
779
|
-
trailsClient,
|
|
780
|
-
abortSignal,
|
|
781
|
-
callbacks: {
|
|
782
|
-
onDepositTransactionFound: async (txHash, receipt) => {
|
|
783
|
-
logger.console.log(
|
|
784
|
-
"[trails-sdk] Deposit transaction found:",
|
|
785
|
-
txHash,
|
|
786
|
-
)
|
|
787
|
-
|
|
788
|
-
if (localTransactionStates[0]) {
|
|
789
|
-
if (isSyntheticTransactionHash(txHash)) {
|
|
790
|
-
logger.console.log(
|
|
791
|
-
"[trails-sdk] Deposit transaction hash is synthetic, marking deposit from status",
|
|
792
|
-
{
|
|
793
|
-
txHash,
|
|
794
|
-
status: receipt.depositTransaction?.status,
|
|
795
|
-
},
|
|
796
|
-
)
|
|
797
|
-
|
|
798
|
-
if (receipt.depositTransaction?.status === "SUCCEEDED") {
|
|
799
|
-
const existingHash = localTransactionStates[0].transactionHash
|
|
800
|
-
const existingExplorerUrl =
|
|
801
|
-
localTransactionStates[0].explorerUrl
|
|
802
|
-
const hasClientSideHash =
|
|
803
|
-
isDisplayableTransactionHash(existingHash)
|
|
804
|
-
|
|
805
|
-
localTransactionStates[0] = {
|
|
806
|
-
...localTransactionStates[0],
|
|
807
|
-
state: "confirmed",
|
|
808
|
-
transactionHash: hasClientSideHash ? existingHash : "",
|
|
809
|
-
explorerUrl: hasClientSideHash ? existingExplorerUrl : "",
|
|
810
|
-
txnMinedAt:
|
|
811
|
-
receipt.depositTransaction?.txnMinedAt || undefined,
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
publishTransactionStates(localTransactionStates)
|
|
815
|
-
}
|
|
816
|
-
return
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
try {
|
|
820
|
-
const depositTxReceipt =
|
|
821
|
-
await effectivePublicClient.getTransactionReceipt({
|
|
822
|
-
hash: txHash as `0x${string}`,
|
|
823
|
-
})
|
|
824
|
-
|
|
825
|
-
localTransactionStates[0] = getTransactionStateFromReceipt(
|
|
826
|
-
depositTxReceipt,
|
|
827
|
-
effectiveOriginChainId,
|
|
828
|
-
localTransactionStates[0]?.label,
|
|
829
|
-
)
|
|
830
|
-
|
|
831
|
-
// Decode events
|
|
832
|
-
localTransactionStates[0].decodedTokenSweeperEvents =
|
|
833
|
-
decodeTokenSweeperEvents(depositTxReceipt)
|
|
834
|
-
localTransactionStates[0].decodedGuestModuleEvents =
|
|
835
|
-
decodeGuestModuleEvents(depositTxReceipt)
|
|
836
|
-
|
|
837
|
-
publishTransactionStates(localTransactionStates)
|
|
838
|
-
} catch (error) {
|
|
839
|
-
logger.console.error(
|
|
840
|
-
"[trails-sdk] Error fetching deposit receipt:",
|
|
841
|
-
error,
|
|
842
|
-
)
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
},
|
|
846
|
-
onOriginTransactionFound: async (txHash, receipt) => {
|
|
847
|
-
logger.console.log("[trails-sdk] Origin transaction found:", txHash)
|
|
848
|
-
|
|
849
|
-
originIntentTransaction = { txnHash: txHash } as IntentTransaction
|
|
850
|
-
|
|
851
|
-
try {
|
|
852
|
-
const originTxReceipt =
|
|
853
|
-
await effectivePublicClient.getTransactionReceipt({
|
|
854
|
-
hash: txHash as `0x${string}`,
|
|
855
|
-
})
|
|
856
|
-
|
|
857
|
-
// Find the appropriate index for origin transaction
|
|
858
|
-
const originStateIndex = localTransactionStates.length > 1 ? 1 : 0
|
|
859
|
-
if (localTransactionStates[originStateIndex]) {
|
|
860
|
-
localTransactionStates[originStateIndex] =
|
|
861
|
-
getTransactionStateFromReceipt(
|
|
862
|
-
originTxReceipt,
|
|
863
|
-
effectiveOriginChainId,
|
|
864
|
-
localTransactionStates[originStateIndex]?.label,
|
|
865
|
-
)
|
|
866
|
-
|
|
867
|
-
// Decode events
|
|
868
|
-
localTransactionStates[
|
|
869
|
-
originStateIndex
|
|
870
|
-
].decodedTokenSweeperEvents =
|
|
871
|
-
decodeTokenSweeperEvents(originTxReceipt)
|
|
872
|
-
localTransactionStates[
|
|
873
|
-
originStateIndex
|
|
874
|
-
].decodedGuestModuleEvents =
|
|
875
|
-
decodeGuestModuleEvents(originTxReceipt)
|
|
876
|
-
|
|
877
|
-
// Some external funding flows do not surface a distinct
|
|
878
|
-
// depositTransaction in the receipt. In those cases the origin
|
|
879
|
-
// transaction implicitly covers the deposit step as well.
|
|
880
|
-
if (
|
|
881
|
-
!receipt.depositTransaction?.txnHash &&
|
|
882
|
-
!receipt.depositTransaction?.status &&
|
|
883
|
-
localTransactionStates.length > 1 &&
|
|
884
|
-
localTransactionStates[0]
|
|
885
|
-
) {
|
|
886
|
-
localTransactionStates[0] = getTransactionStateFromReceipt(
|
|
887
|
-
originTxReceipt,
|
|
888
|
-
effectiveOriginChainId,
|
|
889
|
-
localTransactionStates[0]?.label,
|
|
890
|
-
)
|
|
891
|
-
localTransactionStates[0].decodedTokenSweeperEvents =
|
|
892
|
-
decodeTokenSweeperEvents(originTxReceipt)
|
|
893
|
-
localTransactionStates[0].decodedGuestModuleEvents =
|
|
894
|
-
decodeGuestModuleEvents(originTxReceipt)
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
publishTransactionStates(localTransactionStates)
|
|
898
|
-
}
|
|
899
|
-
} catch (error) {
|
|
900
|
-
logger.console.error(
|
|
901
|
-
"[trails-sdk] Error fetching origin receipt:",
|
|
902
|
-
error,
|
|
903
|
-
)
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
onDestinationTransactionFound: async (txHash) => {
|
|
907
|
-
logger.console.log(
|
|
908
|
-
"[trails-sdk] Destination transaction found:",
|
|
909
|
-
txHash,
|
|
910
|
-
)
|
|
911
|
-
|
|
912
|
-
destinationIntentTransaction = {
|
|
913
|
-
txnHash: txHash,
|
|
914
|
-
} as IntentTransaction
|
|
915
|
-
|
|
916
|
-
try {
|
|
917
|
-
const destinationTxReceipt =
|
|
918
|
-
await destinationPublicClient.getTransactionReceipt({
|
|
919
|
-
hash: txHash as `0x${string}`,
|
|
920
|
-
})
|
|
921
|
-
|
|
922
|
-
// Find the appropriate index for destination transaction
|
|
923
|
-
const destStateIndex = localTransactionStates.length - 1
|
|
924
|
-
if (localTransactionStates[destStateIndex]) {
|
|
925
|
-
localTransactionStates[destStateIndex] =
|
|
926
|
-
getTransactionStateFromReceipt(
|
|
927
|
-
destinationTxReceipt,
|
|
928
|
-
params.destinationChainId,
|
|
929
|
-
localTransactionStates[destStateIndex]?.label,
|
|
930
|
-
)
|
|
931
|
-
|
|
932
|
-
// Decode events
|
|
933
|
-
localTransactionStates[
|
|
934
|
-
destStateIndex
|
|
935
|
-
].decodedTokenSweeperEvents =
|
|
936
|
-
decodeTokenSweeperEvents(destinationTxReceipt)
|
|
937
|
-
localTransactionStates[
|
|
938
|
-
destStateIndex
|
|
939
|
-
].decodedGuestModuleEvents =
|
|
940
|
-
decodeGuestModuleEvents(destinationTxReceipt)
|
|
941
|
-
|
|
942
|
-
publishTransactionStates(localTransactionStates)
|
|
943
|
-
}
|
|
944
|
-
} catch (error) {
|
|
945
|
-
logger.console.error(
|
|
946
|
-
"[trails-sdk] Error fetching destination receipt:",
|
|
947
|
-
error,
|
|
948
|
-
)
|
|
949
|
-
}
|
|
950
|
-
},
|
|
951
|
-
onReceiptUpdate: async (receipt, done) => {
|
|
952
|
-
// Log receipt updates for debugging
|
|
953
|
-
logger.console.log("[trails-sdk] Receipt update:", {
|
|
954
|
-
status: receipt.status,
|
|
955
|
-
done,
|
|
956
|
-
hasOrigin: !!receipt.originTransaction,
|
|
957
|
-
hasDestination: !!receipt.destinationTransaction,
|
|
958
|
-
hasRefund: !!receipt.refundTransaction,
|
|
959
|
-
})
|
|
960
|
-
|
|
961
|
-
const reconciledStates = applyIntentReceiptToTransactionStates({
|
|
962
|
-
currentStates: localTransactionStates,
|
|
963
|
-
receipt,
|
|
964
|
-
})
|
|
965
|
-
if (reconciledStates.changed) {
|
|
966
|
-
localTransactionStates = reconciledStates.transactionStates
|
|
967
|
-
publishTransactionStates(localTransactionStates)
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
// Handle terminal status - mark pending steps as aborted/failed
|
|
971
|
-
if (
|
|
972
|
-
done &&
|
|
973
|
-
(receipt.status === "ABORTED" || receipt.status === "FAILED")
|
|
974
|
-
) {
|
|
975
|
-
const targetState =
|
|
976
|
-
receipt.status === "ABORTED" ? "aborted" : "failed"
|
|
977
|
-
const statusReason =
|
|
978
|
-
receipt.depositTransaction?.statusReason ||
|
|
979
|
-
receipt.originTransaction?.statusReason ||
|
|
980
|
-
receipt.destinationTransaction?.statusReason
|
|
981
|
-
|
|
982
|
-
for (const state of localTransactionStates) {
|
|
983
|
-
if (state.state === "pending") {
|
|
984
|
-
state.state = targetState as "aborted" | "failed"
|
|
985
|
-
if (statusReason) state.statusReason = statusReason
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
publishTransactionStates(localTransactionStates)
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
// Handle deposit tx revert - mark all txs as failed
|
|
993
|
-
if (receipt.depositTransaction?.status === "REVERTED") {
|
|
994
|
-
const statusReason =
|
|
995
|
-
receipt.depositTransaction.statusReason || "deposit reverted"
|
|
996
|
-
|
|
997
|
-
for (const state of localTransactionStates) {
|
|
998
|
-
if (state.state === "pending") {
|
|
999
|
-
state.state = "failed"
|
|
1000
|
-
state.statusReason = statusReason
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
publishTransactionStates(localTransactionStates)
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
// Insert refund transaction state if refund exists
|
|
1008
|
-
if (receipt.refundTransaction) {
|
|
1009
|
-
const updatedStates = insertRefundTransactionState(
|
|
1010
|
-
localTransactionStates,
|
|
1011
|
-
{
|
|
1012
|
-
chainId: receipt.refundTransaction.chainId,
|
|
1013
|
-
txnHash: receipt.refundTransaction.txnHash,
|
|
1014
|
-
status: receipt.refundTransaction.status,
|
|
1015
|
-
},
|
|
1016
|
-
)
|
|
1017
|
-
|
|
1018
|
-
// Check if states actually changed (length or content)
|
|
1019
|
-
const statesChanged =
|
|
1020
|
-
updatedStates.length !== localTransactionStates.length ||
|
|
1021
|
-
JSON.stringify(updatedStates) !==
|
|
1022
|
-
JSON.stringify(localTransactionStates)
|
|
1023
|
-
|
|
1024
|
-
if (statesChanged) {
|
|
1025
|
-
localTransactionStates.length = 0
|
|
1026
|
-
localTransactionStates.push(...updatedStates)
|
|
1027
|
-
publishTransactionStates(localTransactionStates)
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
},
|
|
1031
|
-
},
|
|
1032
|
-
maxWaitTime,
|
|
1033
|
-
})
|
|
1034
|
-
|
|
1035
|
-
// Verify the receipt status is terminal before proceeding to success
|
|
1036
|
-
const terminalStatuses: string[] = [
|
|
1037
|
-
IntentStatus.SUCCEEDED,
|
|
1038
|
-
IntentStatus.FAILED,
|
|
1039
|
-
IntentStatus.REFUNDED,
|
|
1040
|
-
IntentStatus.ABORTED,
|
|
1041
|
-
]
|
|
1042
|
-
const summary = (
|
|
1043
|
-
finalReceipt as unknown as { summary?: { finishedAt?: string | null } }
|
|
1044
|
-
)?.summary
|
|
1045
|
-
const hasFinishedMarker = Boolean(
|
|
1046
|
-
summary?.finishedAt ||
|
|
1047
|
-
finalReceipt?.destinationTransaction?.txnMinedAt ||
|
|
1048
|
-
finalReceipt?.destinationTransaction?.txnHash,
|
|
1049
|
-
)
|
|
1050
|
-
const destinationSucceeded =
|
|
1051
|
-
finalReceipt?.destinationTransaction?.status === "SUCCEEDED"
|
|
1052
|
-
const completeViaDestinationFallback =
|
|
1053
|
-
!!finalReceipt && destinationSucceeded && hasFinishedMarker
|
|
1054
|
-
const isComplete =
|
|
1055
|
-
!!finalReceipt &&
|
|
1056
|
-
(terminalStatuses.includes(finalReceipt.status) ||
|
|
1057
|
-
completeViaDestinationFallback)
|
|
1058
|
-
|
|
1059
|
-
if (!isComplete) {
|
|
1060
|
-
const elapsedMs = pollStartMs > 0 ? Date.now() - pollStartMs : 0
|
|
1061
|
-
const timedOut = elapsedMs >= maxWaitTime
|
|
1062
|
-
const reason = timedOut
|
|
1063
|
-
? `Intent execution timed out after ${Math.round(maxWaitTime / 60000)} minutes.`
|
|
1064
|
-
: "Unable to confirm final intent status from receipt polling."
|
|
1065
|
-
|
|
1066
|
-
logger.console.warn(
|
|
1067
|
-
"[trails-sdk] Intent polling ended without terminal status",
|
|
1068
|
-
{
|
|
1069
|
-
intentId: intent.intentId,
|
|
1070
|
-
status: finalReceipt?.status,
|
|
1071
|
-
maxWaitTime,
|
|
1072
|
-
elapsedMs,
|
|
1073
|
-
timedOut,
|
|
1074
|
-
},
|
|
1075
|
-
)
|
|
1076
|
-
|
|
1077
|
-
trackPaymentError({
|
|
1078
|
-
error: `${reason} Please check transaction history or query GetIntentReceipt.`,
|
|
1079
|
-
userAddress: account.address,
|
|
1080
|
-
mode,
|
|
1081
|
-
fundMethod,
|
|
1082
|
-
originTokenAddress: params.originTokenAddress,
|
|
1083
|
-
})
|
|
1084
|
-
|
|
1085
|
-
invalidateTokenBalancesCache(undefined, effectiveQueryClient)
|
|
1086
|
-
|
|
1087
|
-
if (checkoutOnHandlers?.triggerCheckoutError) {
|
|
1088
|
-
checkoutOnHandlers.triggerCheckoutError(
|
|
1089
|
-
"Unable to confirm final transaction status",
|
|
1090
|
-
)
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
throw new Error(
|
|
1094
|
-
`${reason} Please check transaction history or query GetIntentReceipt with this intent ID.`,
|
|
1095
|
-
)
|
|
1096
|
-
}
|
|
1097
|
-
} catch (error) {
|
|
1098
|
-
logger.console.error(
|
|
1099
|
-
"[trails-sdk] Error polling for intent receipt:",
|
|
1100
|
-
error,
|
|
1101
|
-
)
|
|
1102
|
-
// Polling failed — outcome is unknown. Do not report success.
|
|
1103
|
-
trackPaymentError({
|
|
1104
|
-
error: `Polling failed: ${getFullErrorMessage(error)}`,
|
|
1105
|
-
userAddress: account.address,
|
|
1106
|
-
mode,
|
|
1107
|
-
fundMethod,
|
|
1108
|
-
originTokenAddress: params.originTokenAddress,
|
|
1109
|
-
})
|
|
1110
|
-
|
|
1111
|
-
invalidateTokenBalancesCache(undefined, effectiveQueryClient)
|
|
1112
|
-
|
|
1113
|
-
if (checkoutOnHandlers?.triggerCheckoutError) {
|
|
1114
|
-
checkoutOnHandlers.triggerCheckoutError(
|
|
1115
|
-
"Unable to confirm transaction status",
|
|
1116
|
-
)
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
throw new Error(
|
|
1120
|
-
`Unable to confirm transaction status: polling for intent receipt failed: ${getFullErrorMessage(error)}`,
|
|
1121
|
-
)
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
// Check if intent was ABORTED or FAILED
|
|
1126
|
-
if (
|
|
1127
|
-
finalReceipt &&
|
|
1128
|
-
(finalReceipt.status === "ABORTED" || finalReceipt.status === "FAILED")
|
|
1129
|
-
) {
|
|
1130
|
-
const statusReason = localTransactionStates[0]?.statusReason
|
|
1131
|
-
const errorMsg = statusReason
|
|
1132
|
-
? `Transaction ${finalReceipt.status.toLowerCase()}: ${statusReason}`
|
|
1133
|
-
: `Transaction ${finalReceipt.status.toLowerCase()}`
|
|
1134
|
-
logger.console.error(
|
|
1135
|
-
`[trails-sdk] Intent ${finalReceipt.status}:`,
|
|
1136
|
-
intent.intentId,
|
|
1137
|
-
)
|
|
1138
|
-
|
|
1139
|
-
trackPaymentError({
|
|
1140
|
-
error: errorMsg,
|
|
1141
|
-
userAddress: account.address,
|
|
1142
|
-
mode,
|
|
1143
|
-
fundMethod,
|
|
1144
|
-
originTokenAddress: params.originTokenAddress,
|
|
1145
|
-
})
|
|
1146
|
-
|
|
1147
|
-
invalidateTokenBalancesCache(undefined, effectiveQueryClient)
|
|
1148
|
-
|
|
1149
|
-
if (checkoutOnHandlers?.triggerCheckoutError) {
|
|
1150
|
-
checkoutOnHandlers.triggerCheckoutError(errorMsg)
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
throw new Error(errorMsg)
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
// Track payment completion
|
|
1157
|
-
const hasAnyCallFailed = localTransactionStates.some((tx) =>
|
|
1158
|
-
tx?.decodedGuestModuleEvents?.some((e: any) => e?.type === "CallFailed"),
|
|
1159
|
-
)
|
|
1160
|
-
const hasAnyRefunded = localTransactionStates.some((tx) => tx?.refunded)
|
|
1161
|
-
const hasAnyFailed = localTransactionStates.some(
|
|
1162
|
-
(tx) => tx?.state === "failed",
|
|
1163
|
-
)
|
|
1164
|
-
const txStatus =
|
|
1165
|
-
!hasAnyCallFailed && !hasAnyRefunded && !hasAnyFailed ? "success" : "fail"
|
|
1166
|
-
|
|
1167
|
-
trackPaymentCompleted({
|
|
1168
|
-
userAddress: account.address,
|
|
1169
|
-
originIntentAddress: intent.originIntentAddress,
|
|
1170
|
-
originTxHash: depositUserTxnReceipt?.transactionHash,
|
|
1171
|
-
destinationTxHash: (
|
|
1172
|
-
destinationIntentTransaction as IntentTransaction | null
|
|
1173
|
-
)?.txnHash,
|
|
1174
|
-
originChainId: params.originChainId,
|
|
1175
|
-
destinationChainId: params.destinationChainId,
|
|
1176
|
-
swapProvider: swapProvider || undefined,
|
|
1177
|
-
bridgeProvider: bridgeProvider || undefined,
|
|
1178
|
-
mode,
|
|
1179
|
-
fundMethod,
|
|
1180
|
-
originTokenAddress: params.originTokenAddress,
|
|
1181
|
-
originTokenSymbol,
|
|
1182
|
-
originTokenAmount: depositAmount,
|
|
1183
|
-
originTokenAmountFormatted: depositAmountFormatted,
|
|
1184
|
-
destinationTokenAddress: params.destinationTokenAddress,
|
|
1185
|
-
destinationTokenSymbol,
|
|
1186
|
-
depositTokenAmount: depositAmount,
|
|
1187
|
-
depositTokenAmountFormatted: depositAmountFormatted,
|
|
1188
|
-
depositTokenAmountUsd: depositAmountUsd,
|
|
1189
|
-
destinationTokenAmount: intent.quote?.toAmount?.toString() || depositAmount,
|
|
1190
|
-
destinationTokenAmountFormatted: formatRawAmount(
|
|
1191
|
-
intent.quote?.toAmount?.toString() || depositAmount,
|
|
1192
|
-
destinationTokenDecimals,
|
|
1193
|
-
),
|
|
1194
|
-
originTokenDecimals,
|
|
1195
|
-
destinationTokenDecimals,
|
|
1196
|
-
tradeType: tradeType?.toString(),
|
|
1197
|
-
sourceTokenPriceUsd,
|
|
1198
|
-
destinationTokenPriceUsd,
|
|
1199
|
-
walletId,
|
|
1200
|
-
destinationCalldata,
|
|
1201
|
-
})
|
|
1202
|
-
|
|
1203
|
-
invalidateTokenBalancesCache(undefined, effectiveQueryClient)
|
|
1204
|
-
|
|
1205
|
-
if (checkoutOnHandlers?.triggerCheckoutComplete) {
|
|
1206
|
-
checkoutOnHandlers.triggerCheckoutComplete(txStatus, account.address)
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
return {
|
|
1210
|
-
depositUserTxnReceipt,
|
|
1211
|
-
originIntentTransaction,
|
|
1212
|
-
destinationIntentTransaction,
|
|
1213
|
-
totalCompletionSeconds: await getTxTimeDiff(
|
|
1214
|
-
localTransactionStates[0],
|
|
1215
|
-
localTransactionStates[localTransactionStates.length - 1],
|
|
1216
|
-
),
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
/**
|
|
1221
|
-
* Unified intent handler that supports both passthrough and intent flows.
|
|
1222
|
-
* The backend decides the flow type via `intent.passthrough` flag.
|
|
1223
|
-
*/
|
|
1224
|
-
export async function handleIntent(
|
|
1225
|
-
params: IntentHandlerParams,
|
|
1226
|
-
): Promise<PrepareSendReturn> {
|
|
1227
|
-
const {
|
|
1228
|
-
mainSignerAddress,
|
|
1229
|
-
originChainId,
|
|
1230
|
-
originTokenAddress,
|
|
1231
|
-
originTokenBalance,
|
|
1232
|
-
originTokenDecimals,
|
|
1233
|
-
originTokenSymbol,
|
|
1234
|
-
destinationChainId,
|
|
1235
|
-
destinationTokenAddress,
|
|
1236
|
-
destinationTokenSymbol,
|
|
1237
|
-
destinationTokenDecimals,
|
|
1238
|
-
swapAmount,
|
|
1239
|
-
recipient,
|
|
1240
|
-
destinationApproveAddress,
|
|
1241
|
-
destinationCalldata,
|
|
1242
|
-
account,
|
|
1243
|
-
chain,
|
|
1244
|
-
trailsClient,
|
|
1245
|
-
sourceTokenPriceUsd,
|
|
1246
|
-
destinationTokenPriceUsd,
|
|
1247
|
-
originNativeTokenPriceUsd,
|
|
1248
|
-
slippageTolerance,
|
|
1249
|
-
tradeType = TradeType.EXACT_INPUT,
|
|
1250
|
-
swapProvider: initialSwapProvider,
|
|
1251
|
-
bridgeProvider: initialBridgeProvider,
|
|
1252
|
-
swapProviderFallback,
|
|
1253
|
-
bridgeProviderFallback,
|
|
1254
|
-
fundMethod: fundMethodFromParams,
|
|
1255
|
-
mode,
|
|
1256
|
-
checkoutOnHandlers,
|
|
1257
|
-
selectedFeeOption,
|
|
1258
|
-
walletId,
|
|
1259
|
-
abortSignal,
|
|
1260
|
-
commitIntentFn,
|
|
1261
|
-
isSmartWallet,
|
|
1262
|
-
isSenderContractOnOrigin,
|
|
1263
|
-
trailsApiKey,
|
|
1264
|
-
trailsApiUrl,
|
|
1265
|
-
sequenceMetadataUrl,
|
|
1266
|
-
} = params
|
|
1267
|
-
|
|
1268
|
-
logger.console.log("[trails-sdk] handleIntent called")
|
|
1269
|
-
|
|
1270
|
-
const effectiveFundMethod = fundMethodFromParams ?? "wallet"
|
|
1271
|
-
const effectiveOriginChain = chain
|
|
1272
|
-
const effectiveOriginTokenAddress = originTokenAddress
|
|
1273
|
-
const effectivePublicClient =
|
|
1274
|
-
params.publicClient ?? getChainRpcClient(effectiveOriginChain.id)
|
|
1275
|
-
|
|
1276
|
-
const isToSameChain = isSameChain(originChainId, destinationChainId)
|
|
1277
|
-
const isToSameToken = isSameToken(originTokenAddress, destinationTokenAddress)
|
|
1278
|
-
const isSameChainSameToken = isToSameChain && isToSameToken
|
|
1279
|
-
|
|
1280
|
-
const swapProvider = initialSwapProvider
|
|
1281
|
-
const bridgeProvider = initialBridgeProvider
|
|
1282
|
-
|
|
1283
|
-
// SPEC: Same-chain same-token wallet scenarios (C9b/C10/C11b/C12/D9b/D10/D11b/D12) may use passthrough when native gas is selected.
|
|
1284
|
-
// SPEC: Intent-only scenarios (C9a/C11a/D9a/D11a) require gasless fee options or have insufficient allowance.
|
|
1285
|
-
// SPEC: Non-wallet fund methods (C13/C14/D13/D14) must use intent flow to provide deposit addresses.
|
|
1286
|
-
// Balance check is done later after we know the actual deposit amount from the intent API
|
|
1287
|
-
// For cross-token swaps, swapAmount is in destination token units, not origin token units
|
|
1288
|
-
let noSufficientBalance = false
|
|
1289
|
-
|
|
1290
|
-
const hasCustomCalldata = getIsCustomCalldata(destinationCalldata)
|
|
1291
|
-
const isNativeOriginToken = isNativeToken(effectiveOriginTokenAddress)
|
|
1292
|
-
|
|
1293
|
-
// Build intent args
|
|
1294
|
-
// EXACT_OUTPUT: pass swapAmount for both (backend uses destination as target, origin as hint)
|
|
1295
|
-
// EXACT_INPUT: pass swapAmount as origin, 0 as destination (backend calculates destination)
|
|
1296
|
-
const intentArgs = await getIntentArgs(
|
|
1297
|
-
mainSignerAddress,
|
|
1298
|
-
originChainId,
|
|
1299
|
-
originTokenAddress,
|
|
1300
|
-
swapAmount,
|
|
1301
|
-
destinationChainId,
|
|
1302
|
-
destinationTokenAddress,
|
|
1303
|
-
tradeType === TradeType.EXACT_OUTPUT ? swapAmount : "0",
|
|
1304
|
-
recipient,
|
|
1305
|
-
destinationApproveAddress,
|
|
1306
|
-
destinationCalldata,
|
|
1307
|
-
slippageTolerance,
|
|
1308
|
-
tradeType,
|
|
1309
|
-
swapProvider,
|
|
1310
|
-
bridgeProvider,
|
|
1311
|
-
swapProviderFallback,
|
|
1312
|
-
bridgeProviderFallback,
|
|
1313
|
-
undefined,
|
|
1314
|
-
walletId,
|
|
1315
|
-
isSmartWallet,
|
|
1316
|
-
isSenderContractOnOrigin,
|
|
1317
|
-
)
|
|
1318
|
-
|
|
1319
|
-
// For same-chain same-token with native calldata, add call value
|
|
1320
|
-
if (isSameChainSameToken && hasCustomCalldata && isNativeOriginToken) {
|
|
1321
|
-
intentArgs.destinationCallValue = BigInt(swapAmount)
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
// Add fundMethod to intent args for backend passthrough decision
|
|
1325
|
-
intentArgs.fundMethod = toApiFundMethod(effectiveFundMethod)
|
|
1326
|
-
|
|
1327
|
-
logger.console.log("[trails-sdk] Creating intent with args:", intentArgs)
|
|
1328
|
-
|
|
1329
|
-
// Call quoteIntent first to get depositTransaction from API
|
|
1330
|
-
const quoteResult = await quoteIntent(
|
|
1331
|
-
trailsClient,
|
|
1332
|
-
intentArgs,
|
|
1333
|
-
{
|
|
1334
|
-
originTokenSymbol,
|
|
1335
|
-
destinationTokenSymbol,
|
|
1336
|
-
feeTokenSymbol: originTokenSymbol,
|
|
1337
|
-
},
|
|
1338
|
-
abortSignal,
|
|
1339
|
-
)
|
|
1340
|
-
|
|
1341
|
-
const {
|
|
1342
|
-
intent,
|
|
1343
|
-
gasFeeOptions,
|
|
1344
|
-
trailsContracts,
|
|
1345
|
-
passthrough,
|
|
1346
|
-
transactionStates: apiTransactionStates,
|
|
1347
|
-
} = quoteResult
|
|
1348
|
-
logger.console.log("[trails-sdk] Quote intent:", intent)
|
|
1349
|
-
logger.console.log("[trails-sdk] Quote intent gasFeeOptions:", gasFeeOptions)
|
|
1350
|
-
logger.console.log("[trails-sdk] Quote passthrough:", passthrough)
|
|
1351
|
-
logger.console.log(
|
|
1352
|
-
"[trails-sdk] Quote transactionStates:",
|
|
1353
|
-
apiTransactionStates,
|
|
1354
|
-
)
|
|
1355
|
-
|
|
1356
|
-
if (!intent.originPrecondition || !intent.originCalls) {
|
|
1357
|
-
throw new Error("Invalid intent")
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
// Determine if passthrough should be used
|
|
1361
|
-
// SPEC: Only same-chain same-token with wallet fund method may use passthrough (C9b/C10/C11b/C12/D9b/D10/D11b/D12).
|
|
1362
|
-
// SPEC: Cross-chain (A/B), different-token (C1-C8/D1-D8), non-wallet (C13/C14/D13/D14), and gasless (G1-G20) must always use intents.
|
|
1363
|
-
// SPEC: Intent-only scenarios (C9a/C11a/D9a/D11a) cannot use passthrough due to gasless fee options.
|
|
1364
|
-
// Backend sets passthrough.eligible, but we enforce structural invariants client-side as a safety net.
|
|
1365
|
-
// For ERC20 passthrough with custom calldata, the SDK handles approval if insufficient (see executePassthrough).
|
|
1366
|
-
const usePassthrough =
|
|
1367
|
-
effectiveFundMethod === "wallet" &&
|
|
1368
|
-
passthrough?.eligible === true &&
|
|
1369
|
-
!!passthrough?.passthroughTransaction &&
|
|
1370
|
-
isFeeSelectionPassthroughEligible({
|
|
1371
|
-
selectedFeeOption,
|
|
1372
|
-
gasFeeOptions,
|
|
1373
|
-
})
|
|
1374
|
-
|
|
1375
|
-
logger.console.log("[trails-sdk] Passthrough decision:", {
|
|
1376
|
-
usePassthrough,
|
|
1377
|
-
isSameChainSameToken,
|
|
1378
|
-
fundMethod: effectiveFundMethod,
|
|
1379
|
-
passthroughEligible: passthrough?.eligible,
|
|
1380
|
-
hasPassthroughTransaction: !!passthrough?.passthroughTransaction,
|
|
1381
|
-
feeOptionPassthroughEligible: selectedFeeOption?.isPassthroughEligible,
|
|
1382
|
-
selectedFeeOption,
|
|
1383
|
-
})
|
|
1384
|
-
|
|
1385
|
-
// Use passthrough-specific deposit transaction and states when doing passthrough
|
|
1386
|
-
const effectiveDepositTransaction: DepositTransaction | undefined =
|
|
1387
|
-
usePassthrough && passthrough?.passthroughTransaction
|
|
1388
|
-
? passthrough.passthroughTransaction
|
|
1389
|
-
: intent.depositTransaction
|
|
1390
|
-
|
|
1391
|
-
const depositAmount = effectiveDepositTransaction.amount.toString()
|
|
1392
|
-
const quoteToAmount = intent.quote.toAmount.toString()
|
|
1393
|
-
const quoteToAmountMin = intent.quote.toAmountMin.toString() || quoteToAmount
|
|
1394
|
-
|
|
1395
|
-
// Compute transaction states for both passthrough and intent flows
|
|
1396
|
-
// This allows the UI to switch between them based on fee option selection
|
|
1397
|
-
// SPEC: Passthrough-capable scenarios (C9b/C10/C11b/C12/D9b/D10/D11b/D12) expose passthrough transaction states; other scenarios use intent-flow states.
|
|
1398
|
-
const passthroughTransactionStates = passthrough?.transactionStates?.length
|
|
1399
|
-
? getNormalizedTransactionStates({
|
|
1400
|
-
transactionStates: passthrough.transactionStates,
|
|
1401
|
-
})
|
|
1402
|
-
: []
|
|
1403
|
-
|
|
1404
|
-
const intentTransactionStates = apiTransactionStates?.length
|
|
1405
|
-
? getNormalizedTransactionStates({
|
|
1406
|
-
transactionStates: apiTransactionStates,
|
|
1407
|
-
})
|
|
1408
|
-
: []
|
|
1409
|
-
|
|
1410
|
-
// Use the appropriate states based on current passthrough decision
|
|
1411
|
-
const transactionStates = usePassthrough
|
|
1412
|
-
? passthroughTransactionStates
|
|
1413
|
-
: intentTransactionStates
|
|
1414
|
-
|
|
1415
|
-
// Run balance check and quote normalization in parallel to reduce latency
|
|
1416
|
-
const [balanceResult, quote] = await Promise.all([
|
|
1417
|
-
effectiveFundMethod === "wallet"
|
|
1418
|
-
? checkAccountBalance({
|
|
1419
|
-
account,
|
|
1420
|
-
tokenAddress: originTokenAddress,
|
|
1421
|
-
depositAmount: depositAmount,
|
|
1422
|
-
publicClient: effectivePublicClient,
|
|
1423
|
-
knownBalance:
|
|
1424
|
-
originTokenBalance && originTokenBalance !== "0"
|
|
1425
|
-
? originTokenBalance
|
|
1426
|
-
: undefined,
|
|
1427
|
-
decimals: originTokenDecimals,
|
|
1428
|
-
})
|
|
1429
|
-
: Promise.resolve({ hasEnoughBalance: true }),
|
|
1430
|
-
getNormalizedQuoteObject({
|
|
1431
|
-
originDepositAddress: usePassthrough
|
|
1432
|
-
? recipient
|
|
1433
|
-
: intent.originIntentAddress,
|
|
1434
|
-
destinationDepositAddress: usePassthrough
|
|
1435
|
-
? recipient
|
|
1436
|
-
: intent.destinationIntentAddress,
|
|
1437
|
-
destinationAddress: recipient,
|
|
1438
|
-
trailsApiKey: trailsApiKey || "",
|
|
1439
|
-
trailsApiUrl: trailsApiUrl || "",
|
|
1440
|
-
sequenceMetadataUrl: sequenceMetadataUrl || "",
|
|
1441
|
-
destinationCalldata,
|
|
1442
|
-
originAmount: depositAmount,
|
|
1443
|
-
destinationAmount: quoteToAmount,
|
|
1444
|
-
originAmountMin: depositAmount,
|
|
1445
|
-
destinationAmountMin: quoteToAmountMin,
|
|
1446
|
-
originTokenAddress,
|
|
1447
|
-
destinationTokenAddress,
|
|
1448
|
-
originTokenPriceUsd: sourceTokenPriceUsd?.toString() || null,
|
|
1449
|
-
destinationTokenPriceUsd: destinationTokenPriceUsd?.toString() || null,
|
|
1450
|
-
fees: isSameChainSameToken
|
|
1451
|
-
? undefined
|
|
1452
|
-
: getFeesFromIntent(intent, {
|
|
1453
|
-
tradeType,
|
|
1454
|
-
fromAmountUsd: calcAmountUsdPrice({
|
|
1455
|
-
amount: rawAmountToNumber(depositAmount, originTokenDecimals),
|
|
1456
|
-
usdPrice: sourceTokenPriceUsd,
|
|
1457
|
-
}),
|
|
1458
|
-
toAmountUsd: calcAmountUsdPrice({
|
|
1459
|
-
amount: rawAmountToNumber(
|
|
1460
|
-
quoteToAmount,
|
|
1461
|
-
destinationTokenDecimals,
|
|
1462
|
-
),
|
|
1463
|
-
usdPrice: destinationTokenPriceUsd,
|
|
1464
|
-
}),
|
|
1465
|
-
}),
|
|
1466
|
-
originChainId,
|
|
1467
|
-
destinationChainId,
|
|
1468
|
-
slippageTolerance,
|
|
1469
|
-
priceImpact: getPriceImpactFromIntent(intent),
|
|
1470
|
-
priceImpactUsd: getPriceImpactUsdFromIntent(intent),
|
|
1471
|
-
transactionStates,
|
|
1472
|
-
originNativeTokenPriceUsd,
|
|
1473
|
-
intent: usePassthrough ? undefined : intent,
|
|
1474
|
-
}),
|
|
1475
|
-
])
|
|
1476
|
-
|
|
1477
|
-
noSufficientBalance = !balanceResult.hasEnoughBalance
|
|
1478
|
-
quote.noSufficientBalance = noSufficientBalance
|
|
1479
|
-
if (effectiveFundMethod === "wallet") {
|
|
1480
|
-
logger.console.log(
|
|
1481
|
-
"[trails-sdk] Balance check with actual deposit amount:",
|
|
1482
|
-
{
|
|
1483
|
-
depositAmount,
|
|
1484
|
-
originTokenAddress,
|
|
1485
|
-
hasEnoughBalance: balanceResult.hasEnoughBalance,
|
|
1486
|
-
noSufficientBalance,
|
|
1487
|
-
},
|
|
1488
|
-
)
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
// Add passthrough-specific fields to the quote
|
|
1492
|
-
// This allows the UI to switch between passthrough and intent states based on fee option
|
|
1493
|
-
// SPEC: Quote includes passthrough info for passthrough-capable scenarios (C9b/C10/C11b/C12/D9b/D10/D11b/D12) so UI can toggle flows.
|
|
1494
|
-
quote.passthroughTransactionStates = passthroughTransactionStates
|
|
1495
|
-
quote.passthroughEligible = passthrough?.eligible === true
|
|
1496
|
-
|
|
1497
|
-
// Call onCheckoutQuote callback
|
|
1498
|
-
if (checkoutOnHandlers?.triggerCheckoutQuote) {
|
|
1499
|
-
checkoutOnHandlers.triggerCheckoutQuote(quote)
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
logger.console.log(
|
|
1503
|
-
"[trails-sdk] handleIntent returning quote and send function",
|
|
1504
|
-
)
|
|
1505
|
-
|
|
1506
|
-
return {
|
|
1507
|
-
quote,
|
|
1508
|
-
feeOptions: gasFeeOptions,
|
|
1509
|
-
send: async (options) => {
|
|
1510
|
-
const { skipCommit } = options
|
|
1511
|
-
|
|
1512
|
-
try {
|
|
1513
|
-
// Recalculate passthrough decision at send time based on fee option.
|
|
1514
|
-
// This allows switching between passthrough and intent flow after quote.
|
|
1515
|
-
const sendFeeOption = options.selectedFeeOption
|
|
1516
|
-
const sendUsePassthrough =
|
|
1517
|
-
effectiveFundMethod === "wallet" &&
|
|
1518
|
-
passthrough?.eligible === true &&
|
|
1519
|
-
!!passthrough?.passthroughTransaction &&
|
|
1520
|
-
isFeeSelectionPassthroughEligible({
|
|
1521
|
-
selectedFeeOption: sendFeeOption,
|
|
1522
|
-
gasFeeOptions,
|
|
1523
|
-
})
|
|
1524
|
-
|
|
1525
|
-
logger.console.log("[trails-sdk] Send passthrough decision:", {
|
|
1526
|
-
sendUsePassthrough,
|
|
1527
|
-
passthroughEligible: passthrough?.eligible,
|
|
1528
|
-
hasPassthroughTransaction: !!passthrough?.passthroughTransaction,
|
|
1529
|
-
sendFeeOptionPassthroughEligible:
|
|
1530
|
-
sendFeeOption?.isPassthroughEligible,
|
|
1531
|
-
sendFeeOption,
|
|
1532
|
-
})
|
|
1533
|
-
|
|
1534
|
-
// Select the correct deposit transaction based on passthrough decision at send time
|
|
1535
|
-
const sendDepositTransaction: DepositTransaction | undefined =
|
|
1536
|
-
sendUsePassthrough && passthrough?.passthroughTransaction
|
|
1537
|
-
? passthrough.passthroughTransaction
|
|
1538
|
-
: intent.depositTransaction
|
|
1539
|
-
|
|
1540
|
-
// Select the correct transaction states based on passthrough decision at send time
|
|
1541
|
-
const sendTransactionStates = sendUsePassthrough
|
|
1542
|
-
? passthroughTransactionStates
|
|
1543
|
-
: intentTransactionStates
|
|
1544
|
-
|
|
1545
|
-
const commitIntentIfNeeded = async () => {
|
|
1546
|
-
if (skipCommit) {
|
|
1547
|
-
return
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
try {
|
|
1551
|
-
logger.console.log(
|
|
1552
|
-
"[trails-sdk] intentHandler: About to commit intent",
|
|
1553
|
-
{
|
|
1554
|
-
hasCommitIntentFn: !!commitIntentFn,
|
|
1555
|
-
intentId: intent.intentId,
|
|
1556
|
-
},
|
|
1557
|
-
)
|
|
1558
|
-
|
|
1559
|
-
const commitIntentFnToUse =
|
|
1560
|
-
commitIntentFn ||
|
|
1561
|
-
((intent: Intent) =>
|
|
1562
|
-
commitIntent(trailsClient, intent, {
|
|
1563
|
-
originTokenSymbol,
|
|
1564
|
-
destinationTokenSymbol,
|
|
1565
|
-
}))
|
|
1566
|
-
await commitIntentFnToUse(intent)
|
|
1567
|
-
|
|
1568
|
-
logger.console.log("[trails-sdk] Intent committed successfully")
|
|
1569
|
-
} catch (error) {
|
|
1570
|
-
logger.console.error("[trails-sdk] Error committing intent", error)
|
|
1571
|
-
throw error
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
if (sendUsePassthrough && sendDepositTransaction) {
|
|
1576
|
-
return executePassthrough(
|
|
1577
|
-
params,
|
|
1578
|
-
sendDepositTransaction,
|
|
1579
|
-
sendTransactionStates,
|
|
1580
|
-
options,
|
|
1581
|
-
)
|
|
1582
|
-
} else {
|
|
1583
|
-
await commitIntentIfNeeded()
|
|
1584
|
-
return executeIntent(
|
|
1585
|
-
params,
|
|
1586
|
-
intent,
|
|
1587
|
-
sendTransactionStates,
|
|
1588
|
-
gasFeeOptions,
|
|
1589
|
-
trailsContracts,
|
|
1590
|
-
options,
|
|
1591
|
-
)
|
|
1592
|
-
}
|
|
1593
|
-
} catch (error) {
|
|
1594
|
-
const errorMessage = getFullErrorMessage(error)
|
|
1595
|
-
logger.console.error("[trails-sdk] Error in handleIntent send:", error)
|
|
1596
|
-
|
|
1597
|
-
trackPaymentError({
|
|
1598
|
-
error: errorMessage,
|
|
1599
|
-
userAddress: account.address,
|
|
1600
|
-
mode,
|
|
1601
|
-
fundMethod: effectiveFundMethod,
|
|
1602
|
-
originTokenAddress,
|
|
1603
|
-
})
|
|
1604
|
-
|
|
1605
|
-
if (checkoutOnHandlers?.triggerCheckoutError) {
|
|
1606
|
-
checkoutOnHandlers.triggerCheckoutError(errorMessage)
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
throw error
|
|
1610
|
-
}
|
|
1611
|
-
},
|
|
1612
|
-
}
|
|
1613
|
-
}
|