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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Account, Chain, WalletClient, TransactionReceipt } from "viem"
|
|
2
2
|
import { formatUnits } from "viem"
|
|
3
3
|
import { getChainRpcClient } from "../../chains.js"
|
|
4
|
-
import type { FeeOption, TrailsApi } from "@
|
|
4
|
+
import type { FeeOption, TrailsApi } from "@0xtrails/api"
|
|
5
5
|
import type { PrepareSendReturn, SendReturn } from "../types.js"
|
|
6
|
-
import type { IntentTransaction } from "@
|
|
6
|
+
import type { IntentTransaction } from "@0xtrails/api"
|
|
7
7
|
import type { TransactionState } from "../../transactions.js"
|
|
8
8
|
import type { CheckoutOnHandlers } from "../../widget/hooks/useCheckout.js"
|
|
9
9
|
import type {
|
|
@@ -11,12 +11,9 @@ import type {
|
|
|
11
11
|
CommitIntentResponse,
|
|
12
12
|
DepositSignature,
|
|
13
13
|
ExecuteIntentResponse,
|
|
14
|
-
} from "@
|
|
14
|
+
} from "@0xtrails/api"
|
|
15
15
|
import { logger } from "../../logger.js"
|
|
16
|
-
import {
|
|
17
|
-
isTestnetDebugMode,
|
|
18
|
-
getTestnetOriginTokenAddress,
|
|
19
|
-
} from "../utils/testnetHelpers.js"
|
|
16
|
+
import { isTestnetDebugMode } from "../utils/testnetHelpers.js"
|
|
20
17
|
import { checkAccountBalance } from "../utils/balanceChecker.js"
|
|
21
18
|
import { getTestnetChainInfo } from "../../chains.js"
|
|
22
19
|
import { getIsCustomCalldata } from "../../contractUtils.js"
|
|
@@ -78,6 +75,8 @@ export async function handleSameChainSameToken({
|
|
|
78
75
|
sequenceProjectAccessKey,
|
|
79
76
|
sequenceIndexerUrl,
|
|
80
77
|
isSmartWallet,
|
|
78
|
+
trailsApiKey,
|
|
79
|
+
trailsApiUrl,
|
|
81
80
|
}: {
|
|
82
81
|
mainSignerAddress: string
|
|
83
82
|
originTokenAddress: string
|
|
@@ -100,7 +99,7 @@ export async function handleSameChainSameToken({
|
|
|
100
99
|
slippageTolerance: string
|
|
101
100
|
quoteProvider?: string | null
|
|
102
101
|
checkoutOnHandlers?: Partial<CheckoutOnHandlers>
|
|
103
|
-
mode?: "pay" | "fund" | "earn" | "swap"
|
|
102
|
+
mode?: "pay" | "fund" | "earn" | "swap"
|
|
104
103
|
fundMethod?: string
|
|
105
104
|
paymasterUrl?: string
|
|
106
105
|
walletId?: string
|
|
@@ -115,27 +114,29 @@ export async function handleSameChainSameToken({
|
|
|
115
114
|
sequenceProjectAccessKey?: string
|
|
116
115
|
sequenceIndexerUrl?: string
|
|
117
116
|
isSmartWallet?: boolean
|
|
117
|
+
trailsApiKey?: string
|
|
118
|
+
trailsApiUrl?: string
|
|
118
119
|
}): Promise<PrepareSendReturn> {
|
|
119
120
|
logger.console.log("[trails-sdk] isToSameToken && isToSameChain")
|
|
120
121
|
const testnet = isTestnetDebugMode()
|
|
121
122
|
const effectiveOriginChain = testnet ? getTestnetChainInfo(chain)! : chain
|
|
122
123
|
const effectiveOriginChainId = effectiveOriginChain.id
|
|
123
|
-
const effectiveOriginTokenAddress =
|
|
124
|
-
? getTestnetOriginTokenAddress(effectiveOriginChainId)
|
|
125
|
-
: originTokenAddress
|
|
124
|
+
const effectiveOriginTokenAddress = originTokenAddress
|
|
126
125
|
const effectivePublicClient = getChainRpcClient(effectiveOriginChain.id)
|
|
127
126
|
|
|
128
127
|
let noSufficientBalance = false
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
if (!(fundMethod === "qr-code" || fundMethod === "exchange")) {
|
|
130
|
+
const { hasEnoughBalance } = await checkAccountBalance({
|
|
131
|
+
account,
|
|
132
|
+
tokenAddress: originTokenAddress,
|
|
133
|
+
depositAmount: swapAmount,
|
|
134
|
+
publicClient: effectivePublicClient,
|
|
135
|
+
})
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
if (!hasEnoughBalance) {
|
|
138
|
+
noSufficientBalance = true
|
|
139
|
+
}
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
const hasCustomCalldata = getIsCustomCalldata(destinationCalldata)
|
|
@@ -203,6 +204,8 @@ export async function handleSameChainSameToken({
|
|
|
203
204
|
quoteProvider: quoteProvider || "direct",
|
|
204
205
|
noSufficientBalance,
|
|
205
206
|
estimatedGasLimit: estimatedGasLimitForQuote,
|
|
207
|
+
trailsApiKey: trailsApiKey || "",
|
|
208
|
+
trailsApiUrl: trailsApiUrl || "",
|
|
206
209
|
// No intent for direct transfers
|
|
207
210
|
})
|
|
208
211
|
|
|
@@ -372,8 +375,20 @@ export async function handleSameChainSameToken({
|
|
|
372
375
|
mode,
|
|
373
376
|
fundMethod,
|
|
374
377
|
originTokenAddress: effectiveOriginTokenAddress,
|
|
378
|
+
originTokenSymbol,
|
|
379
|
+
originTokenAmount: swapAmount,
|
|
380
|
+
originTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
381
|
+
destinationTokenAddress: effectiveOriginTokenAddress, // same chain same token
|
|
382
|
+
destinationTokenSymbol: destinationTokenSymbol,
|
|
383
|
+
depositTokenAmount: swapAmount,
|
|
384
|
+
depositTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
375
385
|
depositTokenAmountUsd: depositAmountUsd?.toString(),
|
|
386
|
+
destinationTokenAmount: swapAmount, // same as deposit amount
|
|
387
|
+
destinationTokenAmountFormatted:
|
|
388
|
+
depositAmountFormatted.toString(), // same as deposit amount
|
|
376
389
|
destinationTokenAmountUsd: depositAmountUsd?.toString(), // same as deposit amount
|
|
390
|
+
originTokenDecimals: originTokenDecimals,
|
|
391
|
+
destinationTokenDecimals: originTokenDecimals, // same chain same token
|
|
377
392
|
})
|
|
378
393
|
|
|
379
394
|
// Call onCheckoutComplete callback if provided
|
|
@@ -461,7 +476,7 @@ export async function handleSameChainSameToken({
|
|
|
461
476
|
intentArgs,
|
|
462
477
|
)
|
|
463
478
|
|
|
464
|
-
const { intent, gasFeeOptions } = await quoteIntent(
|
|
479
|
+
const { intent, gasFeeOptions, trailsContracts } = await quoteIntent(
|
|
465
480
|
trailsClient,
|
|
466
481
|
intentArgs,
|
|
467
482
|
{
|
|
@@ -473,6 +488,10 @@ export async function handleSameChainSameToken({
|
|
|
473
488
|
|
|
474
489
|
logger.console.log("[trails-sdk] Quote intent:", intent)
|
|
475
490
|
logger.console.log("[trails-sdk] Quote intent gasFeeOptions:", gasFeeOptions)
|
|
491
|
+
logger.console.log(
|
|
492
|
+
"[trails-sdk] Quote intent trailsContracts:",
|
|
493
|
+
trailsContracts,
|
|
494
|
+
)
|
|
476
495
|
|
|
477
496
|
if (!intent.originPrecondition || !intent.originCalls) {
|
|
478
497
|
throw new Error("Invalid intent")
|
|
@@ -519,6 +538,8 @@ export async function handleSameChainSameToken({
|
|
|
519
538
|
originDepositAddress: intent.originIntentAddress,
|
|
520
539
|
destinationDepositAddress: intent.destinationIntentAddress,
|
|
521
540
|
destinationAddress: recipient,
|
|
541
|
+
trailsApiKey: trailsApiKey || "",
|
|
542
|
+
trailsApiUrl: trailsApiUrl || "",
|
|
522
543
|
destinationCalldata,
|
|
523
544
|
originAmount: swapAmount,
|
|
524
545
|
destinationAmount: swapAmount,
|
|
@@ -743,6 +764,7 @@ export async function handleSameChainSameToken({
|
|
|
743
764
|
destinationTokenSymbol,
|
|
744
765
|
depositAmountUsd,
|
|
745
766
|
feeOptions: gasFeeOptions,
|
|
767
|
+
trailsContracts,
|
|
746
768
|
trailsClient,
|
|
747
769
|
selectedFeeOption: effectiveSelectedFeeOption,
|
|
748
770
|
walletId,
|
|
@@ -1149,8 +1171,20 @@ export async function handleSameChainSameToken({
|
|
|
1149
1171
|
mode,
|
|
1150
1172
|
fundMethod,
|
|
1151
1173
|
originTokenAddress,
|
|
1174
|
+
originTokenSymbol,
|
|
1175
|
+
originTokenAmount: swapAmount,
|
|
1176
|
+
originTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
1177
|
+
destinationTokenAddress: originTokenAddress, // same chain same token
|
|
1178
|
+
destinationTokenSymbol: destinationTokenSymbol,
|
|
1179
|
+
depositTokenAmount: swapAmount,
|
|
1180
|
+
depositTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
1152
1181
|
depositTokenAmountUsd: depositAmountUsd?.toString(),
|
|
1182
|
+
destinationTokenAmount: swapAmount, // same as deposit amount
|
|
1183
|
+
destinationTokenAmountFormatted:
|
|
1184
|
+
depositAmountFormatted.toString(), // same as deposit amount
|
|
1153
1185
|
destinationTokenAmountUsd: depositAmountUsd?.toString(), // same as deposit amount
|
|
1186
|
+
originTokenDecimals: originTokenDecimals,
|
|
1187
|
+
destinationTokenDecimals: originTokenDecimals, // same chain same token
|
|
1154
1188
|
})
|
|
1155
1189
|
|
|
1156
1190
|
// Call onCheckoutComplete callback with transaction status
|
|
@@ -1195,8 +1229,20 @@ export async function handleSameChainSameToken({
|
|
|
1195
1229
|
mode,
|
|
1196
1230
|
fundMethod,
|
|
1197
1231
|
originTokenAddress,
|
|
1232
|
+
originTokenSymbol,
|
|
1233
|
+
originTokenAmount: swapAmount,
|
|
1234
|
+
originTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
1235
|
+
destinationTokenAddress: originTokenAddress, // same chain same token
|
|
1236
|
+
destinationTokenSymbol: destinationTokenSymbol,
|
|
1237
|
+
depositTokenAmount: swapAmount,
|
|
1238
|
+
depositTokenAmountFormatted: depositAmountFormatted.toString(),
|
|
1198
1239
|
depositTokenAmountUsd: depositAmountUsd?.toString(),
|
|
1240
|
+
destinationTokenAmount: swapAmount, // same as deposit amount
|
|
1241
|
+
destinationTokenAmountFormatted:
|
|
1242
|
+
depositAmountFormatted.toString(), // same as deposit amount
|
|
1199
1243
|
destinationTokenAmountUsd: depositAmountUsd?.toString(),
|
|
1244
|
+
originTokenDecimals: originTokenDecimals,
|
|
1245
|
+
destinationTokenDecimals: originTokenDecimals, // same chain same token
|
|
1200
1246
|
})
|
|
1201
1247
|
|
|
1202
1248
|
// Call onCheckoutComplete callback with transaction status
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Intent } from "@
|
|
2
|
-
import type { RelayQuote } from "../../relaySdk.js"
|
|
1
|
+
import type { Intent } from "@0xtrails/api"
|
|
3
2
|
import { zeroAddress } from "viem"
|
|
4
3
|
import { formatUsdAmountDisplay } from "../../tokenBalances.js"
|
|
5
4
|
import { logger } from "../../logger.js"
|
|
@@ -44,33 +43,6 @@ export function getPriceImpactUsdFromIntent(intent: Intent): string {
|
|
|
44
43
|
return intent?.quote?.priceImpactUsd?.toString() ?? "0"
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
export function getFeesFromRelaySdkQuote(quote: RelayQuote): PrepareSendFees {
|
|
48
|
-
const totalFeeAmountUsd = quote?.fees?.relayer?.amount ?? 0
|
|
49
|
-
const totalFeeAmountUsdDisplay = formatUsdAmountDisplay(totalFeeAmountUsd)
|
|
50
|
-
return {
|
|
51
|
-
feeTokenAddress: quote?.fees?.relayer?.currency?.address ?? zeroAddress,
|
|
52
|
-
totalFeeAmount: quote?.fees?.relayer?.amount ?? "0",
|
|
53
|
-
totalFeeAmountUsd: totalFeeAmountUsd.toString(),
|
|
54
|
-
totalFeeAmountUsdDisplay,
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function getSlippageToleranceFromRelaySdkQuote(
|
|
59
|
-
quote: RelayQuote,
|
|
60
|
-
): string {
|
|
61
|
-
return (
|
|
62
|
-
Number(quote?.details?.slippageTolerance?.origin?.percent ?? "0") / 100
|
|
63
|
-
).toString()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function getPriceImpactFromRelaySdkQuote(quote: RelayQuote): string {
|
|
67
|
-
return (quote?.details?.swapImpact?.percent ?? 0).toString()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function getPriceImpactUsdFromRelaySdkQuote(quote: RelayQuote): string {
|
|
71
|
-
return (quote?.details?.swapImpact?.usd ?? 0).toString()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
46
|
export function getZeroFees(): PrepareSendFees {
|
|
75
47
|
return {
|
|
76
48
|
feeTokenAddress: zeroAddress,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Intent } from "@
|
|
1
|
+
import type { Intent } from "@0xtrails/api"
|
|
2
2
|
import type { TransactionState } from "../../transactions.js"
|
|
3
3
|
import type { PrepareSendQuote, PrepareSendFees } from "../types.js"
|
|
4
4
|
import type { QuoteProviderInfo } from "../../widget/hooks/useQuote.js"
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "../../estimate.js"
|
|
23
23
|
import { extractTrailsFeeBreakdown } from "../../fees.js"
|
|
24
24
|
import { getZeroFees } from "./feeExtractors.js"
|
|
25
|
+
import { formatCompletionTime } from "../../time.js"
|
|
25
26
|
|
|
26
27
|
// TODO: make this dyanamic
|
|
27
28
|
export function getCompletionEstimateSeconds({
|
|
@@ -67,6 +68,8 @@ export async function getNormalizedQuoteObject({
|
|
|
67
68
|
noSufficientBalance,
|
|
68
69
|
estimatedGasLimit,
|
|
69
70
|
intent,
|
|
71
|
+
trailsApiKey,
|
|
72
|
+
trailsApiUrl,
|
|
70
73
|
}: {
|
|
71
74
|
originDepositAddress?: string
|
|
72
75
|
destinationDepositAddress?: string
|
|
@@ -92,6 +95,8 @@ export async function getNormalizedQuoteObject({
|
|
|
92
95
|
noSufficientBalance?: boolean
|
|
93
96
|
estimatedGasLimit?: bigint
|
|
94
97
|
intent?: Intent
|
|
98
|
+
trailsApiKey: string
|
|
99
|
+
trailsApiUrl: string
|
|
95
100
|
}): Promise<PrepareSendQuote> {
|
|
96
101
|
if (!destinationChainId) {
|
|
97
102
|
throw new Error("Destination chain id is required")
|
|
@@ -109,10 +114,17 @@ export async function getNormalizedQuoteObject({
|
|
|
109
114
|
throw new Error("Destination token address is required")
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
const originToken = await getTokenInfo(originChainId, originTokenAddress
|
|
117
|
+
const originToken = await getTokenInfo(originChainId, originTokenAddress, {
|
|
118
|
+
trailsApiKey,
|
|
119
|
+
trailsApiUrl,
|
|
120
|
+
})
|
|
113
121
|
const destinationToken = await getTokenInfo(
|
|
114
122
|
destinationChainId,
|
|
115
123
|
destinationTokenAddress,
|
|
124
|
+
{
|
|
125
|
+
trailsApiKey,
|
|
126
|
+
trailsApiUrl,
|
|
127
|
+
},
|
|
116
128
|
)
|
|
117
129
|
|
|
118
130
|
const originChain = getChainInfo(originChainId)
|
|
@@ -277,11 +289,65 @@ export async function getNormalizedQuoteObject({
|
|
|
277
289
|
|
|
278
290
|
const priceImpactUsdDisplay = formatUsdAmountDisplay(priceImpactUsd)
|
|
279
291
|
|
|
280
|
-
// Extract fee breakdown from intent
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
trailsFeeBreakdown
|
|
284
|
-
|
|
292
|
+
// Extract fee breakdown and calculate all fee values from intent
|
|
293
|
+
// Use raw USD values to avoid parsing display strings
|
|
294
|
+
const {
|
|
295
|
+
trailsFeeBreakdown,
|
|
296
|
+
grandTotalUsd,
|
|
297
|
+
grandTotalUsdDisplay,
|
|
298
|
+
originGasUsd,
|
|
299
|
+
destGasUsd,
|
|
300
|
+
totalGasUsd,
|
|
301
|
+
providerUsd,
|
|
302
|
+
trailsUsd,
|
|
303
|
+
swapFeesUsd,
|
|
304
|
+
totalProviderUsd,
|
|
305
|
+
allProviderFeesUsd,
|
|
306
|
+
originGasUsdDisplay,
|
|
307
|
+
destGasUsdDisplay,
|
|
308
|
+
totalGasUsdDisplay,
|
|
309
|
+
providerUsdDisplay,
|
|
310
|
+
trailsUsdDisplay,
|
|
311
|
+
explicitProviderUsdDisplay,
|
|
312
|
+
swapFeesUsdDisplay,
|
|
313
|
+
totalProviderUsdDisplay,
|
|
314
|
+
allProviderFeesUsdDisplay,
|
|
315
|
+
} = intent
|
|
316
|
+
? await extractTrailsFeeBreakdown(
|
|
317
|
+
intent,
|
|
318
|
+
{ trailsApiKey, trailsApiUrl },
|
|
319
|
+
{
|
|
320
|
+
originAmountUsd: parseFloat(originAmountUsdFormatted || "0"),
|
|
321
|
+
destinationAmountUsd: parseFloat(
|
|
322
|
+
destinationAmountUsdFormatted || "0",
|
|
323
|
+
),
|
|
324
|
+
totalFeesUsd: parseFloat(
|
|
325
|
+
fees?.totalFeeAmountUsdDisplay?.replace(/[^0-9.-]/g, "") || "0",
|
|
326
|
+
),
|
|
327
|
+
},
|
|
328
|
+
)
|
|
329
|
+
: {
|
|
330
|
+
trailsFeeBreakdown: null,
|
|
331
|
+
grandTotalUsd: 0,
|
|
332
|
+
grandTotalUsdDisplay: "$0.00",
|
|
333
|
+
originGasUsd: 0,
|
|
334
|
+
destGasUsd: 0,
|
|
335
|
+
totalGasUsd: 0,
|
|
336
|
+
providerUsd: 0,
|
|
337
|
+
trailsUsd: 0,
|
|
338
|
+
swapFeesUsd: 0,
|
|
339
|
+
totalProviderUsd: 0,
|
|
340
|
+
allProviderFeesUsd: 0,
|
|
341
|
+
originGasUsdDisplay: "$0.00",
|
|
342
|
+
destGasUsdDisplay: "$0.00",
|
|
343
|
+
totalGasUsdDisplay: "$0.00",
|
|
344
|
+
providerUsdDisplay: "$0.00",
|
|
345
|
+
trailsUsdDisplay: "$0.00",
|
|
346
|
+
explicitProviderUsdDisplay: "$0.00",
|
|
347
|
+
swapFeesUsdDisplay: "$0.00",
|
|
348
|
+
totalProviderUsdDisplay: "$0.00",
|
|
349
|
+
allProviderFeesUsdDisplay: "$0.00",
|
|
350
|
+
}
|
|
285
351
|
|
|
286
352
|
return {
|
|
287
353
|
originDepositAddress: originDepositAddress || "",
|
|
@@ -308,6 +374,7 @@ export async function getNormalizedQuoteObject({
|
|
|
308
374
|
fees: fees || getZeroFees(),
|
|
309
375
|
slippageTolerance: slippageTolerance || "0",
|
|
310
376
|
priceImpact: priceImpact || "0",
|
|
377
|
+
priceImpactUsd: priceImpactUsd || undefined,
|
|
311
378
|
priceImpactUsdDisplay: priceImpactUsdDisplay || "0",
|
|
312
379
|
originChain,
|
|
313
380
|
destinationChain,
|
|
@@ -315,6 +382,12 @@ export async function getNormalizedQuoteObject({
|
|
|
315
382
|
originChainId,
|
|
316
383
|
destinationChainId,
|
|
317
384
|
}),
|
|
385
|
+
completionEstimateDisplay: formatCompletionTime(
|
|
386
|
+
getCompletionEstimateSeconds({
|
|
387
|
+
originChainId,
|
|
388
|
+
destinationChainId,
|
|
389
|
+
}),
|
|
390
|
+
),
|
|
318
391
|
transactionStates: transactionStates || [],
|
|
319
392
|
gasCostUsd,
|
|
320
393
|
gasCostUsdDisplay,
|
|
@@ -331,6 +404,25 @@ export async function getNormalizedQuoteObject({
|
|
|
331
404
|
quoteProvider: quoteProviderInfo,
|
|
332
405
|
noSufficientBalance: noSufficientBalance || false,
|
|
333
406
|
trailsFeeBreakdown,
|
|
407
|
+
grandTotalUsd,
|
|
408
|
+
grandTotalUsdDisplay,
|
|
409
|
+
originGasUsd,
|
|
410
|
+
destGasUsd,
|
|
411
|
+
totalGasUsd,
|
|
412
|
+
providerUsd,
|
|
413
|
+
trailsUsd,
|
|
414
|
+
swapFeesUsd,
|
|
415
|
+
totalProviderUsd,
|
|
416
|
+
allProviderFeesUsd,
|
|
417
|
+
originGasUsdDisplay,
|
|
418
|
+
destGasUsdDisplay,
|
|
419
|
+
totalGasUsdDisplay,
|
|
420
|
+
providerUsdDisplay,
|
|
421
|
+
trailsUsdDisplay,
|
|
422
|
+
explicitProviderUsdDisplay,
|
|
423
|
+
swapFeesUsdDisplay,
|
|
424
|
+
totalProviderUsdDisplay,
|
|
425
|
+
allProviderFeesUsdDisplay,
|
|
334
426
|
}
|
|
335
427
|
}
|
|
336
428
|
|
|
@@ -13,13 +13,13 @@ import type {
|
|
|
13
13
|
FeeOption,
|
|
14
14
|
GasFeeOptions,
|
|
15
15
|
ExecuteIntentResponse,
|
|
16
|
-
} from "@
|
|
16
|
+
} from "@0xtrails/api"
|
|
17
17
|
import type { TransactionState } from "../transactions.js"
|
|
18
|
-
import type {
|
|
18
|
+
import type { Token } from "../tokens.js"
|
|
19
19
|
import type { CheckoutOnHandlers } from "../widget/hooks/useCheckout.js"
|
|
20
20
|
import type { QuoteProviderInfo } from "../widget/hooks/useQuote.js"
|
|
21
21
|
import type { TrailsFeeBreakdown } from "../fees.js"
|
|
22
|
-
import type { IntentTransaction } from "@
|
|
22
|
+
import type { IntentTransaction } from "@0xtrails/api"
|
|
23
23
|
|
|
24
24
|
export enum TradeType {
|
|
25
25
|
EXACT_INPUT = "EXACT_INPUT",
|
|
@@ -56,7 +56,7 @@ export type PrepareSendOptions = {
|
|
|
56
56
|
originNativeTokenPriceUsd?: number | null
|
|
57
57
|
quoteProvider?: string | null
|
|
58
58
|
fundMethod?: string
|
|
59
|
-
mode?: "pay" | "fund" | "earn" | "swap"
|
|
59
|
+
mode?: "pay" | "fund" | "earn" | "swap"
|
|
60
60
|
originPublicClient?: PublicClient
|
|
61
61
|
destinationPublicClient?: PublicClient
|
|
62
62
|
checkoutOnHandlers?: Partial<CheckoutOnHandlers>
|
|
@@ -65,6 +65,8 @@ export type PrepareSendOptions = {
|
|
|
65
65
|
walletId?: string
|
|
66
66
|
abortSignal?: AbortSignal
|
|
67
67
|
isSmartWallet?: boolean
|
|
68
|
+
trailsApiKey?: string
|
|
69
|
+
trailsApiUrl?: string
|
|
68
70
|
// Optional mutation callbacks for React Query integration
|
|
69
71
|
commitIntentFn?: (intent: Intent) => Promise<CommitIntentResponse>
|
|
70
72
|
executeIntentFn?: (params: {
|
|
@@ -107,13 +109,15 @@ export type PrepareSendQuote = {
|
|
|
107
109
|
destinationAmountFormatted: string
|
|
108
110
|
destinationAmountUsdFormatted: string
|
|
109
111
|
destinationAmountUsdDisplay: string
|
|
110
|
-
originToken:
|
|
111
|
-
destinationToken:
|
|
112
|
+
originToken: Token
|
|
113
|
+
destinationToken: Token
|
|
112
114
|
fees: PrepareSendFees
|
|
113
115
|
slippageTolerance: string
|
|
114
116
|
priceImpact: string
|
|
117
|
+
priceImpactUsd?: string
|
|
115
118
|
priceImpactUsdDisplay: string
|
|
116
119
|
completionEstimateSeconds: number
|
|
120
|
+
completionEstimateDisplay: string
|
|
117
121
|
transactionStates: TransactionState[]
|
|
118
122
|
gasCostUsd: number
|
|
119
123
|
gasCostUsdDisplay: string
|
|
@@ -124,6 +128,27 @@ export type PrepareSendQuote = {
|
|
|
124
128
|
quoteProvider: QuoteProviderInfo | null
|
|
125
129
|
noSufficientBalance: boolean
|
|
126
130
|
trailsFeeBreakdown?: TrailsFeeBreakdown | null
|
|
131
|
+
grandTotalUsd?: number
|
|
132
|
+
grandTotalUsdDisplay?: string
|
|
133
|
+
// Fee breakdown values from extractTrailsFeeBreakdown
|
|
134
|
+
originGasUsd?: number
|
|
135
|
+
destGasUsd?: number
|
|
136
|
+
totalGasUsd?: number
|
|
137
|
+
providerUsd?: number
|
|
138
|
+
trailsUsd?: number
|
|
139
|
+
swapFeesUsd?: number
|
|
140
|
+
totalProviderUsd?: number
|
|
141
|
+
allProviderFeesUsd?: number
|
|
142
|
+
// Display values
|
|
143
|
+
originGasUsdDisplay?: string
|
|
144
|
+
destGasUsdDisplay?: string
|
|
145
|
+
totalGasUsdDisplay?: string
|
|
146
|
+
providerUsdDisplay?: string
|
|
147
|
+
trailsUsdDisplay?: string
|
|
148
|
+
explicitProviderUsdDisplay?: string
|
|
149
|
+
swapFeesUsdDisplay?: string
|
|
150
|
+
totalProviderUsdDisplay?: string
|
|
151
|
+
allProviderFeesUsdDisplay?: string
|
|
127
152
|
}
|
|
128
153
|
|
|
129
154
|
export type PrepareSendReturn = {
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { getQueryParam } from "../../queryParams.js"
|
|
2
|
-
import { getUSDCTokenAddress } from "../../cctp.js"
|
|
3
2
|
|
|
4
3
|
export function isTestnetDebugMode(): boolean {
|
|
5
4
|
return getQueryParam("testnet") === "true"
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
export function getTestnetOriginTokenAddress(testnetChainId: number): string {
|
|
9
|
-
return getUSDCTokenAddress(testnetChainId)!
|
|
10
|
-
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { getIsUsdcAddress } from "../cctp.js"
|
|
2
|
-
|
|
3
1
|
export function isSameChain(
|
|
4
2
|
originChainId: number,
|
|
5
3
|
destinationChainId: number,
|
|
@@ -27,31 +25,3 @@ export function isSameChainAndToken(
|
|
|
27
25
|
isSameToken(originTokenAddress, destinationTokenAddress)
|
|
28
26
|
)
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
export function shouldUseCctp(
|
|
32
|
-
originTokenAddress: string,
|
|
33
|
-
destinationTokenAddress: string,
|
|
34
|
-
originChainId: number,
|
|
35
|
-
destinationChainId: number,
|
|
36
|
-
) {
|
|
37
|
-
return (
|
|
38
|
-
getIsUsdcAddress(originTokenAddress, originChainId) &&
|
|
39
|
-
getIsUsdcAddress(destinationTokenAddress, destinationChainId)
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function validateCctpDestinationToken(
|
|
44
|
-
destinationTokenAddress: string,
|
|
45
|
-
destinationChainId: number,
|
|
46
|
-
quoteProvider?: string | null,
|
|
47
|
-
): void {
|
|
48
|
-
// If CCTP provider is selected, destination token must be USDC
|
|
49
|
-
if (
|
|
50
|
-
quoteProvider === "cctp" &&
|
|
51
|
-
!getIsUsdcAddress(destinationTokenAddress, destinationChainId)
|
|
52
|
-
) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`CCTP provider requires destination token to be USDC. Current destination token: ${destinationTokenAddress} on chain ${destinationChainId}. Please ensure the destination token is USDC as listed in the Circle CCTP documentation.`,
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
}
|
package/src/transactions.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query"
|
|
2
2
|
import { getChainInfo } from "./chains.js"
|
|
3
|
-
import type { GuestModuleEvent,
|
|
3
|
+
import type { GuestModuleEvent, TokenSweeperEvent } from "./decoders.js"
|
|
4
4
|
import { logger } from "./logger.js"
|
|
5
5
|
import { getExplorerUrl } from "./explorer.js"
|
|
6
|
-
import { JsonEncode } from "@
|
|
6
|
+
import { JsonEncode } from "@0xtrails/api"
|
|
7
7
|
import { getChainIndexerUrl } from "./indexerClient.js"
|
|
8
8
|
import { abortControllerRegistry } from "./abortController.js"
|
|
9
9
|
import { useTrails } from "./widget/providers/TrailsProvider.js"
|
|
@@ -21,7 +21,7 @@ export type TransactionState = {
|
|
|
21
21
|
chainId: number
|
|
22
22
|
state: TransactionStateStatus
|
|
23
23
|
label: string
|
|
24
|
-
|
|
24
|
+
decodedTokenSweeperEvents?: TokenSweeperEvent[]
|
|
25
25
|
decodedGuestModuleEvents?: GuestModuleEvent[]
|
|
26
26
|
refunded?: boolean
|
|
27
27
|
txnMinedAt?: string
|
package/src/utils.ts
CHANGED
|
@@ -121,3 +121,21 @@ export function isZeroAccount(address?: string | null): boolean {
|
|
|
121
121
|
|
|
122
122
|
export const normalizeAddress = (address?: string | null): string =>
|
|
123
123
|
(address ?? "").toLowerCase()
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Checks if a formatted value (string with currency symbols, commas, etc.) represents zero
|
|
127
|
+
* Strips all non-numeric characters and checks if the numeric value is zero
|
|
128
|
+
* @param value - The value to check (can be string like "$1,000.00" or number)
|
|
129
|
+
* @returns True if the value represents zero
|
|
130
|
+
*/
|
|
131
|
+
export function isValueZero(value?: string | number | null): boolean {
|
|
132
|
+
if (value === null || value === undefined) return true
|
|
133
|
+
if (typeof value === "number") return value === 0
|
|
134
|
+
|
|
135
|
+
// Strip all non-numeric characters except decimal point and minus sign
|
|
136
|
+
const numericString = value.replace(/[^0-9.-]/g, "")
|
|
137
|
+
if (!numericString || numericString === "-") return true
|
|
138
|
+
|
|
139
|
+
const numValue = parseFloat(numericString)
|
|
140
|
+
return Number.isNaN(numValue) || numValue === 0
|
|
141
|
+
}
|