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/src/decoders.ts
CHANGED
|
@@ -100,10 +100,7 @@ export type GuestModuleEvent =
|
|
|
100
100
|
| CallSkippedEvent
|
|
101
101
|
|
|
102
102
|
// Trails Token Sweeper events: see PR references above for canonical specs.
|
|
103
|
-
export type
|
|
104
|
-
| RefundEvent
|
|
105
|
-
| SweepEvent
|
|
106
|
-
| RefundAndSweepEvent
|
|
103
|
+
export type TokenSweeperEvent = RefundEvent | SweepEvent | RefundAndSweepEvent
|
|
107
104
|
|
|
108
105
|
// === Decoders ===
|
|
109
106
|
|
|
@@ -285,10 +282,10 @@ export function decodeSweep(log: Log): SweepEvent | null {
|
|
|
285
282
|
|
|
286
283
|
// === Main decoder ===
|
|
287
284
|
|
|
288
|
-
export function
|
|
285
|
+
export function decodeTokenSweeperEvents(
|
|
289
286
|
receipt: TransactionReceipt,
|
|
290
|
-
):
|
|
291
|
-
const events:
|
|
287
|
+
): TokenSweeperEvent[] {
|
|
288
|
+
const events: TokenSweeperEvent[] = []
|
|
292
289
|
|
|
293
290
|
for (const log of receipt.logs) {
|
|
294
291
|
const refund = decodeRefund(log)
|
package/src/error.ts
CHANGED
|
@@ -33,9 +33,13 @@ export function getIsUserRejectionError(
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Check if the error message indicates a user rejection
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
36
|
+
// Use getFullErrorMessage to check nested error messages as well
|
|
37
|
+
// Match patterns like: "rejected", "denied", "user rejected", "denied transaction signature", etc.
|
|
38
|
+
const errorString = getFullErrorMessage(err).toLowerCase()
|
|
39
|
+
const isRejected =
|
|
40
|
+
/rejected|denied|user rejected|denied transaction signature|user denied transaction|user denied the request/gi.test(
|
|
41
|
+
errorString,
|
|
42
|
+
)
|
|
39
43
|
return isRejected
|
|
40
44
|
}
|
|
41
45
|
|
package/src/fees.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Intent } from "@
|
|
1
|
+
import type { Intent } from "@0xtrails/api"
|
|
2
2
|
import { getTokenInfo } from "./tokens.js"
|
|
3
3
|
import { formatRawAmount, formatUsdAmountDisplay } from "./tokenBalances.js"
|
|
4
4
|
import { zeroAddress } from "viem"
|
|
@@ -26,13 +26,14 @@ async function formatTokenAmount(
|
|
|
26
26
|
amount: string | number | undefined,
|
|
27
27
|
tokenAddress: string,
|
|
28
28
|
chainId: number,
|
|
29
|
+
config: { trailsApiKey: string; trailsApiUrl: string },
|
|
29
30
|
): Promise<string> {
|
|
30
31
|
if (!amount) return "0"
|
|
31
32
|
const num = typeof amount === "string" ? parseFloat(amount) : amount
|
|
32
33
|
if (num === 0) return "0"
|
|
33
34
|
|
|
34
35
|
// Get token info to determine decimals
|
|
35
|
-
const tokenInfo = await getTokenInfo(chainId, tokenAddress)
|
|
36
|
+
const tokenInfo = await getTokenInfo(chainId, tokenAddress, config)
|
|
36
37
|
if (!tokenInfo?.decimals) {
|
|
37
38
|
throw new Error(
|
|
38
39
|
`Token decimals not found for token ${tokenAddress} on chain ${chainId}`,
|
|
@@ -49,13 +50,73 @@ async function formatTokenAmount(
|
|
|
49
50
|
return formatted
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Extract fee breakdown and calculate all fee values from intent data
|
|
55
|
+
* Uses raw USD values from intent to avoid parsing display strings
|
|
56
|
+
*/
|
|
53
57
|
export async function extractTrailsFeeBreakdown(
|
|
54
58
|
intent: Intent,
|
|
55
|
-
|
|
59
|
+
config: { trailsApiKey: string; trailsApiUrl: string },
|
|
60
|
+
options?: {
|
|
61
|
+
originAmountUsd?: number
|
|
62
|
+
destinationAmountUsd?: number
|
|
63
|
+
totalFeesUsd?: number
|
|
64
|
+
},
|
|
65
|
+
): Promise<{
|
|
66
|
+
trailsFeeBreakdown: TrailsFeeBreakdown | null
|
|
67
|
+
// Calculated fee values (using raw USD numbers)
|
|
68
|
+
originGasUsd: number
|
|
69
|
+
destGasUsd: number
|
|
70
|
+
totalGasUsd: number
|
|
71
|
+
providerUsd: number
|
|
72
|
+
trailsUsd: number
|
|
73
|
+
originUsd: number
|
|
74
|
+
destUsd: number
|
|
75
|
+
totalFeesUsd: number
|
|
76
|
+
swapFeesUsd: number
|
|
77
|
+
totalProviderUsd: number
|
|
78
|
+
allProviderFeesUsd: number
|
|
79
|
+
grandTotalUsd: number
|
|
80
|
+
grandTotalUsdDisplay: string
|
|
81
|
+
// Display values
|
|
82
|
+
originGasUsdDisplay: string
|
|
83
|
+
destGasUsdDisplay: string
|
|
84
|
+
totalGasUsdDisplay: string
|
|
85
|
+
providerUsdDisplay: string
|
|
86
|
+
trailsUsdDisplay: string
|
|
87
|
+
explicitProviderUsdDisplay: string
|
|
88
|
+
swapFeesUsdDisplay: string
|
|
89
|
+
totalProviderUsdDisplay: string
|
|
90
|
+
allProviderFeesUsdDisplay: string
|
|
91
|
+
}> {
|
|
56
92
|
const fees = intent?.fees
|
|
57
93
|
if (!fees) {
|
|
58
|
-
|
|
94
|
+
// Return zero values if no fees
|
|
95
|
+
return {
|
|
96
|
+
trailsFeeBreakdown: null,
|
|
97
|
+
originGasUsd: 0,
|
|
98
|
+
destGasUsd: 0,
|
|
99
|
+
totalGasUsd: 0,
|
|
100
|
+
providerUsd: 0,
|
|
101
|
+
trailsUsd: 0,
|
|
102
|
+
originUsd: options?.originAmountUsd ?? 0,
|
|
103
|
+
destUsd: options?.destinationAmountUsd ?? 0,
|
|
104
|
+
totalFeesUsd: options?.totalFeesUsd ?? 0,
|
|
105
|
+
swapFeesUsd: 0,
|
|
106
|
+
totalProviderUsd: 0,
|
|
107
|
+
grandTotalUsd: 0,
|
|
108
|
+
grandTotalUsdDisplay: formatUsdAmountDisplay(0),
|
|
109
|
+
originGasUsdDisplay: formatUsdAmountDisplay(0),
|
|
110
|
+
destGasUsdDisplay: formatUsdAmountDisplay(0),
|
|
111
|
+
totalGasUsdDisplay: formatUsdAmountDisplay(0),
|
|
112
|
+
providerUsdDisplay: formatUsdAmountDisplay(0),
|
|
113
|
+
trailsUsdDisplay: formatUsdAmountDisplay(0),
|
|
114
|
+
explicitProviderUsdDisplay: formatUsdAmountDisplay(0),
|
|
115
|
+
swapFeesUsdDisplay: formatUsdAmountDisplay(0),
|
|
116
|
+
totalProviderUsdDisplay: formatUsdAmountDisplay(0),
|
|
117
|
+
allProviderFeesUsd: 0,
|
|
118
|
+
allProviderFeesUsdDisplay: formatUsdAmountDisplay(0),
|
|
119
|
+
}
|
|
59
120
|
}
|
|
60
121
|
|
|
61
122
|
// Get chain IDs from origin and destination calls
|
|
@@ -66,140 +127,193 @@ export async function extractTrailsFeeBreakdown(
|
|
|
66
127
|
const originChainQuote = fees.originGas
|
|
67
128
|
const destinationChainQuote = fees.destinationGas
|
|
68
129
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
130
|
+
// Extract raw USD values (use numbers directly, avoid parsing strings)
|
|
131
|
+
const originGasUsd =
|
|
132
|
+
typeof originChainQuote?.totalFeeUsd === "string"
|
|
133
|
+
? parseFloat(originChainQuote.totalFeeUsd)
|
|
134
|
+
: (originChainQuote?.totalFeeUsd ?? 0)
|
|
135
|
+
const destGasUsd =
|
|
136
|
+
typeof destinationChainQuote?.totalFeeUsd === "string"
|
|
137
|
+
? parseFloat(destinationChainQuote.totalFeeUsd)
|
|
138
|
+
: (destinationChainQuote?.totalFeeUsd ?? 0)
|
|
139
|
+
const providerUsd =
|
|
140
|
+
typeof fees.provider?.quoteProviderFeeUsd === "number"
|
|
141
|
+
? fees.provider.quoteProviderFeeUsd
|
|
142
|
+
: 0
|
|
143
|
+
const trailsUsd =
|
|
144
|
+
typeof fees.provider?.trailsFeeUsd === "number"
|
|
145
|
+
? fees.provider.trailsFeeUsd
|
|
146
|
+
: 0
|
|
80
147
|
|
|
81
|
-
|
|
148
|
+
// Use provided USD amounts or calculate from intent if available
|
|
149
|
+
const originUsd = options?.originAmountUsd ?? 0
|
|
150
|
+
const destUsd = options?.destinationAmountUsd ?? 0
|
|
151
|
+
const totalFeesUsd = options?.totalFeesUsd ?? 0
|
|
82
152
|
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
const originTokenSymbol = originChainQuote.nativeTokenSymbol || "ETH"
|
|
86
|
-
const originChainIdNum = originChainId
|
|
87
|
-
const nativeTokenAddress = zeroAddress
|
|
153
|
+
// Calculate swap fees: (originAmount - destinationAmount) - totalFees
|
|
154
|
+
const swapFeesUsd = Math.max(0, originUsd - destUsd - totalFeesUsd)
|
|
88
155
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
chainId: originChainIdNum,
|
|
98
|
-
usdValue: formatUsdAmountDisplay(originChainQuote.totalFeeUsd),
|
|
99
|
-
}
|
|
100
|
-
breakdown.originChainId = originChainIdNum
|
|
101
|
-
}
|
|
156
|
+
// Calculate totals
|
|
157
|
+
const totalGasUsd = originGasUsd + destGasUsd
|
|
158
|
+
const explicitProviderUsd = providerUsd + trailsUsd
|
|
159
|
+
const totalProviderUsd = providerUsd + trailsUsd + swapFeesUsd
|
|
160
|
+
// All provider fees = provider fee + swap fee (excluding trails)
|
|
161
|
+
const allProviderFeesUsd = providerUsd + swapFeesUsd
|
|
162
|
+
// Grand total = all gas costs + all provider fees
|
|
163
|
+
const grandTotalUsd = totalGasUsd + allProviderFeesUsd
|
|
102
164
|
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const destinationChainIdNum = destinationChainId
|
|
108
|
-
const nativeTokenAddress = zeroAddress
|
|
109
|
-
|
|
110
|
-
breakdown.destinationRelayFee = {
|
|
111
|
-
amount: await formatTokenAmount(
|
|
112
|
-
destinationChainQuote.totalFeeAmount.toString(),
|
|
113
|
-
nativeTokenAddress,
|
|
114
|
-
destinationChainIdNum,
|
|
115
|
-
),
|
|
116
|
-
tokenSymbol: destinationTokenSymbol,
|
|
117
|
-
tokenAddress: nativeTokenAddress,
|
|
118
|
-
chainId: destinationChainIdNum,
|
|
119
|
-
usdValue: formatUsdAmountDisplay(destinationChainQuote.totalFeeUsd),
|
|
120
|
-
}
|
|
121
|
-
breakdown.destinationChainId = destinationChainIdNum
|
|
122
|
-
}
|
|
165
|
+
// Build breakdown for display (only if we have chain quotes)
|
|
166
|
+
let breakdown: TrailsFeeBreakdown | null = null
|
|
167
|
+
if (originChainQuote || destinationChainQuote) {
|
|
168
|
+
breakdown = {}
|
|
123
169
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
170
|
+
// Extract origin relay fee if available
|
|
171
|
+
if (originChainQuote && originChainId !== undefined) {
|
|
172
|
+
const originTokenSymbol = originChainQuote.nativeTokenSymbol || "ETH"
|
|
173
|
+
const originChainIdNum = originChainId
|
|
174
|
+
const nativeTokenAddress = zeroAddress
|
|
175
|
+
|
|
176
|
+
breakdown.originRelayFee = {
|
|
177
|
+
amount: await formatTokenAmount(
|
|
178
|
+
originChainQuote.totalFeeAmount.toString(),
|
|
179
|
+
nativeTokenAddress,
|
|
180
|
+
originChainIdNum,
|
|
181
|
+
config,
|
|
182
|
+
),
|
|
183
|
+
tokenSymbol: originTokenSymbol,
|
|
184
|
+
tokenAddress: nativeTokenAddress,
|
|
185
|
+
chainId: originChainIdNum,
|
|
186
|
+
usdValue: formatUsdAmountDisplay(originGasUsd),
|
|
187
|
+
}
|
|
188
|
+
breakdown.originChainId = originChainIdNum
|
|
141
189
|
}
|
|
142
190
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
191
|
+
// Extract destination relay fee if available
|
|
192
|
+
if (destinationChainQuote && destinationChainId !== undefined) {
|
|
193
|
+
const destinationTokenSymbol =
|
|
194
|
+
destinationChainQuote.nativeTokenSymbol || "ETH"
|
|
195
|
+
const destinationChainIdNum = destinationChainId
|
|
196
|
+
const nativeTokenAddress = zeroAddress
|
|
197
|
+
|
|
198
|
+
breakdown.destinationRelayFee = {
|
|
199
|
+
amount: await formatTokenAmount(
|
|
200
|
+
destinationChainQuote.totalFeeAmount.toString(),
|
|
201
|
+
nativeTokenAddress,
|
|
202
|
+
destinationChainIdNum,
|
|
203
|
+
config,
|
|
204
|
+
),
|
|
205
|
+
tokenSymbol: destinationTokenSymbol,
|
|
206
|
+
tokenAddress: nativeTokenAddress,
|
|
207
|
+
chainId: destinationChainIdNum,
|
|
208
|
+
usdValue: formatUsdAmountDisplay(destGasUsd),
|
|
209
|
+
}
|
|
210
|
+
breakdown.destinationChainId = destinationChainIdNum
|
|
153
211
|
}
|
|
154
|
-
}
|
|
155
212
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
213
|
+
// Extract provider fee from provider fees if available
|
|
214
|
+
const providerFeeRawAmount = fees.provider?.quoteProviderFee
|
|
215
|
+
if (
|
|
216
|
+
(providerUsd > 0 || providerFeeRawAmount !== undefined) &&
|
|
217
|
+
originChainId !== undefined
|
|
218
|
+
) {
|
|
219
|
+
const feeTokenAddress = fees.feeTokenAddress || zeroAddress
|
|
220
|
+
const originChainIdNum =
|
|
221
|
+
typeof originChainId === "bigint"
|
|
222
|
+
? Number(originChainId)
|
|
223
|
+
: originChainId
|
|
224
|
+
|
|
225
|
+
// Get token info to determine the actual token symbol
|
|
226
|
+
const feeTokenInfo = await getTokenInfo(
|
|
227
|
+
originChainIdNum,
|
|
228
|
+
feeTokenAddress,
|
|
229
|
+
config,
|
|
172
230
|
)
|
|
231
|
+
if (!feeTokenInfo?.symbol) {
|
|
232
|
+
throw new Error(
|
|
233
|
+
`Token symbol not found for provider fee token ${feeTokenAddress} on chain ${originChainIdNum}`,
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
breakdown.providerFee = {
|
|
238
|
+
amount: await formatTokenAmount(
|
|
239
|
+
providerFeeRawAmount?.toString(),
|
|
240
|
+
feeTokenAddress,
|
|
241
|
+
originChainIdNum,
|
|
242
|
+
config,
|
|
243
|
+
),
|
|
244
|
+
tokenSymbol: feeTokenInfo.symbol,
|
|
245
|
+
tokenAddress: feeTokenAddress,
|
|
246
|
+
chainId: originChainIdNum,
|
|
247
|
+
usdValue: formatUsdAmountDisplay(providerUsd),
|
|
248
|
+
}
|
|
173
249
|
}
|
|
174
250
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
251
|
+
// Extract Trails platform fee from provider fees if available
|
|
252
|
+
const trailsFeeRawAmount = fees.provider?.trailsFee
|
|
253
|
+
if (
|
|
254
|
+
(trailsUsd > 0 || trailsFeeRawAmount !== undefined) &&
|
|
255
|
+
originChainId !== undefined
|
|
256
|
+
) {
|
|
257
|
+
const feeTokenAddress = fees.feeTokenAddress || zeroAddress
|
|
258
|
+
const originChainIdNum =
|
|
259
|
+
typeof originChainId === "bigint"
|
|
260
|
+
? Number(originChainId)
|
|
261
|
+
: originChainId
|
|
262
|
+
|
|
263
|
+
// Get token info to determine the actual token symbol
|
|
264
|
+
const feeTokenInfo = await getTokenInfo(
|
|
179
265
|
originChainIdNum,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
266
|
+
feeTokenAddress,
|
|
267
|
+
config,
|
|
268
|
+
)
|
|
269
|
+
if (!feeTokenInfo?.symbol) {
|
|
270
|
+
throw new Error(
|
|
271
|
+
`Token symbol not found for trails fee token ${feeTokenAddress} on chain ${originChainIdNum}`,
|
|
272
|
+
)
|
|
273
|
+
}
|
|
187
274
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
275
|
+
breakdown.trailsFee = {
|
|
276
|
+
amount: await formatTokenAmount(
|
|
277
|
+
trailsFeeRawAmount?.toString(),
|
|
278
|
+
feeTokenAddress,
|
|
279
|
+
originChainIdNum,
|
|
280
|
+
config,
|
|
281
|
+
),
|
|
282
|
+
tokenSymbol: feeTokenInfo.symbol,
|
|
283
|
+
tokenAddress: feeTokenAddress,
|
|
284
|
+
chainId: originChainIdNum,
|
|
285
|
+
usdValue: formatUsdAmountDisplay(trailsUsd),
|
|
286
|
+
}
|
|
287
|
+
}
|
|
201
288
|
|
|
202
|
-
|
|
289
|
+
// Calculate total USD value for breakdown display
|
|
290
|
+
const totalUsd = originGasUsd + destGasUsd + providerUsd + trailsUsd
|
|
291
|
+
breakdown.totalUsdValue = formatUsdAmountDisplay(totalUsd)
|
|
292
|
+
}
|
|
203
293
|
|
|
204
|
-
return
|
|
294
|
+
return {
|
|
295
|
+
trailsFeeBreakdown: breakdown,
|
|
296
|
+
originGasUsd,
|
|
297
|
+
destGasUsd,
|
|
298
|
+
totalGasUsd,
|
|
299
|
+
providerUsd,
|
|
300
|
+
trailsUsd,
|
|
301
|
+
originUsd,
|
|
302
|
+
destUsd,
|
|
303
|
+
totalFeesUsd,
|
|
304
|
+
swapFeesUsd,
|
|
305
|
+
totalProviderUsd,
|
|
306
|
+
allProviderFeesUsd,
|
|
307
|
+
grandTotalUsd,
|
|
308
|
+
grandTotalUsdDisplay: formatUsdAmountDisplay(grandTotalUsd),
|
|
309
|
+
originGasUsdDisplay: formatUsdAmountDisplay(originGasUsd),
|
|
310
|
+
destGasUsdDisplay: formatUsdAmountDisplay(destGasUsd),
|
|
311
|
+
totalGasUsdDisplay: formatUsdAmountDisplay(totalGasUsd),
|
|
312
|
+
providerUsdDisplay: formatUsdAmountDisplay(providerUsd),
|
|
313
|
+
trailsUsdDisplay: formatUsdAmountDisplay(trailsUsd),
|
|
314
|
+
explicitProviderUsdDisplay: formatUsdAmountDisplay(explicitProviderUsd),
|
|
315
|
+
swapFeesUsdDisplay: formatUsdAmountDisplay(swapFeesUsd),
|
|
316
|
+
totalProviderUsdDisplay: formatUsdAmountDisplay(totalProviderUsd),
|
|
317
|
+
allProviderFeesUsdDisplay: formatUsdAmountDisplay(allProviderFeesUsd),
|
|
318
|
+
}
|
|
205
319
|
}
|
package/src/gasless.ts
CHANGED
|
@@ -92,38 +92,6 @@ export function getTransferCalldata({
|
|
|
92
92
|
return transferCalldata
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export function getPermitCalls(
|
|
96
|
-
connectedAccount: `0x${string}`,
|
|
97
|
-
delegatorSmartAccountAddress: `0x${string}`,
|
|
98
|
-
amount: bigint,
|
|
99
|
-
deadline: bigint,
|
|
100
|
-
signature: `0x${string}`,
|
|
101
|
-
recipient: `0x${string}`,
|
|
102
|
-
tokenAddress: `0x${string}`,
|
|
103
|
-
): { to: `0x${string}`; data: `0x${string}`; value: string }[] {
|
|
104
|
-
const permitCalldata = getPermitCalldata({
|
|
105
|
-
signer: connectedAccount,
|
|
106
|
-
spender: delegatorSmartAccountAddress,
|
|
107
|
-
amount,
|
|
108
|
-
deadline,
|
|
109
|
-
signature,
|
|
110
|
-
})
|
|
111
|
-
const transferFromCalldata = getTransferFromCalldata({
|
|
112
|
-
signer: connectedAccount,
|
|
113
|
-
spender: delegatorSmartAccountAddress,
|
|
114
|
-
amount,
|
|
115
|
-
})
|
|
116
|
-
const transferCalldata = getTransferCalldata({ recipient, amount })
|
|
117
|
-
|
|
118
|
-
return [permitCalldata, transferFromCalldata, transferCalldata].map(
|
|
119
|
-
(call) => ({
|
|
120
|
-
to: tokenAddress,
|
|
121
|
-
data: call,
|
|
122
|
-
value: "0",
|
|
123
|
-
}),
|
|
124
|
-
)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
95
|
export type GetPermitSignatureParams = {
|
|
128
96
|
publicClient: PublicClient
|
|
129
97
|
walletClient: WalletClient
|
|
@@ -318,6 +286,60 @@ export async function getPermitSignature({
|
|
|
318
286
|
return { signature, deadline, v, r, s }
|
|
319
287
|
}
|
|
320
288
|
|
|
289
|
+
export type GetNeedsIntentEntrypointApprovalParams = {
|
|
290
|
+
client: PublicClient
|
|
291
|
+
token: Address
|
|
292
|
+
account: Address
|
|
293
|
+
entrypoint: Address
|
|
294
|
+
amount: bigint
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export async function getNeedsIntentEntrypointApproval({
|
|
298
|
+
client,
|
|
299
|
+
token,
|
|
300
|
+
account,
|
|
301
|
+
entrypoint,
|
|
302
|
+
amount,
|
|
303
|
+
}: GetNeedsIntentEntrypointApprovalParams): Promise<boolean> {
|
|
304
|
+
const allowance = await client.readContract({
|
|
305
|
+
address: token,
|
|
306
|
+
abi: erc20Abi,
|
|
307
|
+
functionName: "allowance",
|
|
308
|
+
args: [getAddress(account), getAddress(entrypoint)],
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
return allowance < amount
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export type GetUserNonceParams = {
|
|
315
|
+
publicClient: PublicClient
|
|
316
|
+
userAddress: `0x${string}`
|
|
317
|
+
intentEntrypoint: `0x${string}`
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export async function getUserNonce({
|
|
321
|
+
publicClient,
|
|
322
|
+
userAddress,
|
|
323
|
+
intentEntrypoint,
|
|
324
|
+
}: GetUserNonceParams): Promise<bigint> {
|
|
325
|
+
const nonce = await publicClient.readContract({
|
|
326
|
+
address: intentEntrypoint as `0x${string}`,
|
|
327
|
+
abi: [
|
|
328
|
+
{
|
|
329
|
+
name: "nonces",
|
|
330
|
+
type: "function",
|
|
331
|
+
stateMutability: "view",
|
|
332
|
+
inputs: [{ name: "user", type: "address" }],
|
|
333
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
functionName: "nonces",
|
|
337
|
+
args: [userAddress],
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
return nonce as bigint
|
|
341
|
+
}
|
|
342
|
+
|
|
321
343
|
export type GetDepositToIntentWithPermitCalldataParams = {
|
|
322
344
|
user: `0x${string}`
|
|
323
345
|
token: `0x${string}`
|
|
@@ -438,71 +460,6 @@ export function getDepositToIntentWithoutPermitCalldata({
|
|
|
438
460
|
})
|
|
439
461
|
}
|
|
440
462
|
|
|
441
|
-
export type GetDepositToIntentCallsParams = {
|
|
442
|
-
publicClient: PublicClient
|
|
443
|
-
walletClient: WalletClient
|
|
444
|
-
account: Account
|
|
445
|
-
intentEntrypoint: `0x${string}`
|
|
446
|
-
depositTokenAddress: `0x${string}`
|
|
447
|
-
depositTokenAmount: bigint
|
|
448
|
-
depositRecipient: `0x${string}`
|
|
449
|
-
chain: Chain
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
export type GetNeedsIntentEntrypointApprovalParams = {
|
|
453
|
-
client: PublicClient
|
|
454
|
-
token: Address
|
|
455
|
-
account: Address
|
|
456
|
-
entrypoint: Address
|
|
457
|
-
amount: bigint
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
export async function getNeedsIntentEntrypointApproval({
|
|
461
|
-
client,
|
|
462
|
-
token,
|
|
463
|
-
account,
|
|
464
|
-
entrypoint,
|
|
465
|
-
amount,
|
|
466
|
-
}: GetNeedsIntentEntrypointApprovalParams): Promise<boolean> {
|
|
467
|
-
const allowance = await client.readContract({
|
|
468
|
-
address: token,
|
|
469
|
-
abi: erc20Abi,
|
|
470
|
-
functionName: "allowance",
|
|
471
|
-
args: [getAddress(account), getAddress(entrypoint)],
|
|
472
|
-
})
|
|
473
|
-
|
|
474
|
-
return allowance < amount
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
export type GetUserNonceParams = {
|
|
478
|
-
publicClient: PublicClient
|
|
479
|
-
userAddress: `0x${string}`
|
|
480
|
-
intentEntrypoint: `0x${string}`
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
export async function getUserNonce({
|
|
484
|
-
publicClient,
|
|
485
|
-
userAddress,
|
|
486
|
-
intentEntrypoint,
|
|
487
|
-
}: GetUserNonceParams): Promise<bigint> {
|
|
488
|
-
const nonce = await publicClient.readContract({
|
|
489
|
-
address: intentEntrypoint as `0x${string}`,
|
|
490
|
-
abi: [
|
|
491
|
-
{
|
|
492
|
-
name: "nonces",
|
|
493
|
-
type: "function",
|
|
494
|
-
stateMutability: "view",
|
|
495
|
-
inputs: [{ name: "user", type: "address" }],
|
|
496
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
497
|
-
},
|
|
498
|
-
],
|
|
499
|
-
functionName: "nonces",
|
|
500
|
-
args: [userAddress],
|
|
501
|
-
})
|
|
502
|
-
|
|
503
|
-
return nonce as bigint
|
|
504
|
-
}
|
|
505
|
-
|
|
506
463
|
export type IntentParams = {
|
|
507
464
|
user: `0x${string}`
|
|
508
465
|
token: `0x${string}`
|
|
@@ -609,17 +566,6 @@ function getSignatureBytes(signature: string): number {
|
|
|
609
566
|
: signature.length / 2
|
|
610
567
|
}
|
|
611
568
|
|
|
612
|
-
/**
|
|
613
|
-
* Validates that a signature is exactly 65 bytes (standard ECDSA signature length).
|
|
614
|
-
* @param signature - The signature to validate (hex string with or without 0x prefix)
|
|
615
|
-
* @returns true if signature is 65 bytes, false otherwise
|
|
616
|
-
*/
|
|
617
|
-
export function isValidGaslessSignature(signature: string): boolean {
|
|
618
|
-
// Standard ECDSA signatures are 65 bytes (32 bytes r + 32 bytes s + 1 byte v)
|
|
619
|
-
// Smart contract wallets return longer signatures which are not supported
|
|
620
|
-
return getSignatureBytes(signature) === 65
|
|
621
|
-
}
|
|
622
|
-
|
|
623
569
|
/**
|
|
624
570
|
* Validates that a signature is exactly 65 bytes and throws an appropriate error if invalid.
|
|
625
571
|
* @param signature - The signature to validate (hex string with or without 0x prefix)
|