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
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { useEffect, useCallback, useRef, useState } from "react"
|
|
2
|
+
import { useConnect } from "wagmi"
|
|
3
|
+
import { walletConnect } from "wagmi/connectors"
|
|
4
|
+
import { useTrails } from "../providers/TrailsProvider.js"
|
|
5
|
+
import { logger } from "../../logger.js"
|
|
6
|
+
|
|
7
|
+
// Local singleton to avoid multiple Core initializations
|
|
8
|
+
let wcConnectorSingleton: ReturnType<typeof walletConnect> | null = null
|
|
9
|
+
function getWalletConnectConnector(projectId: string) {
|
|
10
|
+
if (!wcConnectorSingleton) {
|
|
11
|
+
logger.console.log(
|
|
12
|
+
"[trails-sdk] [useWalletConnectUri] Creating new connector with projectId:",
|
|
13
|
+
projectId,
|
|
14
|
+
)
|
|
15
|
+
wcConnectorSingleton = walletConnect({
|
|
16
|
+
projectId: projectId,
|
|
17
|
+
showQrModal: false,
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
return wcConnectorSingleton
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Hook to get WalletConnect URI
|
|
25
|
+
* Returns the current WalletConnect URI and automatically starts connection
|
|
26
|
+
*/
|
|
27
|
+
export function useWalletConnectUri(projectId?: string): {
|
|
28
|
+
walletConnectUri: string | null
|
|
29
|
+
isConnecting: boolean
|
|
30
|
+
error: Error | null
|
|
31
|
+
reconnect: () => void
|
|
32
|
+
} {
|
|
33
|
+
const config = useTrails()
|
|
34
|
+
const finalProjectId = projectId || config.walletConnectProjectId
|
|
35
|
+
const { connect, connectors, status } = useConnect() as any
|
|
36
|
+
const [wcUri, setWcUri] = useState<string | null>(null)
|
|
37
|
+
const [error, setError] = useState<Error | null>(null)
|
|
38
|
+
const listenerRef = useRef<(() => void) | null>(null)
|
|
39
|
+
const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
|
40
|
+
|
|
41
|
+
// Debounced setWcUri to prevent rapid QR code changes
|
|
42
|
+
const debouncedSetWcUri = useCallback((uri: string | null) => {
|
|
43
|
+
if (debounceTimeoutRef.current) {
|
|
44
|
+
clearTimeout(debounceTimeoutRef.current)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
debounceTimeoutRef.current = setTimeout(() => {
|
|
48
|
+
setWcUri(uri)
|
|
49
|
+
}, 500) // 500ms debounce delay
|
|
50
|
+
}, [])
|
|
51
|
+
|
|
52
|
+
const wcConnectorFromConfig = connectors.find((c: any) =>
|
|
53
|
+
(c.id || "").toLowerCase().includes("walletconnect"),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const handleConnect = useCallback(
|
|
57
|
+
async (force: boolean = false) => {
|
|
58
|
+
if (!finalProjectId) {
|
|
59
|
+
logger.console.error(
|
|
60
|
+
"[trails-sdk] [useWalletConnectUri] No projectId provided",
|
|
61
|
+
)
|
|
62
|
+
setError(new Error("WalletConnect projectId is required"))
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
logger.console.log("[trails-sdk] [useWalletConnectUri] handleConnect", {
|
|
67
|
+
status,
|
|
68
|
+
wcUri,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
if ((status === "pending" || status === "success") && !force) return
|
|
72
|
+
|
|
73
|
+
const makeConnector = () => getWalletConnectConnector(finalProjectId)
|
|
74
|
+
const connector = wcConnectorFromConfig || makeConnector()
|
|
75
|
+
|
|
76
|
+
logger.console.log(
|
|
77
|
+
"[trails-sdk] [useWalletConnectUri] wcConnectorFromConfig",
|
|
78
|
+
wcConnectorFromConfig,
|
|
79
|
+
)
|
|
80
|
+
logger.console.log(
|
|
81
|
+
"[trails-sdk] [useWalletConnectUri] connector",
|
|
82
|
+
connector,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
logger.console.log(
|
|
87
|
+
"[trails-sdk] [useWalletConnectUri] Starting connection...",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
// Set up message listener for display_uri events (like ConnectKit does)
|
|
91
|
+
const handleMessage = (message: any) => {
|
|
92
|
+
const { type, data } = message
|
|
93
|
+
logger.console.log(
|
|
94
|
+
"[trails-sdk] [useWalletConnectUri] Message received:",
|
|
95
|
+
type,
|
|
96
|
+
data,
|
|
97
|
+
)
|
|
98
|
+
if (type === "display_uri") {
|
|
99
|
+
logger.console.log(
|
|
100
|
+
"[trails-sdk] [useWalletConnectUri] Setting URI from display_uri event:",
|
|
101
|
+
data,
|
|
102
|
+
)
|
|
103
|
+
debouncedSetWcUri(data)
|
|
104
|
+
setError(null)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Set up disconnect handler to regenerate QR code
|
|
109
|
+
const handleDisconnect = async () => {
|
|
110
|
+
logger.console.log(
|
|
111
|
+
"[trails-sdk] [useWalletConnectUri] Disconnected, regenerating QR code",
|
|
112
|
+
)
|
|
113
|
+
debouncedSetWcUri(null)
|
|
114
|
+
// Try to reconnect
|
|
115
|
+
try {
|
|
116
|
+
await connect({ connector })
|
|
117
|
+
} catch (error: any) {
|
|
118
|
+
logger.console.error(
|
|
119
|
+
"[trails-sdk] [useWalletConnectUri] Reconnection error:",
|
|
120
|
+
error,
|
|
121
|
+
)
|
|
122
|
+
setError(error instanceof Error ? error : new Error(String(error)))
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Add listeners to connector emitter
|
|
127
|
+
if ((connector as any).emitter) {
|
|
128
|
+
logger.console.log(
|
|
129
|
+
"[trails-sdk] [useWalletConnectUri] Adding listeners to connector emitter",
|
|
130
|
+
)
|
|
131
|
+
;(connector as any).emitter.on("message", handleMessage)
|
|
132
|
+
;(connector as any).emitter.on("disconnect", handleDisconnect)
|
|
133
|
+
|
|
134
|
+
// Store listeners for cleanup
|
|
135
|
+
listenerRef.current = () => {
|
|
136
|
+
;(connector as any).emitter.off("message", handleMessage)
|
|
137
|
+
;(connector as any).emitter.off("disconnect", handleDisconnect)
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
logger.console.log(
|
|
141
|
+
"[trails-sdk] [useWalletConnectUri] No emitter found on connector",
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
await connect({ connector })
|
|
146
|
+
} catch (err) {
|
|
147
|
+
logger.console.error(
|
|
148
|
+
"[trails-sdk] [useWalletConnectUri] connect error",
|
|
149
|
+
err,
|
|
150
|
+
)
|
|
151
|
+
const error = err instanceof Error ? err : new Error(String(err))
|
|
152
|
+
setError(error)
|
|
153
|
+
|
|
154
|
+
// If user rejected, try to regenerate QR code
|
|
155
|
+
if ((err as any).code === 4001) {
|
|
156
|
+
logger.console.log(
|
|
157
|
+
"[trails-sdk] [useWalletConnectUri] User rejected, regenerating QR code",
|
|
158
|
+
)
|
|
159
|
+
debouncedSetWcUri(null)
|
|
160
|
+
// Try to reconnect after a short delay
|
|
161
|
+
setTimeout(() => {
|
|
162
|
+
handleConnect()
|
|
163
|
+
}, 0)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
[
|
|
168
|
+
connect,
|
|
169
|
+
wcConnectorFromConfig,
|
|
170
|
+
finalProjectId,
|
|
171
|
+
status,
|
|
172
|
+
wcUri,
|
|
173
|
+
debouncedSetWcUri,
|
|
174
|
+
],
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
// Auto-start WalletConnect connection when component mounts (if not already connected)
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (!wcUri && status !== "pending" && status !== "success") {
|
|
180
|
+
logger.console.log(
|
|
181
|
+
"[trails-sdk] [useWalletConnectUri] Auto-starting connection on mount",
|
|
182
|
+
)
|
|
183
|
+
handleConnect()
|
|
184
|
+
}
|
|
185
|
+
}, [wcUri, status, handleConnect])
|
|
186
|
+
|
|
187
|
+
// Force QR code regeneration when wcUri is cleared
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
if (!wcUri && status !== "pending" && status !== "success") {
|
|
190
|
+
logger.console.log(
|
|
191
|
+
"[trails-sdk] [useWalletConnectUri] URI cleared, regenerating QR code",
|
|
192
|
+
)
|
|
193
|
+
handleConnect()
|
|
194
|
+
}
|
|
195
|
+
}, [wcUri, status, handleConnect])
|
|
196
|
+
|
|
197
|
+
// Cleanup listeners on unmount
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
return () => {
|
|
200
|
+
try {
|
|
201
|
+
// Clean up the listener function if it exists
|
|
202
|
+
if (listenerRef.current) {
|
|
203
|
+
listenerRef.current()
|
|
204
|
+
}
|
|
205
|
+
// Clean up debounce timeout
|
|
206
|
+
if (debounceTimeoutRef.current) {
|
|
207
|
+
clearTimeout(debounceTimeoutRef.current)
|
|
208
|
+
}
|
|
209
|
+
} catch (err) {
|
|
210
|
+
logger.console.error(
|
|
211
|
+
"[trails-sdk] [useWalletConnectUri] Cleanup error:",
|
|
212
|
+
err,
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}, [])
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
walletConnectUri: wcUri,
|
|
220
|
+
isConnecting: status === "pending",
|
|
221
|
+
error,
|
|
222
|
+
reconnect: () => {
|
|
223
|
+
setError(null)
|
|
224
|
+
debouncedSetWcUri(null)
|
|
225
|
+
handleConnect(true)
|
|
226
|
+
},
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -6,7 +6,9 @@ interface WidgetPropsContextType {
|
|
|
6
6
|
props: TrailsWidgetProps
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const WidgetPropsContext = createContext<WidgetPropsContextType | null>(
|
|
9
|
+
export const WidgetPropsContext = createContext<WidgetPropsContextType | null>(
|
|
10
|
+
null,
|
|
11
|
+
)
|
|
10
12
|
|
|
11
13
|
export function WidgetPropsProvider({
|
|
12
14
|
children,
|
package/src/widget/index.tsx
CHANGED
|
@@ -13,3 +13,15 @@ export {
|
|
|
13
13
|
type TrailsConfig,
|
|
14
14
|
type SequenceEnv,
|
|
15
15
|
} from "./providers/TrailsProvider.js"
|
|
16
|
+
|
|
17
|
+
// Export modal provider and hooks
|
|
18
|
+
export {
|
|
19
|
+
TrailsModalProvider,
|
|
20
|
+
useTrailsModal,
|
|
21
|
+
type TrailsModalContextType,
|
|
22
|
+
type ModalSelectionParams,
|
|
23
|
+
} from "./providers/TrailsModalProvider.js"
|
|
24
|
+
|
|
25
|
+
// Export TrailsHookModal for use with useTrailsSendTransaction
|
|
26
|
+
// Must be rendered inside WagmiProvider for the modal to work
|
|
27
|
+
export { TrailsHookModal } from "./components/TrailsHookModal.js"
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { createContext, useContext, useState, useCallback, useRef } from "react"
|
|
2
|
+
import { AnimatePresence } from "motion/react"
|
|
3
|
+
import { logger } from "../../logger.js"
|
|
4
|
+
import type { PrepareSendQuote } from "../../prepareSend.js"
|
|
5
|
+
import type { TransactionState } from "../../transactions.js"
|
|
6
|
+
import { TrailsHookModal } from "../components/TrailsHookModal.js"
|
|
7
|
+
|
|
8
|
+
export interface ModalSelectionParams {
|
|
9
|
+
fromTokenAddress: string
|
|
10
|
+
fromChainId: number
|
|
11
|
+
fromAmount?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type HostTransactionStatus =
|
|
15
|
+
| "idle"
|
|
16
|
+
| "awaiting-origin"
|
|
17
|
+
| "awaiting-amount"
|
|
18
|
+
| "confirmation"
|
|
19
|
+
| "pending"
|
|
20
|
+
| "success"
|
|
21
|
+
| "error"
|
|
22
|
+
|
|
23
|
+
export interface HostTransactionDetails {
|
|
24
|
+
to?: string
|
|
25
|
+
tokenAddress?: string
|
|
26
|
+
tokenAmount?: string
|
|
27
|
+
toChainId?: number
|
|
28
|
+
data?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface HostTransactionResultLinks {
|
|
32
|
+
originTxHash?: string
|
|
33
|
+
originExplorerUrl?: string
|
|
34
|
+
destinationTxHash?: string
|
|
35
|
+
destinationExplorerUrl?: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface HostTransactionState {
|
|
39
|
+
status: HostTransactionStatus
|
|
40
|
+
details?: HostTransactionDetails
|
|
41
|
+
error?: string
|
|
42
|
+
result?: HostTransactionResultLinks
|
|
43
|
+
retryEnabled?: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface TrailsModalContextType {
|
|
47
|
+
isModalOpen: boolean
|
|
48
|
+
openModal: () => void
|
|
49
|
+
closeModal: () => void
|
|
50
|
+
pendingSelection?: {
|
|
51
|
+
resolve: (selection: ModalSelectionParams) => void
|
|
52
|
+
reject: (error: Error) => void
|
|
53
|
+
requireAmountInput?: boolean
|
|
54
|
+
}
|
|
55
|
+
setPendingSelection: (
|
|
56
|
+
pending:
|
|
57
|
+
| {
|
|
58
|
+
resolve: (selection: ModalSelectionParams) => void
|
|
59
|
+
reject: (error: Error) => void
|
|
60
|
+
requireAmountInput?: boolean
|
|
61
|
+
}
|
|
62
|
+
| undefined,
|
|
63
|
+
) => void
|
|
64
|
+
hostTransactionState: HostTransactionState
|
|
65
|
+
setHostTransactionState: (
|
|
66
|
+
next:
|
|
67
|
+
| HostTransactionState
|
|
68
|
+
| ((prev: HostTransactionState) => HostTransactionState),
|
|
69
|
+
) => void
|
|
70
|
+
resetHostTransactionState: () => void
|
|
71
|
+
hostTransactionQuote: PrepareSendQuote | null
|
|
72
|
+
setHostTransactionQuote: (
|
|
73
|
+
quote:
|
|
74
|
+
| PrepareSendQuote
|
|
75
|
+
| null
|
|
76
|
+
| ((prev: PrepareSendQuote | null) => PrepareSendQuote | null),
|
|
77
|
+
) => void
|
|
78
|
+
hostTransactionStates: TransactionState[]
|
|
79
|
+
setHostTransactionStates: (
|
|
80
|
+
states:
|
|
81
|
+
| TransactionState[]
|
|
82
|
+
| ((prev: TransactionState[]) => TransactionState[]),
|
|
83
|
+
) => void
|
|
84
|
+
hostTransactionTimestamp: number | null
|
|
85
|
+
setHostTransactionTimestamp: (
|
|
86
|
+
value: number | null | ((prev: number | null) => number | null),
|
|
87
|
+
) => void
|
|
88
|
+
receiptActionButtonText: string | null
|
|
89
|
+
setReceiptActionButtonText: (text: string | null) => void
|
|
90
|
+
onReceiptAction: (() => void) | null
|
|
91
|
+
setOnReceiptAction: (callback: (() => void) | null) => void
|
|
92
|
+
retryTransactionRef: { current: (() => void) | null }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const TrailsModalContext = createContext<TrailsModalContextType | null>(null)
|
|
96
|
+
|
|
97
|
+
export interface TrailsModalProviderProps {
|
|
98
|
+
children: React.ReactNode
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const TrailsModalProvider = ({ children }: TrailsModalProviderProps) => {
|
|
102
|
+
// Modal state management for useTrailsSendTransaction hook
|
|
103
|
+
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
104
|
+
const [pendingSelection, setPendingSelection] = useState<
|
|
105
|
+
| {
|
|
106
|
+
resolve: (selection: ModalSelectionParams) => void
|
|
107
|
+
reject: (error: Error) => void
|
|
108
|
+
requireAmountInput?: boolean
|
|
109
|
+
}
|
|
110
|
+
| undefined
|
|
111
|
+
>(undefined)
|
|
112
|
+
const [hostTransactionState, setHostTransactionState] =
|
|
113
|
+
useState<HostTransactionState>({ status: "idle" })
|
|
114
|
+
const [hostTransactionQuote, setHostTransactionQuote] =
|
|
115
|
+
useState<PrepareSendQuote | null>(null)
|
|
116
|
+
const [hostTransactionStates, setHostTransactionStates] = useState<
|
|
117
|
+
TransactionState[]
|
|
118
|
+
>([])
|
|
119
|
+
const [hostTransactionTimestamp, setHostTransactionTimestamp] = useState<
|
|
120
|
+
number | null
|
|
121
|
+
>(null)
|
|
122
|
+
const [receiptActionButtonText, setReceiptActionButtonText] = useState<
|
|
123
|
+
string | null
|
|
124
|
+
>(null)
|
|
125
|
+
const [onReceiptAction, setOnReceiptAction] = useState<(() => void) | null>(
|
|
126
|
+
null,
|
|
127
|
+
)
|
|
128
|
+
const retryTransactionRef = useRef<(() => void) | null>(null)
|
|
129
|
+
|
|
130
|
+
const openModal = useCallback(() => {
|
|
131
|
+
logger.console.log("[trails-sdk] [TrailsModalProvider] openModal called")
|
|
132
|
+
setIsModalOpen(true)
|
|
133
|
+
}, [])
|
|
134
|
+
|
|
135
|
+
const closeModal = useCallback(() => {
|
|
136
|
+
setIsModalOpen(false)
|
|
137
|
+
// Reject any pending selection if modal is closed
|
|
138
|
+
if (pendingSelection) {
|
|
139
|
+
pendingSelection.reject(
|
|
140
|
+
new Error("Modal was closed before selection completed"),
|
|
141
|
+
)
|
|
142
|
+
setPendingSelection(undefined)
|
|
143
|
+
}
|
|
144
|
+
}, [pendingSelection])
|
|
145
|
+
|
|
146
|
+
const resetHostTransactionState = useCallback(() => {
|
|
147
|
+
setHostTransactionState({ status: "idle" })
|
|
148
|
+
setHostTransactionQuote(null)
|
|
149
|
+
setHostTransactionStates([])
|
|
150
|
+
setHostTransactionTimestamp(null)
|
|
151
|
+
setReceiptActionButtonText(null)
|
|
152
|
+
setOnReceiptAction(null)
|
|
153
|
+
retryTransactionRef.current = null
|
|
154
|
+
}, [])
|
|
155
|
+
|
|
156
|
+
const value: TrailsModalContextType = {
|
|
157
|
+
isModalOpen,
|
|
158
|
+
openModal,
|
|
159
|
+
closeModal,
|
|
160
|
+
pendingSelection,
|
|
161
|
+
setPendingSelection,
|
|
162
|
+
hostTransactionState,
|
|
163
|
+
setHostTransactionState,
|
|
164
|
+
resetHostTransactionState,
|
|
165
|
+
hostTransactionQuote,
|
|
166
|
+
setHostTransactionQuote,
|
|
167
|
+
hostTransactionStates,
|
|
168
|
+
setHostTransactionStates,
|
|
169
|
+
hostTransactionTimestamp,
|
|
170
|
+
setHostTransactionTimestamp,
|
|
171
|
+
receiptActionButtonText,
|
|
172
|
+
setReceiptActionButtonText,
|
|
173
|
+
onReceiptAction,
|
|
174
|
+
setOnReceiptAction,
|
|
175
|
+
retryTransactionRef,
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<TrailsModalContext.Provider value={value}>
|
|
180
|
+
{children}
|
|
181
|
+
{/* Render TrailsHookModal with AnimatePresence for proper exit animations */}
|
|
182
|
+
<AnimatePresence>{isModalOpen && <TrailsHookModal />}</AnimatePresence>
|
|
183
|
+
</TrailsModalContext.Provider>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function useTrailsModal(): TrailsModalContextType {
|
|
188
|
+
const context = useContext(TrailsModalContext)
|
|
189
|
+
|
|
190
|
+
if (!context) {
|
|
191
|
+
throw new Error("useTrailsModal must be used within a TrailsModalProvider")
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return context
|
|
195
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SequenceHooksProvider } from "@0xsequence/hooks"
|
|
2
2
|
import { createContext, useContext, useMemo, useEffect } from "react"
|
|
3
3
|
import type { ComponentProps } from "react"
|
|
4
|
+
import { TrailsModalProvider } from "./TrailsModalProvider.js"
|
|
4
5
|
import {
|
|
5
6
|
DEFAULT_SLIPPAGE_TOLERANCE,
|
|
6
7
|
DEFAULT_WALLETCONNECT_PROJECT_ID,
|
|
@@ -90,9 +91,14 @@ export const TrailsProvider = ({ children, config }: TrailsProviderProps) => {
|
|
|
90
91
|
useEffect(() => {
|
|
91
92
|
updateGlobalConfig({
|
|
92
93
|
trailsApiKey: trailsConfig.trailsApiKey,
|
|
94
|
+
trailsApiUrl: trailsConfig.trailsApiUrl,
|
|
93
95
|
sequenceNodeGatewayUrl: trailsConfig.sequenceNodeGatewayUrl,
|
|
94
96
|
})
|
|
95
|
-
}, [
|
|
97
|
+
}, [
|
|
98
|
+
trailsConfig.trailsApiKey,
|
|
99
|
+
trailsConfig.trailsApiUrl,
|
|
100
|
+
trailsConfig.sequenceNodeGatewayUrl,
|
|
101
|
+
])
|
|
96
102
|
|
|
97
103
|
// Create a sequence hooks config based on the trails config
|
|
98
104
|
const sequenceHooksConfig = useMemo(() => {
|
|
@@ -112,13 +118,13 @@ export const TrailsProvider = ({ children, config }: TrailsProviderProps) => {
|
|
|
112
118
|
return (
|
|
113
119
|
<TrailsContext.Provider value={trailsConfig}>
|
|
114
120
|
<SequenceHooksProvider config={sequenceHooksConfig}>
|
|
115
|
-
{children}
|
|
121
|
+
<TrailsModalProvider>{children}</TrailsModalProvider>
|
|
116
122
|
</SequenceHooksProvider>
|
|
117
123
|
</TrailsContext.Provider>
|
|
118
124
|
)
|
|
119
125
|
}
|
|
120
126
|
|
|
121
|
-
export
|
|
127
|
+
export function useTrails(): Readonly<TrailsConfig> {
|
|
122
128
|
const context = useContext(TrailsContext)
|
|
123
129
|
|
|
124
130
|
if (!context) {
|
package/src/widget/types.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
export interface FeeToken {
|
|
3
|
-
chainId: number
|
|
4
|
-
name: string
|
|
5
|
-
symbol: string
|
|
6
|
-
type: string
|
|
7
|
-
decimals: number
|
|
8
|
-
logoURL?: string
|
|
9
|
-
contractAddress: string
|
|
10
|
-
tokenID?: string
|
|
11
|
-
}
|
|
1
|
+
import type { Token } from "../tokens.js"
|
|
12
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Processed FeeOption with Token
|
|
5
|
+
* Note: This is a local processed type. The API FeeOption from @0xtrails/api uses a different structure.
|
|
6
|
+
*/
|
|
13
7
|
export interface FeeOption {
|
|
14
|
-
token:
|
|
8
|
+
token: Token
|
|
15
9
|
to: string
|
|
16
10
|
value: string
|
|
17
11
|
gasLimit: number
|
|
18
12
|
feeValue: string
|
|
19
13
|
decimals: number
|
|
20
|
-
|
|
14
|
+
priceUsd?: number
|
|
15
|
+
priceUsdFormatted?: string
|
|
16
|
+
priceUsdDisplay?: string
|
|
17
|
+
// Legacy price object for backward compatibility (deprecated)
|
|
18
|
+
/** @deprecated Use priceUsd, priceUsdFormatted, priceUsdDisplay instead */
|
|
19
|
+
price?: {
|
|
21
20
|
value: number
|
|
22
21
|
currency: string
|
|
23
22
|
}
|
|
@@ -33,13 +32,6 @@ export interface RelayerFeeOptions {
|
|
|
33
32
|
quote?: FeeQuote
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
export interface FeeTokenMetadata {
|
|
37
|
-
symbol: string
|
|
38
|
-
name: string
|
|
39
|
-
imageUrl: string
|
|
40
|
-
contractAddress: string
|
|
41
|
-
}
|
|
42
|
-
|
|
43
35
|
// Raw API Types
|
|
44
36
|
export interface RawFeeOption {
|
|
45
37
|
token: string
|