0xtrails 0.6.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aave.d.ts +10 -2
- package/dist/aave.d.ts.map +1 -1
- package/dist/analytics.d.ts +26 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-CbJrlK-L.js → ccip-fConRNoG.js} +21 -21
- package/dist/chains.d.ts +23 -8
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/customTokens.d.ts +12 -0
- package/dist/customTokens.d.ts.map +1 -0
- package/dist/decoders.d.ts +2 -2
- package/dist/decoders.d.ts.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/fees.d.ts +37 -2
- package/dist/fees.d.ts.map +1 -1
- package/dist/gasless.d.ts +15 -36
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-w7_dK4c5.js → index-BbajxCG_.js} +59269 -77146
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +828 -359
- package/dist/indexerClient.d.ts.map +1 -1
- package/dist/intentReceiptMonitor.d.ts +1 -1
- package/dist/intentReceiptMonitor.d.ts.map +1 -1
- package/dist/intentReceiptPoller.d.ts +1 -1
- package/dist/intentReceiptPoller.d.ts.map +1 -1
- package/dist/intents.d.ts +3 -2
- package/dist/intents.d.ts.map +1 -1
- package/dist/mode.d.ts +1 -1
- package/dist/mode.d.ts.map +1 -1
- package/dist/mutations.d.ts +2 -2
- package/dist/mutations.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +2 -2
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +1 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +2 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/time.d.ts +6 -0
- package/dist/time.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +40 -25
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +54 -14
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +1 -1
- package/dist/trailsClient.d.ts.map +1 -1
- package/dist/trailsRouter.d.ts +2 -1
- package/dist/trailsRouter.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +3 -2
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/crossChain.d.ts +5 -3
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +5 -3
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
- package/dist/transactionIntent/quote/feeExtractors.d.ts +1 -6
- package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts +4 -2
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +28 -5
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactionIntent/utils/testnetHelpers.d.ts +0 -1
- package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/validators.d.ts +0 -2
- package/dist/transactionIntent/validators.d.ts.map +1 -1
- package/dist/transactions.d.ts +2 -2
- package/dist/transactions.d.ts.map +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/wallets.d.ts +1 -0
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/AddressWalletIcon.d.ts +6 -0
- package/dist/widget/components/AddressWalletIcon.d.ts.map +1 -0
- package/dist/widget/components/ChainFilterDropdown.d.ts +2 -6
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ChainImage.d.ts.map +1 -1
- package/dist/widget/components/ChainList.d.ts +0 -5
- package/dist/widget/components/ChainList.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +6 -6
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DebugMenu.d.ts +1 -1
- package/dist/widget/components/DebugMenu.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
- package/dist/widget/components/DepositTracker.d.ts.map +1 -1
- package/dist/widget/components/Earn.d.ts +5 -5
- 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 +2 -2
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Footer.d.ts +1 -1
- package/dist/widget/components/Footer.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +5 -5
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts +0 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSwap.d.ts +6 -6
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/HookModalContent.d.ts +8 -0
- package/dist/widget/components/HookModalContent.d.ts.map +1 -0
- package/dist/widget/components/OriginSelectionAmount.d.ts +11 -0
- package/dist/widget/components/OriginSelectionAmount.d.ts.map +1 -0
- package/dist/widget/components/Pay.d.ts +5 -5
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +5 -5
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +3 -3
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts +2 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/RecentTokens.d.ts +4 -4
- package/dist/widget/components/RecentTokens.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/ShadowPortal.d.ts +6 -0
- package/dist/widget/components/ShadowPortal.d.ts.map +1 -0
- package/dist/widget/components/Swap.d.ts +6 -6
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts +3 -4
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts +3 -4
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/Tooltip.d.ts +6 -1
- package/dist/widget/components/Tooltip.d.ts.map +1 -1
- package/dist/widget/components/TrailsHookModal.d.ts +10 -0
- package/dist/widget/components/TrailsHookModal.d.ts.map +1 -0
- package/dist/widget/components/WaasFeeOptions.d.ts +3 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WidgetProviders.d.ts +14 -0
- package/dist/widget/components/WidgetProviders.d.ts.map +1 -0
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useAddressWalletIcon.d.ts +10 -0
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -0
- package/dist/widget/hooks/useBalanceVisible.d.ts +1 -1
- package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
- package/dist/widget/hooks/useChainFilter.d.ts +1 -1
- package/dist/widget/hooks/useChainFilter.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +13 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useConnector.d.ts +4 -0
- package/dist/widget/hooks/useConnector.d.ts.map +1 -0
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useCustomTokenFetch.d.ts +19 -0
- package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +1 -0
- package/dist/widget/hooks/useCustomTokenSearch.d.ts +20 -0
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -0
- package/dist/widget/hooks/useDebounce.d.ts +10 -0
- package/dist/widget/hooks/useDebounce.d.ts.map +1 -0
- package/dist/widget/hooks/useDebugScreens.d.ts +7 -2
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -19
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useDestinationSelectedToken.d.ts +1 -14
- package/dist/widget/hooks/useDestinationSelectedToken.d.ts.map +1 -1
- package/dist/widget/hooks/useEarnPool.d.ts +1 -1
- package/dist/widget/hooks/useEarnPool.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useIsMobile.d.ts +5 -0
- package/dist/widget/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/widget/hooks/useMode.d.ts +2 -2
- package/dist/widget/hooks/useMode.d.ts.map +1 -1
- package/dist/widget/hooks/useOriginSelectedToken.d.ts +2 -15
- package/dist/widget/hooks/useOriginSelectedToken.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/usePriceImpactWarning.d.ts +1 -1
- package/dist/widget/hooks/usePriceImpactWarning.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +173 -4
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useRecentTokens.d.ts +3 -3
- package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
- package/dist/widget/hooks/useRecipients.d.ts +1 -1
- package/dist/widget/hooks/useRecipients.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeOption.d.ts +2 -2
- package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedRecipient.d.ts +1 -1
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +9 -31
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -1
- package/dist/widget/hooks/useTheme.d.ts +1 -1
- package/dist/widget/hooks/useTheme.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +7 -31
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts +83 -0
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +1 -0
- package/dist/widget/hooks/useWalletConnectUri.d.ts +11 -0
- package/dist/widget/hooks/useWalletConnectUri.d.ts.map +1 -0
- package/dist/widget/hooks/useWidgetProps.d.ts +5 -0
- package/dist/widget/hooks/useWidgetProps.d.ts.map +1 -1
- package/dist/widget/index.d.ts +2 -0
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +8 -5
- package/dist/widget/providers/TrailsModalProvider.d.ts +65 -0
- package/dist/widget/providers/TrailsModalProvider.d.ts.map +1 -0
- package/dist/widget/providers/TrailsProvider.d.ts +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/types.d.ts +11 -18
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widget.d.ts +20 -11
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +45 -49
- package/src/aave.ts +387 -138
- package/src/analytics.ts +208 -2
- package/src/chains.ts +65 -64
- package/src/constants.ts +18 -14
- package/src/customTokens.ts +151 -0
- package/src/decoders.ts +4 -7
- package/src/error.ts +7 -3
- package/src/fees.ts +239 -125
- package/src/gasless.ts +54 -108
- package/src/index.ts +29 -9
- package/src/indexerClient.ts +2 -0
- package/src/intentReceiptMonitor.ts +1 -4
- package/src/intentReceiptPoller.ts +2 -2
- package/src/intents.ts +16 -5
- package/src/mode.ts +1 -1
- package/src/mutations.ts +7 -3
- package/src/prepareSend.ts +19 -14
- package/src/prices.ts +1 -1
- package/src/sequenceWallet.ts +2 -2
- package/src/time.ts +28 -0
- package/src/tokenBalances.ts +348 -153
- package/src/tokens.ts +393 -142
- package/src/trailsClient.ts +1 -1
- package/src/trailsRouter.ts +4 -5
- package/src/transactionIntent/deposits/depositOrchestrator.ts +6 -2
- package/src/transactionIntent/deposits/gaslessDeposit.ts +13 -7
- package/src/transactionIntent/deposits/standardDeposit.ts +1 -1
- package/src/transactionIntent/execution/transactionState.ts +1 -1
- package/src/transactionIntent/handlers/crossChain.ts +75 -37
- package/src/transactionIntent/handlers/sameChainSameToken.ts +66 -20
- package/src/transactionIntent/quote/feeExtractors.ts +1 -29
- package/src/transactionIntent/quote/normalizeQuote.ts +99 -7
- package/src/transactionIntent/quote/quoteHelpers.ts +1 -1
- package/src/transactionIntent/types.ts +31 -6
- package/src/transactionIntent/utils/testnetHelpers.ts +0 -5
- package/src/transactionIntent/validators.ts +0 -30
- package/src/transactions.ts +3 -3
- package/src/utils.ts +18 -0
- package/src/wallets.ts +32 -10
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +2 -1
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +2 -2
- package/src/widget/components/AddressWalletIcon.tsx +29 -0
- package/src/widget/components/ChainFilterDropdown.tsx +2 -8
- package/src/widget/components/ChainImage.tsx +8 -5
- package/src/widget/components/ChainList.tsx +6 -8
- package/src/widget/components/ClassicSwap.tsx +93 -85
- package/src/widget/components/ConnectWallet.tsx +1 -2
- package/src/widget/components/ConnectedWallets.tsx +17 -4
- package/src/widget/components/DebugMenu.tsx +2 -2
- package/src/widget/components/DebugScreensList.tsx +0 -1
- package/src/widget/components/DepositTracker.tsx +20 -34
- package/src/widget/components/Earn.tsx +7 -6
- package/src/widget/components/FeeOption.tsx +4 -4
- package/src/widget/components/FeeOptions.tsx +19 -39
- package/src/widget/components/Footer.tsx +1 -1
- package/src/widget/components/Fund.tsx +23 -119
- package/src/widget/components/FundMethods.tsx +9 -6
- package/src/widget/components/FundSwap.tsx +6 -5
- package/src/widget/components/FundingMethodSelectorButton.tsx +2 -2
- package/src/widget/components/HookModalContent.tsx +306 -0
- package/src/widget/components/Modal.tsx +1 -1
- package/src/widget/components/OriginSelectionAmount.tsx +135 -0
- package/src/widget/components/Pay.tsx +66 -124
- package/src/widget/components/PoolDeposit.tsx +11 -55
- package/src/widget/components/PoolWithdraw.tsx +3 -3
- package/src/widget/components/QuoteDetails.tsx +473 -728
- package/src/widget/components/Receipt.tsx +74 -7
- package/src/widget/components/RecentTokens.tsx +8 -8
- package/src/widget/components/RecipientSelectorButton.tsx +4 -2
- package/src/widget/components/ScreenHeader.tsx +2 -2
- package/src/widget/components/SearchInputField.tsx +1 -1
- package/src/widget/components/ShadowPortal.tsx +58 -0
- package/src/widget/components/Swap.tsx +6 -5
- package/src/widget/components/ThemeProvider.tsx +1 -1
- package/src/widget/components/TokenList.tsx +3 -4
- package/src/widget/components/TokenSelector.tsx +211 -80
- package/src/widget/components/Tooltip.tsx +18 -7
- package/src/widget/components/TrailsHookModal.tsx +118 -0
- package/src/widget/components/WaasFeeOptions.tsx +333 -138
- package/src/widget/components/WalletConfirmation.tsx +7 -2
- package/src/widget/components/WalletConnect.tsx +197 -235
- package/src/widget/components/WidgetProviders.tsx +75 -0
- package/src/widget/hooks/useAddressWalletIcon.ts +53 -0
- package/src/widget/hooks/useBalanceVisible.tsx +1 -1
- package/src/widget/hooks/useChainFilter.tsx +1 -1
- package/src/widget/hooks/useCheckout.ts +13 -1
- package/src/widget/hooks/useConnector.tsx +18 -0
- package/src/widget/hooks/useCurrentScreen.tsx +3 -3
- package/src/widget/hooks/useCustomTokenFetch.tsx +72 -0
- package/src/widget/hooks/useCustomTokenSearch.tsx +402 -0
- package/src/widget/hooks/useDebounce.ts +25 -0
- package/src/widget/hooks/useDebugScreens.ts +26 -10
- package/src/widget/hooks/useDefaultTokenSelection.tsx +99 -143
- package/src/widget/hooks/useDestinationSelectedToken.tsx +1 -14
- package/src/widget/hooks/useEarnPool.tsx +1 -1
- package/src/widget/hooks/useIntentTransactionHistory.ts +20 -11
- package/src/widget/hooks/useIsMobile.tsx +50 -0
- package/src/widget/hooks/useMode.ts +2 -3
- package/src/widget/hooks/useOriginSelectedToken.tsx +2 -15
- package/src/widget/hooks/usePayMessage.tsx +31 -11
- package/src/widget/hooks/usePriceImpactWarning.ts +1 -1
- package/src/widget/hooks/useQuote.ts +189 -6
- package/src/widget/hooks/useRecentTokens.ts +6 -6
- package/src/widget/hooks/useRecipients.ts +1 -1
- package/src/widget/hooks/useSelectedFeeOption.tsx +2 -2
- package/src/widget/hooks/useSelectedFundMethod.tsx +1 -1
- package/src/widget/hooks/useSelectedRecipient.tsx +1 -1
- package/src/widget/hooks/useSendForm.ts +328 -152
- package/src/widget/hooks/useSwapAmount.tsx +1 -1
- package/src/widget/hooks/useTheme.tsx +1 -1
- package/src/widget/hooks/useTokenList.ts +672 -400
- package/src/widget/hooks/useTrailsSendTransaction.ts +949 -0
- package/src/widget/hooks/useWalletConnectUri.tsx +228 -0
- package/src/widget/hooks/useWidgetProps.tsx +3 -1
- package/src/widget/index.tsx +12 -0
- package/src/widget/providers/TrailsModalProvider.tsx +195 -0
- package/src/widget/providers/TrailsProvider.tsx +9 -3
- package/src/widget/types.ts +12 -20
- package/src/widget/widget.tsx +598 -385
- package/dist/cctp.d.ts +0 -3
- package/dist/cctp.d.ts.map +0 -1
- package/dist/lifi.d.ts +0 -4
- package/dist/lifi.d.ts.map +0 -1
- package/dist/meshconnect.d.ts +0 -171
- package/dist/meshconnect.d.ts.map +0 -1
- package/dist/relaySdk.d.ts +0 -87
- package/dist/relaySdk.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -7
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectFlow.d.ts +0 -13
- package/dist/widget/components/MeshConnectFlow.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectIframe.d.ts +0 -15
- package/dist/widget/components/MeshConnectIframe.d.ts.map +0 -1
- package/dist/widget/components/Receive.d.ts +0 -12
- package/dist/widget/components/Receive.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts +0 -14
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +0 -1
- package/src/cctp.ts +0 -54
- package/src/lifi.ts +0 -108
- package/src/meshconnect.ts +0 -531
- package/src/relaySdk.ts +0 -703
- package/src/widget/components/MeshConnectExchanges.tsx +0 -290
- package/src/widget/components/MeshConnectFlow.tsx +0 -90
- package/src/widget/components/MeshConnectIframe.tsx +0 -500
- package/src/widget/components/Receive.tsx +0 -175
- package/src/widget/hooks/useSelectedMeshExchange.tsx +0 -46
package/dist/index.js
CHANGED
|
@@ -1,421 +1,435 @@
|
|
|
1
|
-
import { l as
|
|
2
|
-
import {
|
|
3
|
-
import { useQuery as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { l as o, u as dt, t as Ht, T as vt, a as Lt, b as qt, g as B, I as bt, c as Et, d as ht, e as pt, f as yt, h as lt, i as It, j, p as St, k as G, m as Nt, n as ft, o as Bt, q as mt, r as Ct } from "./index-BbajxCG_.js";
|
|
2
|
+
import { s as ee, ab as ne, ag as oe, ak as se, aj as re, ad as ie, ai as ae, U as ce, L as le, M as de, N as ue, a5 as ge, ah as fe, a6 as me, a8 as Te, a9 as ke, a7 as he, W as Ce, R as Ae, H as Ee, K as pe, ac as ye, X as Ie, w as Se, v as we, D as Ue, z as De, A as xe, C as Pe, B as Re, x as Oe, y as He, E as ve, ae as Le, J as qe, F as be, a0 as Ne, af as Be, aa as Fe, Q as Me, O as Qe, P as We, Y as $e, S as _e, a2 as je, Z as Ge, _ as Je, V as Ke, G as Xe, a3 as ze, $ as Ve, a4 as Ye, a1 as Ze } from "./index-BbajxCG_.js";
|
|
3
|
+
import { useQuery as wt, useMutation as Tt } from "@tanstack/react-query";
|
|
4
|
+
import { useRef as Ut, useCallback as ct } from "react";
|
|
5
|
+
import { useWalletClient as Ft, useAccount as Mt, useChainId as Qt } from "wagmi";
|
|
6
|
+
import { zeroAddress as R, erc20Abi as Dt } from "viem";
|
|
7
|
+
import { useIndexerGatewayClient as xt } from "@0xsequence/hooks";
|
|
8
|
+
import { useIndexerGatewayClient as en } from "@0xsequence/hooks";
|
|
9
|
+
const At = 150, zt = (d, n) => {
|
|
10
|
+
const s = wt({
|
|
11
|
+
queryKey: ["waitIntentReceipt", d],
|
|
11
12
|
queryFn: async () => {
|
|
12
|
-
if (!
|
|
13
|
+
if (!d)
|
|
13
14
|
throw new Error("Intent ID is required for monitoring");
|
|
14
|
-
|
|
15
|
-
`[trails-sdk] 🔍 Monitoring intent receipt for ${
|
|
15
|
+
o.console.log(
|
|
16
|
+
`[trails-sdk] 🔍 Monitoring intent receipt for ${d}`
|
|
16
17
|
);
|
|
17
|
-
const
|
|
18
|
-
intentId:
|
|
18
|
+
const a = await n.waitIntentReceipt({
|
|
19
|
+
intentId: d
|
|
19
20
|
});
|
|
20
|
-
return
|
|
21
|
-
`[trails-sdk] 📊 Intent ${
|
|
22
|
-
),
|
|
21
|
+
return o.console.log(
|
|
22
|
+
`[trails-sdk] 📊 Intent ${d} status: ${a.intentReceipt.status}, done: ${a.done}`
|
|
23
|
+
), a;
|
|
23
24
|
},
|
|
24
|
-
enabled: !!
|
|
25
|
+
enabled: !!d,
|
|
25
26
|
refetchIntervalInBackground: !0,
|
|
26
|
-
refetchInterval: (
|
|
27
|
-
const
|
|
28
|
-
return
|
|
29
|
-
`[trails-sdk] ✅ Intent monitoring complete for ${
|
|
30
|
-
), !1) :
|
|
27
|
+
refetchInterval: (a) => {
|
|
28
|
+
const c = a.state.data;
|
|
29
|
+
return c && c.done ? (o.console.log(
|
|
30
|
+
`[trails-sdk] ✅ Intent monitoring complete for ${d}`
|
|
31
|
+
), !1) : At;
|
|
31
32
|
},
|
|
32
|
-
retry: (
|
|
33
|
-
`[trails-sdk] ❌ Giving up on intent ${
|
|
34
|
-
|
|
33
|
+
retry: (a, c) => a >= 30 ? (o.console.error(
|
|
34
|
+
`[trails-sdk] ❌ Giving up on intent ${d} after 30 failed API attempts:`,
|
|
35
|
+
c
|
|
35
36
|
), !1) : !0
|
|
36
37
|
});
|
|
37
38
|
return {
|
|
38
|
-
intentReceipt:
|
|
39
|
-
done:
|
|
40
|
-
isLoading:
|
|
41
|
-
isError:
|
|
42
|
-
error:
|
|
39
|
+
intentReceipt: s.data?.intentReceipt ?? null,
|
|
40
|
+
done: s.data?.done ?? !1,
|
|
41
|
+
isLoading: s.isLoading,
|
|
42
|
+
isError: s.isError,
|
|
43
|
+
error: s.error
|
|
43
44
|
};
|
|
44
45
|
};
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
mutationFn: async (
|
|
49
|
-
|
|
50
|
-
intentId:
|
|
51
|
-
originIntentAddress:
|
|
46
|
+
function Pt() {
|
|
47
|
+
const d = dt();
|
|
48
|
+
return Tt({
|
|
49
|
+
mutationFn: async (n) => {
|
|
50
|
+
o.console.log("[trails-sdk] useCommitIntent: Starting commit", {
|
|
51
|
+
intentId: n.intentId,
|
|
52
|
+
originIntentAddress: n.originIntentAddress
|
|
52
53
|
});
|
|
53
|
-
const
|
|
54
|
+
const s = n.quoteRequest.originChainId.toString(), a = n.quoteRequest.destinationChainId.toString();
|
|
54
55
|
try {
|
|
55
|
-
|
|
56
|
-
intentAddress:
|
|
57
|
-
userAddress:
|
|
58
|
-
originChainId:
|
|
59
|
-
destinationChainId:
|
|
56
|
+
Ht({
|
|
57
|
+
intentAddress: n.originIntentAddress,
|
|
58
|
+
userAddress: n.ownerAddress,
|
|
59
|
+
originChainId: s ? Number(s) : void 0,
|
|
60
|
+
destinationChainId: a ? Number(a) : void 0
|
|
60
61
|
});
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
62
|
+
const c = await d.commitIntent({
|
|
63
|
+
intent: n,
|
|
64
|
+
trailsContracts: vt
|
|
65
|
+
});
|
|
66
|
+
return o.console.log("[trails-sdk] useCommitIntent: Commit successful", {
|
|
67
|
+
intentId: n.intentId,
|
|
68
|
+
response: c
|
|
69
|
+
}), Lt({
|
|
70
|
+
intentAddress: n.originIntentAddress,
|
|
71
|
+
userAddress: n.ownerAddress,
|
|
72
|
+
originChainId: s ? Number(s) : void 0,
|
|
73
|
+
destinationChainId: a ? Number(a) : void 0
|
|
74
|
+
}), c;
|
|
75
|
+
} catch (c) {
|
|
76
|
+
throw qt({
|
|
77
|
+
error: B(c),
|
|
78
|
+
userAddress: n.ownerAddress,
|
|
79
|
+
intentAddress: n.originIntentAddress,
|
|
80
|
+
originChainId: s ? Number(s) : void 0,
|
|
81
|
+
destinationChainId: a ? Number(a) : void 0
|
|
82
|
+
}), c;
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
});
|
|
82
86
|
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
85
|
-
return
|
|
87
|
+
function Rt() {
|
|
88
|
+
const d = dt();
|
|
89
|
+
return Tt({
|
|
86
90
|
mutationFn: async ({
|
|
87
|
-
intentId:
|
|
88
|
-
depositTransactionHash:
|
|
89
|
-
depositSignature:
|
|
91
|
+
intentId: n,
|
|
92
|
+
depositTransactionHash: s,
|
|
93
|
+
depositSignature: a
|
|
90
94
|
}) => {
|
|
91
|
-
if (
|
|
92
|
-
intentId:
|
|
93
|
-
depositTransactionHash:
|
|
94
|
-
hasDepositSignature: !!
|
|
95
|
-
}), !
|
|
95
|
+
if (o.console.log("[trails-sdk] useExecuteIntent: Starting execution", {
|
|
96
|
+
intentId: n,
|
|
97
|
+
depositTransactionHash: s,
|
|
98
|
+
hasDepositSignature: !!a
|
|
99
|
+
}), !s && !a)
|
|
96
100
|
throw new Error(
|
|
97
101
|
"[trails-sdk] Either depositTransactionHash or depositSignature must be provided"
|
|
98
102
|
);
|
|
99
|
-
let
|
|
103
|
+
let c;
|
|
100
104
|
try {
|
|
101
|
-
|
|
102
|
-
intentId:
|
|
103
|
-
depositTransactionHash:
|
|
104
|
-
depositSignature:
|
|
105
|
+
c = await d.executeIntent({
|
|
106
|
+
intentId: n,
|
|
107
|
+
depositTransactionHash: s,
|
|
108
|
+
depositSignature: a
|
|
105
109
|
});
|
|
106
|
-
} catch (
|
|
107
|
-
if (
|
|
110
|
+
} catch (T) {
|
|
111
|
+
if (o.console.error(
|
|
108
112
|
"[trails-sdk] useExecuteIntent: Error executing intent",
|
|
109
113
|
{
|
|
110
|
-
intentId:
|
|
111
|
-
error:
|
|
112
|
-
errorJSON: JSON.stringify(
|
|
114
|
+
intentId: n,
|
|
115
|
+
error: T,
|
|
116
|
+
errorJSON: JSON.stringify(T, null, 2)
|
|
113
117
|
}
|
|
114
|
-
),
|
|
115
|
-
return
|
|
118
|
+
), T instanceof Error && T?.message?.includes("status=SUCCEEDED") || T instanceof Error && T?.cause?.message?.includes("status=SUCCEEDED") || T instanceof Error && JSON.stringify(T).includes("status=SUCCEEDED") || T instanceof bt && T?.cause?.toString().includes("status=SUCCEEDED") || JSON.stringify(T).includes("status=SUCCEEDED"))
|
|
119
|
+
return o.console.error(
|
|
116
120
|
"[trails-sdk] useExecuteIntent: Intent already succeeded, treating as success",
|
|
117
|
-
{ intentId:
|
|
121
|
+
{ intentId: n }
|
|
118
122
|
), {
|
|
119
|
-
intentId:
|
|
123
|
+
intentId: n,
|
|
120
124
|
intentStatus: "SUCCEEDED"
|
|
121
125
|
};
|
|
122
|
-
throw
|
|
126
|
+
throw o.console.error(
|
|
123
127
|
"[trails-sdk] useExecuteIntent did not throw IntentStatusError and is not a SUCCEEDED intent",
|
|
124
128
|
{
|
|
125
|
-
intentId:
|
|
126
|
-
error:
|
|
127
|
-
errorJSON: JSON.stringify(
|
|
129
|
+
intentId: n,
|
|
130
|
+
error: T,
|
|
131
|
+
errorJSON: JSON.stringify(T, null, 2)
|
|
128
132
|
}
|
|
129
|
-
),
|
|
133
|
+
), T;
|
|
130
134
|
}
|
|
131
|
-
return
|
|
135
|
+
return o.console.log(
|
|
132
136
|
"[trails-sdk] useExecuteIntent: Execution successful",
|
|
133
137
|
{
|
|
134
|
-
intentId:
|
|
135
|
-
response:
|
|
138
|
+
intentId: n,
|
|
139
|
+
response: c
|
|
136
140
|
}
|
|
137
|
-
),
|
|
141
|
+
), c;
|
|
138
142
|
}
|
|
139
143
|
});
|
|
140
144
|
}
|
|
141
|
-
function
|
|
142
|
-
walletClient:
|
|
143
|
-
fromTokenAddress:
|
|
144
|
-
fromChainId:
|
|
145
|
-
toTokenAddress:
|
|
146
|
-
toChainId:
|
|
147
|
-
swapAmount:
|
|
148
|
-
tradeType:
|
|
149
|
-
toRecipient:
|
|
150
|
-
toCalldata:
|
|
151
|
-
slippageTolerance:
|
|
152
|
-
onStatusUpdate:
|
|
153
|
-
checkoutOnHandlers:
|
|
154
|
-
quoteProvider:
|
|
155
|
-
paymasterUrl:
|
|
156
|
-
selectedFeeOption:
|
|
157
|
-
nodeGatewayEnv:
|
|
158
|
-
abortSignal:
|
|
159
|
-
apiKey:
|
|
145
|
+
function Vt({
|
|
146
|
+
walletClient: d,
|
|
147
|
+
fromTokenAddress: n,
|
|
148
|
+
fromChainId: s,
|
|
149
|
+
toTokenAddress: a,
|
|
150
|
+
toChainId: c,
|
|
151
|
+
swapAmount: T,
|
|
152
|
+
tradeType: Z,
|
|
153
|
+
toRecipient: v,
|
|
154
|
+
toCalldata: tt,
|
|
155
|
+
slippageTolerance: J,
|
|
156
|
+
onStatusUpdate: K,
|
|
157
|
+
checkoutOnHandlers: X,
|
|
158
|
+
quoteProvider: F,
|
|
159
|
+
paymasterUrl: M,
|
|
160
|
+
selectedFeeOption: et,
|
|
161
|
+
nodeGatewayEnv: nt,
|
|
162
|
+
abortSignal: ot,
|
|
163
|
+
apiKey: z,
|
|
160
164
|
isSmartWallet: O
|
|
161
165
|
} = {}) {
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
}),
|
|
168
|
-
|
|
169
|
-
}),
|
|
170
|
-
})() :
|
|
171
|
-
apiKey:
|
|
172
|
-
hostname:
|
|
173
|
-
}),
|
|
166
|
+
nt && (globalThis.__testNodeGatewayEnv = nt);
|
|
167
|
+
const H = Ut(new AbortController()), ut = ot ? (() => {
|
|
168
|
+
const f = new AbortController();
|
|
169
|
+
return ot.addEventListener("abort", () => {
|
|
170
|
+
f.abort(), H.current?.abort();
|
|
171
|
+
}), H.current?.signal.addEventListener("abort", () => {
|
|
172
|
+
f.abort();
|
|
173
|
+
}), f.signal;
|
|
174
|
+
})() : H.current.signal, { trailsApiKey: Q, trailsApiUrl: p, sequenceIndexerUrl: st } = Et(), y = Q, P = dt({
|
|
175
|
+
apiKey: Q,
|
|
176
|
+
hostname: p
|
|
177
|
+
}), V = xt(), Y = ht(s ?? void 0), t = ht(c ?? void 0), { supportedTokens: r } = pt(), u = Pt(), k = Rt(), { data: g, isLoading: I, error: U, refetch: D } = wt({
|
|
174
178
|
queryKey: [
|
|
175
179
|
"prepareSend",
|
|
176
|
-
|
|
177
|
-
t,
|
|
178
|
-
o,
|
|
180
|
+
n,
|
|
179
181
|
s,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
a,
|
|
183
|
+
c,
|
|
184
|
+
T?.toString(),
|
|
185
|
+
v,
|
|
186
|
+
tt,
|
|
187
|
+
Z,
|
|
188
|
+
J,
|
|
189
|
+
F,
|
|
190
|
+
z,
|
|
187
191
|
O
|
|
188
192
|
],
|
|
189
193
|
queryFn: async () => {
|
|
190
194
|
try {
|
|
191
|
-
if (
|
|
195
|
+
if (H.current.signal.aborted && (o.console.log(
|
|
192
196
|
"[trails-sdk] Resetting aborted controller for new query"
|
|
193
|
-
),
|
|
197
|
+
), H.current = new AbortController()), !d || !P || !n || !a || !T || !v || !s || !c || !V)
|
|
194
198
|
return null;
|
|
195
|
-
let
|
|
199
|
+
let f = [];
|
|
196
200
|
try {
|
|
197
|
-
|
|
198
|
-
account:
|
|
199
|
-
indexerGatewayClient:
|
|
200
|
-
trailsClient:
|
|
201
|
+
f = (await yt({
|
|
202
|
+
account: d.account.address,
|
|
203
|
+
indexerGatewayClient: V,
|
|
204
|
+
trailsClient: P
|
|
201
205
|
})).balances;
|
|
202
|
-
} catch (
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
+
} catch (i) {
|
|
207
|
+
const m = B(i), x = m.includes("Cross-Origin") || m.includes("CORS") || m.includes("Same Origin Policy"), _ = m.includes("fetch failed") || m.includes("network");
|
|
208
|
+
if (x || _)
|
|
209
|
+
o.console.warn(
|
|
206
210
|
"[trails-sdk] [useQuote] Network or CORS error fetching balances, proceeding with quote using zero balance:",
|
|
207
211
|
{
|
|
208
|
-
error:
|
|
209
|
-
account:
|
|
212
|
+
error: m,
|
|
213
|
+
account: d.account.address
|
|
210
214
|
}
|
|
211
|
-
),
|
|
215
|
+
), f = [];
|
|
212
216
|
else
|
|
213
|
-
throw
|
|
217
|
+
throw i;
|
|
214
218
|
}
|
|
215
|
-
const
|
|
216
|
-
(
|
|
219
|
+
const E = f.find(
|
|
220
|
+
(i) => i.chainId === s && (i.contractAddress?.toLowerCase() === n.toLowerCase() || !i.contractAddress && n === R)
|
|
217
221
|
)?.balance ?? "0";
|
|
218
|
-
let
|
|
222
|
+
let A = 0;
|
|
219
223
|
try {
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
tokenSymbol:
|
|
223
|
-
tokenAddress:
|
|
224
|
-
chainId:
|
|
225
|
-
}))?.priceUsd ?? 0,
|
|
224
|
+
const m = lt(s)?.nativeCurrency?.symbol ?? "";
|
|
225
|
+
m && (A = (await It(P, {
|
|
226
|
+
tokenSymbol: m,
|
|
227
|
+
tokenAddress: R,
|
|
228
|
+
chainId: s
|
|
229
|
+
}))?.priceUsd ?? 0, o.console.log(
|
|
226
230
|
"[trails-sdk] [useQuote] Origin native token price:",
|
|
227
231
|
{
|
|
228
|
-
chainId:
|
|
229
|
-
symbol:
|
|
230
|
-
priceUsd:
|
|
232
|
+
chainId: s,
|
|
233
|
+
symbol: m,
|
|
234
|
+
priceUsd: A
|
|
231
235
|
}
|
|
232
236
|
));
|
|
233
|
-
} catch (
|
|
234
|
-
|
|
237
|
+
} catch (i) {
|
|
238
|
+
o.console.error(
|
|
235
239
|
"[trails-sdk] [useQuote] Error getting origin native token price:",
|
|
236
|
-
|
|
240
|
+
i
|
|
237
241
|
);
|
|
238
242
|
}
|
|
239
|
-
const
|
|
243
|
+
const L = async (i, m) => {
|
|
240
244
|
try {
|
|
241
|
-
const
|
|
242
|
-
if (!
|
|
243
|
-
return
|
|
244
|
-
`[trails-sdk] No RPC client available for chain ${
|
|
245
|
+
const x = m === s ? Y : m === c ? t : null;
|
|
246
|
+
if (!x)
|
|
247
|
+
return o.console.warn(
|
|
248
|
+
`[trails-sdk] No RPC client available for chain ${m}`
|
|
245
249
|
), null;
|
|
246
|
-
if (
|
|
247
|
-
return
|
|
248
|
-
const
|
|
249
|
-
address:
|
|
250
|
-
abi:
|
|
250
|
+
if (i.toLowerCase() === R.toLowerCase())
|
|
251
|
+
return lt(m)?.nativeCurrency.decimals ?? 18;
|
|
252
|
+
const _ = await x.readContract({
|
|
253
|
+
address: i,
|
|
254
|
+
abi: Dt,
|
|
251
255
|
functionName: "decimals"
|
|
252
256
|
});
|
|
253
|
-
return
|
|
254
|
-
`[trails-sdk] Fetched decimals on-chain for token ${
|
|
255
|
-
),
|
|
256
|
-
} catch (
|
|
257
|
-
return
|
|
258
|
-
`[trails-sdk] Error fetching decimals on-chain for token ${
|
|
259
|
-
|
|
257
|
+
return o.console.log(
|
|
258
|
+
`[trails-sdk] Fetched decimals on-chain for token ${i} on chain ${m}: ${_}`
|
|
259
|
+
), _;
|
|
260
|
+
} catch (x) {
|
|
261
|
+
return o.console.error(
|
|
262
|
+
`[trails-sdk] Error fetching decimals on-chain for token ${i} on chain ${m}:`,
|
|
263
|
+
x
|
|
260
264
|
), null;
|
|
261
265
|
}
|
|
262
|
-
},
|
|
263
|
-
(
|
|
264
|
-
),
|
|
265
|
-
(
|
|
266
|
+
}, S = r?.find(
|
|
267
|
+
(i) => i.contractAddress?.toLowerCase() === n?.toLowerCase() && i.chainId === s
|
|
268
|
+
), w = r?.find(
|
|
269
|
+
(i) => i.contractAddress?.toLowerCase() === a?.toLowerCase() && i.chainId === c
|
|
266
270
|
);
|
|
267
|
-
let
|
|
268
|
-
if (!
|
|
269
|
-
|
|
271
|
+
let q = S?.decimals;
|
|
272
|
+
if (!q && n && s) {
|
|
273
|
+
o.console.warn(
|
|
270
274
|
"[trails-sdk] [useQuote] Source token decimals not found in token list, fetching on-chain:",
|
|
271
275
|
{
|
|
272
|
-
originToken:
|
|
273
|
-
fromTokenAddress:
|
|
274
|
-
fromChainId:
|
|
276
|
+
originToken: S,
|
|
277
|
+
fromTokenAddress: n,
|
|
278
|
+
fromChainId: s
|
|
275
279
|
}
|
|
276
280
|
);
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
const i = await L(
|
|
282
|
+
n,
|
|
283
|
+
s
|
|
280
284
|
);
|
|
281
|
-
|
|
285
|
+
i !== null && (q = i);
|
|
282
286
|
}
|
|
283
|
-
if (!
|
|
284
|
-
throw
|
|
287
|
+
if (!q)
|
|
288
|
+
throw o.console.error(
|
|
285
289
|
"[trails-sdk] [useQuote] Source token decimals not found:",
|
|
286
290
|
{
|
|
287
|
-
originToken:
|
|
288
|
-
fromTokenAddress:
|
|
289
|
-
fromChainId:
|
|
291
|
+
originToken: S,
|
|
292
|
+
fromTokenAddress: n,
|
|
293
|
+
fromChainId: s
|
|
290
294
|
}
|
|
291
295
|
), new Error("Source token decimals not found");
|
|
292
|
-
let
|
|
293
|
-
if (!
|
|
294
|
-
|
|
296
|
+
let b = w?.decimals;
|
|
297
|
+
if (!b && a && c) {
|
|
298
|
+
o.console.warn(
|
|
295
299
|
"[trails-sdk] Destination token decimals not found in token list, fetching on-chain:",
|
|
296
300
|
{
|
|
297
|
-
destinationToken:
|
|
298
|
-
toTokenAddress:
|
|
299
|
-
toChainId:
|
|
301
|
+
destinationToken: w,
|
|
302
|
+
toTokenAddress: a,
|
|
303
|
+
toChainId: c
|
|
300
304
|
}
|
|
301
305
|
);
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
306
|
+
const i = await L(
|
|
307
|
+
a,
|
|
308
|
+
c
|
|
305
309
|
);
|
|
306
|
-
|
|
310
|
+
i !== null && (b = i);
|
|
307
311
|
}
|
|
308
|
-
if (!
|
|
309
|
-
throw
|
|
312
|
+
if (!b)
|
|
313
|
+
throw o.console.error(
|
|
310
314
|
"[trails-sdk] Destination token decimals not found:",
|
|
311
315
|
{
|
|
312
|
-
destinationToken:
|
|
313
|
-
toTokenAddress:
|
|
314
|
-
toChainId:
|
|
316
|
+
destinationToken: w,
|
|
317
|
+
toTokenAddress: a,
|
|
318
|
+
toChainId: c
|
|
315
319
|
}
|
|
316
320
|
), new Error("Destination token decimals not found");
|
|
317
|
-
const
|
|
318
|
-
account:
|
|
319
|
-
originTokenAddress:
|
|
320
|
-
originChainId:
|
|
321
|
-
originTokenBalance:
|
|
322
|
-
destinationChainId:
|
|
323
|
-
recipient:
|
|
324
|
-
destinationTokenAddress:
|
|
325
|
-
swapAmount:
|
|
326
|
-
tradeType:
|
|
327
|
-
originTokenSymbol:
|
|
328
|
-
destinationTokenSymbol:
|
|
329
|
-
destinationCalldata:
|
|
330
|
-
client:
|
|
331
|
-
trailsClient:
|
|
332
|
-
sourceTokenDecimals:
|
|
333
|
-
destinationTokenDecimals:
|
|
321
|
+
const rt = w?.symbol ?? "", it = S?.symbol ?? "", W = {
|
|
322
|
+
account: d.account,
|
|
323
|
+
originTokenAddress: n,
|
|
324
|
+
originChainId: s,
|
|
325
|
+
originTokenBalance: E,
|
|
326
|
+
destinationChainId: c,
|
|
327
|
+
recipient: v,
|
|
328
|
+
destinationTokenAddress: a,
|
|
329
|
+
swapAmount: T.toString(),
|
|
330
|
+
tradeType: Z ?? j.EXACT_OUTPUT,
|
|
331
|
+
originTokenSymbol: it,
|
|
332
|
+
destinationTokenSymbol: rt,
|
|
333
|
+
destinationCalldata: tt,
|
|
334
|
+
client: d,
|
|
335
|
+
trailsClient: P,
|
|
336
|
+
sourceTokenDecimals: q,
|
|
337
|
+
destinationTokenDecimals: b,
|
|
334
338
|
fee: "0",
|
|
335
339
|
dryMode: !1,
|
|
336
|
-
onTransactionStateChange:
|
|
340
|
+
onTransactionStateChange: K ?? (() => {
|
|
337
341
|
}),
|
|
338
|
-
slippageTolerance:
|
|
339
|
-
quoteProvider:
|
|
340
|
-
paymasterUrl:
|
|
341
|
-
selectedFeeOption:
|
|
342
|
-
abortSignal:
|
|
343
|
-
originNativeTokenPriceUsd:
|
|
344
|
-
commitIntentFn:
|
|
345
|
-
executeIntentFn:
|
|
346
|
-
checkoutOnHandlers:
|
|
347
|
-
sequenceIndexerUrl:
|
|
348
|
-
sequenceProjectAccessKey:
|
|
349
|
-
originPublicClient:
|
|
350
|
-
destinationPublicClient:
|
|
351
|
-
isSmartWallet: O ?? void 0
|
|
342
|
+
slippageTolerance: J?.toString(),
|
|
343
|
+
quoteProvider: F,
|
|
344
|
+
paymasterUrl: M,
|
|
345
|
+
selectedFeeOption: et ?? null,
|
|
346
|
+
abortSignal: ut,
|
|
347
|
+
originNativeTokenPriceUsd: A,
|
|
348
|
+
commitIntentFn: u.mutateAsync,
|
|
349
|
+
executeIntentFn: k.mutateAsync,
|
|
350
|
+
checkoutOnHandlers: X,
|
|
351
|
+
sequenceIndexerUrl: st,
|
|
352
|
+
sequenceProjectAccessKey: y,
|
|
353
|
+
originPublicClient: Y ?? void 0,
|
|
354
|
+
destinationPublicClient: t ?? void 0,
|
|
355
|
+
isSmartWallet: O ?? void 0,
|
|
356
|
+
trailsApiKey: Q,
|
|
357
|
+
trailsApiUrl: p
|
|
352
358
|
};
|
|
353
|
-
|
|
354
|
-
const { quote:
|
|
359
|
+
o.console.log("[trails-sdk] options", W);
|
|
360
|
+
const { quote: l, send: at } = await St(W);
|
|
355
361
|
return {
|
|
356
362
|
quote: {
|
|
357
|
-
fromAmount:
|
|
358
|
-
toAmount:
|
|
359
|
-
fromAmountMin:
|
|
360
|
-
toAmountMin:
|
|
361
|
-
originToken:
|
|
362
|
-
destinationToken:
|
|
363
|
-
originChain:
|
|
364
|
-
destinationChain:
|
|
365
|
-
fees:
|
|
366
|
-
priceImpact:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
363
|
+
fromAmount: l.originAmount,
|
|
364
|
+
toAmount: l.destinationAmount,
|
|
365
|
+
fromAmountMin: l.originAmountMin,
|
|
366
|
+
toAmountMin: l.destinationAmountMin,
|
|
367
|
+
originToken: l.originToken,
|
|
368
|
+
destinationToken: l.destinationToken,
|
|
369
|
+
originChain: l.originChain,
|
|
370
|
+
destinationChain: l.destinationChain,
|
|
371
|
+
fees: l.fees,
|
|
372
|
+
priceImpact: l.priceImpact,
|
|
373
|
+
priceImpactUsd: l.priceImpactUsd ?? void 0,
|
|
374
|
+
priceImpactUsdDisplay: l.priceImpactUsdDisplay ?? void 0,
|
|
375
|
+
completionEstimateSeconds: l.completionEstimateSeconds,
|
|
376
|
+
slippageTolerance: l.slippageTolerance,
|
|
377
|
+
transactionStates: l.transactionStates,
|
|
378
|
+
originTokenRate: l.originTokenRate,
|
|
379
|
+
destinationTokenRate: l.destinationTokenRate,
|
|
380
|
+
quoteProvider: l.quoteProvider,
|
|
381
|
+
fromAmountUsdDisplay: l.originAmountUsdDisplay ?? void 0,
|
|
382
|
+
toAmountUsdDisplay: l.destinationAmountUsdDisplay ?? void 0,
|
|
383
|
+
gasCostUsd: l.gasCostUsd ?? void 0,
|
|
384
|
+
gasCostUsdDisplay: l.gasCostUsdDisplay ?? void 0,
|
|
385
|
+
gasCost: l.gasCost ?? void 0,
|
|
386
|
+
gasCostFormatted: l.gasCostFormatted ?? void 0,
|
|
387
|
+
totalFeesUsd: l.grandTotalUsd ?? void 0,
|
|
388
|
+
totalFeesUsdDisplay: l.grandTotalUsdDisplay ?? void 0,
|
|
389
|
+
totalGasUsd: l.totalGasUsd ?? void 0,
|
|
390
|
+
totalGasUsdDisplay: l.totalGasUsdDisplay ?? void 0,
|
|
391
|
+
allProviderFeesUsd: l.allProviderFeesUsd ?? void 0,
|
|
392
|
+
allProviderFeesUsdDisplay: l.allProviderFeesUsdDisplay ?? void 0
|
|
379
393
|
},
|
|
380
394
|
swap: async () => {
|
|
381
395
|
const {
|
|
382
|
-
depositUserTxnReceipt:
|
|
383
|
-
destinationIntentTransaction:
|
|
384
|
-
totalCompletionSeconds:
|
|
385
|
-
} = await
|
|
386
|
-
selectedFeeOption:
|
|
396
|
+
depositUserTxnReceipt: i,
|
|
397
|
+
destinationIntentTransaction: m,
|
|
398
|
+
totalCompletionSeconds: x
|
|
399
|
+
} = await at({
|
|
400
|
+
selectedFeeOption: et ?? null
|
|
387
401
|
});
|
|
388
402
|
return {
|
|
389
403
|
originTransaction: {
|
|
390
|
-
transactionHash:
|
|
391
|
-
explorerUrl:
|
|
392
|
-
txHash:
|
|
393
|
-
chainId:
|
|
404
|
+
transactionHash: i?.transactionHash,
|
|
405
|
+
explorerUrl: G({
|
|
406
|
+
txHash: i?.transactionHash,
|
|
407
|
+
chainId: s
|
|
394
408
|
}),
|
|
395
|
-
receipt:
|
|
409
|
+
receipt: i
|
|
396
410
|
},
|
|
397
411
|
destinationTransaction: {
|
|
398
|
-
transactionHash:
|
|
399
|
-
explorerUrl:
|
|
400
|
-
txHash:
|
|
401
|
-
chainId:
|
|
412
|
+
transactionHash: m?.txnHash,
|
|
413
|
+
explorerUrl: G({
|
|
414
|
+
txHash: m?.txnHash,
|
|
415
|
+
chainId: c
|
|
402
416
|
}),
|
|
403
|
-
receipt:
|
|
417
|
+
receipt: m
|
|
404
418
|
},
|
|
405
|
-
totalCompletionSeconds:
|
|
419
|
+
totalCompletionSeconds: x
|
|
406
420
|
};
|
|
407
421
|
}
|
|
408
422
|
};
|
|
409
|
-
} catch (
|
|
410
|
-
throw
|
|
423
|
+
} catch (f) {
|
|
424
|
+
throw o.console.error(
|
|
411
425
|
"[trails-sdk] [useQuote] Error getting quote:",
|
|
412
|
-
|
|
413
|
-
),
|
|
426
|
+
f
|
|
427
|
+
), B(f);
|
|
414
428
|
}
|
|
415
429
|
},
|
|
416
430
|
// Prevent unnecessary refetching
|
|
417
|
-
enabled: !!(
|
|
418
|
-
|
|
431
|
+
enabled: !!(d && P && n && a && T && v && s && c && V && // !isLoadingTokens &&
|
|
432
|
+
r && r.length > 0),
|
|
419
433
|
staleTime: 30 * 1e3,
|
|
420
434
|
// Consider data fresh for 30 seconds
|
|
421
435
|
refetchOnWindowFocus: !1,
|
|
@@ -430,74 +444,529 @@ function Pe({
|
|
|
430
444
|
// Refetch when network reconnects
|
|
431
445
|
});
|
|
432
446
|
return {
|
|
433
|
-
quote:
|
|
434
|
-
swap:
|
|
435
|
-
isLoadingQuote:
|
|
436
|
-
quoteError:
|
|
437
|
-
quoteErrorPrettified:
|
|
438
|
-
refetchQuote: () =>
|
|
447
|
+
quote: g?.quote || null,
|
|
448
|
+
swap: g?.swap || null,
|
|
449
|
+
isLoadingQuote: I,
|
|
450
|
+
quoteError: U,
|
|
451
|
+
quoteErrorPrettified: Nt(U),
|
|
452
|
+
refetchQuote: () => D(),
|
|
439
453
|
abort: () => {
|
|
440
|
-
|
|
454
|
+
o.console.log("[trails-sdk] useQuote abort() called"), o.console.log(
|
|
441
455
|
"[trails-sdk] Active operations before abort:",
|
|
442
|
-
|
|
443
|
-
),
|
|
456
|
+
ft.getAll()
|
|
457
|
+
), H.current.abort(), ft.abortAll(), o.console.log(
|
|
444
458
|
"[trails-sdk] Abort completed, active operations:",
|
|
445
|
-
|
|
459
|
+
ft.getAll()
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
function Yt(d) {
|
|
465
|
+
const { data: n } = Ft(), { chainId: s } = Mt(), a = Qt(), c = dt(), { trailsApiKey: T, sequenceIndexerUrl: Z } = Et(), {
|
|
466
|
+
openModal: v,
|
|
467
|
+
setPendingSelection: tt,
|
|
468
|
+
setHostTransactionState: J,
|
|
469
|
+
setHostTransactionQuote: K,
|
|
470
|
+
setHostTransactionStates: X,
|
|
471
|
+
setHostTransactionTimestamp: F,
|
|
472
|
+
hostTransactionState: M,
|
|
473
|
+
setReceiptActionButtonText: et,
|
|
474
|
+
setOnReceiptAction: nt,
|
|
475
|
+
retryTransactionRef: ot
|
|
476
|
+
} = Bt(), z = xt(), { supportedTokens: O } = pt(), H = Pt(), ut = Rt(), Q = Ut(null), p = ct(
|
|
477
|
+
(t) => {
|
|
478
|
+
J((r) => ({
|
|
479
|
+
status: t.status ?? r.status,
|
|
480
|
+
details: t.details === null ? void 0 : t.details ? { ...r.details, ...t.details } : r.details,
|
|
481
|
+
error: t.error === null ? void 0 : t.error !== void 0 ? t.error : r.error,
|
|
482
|
+
result: t.result === null ? void 0 : t.result ? { ...r.result, ...t.result } : r.result,
|
|
483
|
+
retryEnabled: t.retryEnabled !== void 0 ? t.retryEnabled : r.retryEnabled
|
|
484
|
+
}));
|
|
485
|
+
},
|
|
486
|
+
[J]
|
|
487
|
+
), st = async (t, r, u) => {
|
|
488
|
+
if (o.console.log(
|
|
489
|
+
"[trails-sdk] [useTrailsSendTransaction] Executing transaction",
|
|
490
|
+
{ variables: t, originSelection: r }
|
|
491
|
+
), !n || !n.account)
|
|
492
|
+
throw new Error(
|
|
493
|
+
"Wallet client not available. Please connect your wallet."
|
|
494
|
+
);
|
|
495
|
+
if (!t.to)
|
|
496
|
+
throw new Error("Transaction 'to' address is required.");
|
|
497
|
+
let k, g, I;
|
|
498
|
+
if (r)
|
|
499
|
+
k = r.fromTokenAddress, g = r.fromChainId, I = r.fromAmount;
|
|
500
|
+
else if (t.fromTokenAddress && t.fromChainId && t.fromAmount)
|
|
501
|
+
k = t.fromTokenAddress, g = t.fromChainId, I = t.fromAmount;
|
|
502
|
+
else if (t.to && t.value !== void 0) {
|
|
503
|
+
const e = s || a;
|
|
504
|
+
if (!e)
|
|
505
|
+
throw new Error("Chain ID not available. Please connect your wallet.");
|
|
506
|
+
g = e, k = R, I = t.value.toString();
|
|
507
|
+
} else
|
|
508
|
+
throw new Error(
|
|
509
|
+
"Origin token parameters are required. Please provide 'value' (native token), or 'fromTokenAddress'/'fromChainId'/'fromAmount' (ERC20 token), or select via modal."
|
|
510
|
+
);
|
|
511
|
+
const U = s || a;
|
|
512
|
+
if (!U)
|
|
513
|
+
throw new Error("Chain ID not available. Please connect your wallet.");
|
|
514
|
+
let D, f, C, E;
|
|
515
|
+
if (t.tokenAddress && t.tokenAmount)
|
|
516
|
+
D = t.tokenAddress, f = O?.find(
|
|
517
|
+
(h) => h.contractAddress?.toLowerCase() === t.tokenAddress?.toLowerCase()
|
|
518
|
+
)?.chainId ?? U, C = t.tokenAmount, E = t.to;
|
|
519
|
+
else if (t.to && t.value !== void 0)
|
|
520
|
+
D = R, f = U, C = t.value.toString(), E = t.to;
|
|
521
|
+
else
|
|
522
|
+
throw new Error(
|
|
523
|
+
"Either 'value' or 'tokenAddress'/'tokenAmount' must be provided."
|
|
524
|
+
);
|
|
525
|
+
const A = t.tokenAddress && t.tokenAmount ? j.EXACT_OUTPUT : j.EXACT_INPUT;
|
|
526
|
+
if (A === j.EXACT_INPUT && !I)
|
|
527
|
+
throw new Error(
|
|
528
|
+
"Origin amount is required for this transaction. Please provide 'value' or 'fromAmount'."
|
|
529
|
+
);
|
|
530
|
+
const L = A === j.EXACT_OUTPUT ? C : I;
|
|
531
|
+
let S = [];
|
|
532
|
+
try {
|
|
533
|
+
S = (await yt({
|
|
534
|
+
account: n.account.address,
|
|
535
|
+
indexerGatewayClient: z,
|
|
536
|
+
trailsClient: c
|
|
537
|
+
})).balances;
|
|
538
|
+
} catch (e) {
|
|
539
|
+
o.console.warn(
|
|
540
|
+
"[trails-sdk] [useTrailsSendTransaction] Error fetching balances, proceeding with zero balance",
|
|
541
|
+
e
|
|
542
|
+
), S = [];
|
|
543
|
+
}
|
|
544
|
+
const q = S.find(
|
|
545
|
+
(e) => e.chainId === g && (e.contractAddress?.toLowerCase() === k?.toLowerCase() || !e.contractAddress && k === R)
|
|
546
|
+
)?.balance ?? "0";
|
|
547
|
+
let b = 0;
|
|
548
|
+
try {
|
|
549
|
+
const h = lt(g)?.nativeCurrency?.symbol ?? "";
|
|
550
|
+
h && (b = (await It(c, {
|
|
551
|
+
tokenSymbol: h,
|
|
552
|
+
tokenAddress: R,
|
|
553
|
+
chainId: g
|
|
554
|
+
}))?.priceUsd ?? 0);
|
|
555
|
+
} catch (e) {
|
|
556
|
+
o.console.warn(
|
|
557
|
+
"[trails-sdk] [useTrailsSendTransaction] Error getting native token price",
|
|
558
|
+
e
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
const rt = O?.find(
|
|
562
|
+
(e) => e.contractAddress?.toLowerCase() === k?.toLowerCase() && e.chainId === g
|
|
563
|
+
), it = O?.find(
|
|
564
|
+
(e) => e.contractAddress?.toLowerCase() === D?.toLowerCase() && e.chainId === f
|
|
565
|
+
), { getChainRpcClient: W } = await import("./index-BbajxCG_.js").then((e) => e.aJ), l = W(g), at = W(f), gt = async (e, h) => {
|
|
566
|
+
try {
|
|
567
|
+
const N = h === g ? l : h === f ? at : W(h);
|
|
568
|
+
return N ? e.toLowerCase() === R.toLowerCase() ? lt(h)?.nativeCurrency.decimals ?? 18 : await N.readContract({
|
|
569
|
+
address: e,
|
|
570
|
+
abi: Dt,
|
|
571
|
+
functionName: "decimals"
|
|
572
|
+
}) : null;
|
|
573
|
+
} catch (N) {
|
|
574
|
+
return o.console.error(
|
|
575
|
+
`[trails-sdk] Error fetching decimals on-chain for token ${e} on chain ${h}:`,
|
|
576
|
+
N
|
|
577
|
+
), null;
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
let $ = rt?.decimals;
|
|
581
|
+
if (!$ && k) {
|
|
582
|
+
const e = await gt(
|
|
583
|
+
k,
|
|
584
|
+
g
|
|
585
|
+
);
|
|
586
|
+
e !== null && ($ = e);
|
|
587
|
+
}
|
|
588
|
+
$ || ($ = 18);
|
|
589
|
+
let i = it?.decimals;
|
|
590
|
+
if (!i && D) {
|
|
591
|
+
const e = await gt(
|
|
592
|
+
D,
|
|
593
|
+
f
|
|
446
594
|
);
|
|
595
|
+
e !== null && (i = e);
|
|
447
596
|
}
|
|
597
|
+
i || (i = 18);
|
|
598
|
+
const m = it?.symbol ?? "", x = rt?.symbol ?? "", _ = (e) => {
|
|
599
|
+
u?.trackInWidget && X(e), d?.onStatusUpdate?.(e);
|
|
600
|
+
}, { send: kt, quote: Ot } = await St({
|
|
601
|
+
account: n.account,
|
|
602
|
+
originTokenAddress: k,
|
|
603
|
+
originChainId: g,
|
|
604
|
+
originTokenBalance: q,
|
|
605
|
+
destinationChainId: f,
|
|
606
|
+
recipient: E,
|
|
607
|
+
destinationTokenAddress: D,
|
|
608
|
+
swapAmount: L,
|
|
609
|
+
tradeType: A,
|
|
610
|
+
originTokenSymbol: x,
|
|
611
|
+
destinationTokenSymbol: m,
|
|
612
|
+
fee: "0",
|
|
613
|
+
client: n,
|
|
614
|
+
dryMode: !1,
|
|
615
|
+
trailsClient: c,
|
|
616
|
+
destinationCalldata: t.data ? t.data.toString() : void 0,
|
|
617
|
+
onTransactionStateChange: _,
|
|
618
|
+
sourceTokenDecimals: $,
|
|
619
|
+
destinationTokenDecimals: i,
|
|
620
|
+
paymasterUrl: d?.paymasterUrl,
|
|
621
|
+
slippageTolerance: d?.slippageTolerance?.toString(),
|
|
622
|
+
originNativeTokenPriceUsd: b,
|
|
623
|
+
quoteProvider: d?.quoteProvider,
|
|
624
|
+
commitIntentFn: H.mutateAsync,
|
|
625
|
+
executeIntentFn: ut.mutateAsync,
|
|
626
|
+
checkoutOnHandlers: d?.checkoutOnHandlers,
|
|
627
|
+
sequenceIndexerUrl: Z,
|
|
628
|
+
sequenceProjectAccessKey: T,
|
|
629
|
+
originPublicClient: l ?? void 0,
|
|
630
|
+
destinationPublicClient: at ?? void 0,
|
|
631
|
+
isSmartWallet: d?.isSmartWallet ?? void 0
|
|
632
|
+
});
|
|
633
|
+
u?.trackInWidget && (K(Ot ?? null), M.details || p({
|
|
634
|
+
details: {
|
|
635
|
+
to: E,
|
|
636
|
+
tokenAddress: D,
|
|
637
|
+
tokenAmount: A === j.EXACT_OUTPUT ? C : void 0,
|
|
638
|
+
toChainId: f,
|
|
639
|
+
data: t.data
|
|
640
|
+
}
|
|
641
|
+
}), (!M.status || M.status === "idle") && F(Date.now()));
|
|
642
|
+
try {
|
|
643
|
+
u?.trackInWidget && p({ retryEnabled: !1 });
|
|
644
|
+
const {
|
|
645
|
+
depositUserTxnReceipt: e,
|
|
646
|
+
destinationIntentTransaction: h,
|
|
647
|
+
totalCompletionSeconds: N
|
|
648
|
+
} = await kt({
|
|
649
|
+
selectedFeeOption: null,
|
|
650
|
+
// Transition to "pending" when wallet signature is complete
|
|
651
|
+
onOriginSend: () => {
|
|
652
|
+
u?.trackInWidget && p({ status: "pending", error: null });
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
return u?.trackInWidget && p({
|
|
656
|
+
status: "success",
|
|
657
|
+
result: {
|
|
658
|
+
originTxHash: e?.transactionHash,
|
|
659
|
+
originExplorerUrl: e?.transactionHash ? G({
|
|
660
|
+
txHash: e.transactionHash,
|
|
661
|
+
chainId: g
|
|
662
|
+
}) : void 0,
|
|
663
|
+
destinationTxHash: h?.txnHash,
|
|
664
|
+
destinationExplorerUrl: h?.txnHash ? G({
|
|
665
|
+
txHash: h.txnHash,
|
|
666
|
+
chainId: f
|
|
667
|
+
}) : void 0
|
|
668
|
+
}
|
|
669
|
+
}), {
|
|
670
|
+
originTransaction: {
|
|
671
|
+
transactionHash: e?.transactionHash,
|
|
672
|
+
explorerUrl: G({
|
|
673
|
+
txHash: e?.transactionHash,
|
|
674
|
+
chainId: g
|
|
675
|
+
}),
|
|
676
|
+
receipt: e
|
|
677
|
+
},
|
|
678
|
+
destinationTransaction: {
|
|
679
|
+
transactionHash: h?.txnHash,
|
|
680
|
+
explorerUrl: G({
|
|
681
|
+
txHash: h?.txnHash,
|
|
682
|
+
chainId: f
|
|
683
|
+
}),
|
|
684
|
+
receipt: h
|
|
685
|
+
},
|
|
686
|
+
totalCompletionSeconds: N
|
|
687
|
+
};
|
|
688
|
+
} catch (e) {
|
|
689
|
+
if (u?.trackInWidget) {
|
|
690
|
+
const h = mt(e);
|
|
691
|
+
p(h ? {
|
|
692
|
+
status: "confirmation",
|
|
693
|
+
error: null,
|
|
694
|
+
retryEnabled: !0
|
|
695
|
+
} : {
|
|
696
|
+
status: "error",
|
|
697
|
+
error: B(e),
|
|
698
|
+
retryEnabled: !1
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
throw e;
|
|
702
|
+
}
|
|
703
|
+
}, y = Tt({
|
|
704
|
+
mutationFn: async (t) => {
|
|
705
|
+
o.console.log(
|
|
706
|
+
"[trails-sdk] [useTrailsSendTransaction] Starting transaction",
|
|
707
|
+
t
|
|
708
|
+
), et(
|
|
709
|
+
d?.receiptActionButtonText ?? "Transact Again"
|
|
710
|
+
), nt(d?.onReceiptAction ?? null);
|
|
711
|
+
const r = t.value !== void 0, u = t.fromTokenAddress !== void 0 && t.fromChainId !== void 0, k = r || u;
|
|
712
|
+
let g;
|
|
713
|
+
if (t.tokenAddress && O) {
|
|
714
|
+
const C = O.find(
|
|
715
|
+
(E) => E.contractAddress?.toLowerCase() === t.tokenAddress?.toLowerCase()
|
|
716
|
+
);
|
|
717
|
+
C && (g = C.chainId);
|
|
718
|
+
}
|
|
719
|
+
g || (g = s || a);
|
|
720
|
+
let I = !0, U = !0;
|
|
721
|
+
if (n?.account)
|
|
722
|
+
try {
|
|
723
|
+
if (k) {
|
|
724
|
+
let C, E, A;
|
|
725
|
+
t.value !== void 0 ? (C = R, E = s || a || 1, A = t.value.toString()) : t.fromTokenAddress && t.fromChainId && (C = t.fromTokenAddress, E = t.fromChainId, A = t.fromAmount), C && E && A && A !== "0" && (I = await Ct({
|
|
726
|
+
account: n.account.address,
|
|
727
|
+
token: C,
|
|
728
|
+
amount: A,
|
|
729
|
+
chainId: E,
|
|
730
|
+
indexerGatewayClient: z,
|
|
731
|
+
trailsClient: c
|
|
732
|
+
}), o.console.log(
|
|
733
|
+
"[trails-sdk] [useTrailsSendTransaction] Origin token balance check:",
|
|
734
|
+
{
|
|
735
|
+
tokenAddress: C,
|
|
736
|
+
amount: A,
|
|
737
|
+
chainId: E,
|
|
738
|
+
hasSufficientBalance: I
|
|
739
|
+
}
|
|
740
|
+
));
|
|
741
|
+
}
|
|
742
|
+
I && t.tokenAddress && t.tokenAmount && (U = await Ct({
|
|
743
|
+
account: n.account.address,
|
|
744
|
+
token: t.tokenAddress,
|
|
745
|
+
amount: t.tokenAmount,
|
|
746
|
+
chainId: g,
|
|
747
|
+
indexerGatewayClient: z,
|
|
748
|
+
trailsClient: c
|
|
749
|
+
}), o.console.log(
|
|
750
|
+
"[trails-sdk] [useTrailsSendTransaction] Destination token balance check:",
|
|
751
|
+
{
|
|
752
|
+
tokenAddress: t.tokenAddress,
|
|
753
|
+
tokenAmount: t.tokenAmount,
|
|
754
|
+
chainId: g,
|
|
755
|
+
hasSufficientBalance: U
|
|
756
|
+
}
|
|
757
|
+
));
|
|
758
|
+
} catch (C) {
|
|
759
|
+
o.console.warn(
|
|
760
|
+
"[trails-sdk] [useTrailsSendTransaction] Error checking balances, defaulting to origin selection:",
|
|
761
|
+
C
|
|
762
|
+
), I = !1, U = !1;
|
|
763
|
+
}
|
|
764
|
+
const D = !k || !I || !U;
|
|
765
|
+
if (o.console.log(
|
|
766
|
+
"[trails-sdk] [useTrailsSendTransaction] Origin selection decision:",
|
|
767
|
+
{
|
|
768
|
+
hasOriginParams: k,
|
|
769
|
+
hasSufficientOriginBalance: I,
|
|
770
|
+
hasSufficientDestinationTokenBalance: U,
|
|
771
|
+
needsOriginSelection: D
|
|
772
|
+
}
|
|
773
|
+
), D) {
|
|
774
|
+
const C = !(t.tokenAddress && t.tokenAmount), E = {
|
|
775
|
+
to: t.to,
|
|
776
|
+
tokenAddress: t.tokenAddress,
|
|
777
|
+
tokenAmount: t.tokenAmount,
|
|
778
|
+
toChainId: g,
|
|
779
|
+
data: t.data
|
|
780
|
+
};
|
|
781
|
+
return p({
|
|
782
|
+
status: "awaiting-origin",
|
|
783
|
+
details: E,
|
|
784
|
+
error: null,
|
|
785
|
+
result: null
|
|
786
|
+
}), K(null), X([]), F(Date.now()), new Promise((A, L) => {
|
|
787
|
+
tt({
|
|
788
|
+
resolve: async (S) => {
|
|
789
|
+
try {
|
|
790
|
+
p({ status: "confirmation" });
|
|
791
|
+
const w = await st(t, S, {
|
|
792
|
+
trackInWidget: !0
|
|
793
|
+
});
|
|
794
|
+
A(w);
|
|
795
|
+
} catch (w) {
|
|
796
|
+
mt(w) || p({
|
|
797
|
+
status: "error",
|
|
798
|
+
error: B(w)
|
|
799
|
+
}), L(w);
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
reject: (S) => {
|
|
803
|
+
const w = S instanceof Error ? S : new Error(String(S));
|
|
804
|
+
p({
|
|
805
|
+
status: "error",
|
|
806
|
+
error: B(w)
|
|
807
|
+
}), L(w);
|
|
808
|
+
},
|
|
809
|
+
requireAmountInput: C
|
|
810
|
+
}), setTimeout(() => {
|
|
811
|
+
o.console.log(
|
|
812
|
+
"[trails-sdk] [useTrailsSendTransaction] Calling openModal()"
|
|
813
|
+
), v();
|
|
814
|
+
}, 0);
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
const f = {
|
|
818
|
+
to: t.to,
|
|
819
|
+
tokenAddress: t.tokenAddress,
|
|
820
|
+
tokenAmount: t.tokenAmount,
|
|
821
|
+
toChainId: g,
|
|
822
|
+
data: t.data
|
|
823
|
+
};
|
|
824
|
+
return p({
|
|
825
|
+
status: "confirmation",
|
|
826
|
+
details: f,
|
|
827
|
+
error: null,
|
|
828
|
+
result: null
|
|
829
|
+
}), K(null), X([]), F(Date.now()), v(), st(t, void 0, { trackInWidget: !0 });
|
|
830
|
+
},
|
|
831
|
+
onSuccess: (t, r) => {
|
|
832
|
+
o.console.log(
|
|
833
|
+
"[trails-sdk] [useTrailsSendTransaction] Transaction successful",
|
|
834
|
+
{ data: t, variables: r }
|
|
835
|
+
), d?.onSuccess?.(t, r);
|
|
836
|
+
},
|
|
837
|
+
onError: (t, r) => {
|
|
838
|
+
o.console.error(
|
|
839
|
+
"[trails-sdk] [useTrailsSendTransaction] Transaction error",
|
|
840
|
+
{ error: t, variables: r }
|
|
841
|
+
);
|
|
842
|
+
const u = B(t), k = mt(t);
|
|
843
|
+
M.status !== "idle" && !k && p({
|
|
844
|
+
status: "error",
|
|
845
|
+
error: u
|
|
846
|
+
}), d?.onError?.(new Error(u), r);
|
|
847
|
+
},
|
|
848
|
+
onSettled: (t, r, u) => {
|
|
849
|
+
o.console.log(
|
|
850
|
+
"[trails-sdk] [useTrailsSendTransaction] Transaction settled",
|
|
851
|
+
{ data: t, error: r, variables: u }
|
|
852
|
+
), d?.onSettled?.(t, r, u);
|
|
853
|
+
}
|
|
854
|
+
}), P = ct(
|
|
855
|
+
(t, r) => {
|
|
856
|
+
y.mutate(t, {
|
|
857
|
+
onSuccess: (u) => {
|
|
858
|
+
r?.onSuccess?.(u);
|
|
859
|
+
},
|
|
860
|
+
onError: (u) => {
|
|
861
|
+
r?.onError?.(u);
|
|
862
|
+
},
|
|
863
|
+
onSettled: (u, k) => {
|
|
864
|
+
r?.onSettled?.(u, k);
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
},
|
|
868
|
+
[y]
|
|
869
|
+
), V = ct(
|
|
870
|
+
async (t, r) => y.mutateAsync(t, {
|
|
871
|
+
onSuccess: (u) => {
|
|
872
|
+
r?.onSuccess?.(u);
|
|
873
|
+
},
|
|
874
|
+
onError: (u) => {
|
|
875
|
+
r?.onError?.(u);
|
|
876
|
+
},
|
|
877
|
+
onSettled: (u, k) => {
|
|
878
|
+
r?.onSettled?.(u, k);
|
|
879
|
+
}
|
|
880
|
+
}),
|
|
881
|
+
[y]
|
|
882
|
+
), Y = ct(() => {
|
|
883
|
+
Q.current && P(Q.current);
|
|
884
|
+
}, [P]);
|
|
885
|
+
return ot.current = Y, {
|
|
886
|
+
sendTransaction: P,
|
|
887
|
+
sendTransactionAsync: V,
|
|
888
|
+
retry: Y,
|
|
889
|
+
data: y.data,
|
|
890
|
+
error: y.error,
|
|
891
|
+
isPending: y.isPending,
|
|
892
|
+
isSuccess: y.isSuccess,
|
|
893
|
+
isError: y.isError,
|
|
894
|
+
isIdle: y.isIdle,
|
|
895
|
+
status: y.status,
|
|
896
|
+
reset: y.reset,
|
|
897
|
+
variables: y.variables
|
|
448
898
|
};
|
|
449
899
|
}
|
|
450
900
|
export {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
St as
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
901
|
+
ee as InsufficientBalanceError,
|
|
902
|
+
ne as TRAILS_ROUTER_PLACEHOLDER_AMOUNT,
|
|
903
|
+
j as TradeType,
|
|
904
|
+
oe as TrailsClient,
|
|
905
|
+
se as TrailsHookModal,
|
|
906
|
+
re as TrailsModalProvider,
|
|
907
|
+
ie as TrailsProvider,
|
|
908
|
+
ae as TrailsWidget,
|
|
909
|
+
ce as UserRejectionError,
|
|
910
|
+
le as calculateIntentAddress,
|
|
911
|
+
de as calculateOriginAndDestinationIntentAddresses,
|
|
912
|
+
ue as commitIntent,
|
|
913
|
+
ge as convertApiTokenInfoToToken,
|
|
914
|
+
fe as createModalController,
|
|
915
|
+
me as formatBalanceFields,
|
|
916
|
+
Te as formatPriceFields,
|
|
917
|
+
ke as formatUsdAmountFormatted,
|
|
918
|
+
he as formatUsdFields,
|
|
919
|
+
Ce as getAccountTotalBalanceUsd,
|
|
920
|
+
Ae as getAccountTransactionHistory,
|
|
921
|
+
Ee as getAllChains,
|
|
922
|
+
lt as getChainInfo,
|
|
923
|
+
pe as getChainRpcClient,
|
|
924
|
+
ye as getERC20TransferData,
|
|
925
|
+
Ct as getHasSufficientBalanceToken,
|
|
926
|
+
Ie as getHasSufficientBalanceUsd,
|
|
927
|
+
Se as getIsApiError,
|
|
928
|
+
we as getIsBalanceTooLowError,
|
|
929
|
+
Ue as getIsInsufficientLiquidityError,
|
|
930
|
+
De as getIsNoAvailableQuoteError,
|
|
931
|
+
xe as getIsQuoteFailedError,
|
|
932
|
+
Pe as getIsQuoteInputError,
|
|
933
|
+
Re as getIsQuoteTokenError,
|
|
934
|
+
Oe as getIsRateLimitedError,
|
|
935
|
+
He as getIsRequiredAmountNotMetError,
|
|
936
|
+
mt as getIsUserRejectionError,
|
|
937
|
+
ve as getIsWalletAlreadyConnectedError,
|
|
938
|
+
Le as getMinLogLevel,
|
|
939
|
+
Nt as getPrettifiedErrorMessage,
|
|
940
|
+
qe as getRpcUrl,
|
|
941
|
+
be as getSupportedChains,
|
|
942
|
+
Ne as getSupportedTokens,
|
|
943
|
+
Be as getTrailsClient,
|
|
944
|
+
Fe as getTxTimeDiff,
|
|
945
|
+
o as logger,
|
|
946
|
+
Me as pollIntentReceipt,
|
|
947
|
+
St as prepareSend,
|
|
948
|
+
Qe as quoteIntent,
|
|
949
|
+
We as sendOriginTransaction,
|
|
950
|
+
$e as useAccountTotalBalanceUsd,
|
|
951
|
+
_e as useAccountTransactionHistory,
|
|
952
|
+
ht as useChainRpcClient,
|
|
953
|
+
Pt as useCommitIntent,
|
|
954
|
+
Rt as useExecuteIntent,
|
|
955
|
+
je as useGetTokenImageUrl,
|
|
956
|
+
Ge as useHasSufficientBalanceToken,
|
|
957
|
+
Je as useHasSufficientBalanceUsd,
|
|
958
|
+
en as useIndexerGatewayClient,
|
|
959
|
+
zt as useIntentReceiptMonitor,
|
|
960
|
+
Ke as useIntentTransactionHistory,
|
|
961
|
+
Vt as useQuote,
|
|
962
|
+
Xe as useSupportedChains,
|
|
963
|
+
pt as useSupportedTokens,
|
|
964
|
+
ze as useTokenAddress,
|
|
965
|
+
Ve as useTokenBalances,
|
|
966
|
+
Ye as useTokenInfo,
|
|
967
|
+
Ze as useTokenList,
|
|
968
|
+
Et as useTrails,
|
|
969
|
+
dt as useTrailsClient,
|
|
970
|
+
Bt as useTrailsModal,
|
|
971
|
+
Yt as useTrailsSendTransaction
|
|
503
972
|
};
|