0xtrails 0.2.4 → 0.2.6
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 +8 -0
- package/dist/aave.d.ts.map +1 -1
- package/dist/abortController.d.ts +8 -0
- package/dist/abortController.d.ts.map +1 -0
- package/dist/{ccip-BlV1Mry3.js → ccip-Xjh9d1gb.js} +7 -7
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/estimate.d.ts +52 -0
- package/dist/estimate.d.ts.map +1 -1
- package/dist/fees.d.ts +19 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/{index-BNWCIGfQ.js → index-BnhdZ8Ho.js} +76406 -75798
- package/dist/index.js +726 -520
- package/dist/intents.d.ts +40 -0
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts +3 -3
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/metaTxns.d.ts +3 -3
- package/dist/metaTxns.d.ts.map +1 -1
- package/dist/morpho.d.ts +8 -0
- package/dist/morpho.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +19 -75
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/queryParams.d.ts.map +1 -1
- package/dist/relayer.d.ts +6 -6
- package/dist/relayer.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +2 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -2
- package/dist/transactions.d.ts.map +1 -1
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts +4 -0
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts.map +1 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +4 -2
- 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 +4 -0
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DynamicInputStyles.d.ts +18 -0
- package/dist/widget/components/DynamicInputStyles.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts +2 -2
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/ErrorAnimationIcon.d.ts +2 -0
- package/dist/widget/components/ErrorAnimationIcon.d.ts.map +1 -0
- package/dist/widget/components/FeeBreakdown.d.ts +9 -0
- package/dist/widget/components/FeeBreakdown.d.ts.map +1 -0
- package/dist/widget/components/Fund.d.ts +2 -2
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/{FundSendForm.d.ts → FundSwap.d.ts} +13 -7
- package/dist/widget/components/FundSwap.d.ts.map +1 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts +4 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Identicon.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -3
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +2 -2
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PercentageMaxButtons.d.ts +12 -0
- package/dist/widget/components/PercentageMaxButtons.d.ts.map +1 -0
- package/dist/widget/components/{PaySendForm.d.ts → PoolDeposit.d.ts} +14 -36
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -0
- package/dist/widget/components/{SimpleSwap.d.ts → PoolWithdraw.d.ts} +19 -10
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -0
- package/dist/widget/components/QuoteDetails.d.ts +1 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/Receive.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts +4 -0
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RequiredPropsError.d.ts +8 -0
- package/dist/widget/components/RequiredPropsError.d.ts.map +1 -0
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +3 -2
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts +11 -0
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts.map +1 -0
- package/dist/widget/components/TokenImage.d.ts +1 -0
- package/dist/widget/components/TokenImage.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts +16 -0
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Tooltip.d.ts +9 -0
- package/dist/widget/components/Tooltip.d.ts.map +1 -0
- package/dist/widget/components/UserPreferences.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +9 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -0
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +2 -0
- package/dist/widget/css/index.css +554 -0
- package/dist/widget/hooks/useBack.d.ts +1 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +1 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -3
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +83 -0
- package/dist/widget/hooks/useQuote.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +12 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +2 -2
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +9 -4
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +18 -12
- package/src/aave.ts +32 -0
- package/src/abortController.ts +35 -0
- package/src/config.ts +12 -4
- package/src/constants.ts +5 -0
- package/src/error.ts +19 -1
- package/src/estimate.ts +416 -5
- package/src/fees.ts +199 -0
- package/src/intents.ts +161 -11
- package/src/metaTxnMonitor.ts +3 -3
- package/src/metaTxns.ts +3 -5
- package/src/morpho.ts +32 -0
- package/src/prepareSend.ts +714 -550
- package/src/queryParams.ts +2 -1
- package/src/relayer.ts +11 -11
- package/src/sequenceWallet.ts +2 -2
- package/src/tokens.ts +7 -1
- package/src/trails.ts +3 -3
- package/src/transactions.ts +62 -18
- package/src/wallets.ts +8 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +3 -13
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
- package/src/widget/components/AccountSettings.tsx +48 -54
- package/src/widget/components/ChainFilterDropdown.tsx +24 -3
- package/src/widget/components/ClassicSwap.tsx +131 -213
- package/src/widget/components/ConnectWallet.tsx +8 -38
- package/src/widget/components/ConnectedWallets.tsx +132 -77
- package/src/widget/components/DynamicInputStyles.tsx +76 -0
- package/src/widget/components/Earn.tsx +82 -593
- package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
- package/src/widget/components/FeeBreakdown.tsx +155 -0
- package/src/widget/components/Fund.tsx +41 -108
- package/src/widget/components/FundMethods.tsx +82 -159
- package/src/widget/components/FundSwap.tsx +52 -0
- package/src/widget/components/FundingMethodSelectorButton.tsx +70 -0
- package/src/widget/components/Identicon.tsx +164 -95
- package/src/widget/components/MeshConnectExchanges.tsx +2 -15
- package/src/widget/components/Modal.tsx +0 -8
- package/src/widget/components/Pay.tsx +214 -237
- package/src/widget/components/PercentageMaxButtons.tsx +77 -0
- package/src/widget/components/PoolDeposit.tsx +569 -0
- package/src/widget/components/PoolWithdraw.tsx +884 -0
- package/src/widget/components/PriceImpactWarning.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +43 -12
- package/src/widget/components/Receipt.tsx +16 -2
- package/src/widget/components/Receive.tsx +0 -2
- package/src/widget/components/RecipientSelectorButton.tsx +44 -0
- package/src/widget/components/Recipients.tsx +63 -157
- package/src/widget/components/RequiredPropsError.tsx +33 -0
- package/src/widget/components/ScreenHeader.tsx +62 -34
- package/src/widget/components/SlippageToleranceSettings.tsx +2 -1
- package/src/widget/components/Swap.tsx +4 -45
- package/src/widget/components/SwapSettings.tsx +2 -14
- package/src/widget/components/ThemeProvider.tsx +2 -1
- package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
- package/src/widget/components/TokenImage.tsx +22 -5
- package/src/widget/components/TokenList.tsx +0 -1
- package/src/widget/components/TokenSelector.tsx +63 -53
- package/src/widget/components/TokenSelectorButton.tsx +98 -0
- package/src/widget/components/Tooltip.tsx +51 -0
- package/src/widget/components/TransferPendingVertical.tsx +1 -1
- package/src/widget/components/UserPreferences.tsx +6 -24
- package/src/widget/components/WaasFeeOptions.tsx +450 -0
- package/src/widget/components/WalletConfirmation.tsx +76 -14
- package/src/widget/components/WalletConnect.tsx +93 -29
- package/src/widget/components/WalletList.tsx +4 -2
- package/src/widget/hooks/useBack.tsx +2 -0
- package/src/widget/hooks/useCheckout.ts +36 -20
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDefaultTokenSelection.tsx +104 -28
- package/src/widget/hooks/usePayMessage.tsx +86 -11
- package/src/widget/hooks/useQuote.ts +413 -0
- package/src/widget/hooks/useSelectedFundMethod.tsx +41 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +10 -0
- package/src/widget/hooks/useSendForm.ts +32 -6
- package/src/widget/index.css +27 -0
- package/src/widget/widget.tsx +326 -283
- package/dist/widget/components/FundSendForm.d.ts.map +0 -1
- package/dist/widget/components/PaySendForm.d.ts.map +0 -1
- package/dist/widget/components/SimpleSwap.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapSettings.d.ts +0 -16
- package/dist/widget/hooks/useSwapSettings.d.ts.map +0 -1
- package/src/widget/components/FundSendForm.tsx +0 -903
- package/src/widget/components/PaySendForm.tsx +0 -869
- package/src/widget/components/SimpleSwap.tsx +0 -983
- package/src/widget/hooks/useSwapSettings.tsx +0 -100
package/src/widget/widget.tsx
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import "@0xsequence/design-system/preset"
|
|
2
2
|
import { SequenceHooksContext, SequenceHooksProvider } from "@0xsequence/hooks"
|
|
3
|
+
import { AaveClient, AaveProvider } from "@aave/react"
|
|
3
4
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
|
|
4
5
|
import { AnimatePresence, motion } from "motion/react"
|
|
5
6
|
import React, {
|
|
7
|
+
createContext,
|
|
6
8
|
forwardRef,
|
|
7
9
|
StrictMode,
|
|
8
10
|
useCallback,
|
|
9
11
|
useContext,
|
|
10
12
|
useEffect,
|
|
11
13
|
useImperativeHandle,
|
|
14
|
+
useMemo,
|
|
12
15
|
useRef,
|
|
13
16
|
useState,
|
|
14
|
-
useMemo,
|
|
15
17
|
} from "react"
|
|
16
18
|
import { createPortal } from "react-dom"
|
|
17
19
|
import type { Chain, WalletClient } from "viem"
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
+
import {
|
|
21
|
+
createWalletClient,
|
|
22
|
+
custom,
|
|
23
|
+
encodeFunctionData,
|
|
24
|
+
http,
|
|
25
|
+
isAddress,
|
|
26
|
+
} from "viem"
|
|
20
27
|
import type { Connector } from "wagmi"
|
|
21
28
|
import {
|
|
22
29
|
createConfig,
|
|
@@ -28,33 +35,6 @@ import {
|
|
|
28
35
|
WagmiContext,
|
|
29
36
|
WagmiProvider,
|
|
30
37
|
} from "wagmi"
|
|
31
|
-
import { getChainInfo, getRpcUrl } from "../chains.js"
|
|
32
|
-
import type { TransactionState } from "../transactions.js"
|
|
33
|
-
import type { RelayerEnv, MetaTxnReceipt } from "../relayer.js"
|
|
34
|
-
import type { Theme } from "../theme.js"
|
|
35
|
-
import { ConnectWallet } from "./components/ConnectWallet.js"
|
|
36
|
-
import Footer from "./components/Footer.js"
|
|
37
|
-
import Modal from "./components/Modal.js"
|
|
38
|
-
import Receipt from "./components/Receipt.js"
|
|
39
|
-
import { WalletList } from "./components/WalletList.js"
|
|
40
|
-
import { Pay } from "./components/Pay.js"
|
|
41
|
-
import TokenList from "./components/TokenList.js"
|
|
42
|
-
import TransferPending from "./components/TransferPendingVertical.js"
|
|
43
|
-
import WalletConfirmation from "./components/WalletConfirmation.js"
|
|
44
|
-
import QRCodeDeposit from "./components/QRCodeDeposit.js"
|
|
45
|
-
import { ThemeProvider } from "./components/ThemeProvider.js"
|
|
46
|
-
import { ToastProvider } from "./components/Toast.js"
|
|
47
|
-
import {
|
|
48
|
-
getCommitHash,
|
|
49
|
-
getSequenceNodeGatewayUrl,
|
|
50
|
-
setWalletConnectProjectId,
|
|
51
|
-
setSequenceNodeGatewayUrl,
|
|
52
|
-
getSequenceEnv,
|
|
53
|
-
} from "../config.js"
|
|
54
|
-
import { useRecentTokens } from "./hooks/useRecentTokens.js"
|
|
55
|
-
import { useTargetAmount } from "./hooks/useTargetAmount.js"
|
|
56
|
-
import { getWethAddress } from "../tokens.js"
|
|
57
|
-
import css from "./compiled.css?inline"
|
|
58
38
|
import {
|
|
59
39
|
getAnalytics,
|
|
60
40
|
getSessionId,
|
|
@@ -62,92 +42,153 @@ import {
|
|
|
62
42
|
trackWalletDisconnected,
|
|
63
43
|
trackWidgetScreen,
|
|
64
44
|
} from "../analytics.js"
|
|
65
|
-
import
|
|
66
|
-
import type { SupportedToken } from "../tokens.js"
|
|
67
|
-
import {
|
|
68
|
-
getIsWalletRejectedError,
|
|
69
|
-
getIsBalanceTooLowError,
|
|
70
|
-
getFullErrorMessage,
|
|
71
|
-
getIsApiError,
|
|
72
|
-
getIsRateLimitedError,
|
|
73
|
-
getPrettifiedErrorMessage,
|
|
74
|
-
} from "../error.js"
|
|
45
|
+
import { getAllChains, getChainInfo, getRpcUrl } from "../chains.js"
|
|
75
46
|
import {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
setTrailsApiUrl,
|
|
79
|
-
setSequenceProjectAccessKey,
|
|
80
|
-
getSequenceIndexerUrl,
|
|
47
|
+
getCommitHash,
|
|
48
|
+
getDebug,
|
|
81
49
|
getSequenceApiUrl,
|
|
50
|
+
getSequenceEnv,
|
|
51
|
+
getSequenceIndexerUrl,
|
|
52
|
+
getSequenceNodeGatewayUrl,
|
|
53
|
+
getSequenceProjectAccessKey,
|
|
82
54
|
getTrailsApiUrl,
|
|
55
|
+
setDebug,
|
|
56
|
+
setSequenceApiUrl,
|
|
83
57
|
setSequenceEnv,
|
|
58
|
+
setSequenceIndexerUrl,
|
|
59
|
+
setSequenceNodeGatewayUrl,
|
|
60
|
+
setSequenceProjectAccessKey,
|
|
84
61
|
setSlippageTolerance,
|
|
85
|
-
|
|
86
|
-
|
|
62
|
+
setTrailsApiUrl,
|
|
63
|
+
setWalletConnectProjectId,
|
|
87
64
|
} from "../config.js"
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
import
|
|
98
|
-
import WalletConnectionPending from "./components/WalletConnectionPending.js"
|
|
99
|
-
import { AccountIntentTransactionHistory } from "./components/AccountIntentTransactionHistory.js"
|
|
100
|
-
import { AccountSettings } from "./components/AccountSettings.js"
|
|
101
|
-
import { UserPreferences } from "./components/UserPreferences.js"
|
|
65
|
+
import { cssObjectToString } from "../cssUtils.js"
|
|
66
|
+
import {
|
|
67
|
+
getFullErrorMessage,
|
|
68
|
+
getIsApiError,
|
|
69
|
+
getIsBalanceTooLowError,
|
|
70
|
+
getIsRateLimitedError,
|
|
71
|
+
getIsWalletRejectedError,
|
|
72
|
+
getPrettifiedErrorMessage,
|
|
73
|
+
} from "../error.js"
|
|
74
|
+
import { logger } from "../logger.js"
|
|
102
75
|
import type { Mode } from "../mode.js"
|
|
103
|
-
import type { OnCompleteProps } from "./hooks/useSendForm.js"
|
|
104
76
|
import type { Pool } from "../pools.js"
|
|
105
77
|
import { usePools } from "../pools.js"
|
|
106
|
-
import {
|
|
107
|
-
import {
|
|
108
|
-
import {
|
|
109
|
-
import {
|
|
110
|
-
import {
|
|
111
|
-
import {
|
|
112
|
-
import {
|
|
113
|
-
import {
|
|
114
|
-
import {
|
|
115
|
-
import
|
|
116
|
-
import {
|
|
78
|
+
import type { PrepareSendQuote } from "../prepareSend.js"
|
|
79
|
+
import { isValidInteger, isValidNumeric } from "../prices.js"
|
|
80
|
+
import type { MetaTxnReceipt, RelayerEnv } from "../relayer.js"
|
|
81
|
+
import type { Theme } from "../theme.js"
|
|
82
|
+
import type { SupportedToken } from "../tokens.js"
|
|
83
|
+
import { getWethAddress } from "../tokens.js"
|
|
84
|
+
import type { TransactionState } from "../transactions.js"
|
|
85
|
+
import { connectors, useWallets, walletConnectConnector } from "../wallets.js"
|
|
86
|
+
// import { useOpenConnectModal } from "@0xsequence/connect"
|
|
87
|
+
import css from "./compiled.css?inline"
|
|
88
|
+
import { AccountIntentTransactionHistory } from "./components/AccountIntentTransactionHistory.js"
|
|
89
|
+
import { AccountSettings } from "./components/AccountSettings.js"
|
|
117
90
|
import { ChainList } from "./components/ChainList.js"
|
|
91
|
+
import { ConnectWallet } from "./components/ConnectWallet.js"
|
|
118
92
|
import { Disconnect } from "./components/Disconnect.js"
|
|
119
|
-
import {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
} from "./
|
|
124
|
-
import
|
|
125
|
-
import {
|
|
126
|
-
import {
|
|
127
|
-
import {
|
|
128
|
-
import
|
|
129
|
-
import {
|
|
130
|
-
import
|
|
131
|
-
import
|
|
93
|
+
import { Earn } from "./components/Earn.js"
|
|
94
|
+
import EarnPools from "./components/EarnPools.js"
|
|
95
|
+
import { ErrorDisplay } from "./components/ErrorDisplay.js"
|
|
96
|
+
import Footer from "./components/Footer.js"
|
|
97
|
+
import { Fund } from "./components/FundSwap.js"
|
|
98
|
+
import FundMethods from "./components/FundMethods.js"
|
|
99
|
+
import { MeshConnectExchanges } from "./components/MeshConnectExchanges.js"
|
|
100
|
+
import { MeshConnectFlow } from "./components/MeshConnectFlow.js"
|
|
101
|
+
import type { MeshConnectProps } from "./components/MeshConnectIframe.js"
|
|
102
|
+
import Modal from "./components/Modal.js"
|
|
103
|
+
import { Pay } from "./components/Pay.js"
|
|
104
|
+
import QRCodeDeposit from "./components/QRCodeDeposit.js"
|
|
105
|
+
import Receipt from "./components/Receipt.js"
|
|
106
|
+
import { Receive } from "./components/Receive.js"
|
|
107
|
+
import { Recipients } from "./components/Recipients.js"
|
|
108
|
+
import { Swap } from "./components/Swap.js"
|
|
109
|
+
import { ThemeProvider } from "./components/ThemeProvider.js"
|
|
132
110
|
import { ThemeSyncer } from "./components/ThemeSyncer.js"
|
|
133
|
-
import {
|
|
134
|
-
import
|
|
111
|
+
import { ToastProvider } from "./components/Toast.js"
|
|
112
|
+
import TokenList from "./components/TokenList.js"
|
|
113
|
+
import TransferPending from "./components/TransferPendingVertical.js"
|
|
114
|
+
import { UserPreferences } from "./components/UserPreferences.js"
|
|
115
|
+
import WalletConfirmation from "./components/WalletConfirmation.js"
|
|
116
|
+
import WalletConnectScreen from "./components/WalletConnect.js"
|
|
117
|
+
import WalletConnectionPending from "./components/WalletConnectionPending.js"
|
|
118
|
+
import { WalletList } from "./components/WalletList.js"
|
|
119
|
+
import { BackProvider, useBack } from "./hooks/useBack.js"
|
|
120
|
+
import { BalanceVisibleProvider } from "./hooks/useBalanceVisible.js"
|
|
121
|
+
import { ChainFilterProvider } from "./hooks/useChainFilter.js"
|
|
122
|
+
import { useCheckout } from "./hooks/useCheckout.js"
|
|
135
123
|
import {
|
|
136
124
|
CurrentScreenProvider,
|
|
137
125
|
useCurrentScreen,
|
|
138
126
|
type Screen,
|
|
139
127
|
} from "./hooks/useCurrentScreen.js"
|
|
140
|
-
import {
|
|
141
|
-
import { useInitialRedirect } from "./hooks/useInitialRedirect.js"
|
|
128
|
+
import { useDebugScreens } from "./hooks/useDebugScreens.js"
|
|
142
129
|
import { DefaultTokenSelectionProvider } from "./hooks/useDefaultTokenSelection.js"
|
|
130
|
+
import { DestinationSelectedTokenProvider } from "./hooks/useDestinationSelectedToken.js"
|
|
131
|
+
import { EarnPoolProvider, useEarnPool } from "./hooks/useEarnPool.js"
|
|
132
|
+
import { useInitialRedirect } from "./hooks/useInitialRedirect.js"
|
|
133
|
+
import { ModeProvider } from "./hooks/useMode.js"
|
|
134
|
+
import {
|
|
135
|
+
OriginSelectedTokenProvider as SelectedTokenProvider,
|
|
136
|
+
useOriginSelectedToken as useSelectedToken,
|
|
137
|
+
type Token,
|
|
138
|
+
} from "./hooks/useOriginSelectedToken.js"
|
|
139
|
+
import { PriceImpactWarningProvider } from "./hooks/usePriceImpactWarning.js"
|
|
140
|
+
import { useRecentTokens } from "./hooks/useRecentTokens.js"
|
|
141
|
+
import { SelectedFeeTokenProvider } from "./hooks/useSelectedFeeToken.js"
|
|
143
142
|
import {
|
|
144
143
|
SelectedMeshExchangeProvider,
|
|
145
144
|
useSelectedMeshExchange,
|
|
146
145
|
} from "./hooks/useSelectedMeshExchange.js"
|
|
147
|
-
import {
|
|
146
|
+
import { SelectedRecipientProvider } from "./hooks/useSelectedRecipient.js"
|
|
147
|
+
import type { OnCompleteProps } from "./hooks/useSendForm.js"
|
|
148
|
+
import { SwapAmountProvider } from "./hooks/useSwapAmount.js"
|
|
149
|
+
import { useTargetAmount } from "./hooks/useTargetAmount.js"
|
|
150
|
+
import { ThemeProvider as ThemePreferenceProvider } from "./hooks/useTheme.js"
|
|
151
|
+
import { useWidgetProps, WidgetPropsProvider } from "./hooks/useWidgetProps.js"
|
|
152
|
+
import {
|
|
153
|
+
SelectedFundMethodProvider,
|
|
154
|
+
useSelectedFundMethod,
|
|
155
|
+
} from "./hooks/useSelectedFundMethod.js"
|
|
156
|
+
import { DEFAULT_MODE } from "../constants.js"
|
|
148
157
|
|
|
149
158
|
export const aaveClient = AaveClient.create()
|
|
150
159
|
|
|
160
|
+
// Modal Context
|
|
161
|
+
interface ModalContextType {
|
|
162
|
+
closeModal: () => void
|
|
163
|
+
isModalOpen: boolean
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const ModalContext = createContext<ModalContextType | null>(null)
|
|
167
|
+
|
|
168
|
+
// Modal Provider Component
|
|
169
|
+
const ModalProvider: React.FC<{
|
|
170
|
+
children: React.ReactNode
|
|
171
|
+
closeModal: () => void
|
|
172
|
+
isModalOpen: boolean
|
|
173
|
+
}> = ({ children, closeModal, isModalOpen }) => (
|
|
174
|
+
<ModalContext.Provider value={{ closeModal, isModalOpen }}>
|
|
175
|
+
{children}
|
|
176
|
+
</ModalContext.Provider>
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
// useModal Hook
|
|
180
|
+
export const useModal = (): ModalContextType => {
|
|
181
|
+
const context = useContext(ModalContext)
|
|
182
|
+
if (!context) {
|
|
183
|
+
// Return a no-op function when not in modal context (e.g., renderInline)
|
|
184
|
+
return {
|
|
185
|
+
closeModal: () => {},
|
|
186
|
+
isModalOpen: false,
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return context
|
|
190
|
+
}
|
|
191
|
+
|
|
151
192
|
// Validate toToken - must be "ETH", "USDC", or a valid hex address
|
|
152
193
|
const isValidToToToken = (toToken: string | null | undefined) => {
|
|
153
194
|
if (toToken === null || toToken === undefined || toToken === "") {
|
|
@@ -178,7 +219,6 @@ export type TrailsWidgetProps = {
|
|
|
178
219
|
renderInline?: boolean
|
|
179
220
|
theme?: Theme
|
|
180
221
|
mode?: Mode
|
|
181
|
-
swapMode?: "simple" | "classic"
|
|
182
222
|
walletOptions?: string[]
|
|
183
223
|
onOriginConfirmation?: (data: {
|
|
184
224
|
txHash: string
|
|
@@ -206,6 +246,7 @@ export type TrailsWidgetProps = {
|
|
|
206
246
|
gasless?: boolean
|
|
207
247
|
buttonText?: string
|
|
208
248
|
customCss?: string | Record<string, string>
|
|
249
|
+
disableCss?: boolean
|
|
209
250
|
quoteProvider?: string
|
|
210
251
|
slippageTolerance?: number | string
|
|
211
252
|
priceImpactWarningThresholdBps?: number
|
|
@@ -245,7 +286,11 @@ const useWalletManager = (
|
|
|
245
286
|
if (!connector) {
|
|
246
287
|
return
|
|
247
288
|
}
|
|
248
|
-
|
|
289
|
+
if (typeof connector?.getProvider !== "function") {
|
|
290
|
+
return
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const activeProvider = await connector.getProvider()
|
|
249
294
|
|
|
250
295
|
if (activeProvider && address && chainId) {
|
|
251
296
|
const chain = getChainInfo(chainId)
|
|
@@ -421,7 +466,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
421
466
|
toCalldata,
|
|
422
467
|
children,
|
|
423
468
|
renderInline = false,
|
|
424
|
-
mode =
|
|
469
|
+
mode = DEFAULT_MODE,
|
|
425
470
|
onOriginConfirmation,
|
|
426
471
|
onDestinationConfirmation,
|
|
427
472
|
onCheckoutStart,
|
|
@@ -441,19 +486,31 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
441
486
|
decoupleWagmi,
|
|
442
487
|
hideDisconnect,
|
|
443
488
|
} = useWidgetProps()
|
|
444
|
-
const { address,
|
|
489
|
+
const { address, chainId, connector } = useAccount()
|
|
490
|
+
// const { setOpenConnectModal } = useOpenConnectModal()
|
|
445
491
|
|
|
446
492
|
// Helper function to detect if the current connector is a Sequence wallet
|
|
447
493
|
const isSequenceWallet = useMemo(() => {
|
|
448
494
|
if (!connector) return false
|
|
449
495
|
const connectorName = connector.name?.toLowerCase() || ""
|
|
450
496
|
const connectorId = connector.id?.toLowerCase() || ""
|
|
451
|
-
|
|
497
|
+
const isSequence =
|
|
452
498
|
connectorName.includes("sequence") || connectorId.includes("sequence")
|
|
453
|
-
|
|
499
|
+
|
|
500
|
+
console.log("[trails-sdk] Sequence wallet detection:", {
|
|
501
|
+
connectorName,
|
|
502
|
+
connectorId,
|
|
503
|
+
isSequence,
|
|
504
|
+
connector: connector.name,
|
|
505
|
+
})
|
|
506
|
+
|
|
507
|
+
return isSequence
|
|
454
508
|
}, [connector])
|
|
455
509
|
const connections = useConnections()
|
|
456
510
|
const { disconnectAsync } = useDisconnect()
|
|
511
|
+
|
|
512
|
+
// Check if there are any connected accounts across all connectors
|
|
513
|
+
const isConnected = connections.length > 0
|
|
457
514
|
const { recentTokens, addRecentToken } = useRecentTokens(address)
|
|
458
515
|
const { wallets: allWallets } = useWallets()
|
|
459
516
|
const { selectedToken, setSelectedToken } = useSelectedToken()
|
|
@@ -461,7 +518,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
461
518
|
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
462
519
|
const [currentMode, setCurrentMode] = useState<Mode>(mode)
|
|
463
520
|
const { currentScreen, setCurrentScreen } = useCurrentScreen()
|
|
464
|
-
const { goBack, clearHistory,
|
|
521
|
+
const { goBack, clearHistory, setCurrentScreenWithBack, getPreviousScreen } =
|
|
465
522
|
useBack()
|
|
466
523
|
|
|
467
524
|
// Wrapper function that clears errors when going back
|
|
@@ -472,7 +529,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
472
529
|
const [previousAddress, setPreviousAddress] = useState<string | undefined>(
|
|
473
530
|
address,
|
|
474
531
|
)
|
|
475
|
-
const
|
|
532
|
+
const { selectedFundMethod, setSelectedFundMethod } = useSelectedFundMethod()
|
|
476
533
|
const { selectedPool, setSelectedPool } = useEarnPool()
|
|
477
534
|
const [selectedWalletId, setSelectedWalletId] = useState<string | null>(
|
|
478
535
|
() => {
|
|
@@ -511,7 +568,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
511
568
|
number | null
|
|
512
569
|
>(null)
|
|
513
570
|
const { connectAsync } = useConnect()
|
|
514
|
-
const [isInitialScreenSet, setIsInitialScreenSet] = useState(false)
|
|
515
571
|
|
|
516
572
|
const getInitialScreenForMode = useCallback((mode: Mode) => {
|
|
517
573
|
if (mode === "swap") {
|
|
@@ -525,54 +581,37 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
525
581
|
} else if (mode === "pay") {
|
|
526
582
|
return "send-form"
|
|
527
583
|
} else {
|
|
528
|
-
return "
|
|
584
|
+
return "send-form"
|
|
529
585
|
}
|
|
530
586
|
}, [])
|
|
531
587
|
|
|
532
|
-
//
|
|
533
|
-
const { hasConnectedBefore } = useInitialRedirect(
|
|
534
|
-
isConnected,
|
|
535
|
-
currentMode,
|
|
536
|
-
getInitialScreenForMode,
|
|
537
|
-
)
|
|
538
|
-
|
|
539
|
-
// Set proper initial screen based on connection state and mode
|
|
588
|
+
// Update currentMode when mode prop changes
|
|
540
589
|
useEffect(() => {
|
|
541
|
-
|
|
542
|
-
return
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
let properInitialScreen: Screen = "connect"
|
|
590
|
+
setCurrentMode(mode)
|
|
546
591
|
|
|
592
|
+
// If connected, navigate to the appropriate screen for the new mode
|
|
547
593
|
if (isConnected) {
|
|
548
|
-
|
|
549
|
-
properInitialScreen = getInitialScreenForMode(currentMode)
|
|
550
|
-
logger.console.log(
|
|
551
|
-
"[trails-sdk] Initial load with connected wallet, going to mode screen:",
|
|
552
|
-
properInitialScreen,
|
|
553
|
-
)
|
|
554
|
-
} else if (currentMode === "receive") {
|
|
555
|
-
properInitialScreen = "receive"
|
|
594
|
+
setCurrentScreen("home")
|
|
556
595
|
}
|
|
596
|
+
}, [mode, isConnected, setCurrentScreen])
|
|
557
597
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
598
|
+
const goHome = useCallback(() => {
|
|
599
|
+
const initialScreen = getInitialScreenForMode(currentMode)
|
|
600
|
+
setCurrentScreen(initialScreen)
|
|
601
|
+
}, [currentMode, setCurrentScreen, getInitialScreenForMode])
|
|
602
|
+
|
|
603
|
+
useEffect(() => {
|
|
604
|
+
if (currentScreen === "home") {
|
|
605
|
+
goHome()
|
|
565
606
|
}
|
|
607
|
+
}, [currentScreen, goHome])
|
|
566
608
|
|
|
567
|
-
|
|
568
|
-
}
|
|
609
|
+
// Use the simple initial redirect hook
|
|
610
|
+
const { hasConnectedBefore } = useInitialRedirect(
|
|
569
611
|
isConnected,
|
|
570
612
|
currentMode,
|
|
571
|
-
currentScreen,
|
|
572
|
-
setCurrentScreen,
|
|
573
|
-
isInitialScreenSet,
|
|
574
613
|
getInitialScreenForMode,
|
|
575
|
-
|
|
614
|
+
)
|
|
576
615
|
|
|
577
616
|
const defaultButtonText = useMemo(() => {
|
|
578
617
|
if (currentMode === "fund") {
|
|
@@ -600,11 +639,27 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
600
639
|
const isValidToToken = isValidToToToken(toToken)
|
|
601
640
|
const isValidToAddress = toAddress ? isAddress(toAddress) : true
|
|
602
641
|
|
|
642
|
+
// Validate paymasterUrls - each url must be a valid URL
|
|
643
|
+
let isValidPaymasterUrls = true
|
|
644
|
+
let invalidPaymasterUrl = ""
|
|
645
|
+
if (paymasterUrls && Array.isArray(paymasterUrls)) {
|
|
646
|
+
for (const paymaster of paymasterUrls) {
|
|
647
|
+
try {
|
|
648
|
+
new URL(paymaster.url)
|
|
649
|
+
} catch {
|
|
650
|
+
isValidPaymasterUrls = false
|
|
651
|
+
invalidPaymasterUrl = paymaster.url
|
|
652
|
+
break
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
603
657
|
if (
|
|
604
658
|
isValidToAmount &&
|
|
605
659
|
isValidToChainId &&
|
|
606
660
|
isValidToToken &&
|
|
607
|
-
isValidToAddress
|
|
661
|
+
isValidToAddress &&
|
|
662
|
+
isValidPaymasterUrls
|
|
608
663
|
) {
|
|
609
664
|
setError(null)
|
|
610
665
|
return
|
|
@@ -648,6 +703,17 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
648
703
|
toAddress,
|
|
649
704
|
)
|
|
650
705
|
setError("Invalid toAddress: must be a valid hex address")
|
|
706
|
+
return
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// Validate paymasterUrls
|
|
710
|
+
if (!isValidPaymasterUrls) {
|
|
711
|
+
logger.console.error(
|
|
712
|
+
"[trails-sdk] Invalid paymasterUrls prop: url must be a valid URL. Received:",
|
|
713
|
+
invalidPaymasterUrl,
|
|
714
|
+
)
|
|
715
|
+
setError("Invalid paymasterUrls: url must be a valid URL")
|
|
716
|
+
return
|
|
651
717
|
}
|
|
652
718
|
|
|
653
719
|
if (currentMode === "fund") {
|
|
@@ -674,7 +740,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
674
740
|
return
|
|
675
741
|
}
|
|
676
742
|
}
|
|
677
|
-
}, [toAmount, toChainId, toToken, currentMode, toAddress])
|
|
743
|
+
}, [toAmount, toChainId, toToken, currentMode, toAddress, paymasterUrls])
|
|
678
744
|
|
|
679
745
|
const walletClient = useWalletManager(address, chainId, connector)
|
|
680
746
|
|
|
@@ -825,28 +891,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
825
891
|
isConnected,
|
|
826
892
|
})
|
|
827
893
|
|
|
828
|
-
// Simple post-connection navigation - let the hook handle the logic
|
|
829
|
-
useEffect(() => {
|
|
830
|
-
if (isNavigatingBack) {
|
|
831
|
-
return
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
// Handle disconnection
|
|
835
|
-
if (!isConnected) {
|
|
836
|
-
if (
|
|
837
|
-
currentScreen !== "connect" &&
|
|
838
|
-
currentScreen !== "wallet-connect" &&
|
|
839
|
-
currentScreen !== "wallet-list" &&
|
|
840
|
-
currentScreen !== "wallet-connection-pending" &&
|
|
841
|
-
currentScreen !== "receive"
|
|
842
|
-
) {
|
|
843
|
-
setTimeout(() => {
|
|
844
|
-
setCurrentScreen("connect")
|
|
845
|
-
}, 0)
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
}, [isConnected, currentScreen, isNavigatingBack, setCurrentScreen])
|
|
849
|
-
|
|
850
894
|
// Auto-detect mode changes and switch screens accordingly
|
|
851
895
|
useEffect(() => {
|
|
852
896
|
if (
|
|
@@ -961,6 +1005,15 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
961
1005
|
"[trails-sdk] Initiating connection to wallet",
|
|
962
1006
|
walletId,
|
|
963
1007
|
)
|
|
1008
|
+
|
|
1009
|
+
// Handle sequence-waas wallet using the openConnectModal hook
|
|
1010
|
+
if (walletId === "sequence-waas") {
|
|
1011
|
+
logger.console.log("[trails-sdk] Opening Sequence WaaS connect modal")
|
|
1012
|
+
// setOpenConnectModal(true)
|
|
1013
|
+
// setIsConnecting(false)
|
|
1014
|
+
return
|
|
1015
|
+
}
|
|
1016
|
+
|
|
964
1017
|
if (config.connector !== walletConnectConnector) {
|
|
965
1018
|
logger.console.log(
|
|
966
1019
|
"[trails-sdk] Initiating connection to walletId",
|
|
@@ -976,21 +1029,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
976
1029
|
// Check if this is the first wallet connection
|
|
977
1030
|
if (!hasConnectedBefore) {
|
|
978
1031
|
// First connection - go to initial screen for the mode
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
"[trails-sdk] First wallet connection, going to initial screen:",
|
|
982
|
-
initialScreen,
|
|
983
|
-
)
|
|
984
|
-
setCurrentScreen(initialScreen)
|
|
1032
|
+
logger.console.log("[trails-sdk] First wallet connection, going home")
|
|
1033
|
+
goHome()
|
|
985
1034
|
} else {
|
|
986
|
-
// Subsequent connection - go to
|
|
1035
|
+
// Subsequent connection - go to home which will route to the appropriate screen
|
|
987
1036
|
logger.console.log(
|
|
988
|
-
"[trails-sdk] Subsequent wallet connection, going to
|
|
989
|
-
)
|
|
990
|
-
setCurrentScreenWithBack(
|
|
991
|
-
"account-settings",
|
|
992
|
-
getInitialScreenForMode(currentMode),
|
|
1037
|
+
"[trails-sdk] Subsequent wallet connection, going to home",
|
|
993
1038
|
)
|
|
1039
|
+
goHome()
|
|
994
1040
|
}
|
|
995
1041
|
} else if (config.connector === walletConnectConnector) {
|
|
996
1042
|
// Store the current connector as previous before switching to WalletConnect
|
|
@@ -1150,7 +1196,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1150
1196
|
const resetState = useCallback(() => {
|
|
1151
1197
|
setSelectedFundMethod("wallet")
|
|
1152
1198
|
// Reset to appropriate screen based on mode
|
|
1153
|
-
setCurrentScreen(
|
|
1199
|
+
setCurrentScreen("home")
|
|
1154
1200
|
setSelectedToken(null)
|
|
1155
1201
|
setSelectedPool(null)
|
|
1156
1202
|
setSelectedWalletId(null)
|
|
@@ -1166,6 +1212,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1166
1212
|
setTotalCompletionSeconds(null)
|
|
1167
1213
|
clearHistory()
|
|
1168
1214
|
}, [
|
|
1215
|
+
setSelectedFundMethod,
|
|
1169
1216
|
setDestinationTxHash,
|
|
1170
1217
|
setDestinationChainId,
|
|
1171
1218
|
setTransactionStates,
|
|
@@ -1173,7 +1220,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1173
1220
|
setOriginChainId,
|
|
1174
1221
|
setSelectedToken,
|
|
1175
1222
|
setSelectedPool,
|
|
1176
|
-
currentMode,
|
|
1177
1223
|
setCurrentScreen,
|
|
1178
1224
|
clearHistory,
|
|
1179
1225
|
])
|
|
@@ -1518,7 +1564,12 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1518
1564
|
setCurrentScreen("wallet-connect")
|
|
1519
1565
|
} else {
|
|
1520
1566
|
saveLastClickedWallet(walletId)
|
|
1521
|
-
|
|
1567
|
+
// Preserve the existing back route from the navigation stack
|
|
1568
|
+
const backRoute = getPreviousScreen()
|
|
1569
|
+
setCurrentScreenWithBack(
|
|
1570
|
+
"wallet-connection-pending",
|
|
1571
|
+
backRoute || undefined,
|
|
1572
|
+
)
|
|
1522
1573
|
// Auto-trigger connection
|
|
1523
1574
|
setTimeout(() => {
|
|
1524
1575
|
handleWalletConnect(walletId)
|
|
@@ -1541,12 +1592,11 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1541
1592
|
onSelectExchangeList={handleSelectExchangeList}
|
|
1542
1593
|
onSelectConnectedAccount={() => {
|
|
1543
1594
|
setSelectedFundMethod("connected-account")
|
|
1544
|
-
|
|
1545
|
-
setCurrentScreen(initialScreen)
|
|
1595
|
+
setCurrentScreen("home")
|
|
1546
1596
|
}}
|
|
1547
1597
|
onSelectQrCode={() => {
|
|
1548
1598
|
setSelectedFundMethod("qr-code")
|
|
1549
|
-
setCurrentScreen(
|
|
1599
|
+
setCurrentScreen("home")
|
|
1550
1600
|
}}
|
|
1551
1601
|
/>
|
|
1552
1602
|
)
|
|
@@ -1566,14 +1616,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1566
1616
|
/>
|
|
1567
1617
|
)
|
|
1568
1618
|
case "send-form":
|
|
1569
|
-
return
|
|
1619
|
+
return (
|
|
1570
1620
|
<Pay
|
|
1571
1621
|
selectedToken={selectedToken}
|
|
1572
1622
|
onSend={handleOnSend}
|
|
1573
1623
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1574
1624
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1575
1625
|
onComplete={handleTransferComplete}
|
|
1576
|
-
account={walletClient
|
|
1626
|
+
account={walletClient?.account}
|
|
1577
1627
|
toRecipient={
|
|
1578
1628
|
selectedPool
|
|
1579
1629
|
? selectedPool.depositAddress
|
|
@@ -1593,7 +1643,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1593
1643
|
toCalldata={
|
|
1594
1644
|
selectedPool ? generatedCalldata : toCalldata || undefined
|
|
1595
1645
|
}
|
|
1596
|
-
walletClient={walletClient}
|
|
1646
|
+
walletClient={walletClient ?? undefined}
|
|
1597
1647
|
isSequenceWallet={isSequenceWallet}
|
|
1598
1648
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1599
1649
|
onError={handleSendError}
|
|
@@ -1634,25 +1684,22 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1634
1684
|
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1635
1685
|
onTrackToken={handleTrackToken}
|
|
1636
1686
|
/>
|
|
1637
|
-
) : (
|
|
1638
|
-
<div className="text-center p-4 rounded-lg text-gray-600 bg-gray-50 dark:text-gray-300 dark:bg-gray-800">
|
|
1639
|
-
Please connect wallet
|
|
1640
|
-
</div>
|
|
1641
1687
|
)
|
|
1642
1688
|
case "fund-form":
|
|
1643
|
-
return
|
|
1689
|
+
return (
|
|
1644
1690
|
<Fund
|
|
1691
|
+
selectedToken={selectedToken}
|
|
1645
1692
|
onSend={handleOnSend}
|
|
1646
1693
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1647
1694
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1648
1695
|
onComplete={handleTransferComplete}
|
|
1649
|
-
account={walletClient
|
|
1696
|
+
account={walletClient?.account}
|
|
1650
1697
|
toAmount={toAmount || undefined}
|
|
1651
1698
|
toRecipient={toAddress || undefined}
|
|
1652
1699
|
toChainId={toChainId ? Number(toChainId) : undefined}
|
|
1653
1700
|
toToken={toToken || undefined}
|
|
1654
1701
|
toCalldata={toCalldata || undefined}
|
|
1655
|
-
walletClient={walletClient}
|
|
1702
|
+
walletClient={walletClient ?? undefined}
|
|
1656
1703
|
isSequenceWallet={isSequenceWallet}
|
|
1657
1704
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1658
1705
|
onError={handleSendError}
|
|
@@ -1667,10 +1714,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1667
1714
|
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1668
1715
|
onTrackToken={handleTrackToken}
|
|
1669
1716
|
/>
|
|
1670
|
-
) : (
|
|
1671
|
-
<div className="text-center p-4 rounded-lg text-gray-600 bg-gray-50 dark:text-gray-300 dark:bg-gray-800">
|
|
1672
|
-
Please connect wallet
|
|
1673
|
-
</div>
|
|
1674
1717
|
)
|
|
1675
1718
|
case "wallet-confirmation":
|
|
1676
1719
|
return (
|
|
@@ -1751,7 +1794,12 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1751
1794
|
)
|
|
1752
1795
|
// Don't reset the redirect flag - user has already been through initial flow
|
|
1753
1796
|
setTimeout(() => {
|
|
1754
|
-
|
|
1797
|
+
// Preserve the existing back route from the navigation stack
|
|
1798
|
+
const backRoute = getPreviousScreen()
|
|
1799
|
+
setCurrentScreenWithBack(
|
|
1800
|
+
"wallet-connection-pending",
|
|
1801
|
+
backRoute || undefined,
|
|
1802
|
+
)
|
|
1755
1803
|
}, 100)
|
|
1756
1804
|
// Auto-trigger connection
|
|
1757
1805
|
setTimeout(() => {
|
|
@@ -1768,11 +1816,11 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1768
1816
|
/>
|
|
1769
1817
|
)
|
|
1770
1818
|
case "earn":
|
|
1771
|
-
return
|
|
1819
|
+
return (
|
|
1772
1820
|
<Earn
|
|
1773
1821
|
onContinue={() => setCurrentScreen("send-form")}
|
|
1774
|
-
account={walletClient
|
|
1775
|
-
walletClient={walletClient}
|
|
1822
|
+
account={walletClient?.account}
|
|
1823
|
+
walletClient={walletClient ?? undefined}
|
|
1776
1824
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1777
1825
|
onError={handleSendError}
|
|
1778
1826
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
@@ -1790,10 +1838,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1790
1838
|
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1791
1839
|
onTrackToken={handleTrackToken}
|
|
1792
1840
|
/>
|
|
1793
|
-
) : (
|
|
1794
|
-
<div className="text-center p-4 rounded-lg text-gray-600 bg-gray-50 dark:text-gray-300 dark:bg-gray-800">
|
|
1795
|
-
Please connect wallet
|
|
1796
|
-
</div>
|
|
1797
1841
|
)
|
|
1798
1842
|
case "earn-pools":
|
|
1799
1843
|
return (
|
|
@@ -1807,20 +1851,21 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1807
1851
|
/>
|
|
1808
1852
|
)
|
|
1809
1853
|
case "swap":
|
|
1810
|
-
return
|
|
1854
|
+
return (
|
|
1811
1855
|
<Swap
|
|
1812
1856
|
onSend={handleOnSend}
|
|
1813
1857
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1814
1858
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1815
1859
|
onComplete={handleTransferComplete}
|
|
1816
1860
|
selectedToken={selectedToken}
|
|
1817
|
-
account={walletClient
|
|
1861
|
+
account={walletClient?.account}
|
|
1818
1862
|
toRecipient={toAddress || undefined}
|
|
1819
1863
|
toAmount={toAmount || undefined}
|
|
1820
1864
|
toChainId={toChainId ? Number(toChainId) : undefined}
|
|
1821
1865
|
toToken={toToken || undefined}
|
|
1822
1866
|
toCalldata={toCalldata || undefined}
|
|
1823
|
-
walletClient={walletClient}
|
|
1867
|
+
walletClient={walletClient ?? undefined}
|
|
1868
|
+
isSequenceWallet={isSequenceWallet}
|
|
1824
1869
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1825
1870
|
onError={handleSendError}
|
|
1826
1871
|
paymasterUrls={paymasterUrls}
|
|
@@ -1835,10 +1880,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1835
1880
|
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1836
1881
|
onTrackToken={handleTrackToken}
|
|
1837
1882
|
/>
|
|
1838
|
-
) : (
|
|
1839
|
-
<div className="text-center p-4 rounded-lg text-gray-600 bg-gray-50 dark:text-gray-300 dark:bg-gray-800">
|
|
1840
|
-
Please connect wallet
|
|
1841
|
-
</div>
|
|
1842
1883
|
)
|
|
1843
1884
|
case "receive":
|
|
1844
1885
|
return (
|
|
@@ -1874,6 +1915,10 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1874
1915
|
/>
|
|
1875
1916
|
)
|
|
1876
1917
|
case "account-settings":
|
|
1918
|
+
if (!isConnected) {
|
|
1919
|
+
setCurrentScreen("connect")
|
|
1920
|
+
return
|
|
1921
|
+
}
|
|
1877
1922
|
return <AccountSettings onBack={handleBack} />
|
|
1878
1923
|
case "user-preferences":
|
|
1879
1924
|
return <UserPreferences onBack={handleBack} />
|
|
@@ -1889,12 +1934,11 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1889
1934
|
/>
|
|
1890
1935
|
)
|
|
1891
1936
|
case "mesh-connect-exchanges":
|
|
1892
|
-
return
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
)
|
|
1937
|
+
return <MeshConnectExchanges onBack={handleBack} />
|
|
1938
|
+
case "home": {
|
|
1939
|
+
// Navigation handled by useEffect above, otherwise it would cause a loop
|
|
1940
|
+
return null
|
|
1941
|
+
}
|
|
1898
1942
|
default:
|
|
1899
1943
|
return null
|
|
1900
1944
|
}
|
|
@@ -1902,68 +1946,70 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1902
1946
|
|
|
1903
1947
|
const renderScreen = () => {
|
|
1904
1948
|
return (
|
|
1905
|
-
<
|
|
1906
|
-
|
|
1907
|
-
mode: currentMode,
|
|
1908
|
-
}}
|
|
1909
|
-
>
|
|
1910
|
-
<PriceImpactWarningProvider
|
|
1949
|
+
<ModalProvider closeModal={handleCloseModal} isModalOpen={isModalOpen}>
|
|
1950
|
+
<ModeProvider
|
|
1911
1951
|
value={{
|
|
1912
|
-
|
|
1913
|
-
warningMessage: priceImpactWarningMessage,
|
|
1914
|
-
fallbackBridgeUrl: priceImpactFallbackBridgeUrl,
|
|
1952
|
+
mode: currentMode,
|
|
1915
1953
|
}}
|
|
1916
1954
|
>
|
|
1917
|
-
<
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
type: "spring",
|
|
1923
|
-
stiffness: 200,
|
|
1924
|
-
damping: 30,
|
|
1925
|
-
mass: 1,
|
|
1955
|
+
<PriceImpactWarningProvider
|
|
1956
|
+
value={{
|
|
1957
|
+
thresholdBps: priceImpactWarningThresholdBps,
|
|
1958
|
+
warningMessage: priceImpactWarningMessage,
|
|
1959
|
+
fallbackBridgeUrl: priceImpactFallbackBridgeUrl,
|
|
1926
1960
|
}}
|
|
1927
|
-
className="flex flex-col min-h-[400px] shadow-xl p-4 sm:p-6 relative w-full sm:w-[400px] mx-auto custom-scrollbar trails-bg-primary trails-text-primary trails-font trails-border-radius-widget trails-widget-border"
|
|
1928
|
-
layout
|
|
1929
|
-
layoutId="modal-container"
|
|
1930
|
-
onClick={(e) => e.stopPropagation()}
|
|
1931
1961
|
>
|
|
1932
|
-
<
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1962
|
+
<motion.div
|
|
1963
|
+
initial={{ opacity: 0, scale: 0.95 }}
|
|
1964
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
1965
|
+
exit={{ opacity: 0, scale: 0.95 }}
|
|
1966
|
+
transition={{
|
|
1967
|
+
type: "spring",
|
|
1968
|
+
stiffness: 200,
|
|
1969
|
+
damping: 30,
|
|
1970
|
+
mass: 1,
|
|
1971
|
+
}}
|
|
1972
|
+
className="flex flex-col min-h-[400px] shadow-xl p-4 sm:p-6 relative w-full sm:w-[400px] mx-auto custom-scrollbar trails-bg-primary trails-text-primary trails-font trails-border-radius-widget trails-widget-border"
|
|
1973
|
+
layout
|
|
1974
|
+
layoutId="modal-container"
|
|
1975
|
+
onClick={(e) => e.stopPropagation()}
|
|
1976
|
+
>
|
|
1977
|
+
<AnimatePresence mode="wait">
|
|
1978
|
+
<motion.div
|
|
1979
|
+
key={currentScreen}
|
|
1980
|
+
initial={{ opacity: 0, x: 20 }}
|
|
1981
|
+
animate={{ opacity: 1, x: 0 }}
|
|
1982
|
+
exit={{ opacity: 0, x: -20 }}
|
|
1983
|
+
transition={{
|
|
1984
|
+
type: "spring",
|
|
1985
|
+
stiffness: 500,
|
|
1986
|
+
damping: 30,
|
|
1987
|
+
mass: 0.6,
|
|
1988
|
+
}}
|
|
1989
|
+
className="flex-1 flex flex-col w-full"
|
|
1990
|
+
layout
|
|
1991
|
+
>
|
|
1992
|
+
{renderScreenContent()}
|
|
1993
|
+
{/* Error Display */}
|
|
1994
|
+
{error && (
|
|
1995
|
+
<div className="mt-2">
|
|
1996
|
+
<ErrorDisplay
|
|
1997
|
+
errorPrettified={getPrettifiedErrorMessage(
|
|
1998
|
+
error,
|
|
1999
|
+
"An error occured",
|
|
2000
|
+
)}
|
|
2001
|
+
error={error}
|
|
2002
|
+
severity="error"
|
|
2003
|
+
/>
|
|
2004
|
+
</div>
|
|
2005
|
+
)}
|
|
2006
|
+
</motion.div>
|
|
2007
|
+
</AnimatePresence>
|
|
2008
|
+
<Footer onDebugScreenSelect={handleDebugScreenSelect} />
|
|
2009
|
+
</motion.div>
|
|
2010
|
+
</PriceImpactWarningProvider>
|
|
2011
|
+
</ModeProvider>
|
|
2012
|
+
</ModalProvider>
|
|
1967
2013
|
)
|
|
1968
2014
|
}
|
|
1969
2015
|
|
|
@@ -2009,8 +2055,7 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2009
2055
|
// Calculate initial screen based on mode and connection state
|
|
2010
2056
|
// Note: We can't use useAccount here as it needs to be inside WagmiProvider
|
|
2011
2057
|
// So we'll use a default and let the WidgetContent handle the logic
|
|
2012
|
-
const initialScreen: Screen =
|
|
2013
|
-
props.mode === "receive" ? "receive" : "connect"
|
|
2058
|
+
const initialScreen: Screen = "home"
|
|
2014
2059
|
|
|
2015
2060
|
return (
|
|
2016
2061
|
<WidgetPropsProvider props={props}>
|
|
@@ -2024,8 +2069,8 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2024
2069
|
<SwapAmountProvider>
|
|
2025
2070
|
<ChainFilterProvider>
|
|
2026
2071
|
<BalanceVisibleProvider>
|
|
2027
|
-
<
|
|
2028
|
-
<
|
|
2072
|
+
<ThemePreferenceProvider>
|
|
2073
|
+
<SelectedFundMethodProvider>
|
|
2029
2074
|
<ThemeSyncer />
|
|
2030
2075
|
<EarnPoolProvider>
|
|
2031
2076
|
<SelectedMeshExchangeProvider>
|
|
@@ -2034,8 +2079,8 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2034
2079
|
</DefaultTokenSelectionProvider>
|
|
2035
2080
|
</SelectedMeshExchangeProvider>
|
|
2036
2081
|
</EarnPoolProvider>
|
|
2037
|
-
</
|
|
2038
|
-
</
|
|
2082
|
+
</SelectedFundMethodProvider>
|
|
2083
|
+
</ThemePreferenceProvider>
|
|
2039
2084
|
</BalanceVisibleProvider>
|
|
2040
2085
|
</ChainFilterProvider>
|
|
2041
2086
|
</SwapAmountProvider>
|
|
@@ -2062,7 +2107,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2062
2107
|
logger.console.warn("appId is deprecated. Use projectAccessKey instead.")
|
|
2063
2108
|
setSequenceProjectAccessKey(props.appId)
|
|
2064
2109
|
}
|
|
2065
|
-
if (props.sequenceEnv) {
|
|
2110
|
+
if (props.sequenceEnv && props.sequenceEnv !== getSequenceEnv()) {
|
|
2066
2111
|
logger.console.log("props.sequenceEnv", props.sequenceEnv)
|
|
2067
2112
|
setSequenceEnv(props.sequenceEnv)
|
|
2068
2113
|
}
|
|
@@ -2100,7 +2145,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2100
2145
|
logger.console.log("props.slippageTolerance", props.slippageTolerance)
|
|
2101
2146
|
setSlippageTolerance(String(props.slippageTolerance))
|
|
2102
2147
|
}
|
|
2103
|
-
if (typeof props.debug === "boolean") {
|
|
2148
|
+
if (typeof props.debug === "boolean" && props.debug !== getDebug()) {
|
|
2104
2149
|
logger.console.log("props.debug", props.debug)
|
|
2105
2150
|
setDebug(props.debug)
|
|
2106
2151
|
}
|
|
@@ -2169,12 +2214,6 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2169
2214
|
},
|
|
2170
2215
|
}
|
|
2171
2216
|
|
|
2172
|
-
logger.console.log("[trails-sdk] sequenceConfig", sequenceConfig)
|
|
2173
|
-
logger.console.log(
|
|
2174
|
-
"[trails-sdk] props.decoupleWagmi",
|
|
2175
|
-
props.decoupleWagmi,
|
|
2176
|
-
)
|
|
2177
|
-
|
|
2178
2217
|
if (props.decoupleWagmi) {
|
|
2179
2218
|
return (
|
|
2180
2219
|
<AaveProvider client={aaveClient}>
|
|
@@ -2231,6 +2270,10 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2231
2270
|
return props.customCss
|
|
2232
2271
|
}, [props.customCss])
|
|
2233
2272
|
|
|
2273
|
+
if (props.disableCss) {
|
|
2274
|
+
return <StrictMode>{content}</StrictMode>
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2234
2277
|
return (
|
|
2235
2278
|
<ShadowPortal customCss={customCss}>
|
|
2236
2279
|
<StrictMode>{content}</StrictMode>
|