0xtrails 0.2.2 → 0.2.5
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/{ccip-ConT1gDe.js → ccip-CXlshvBY.js} +1 -1
- package/dist/chains.d.ts +5 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -4
- 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/{index-CMh8uEbV.js → index-_QuyGrjU.js} +86304 -83380
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/intentEntrypoint.d.ts +0 -8
- package/dist/intentEntrypoint.d.ts.map +1 -1
- package/dist/intents.d.ts +40 -0
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts +5 -4
- 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 +16 -6
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/queryParams.d.ts.map +1 -1
- package/dist/relayer.d.ts +10 -7
- package/dist/relayer.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +7 -0
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +2 -2
- package/dist/trails.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/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +2 -0
- 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/Earn.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +1 -0
- 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} +11 -5
- 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/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +1 -0
- 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} +11 -34
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -0
- package/dist/widget/components/{SimpleSwap.d.ts → PoolWithdraw.d.ts} +16 -8
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -0
- package/dist/widget/components/QuoteDetails.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/RefundWarning.d.ts +1 -0
- package/dist/widget/components/RefundWarning.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 +1 -0
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.d.ts.map +1 -1
- 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/UserPreferences.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +8 -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/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 +6 -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/useInitialRedirect.d.ts +7 -0
- package/dist/widget/hooks/useInitialRedirect.d.ts.map +1 -0
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts +4 -4
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +30 -23
- package/src/aave.ts +32 -0
- package/src/chains.ts +23 -3
- package/src/config.ts +12 -4
- package/src/constants.ts +11 -16
- package/src/error.ts +20 -2
- package/src/estimate.ts +416 -5
- package/src/index.ts +8 -3
- package/src/intentEntrypoint.ts +0 -15
- package/src/intents.ts +161 -11
- package/src/metaTxnMonitor.ts +28 -22
- package/src/metaTxns.ts +3 -3
- package/src/morpho.ts +32 -0
- package/src/prepareSend.ts +710 -458
- package/src/queryParams.ts +2 -1
- package/src/relayer.ts +15 -16
- package/src/sequenceWallet.ts +7 -3
- package/src/tokenBalances.ts +47 -0
- package/src/tokens.ts +17 -1
- package/src/trails.ts +2 -2
- package/src/wallets.ts +8 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +9 -15
- package/src/widget/components/AccountIntentTransactionHistory.tsx +1 -1
- package/src/widget/components/AccountSettings.tsx +10 -27
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +1 -1
- package/src/widget/components/ClassicSwap.tsx +111 -155
- package/src/widget/components/ConnectWallet.tsx +10 -39
- package/src/widget/components/ConnectedWallets.tsx +113 -58
- package/src/widget/components/Earn.tsx +73 -589
- package/src/widget/components/EarnPools.tsx +2 -1
- package/src/widget/components/Fund.tsx +81 -109
- package/src/widget/components/FundMethods.tsx +82 -159
- package/src/widget/components/FundSwap.tsx +52 -0
- package/src/widget/components/FundingMethodSelectorButton.tsx +60 -0
- package/src/widget/components/Modal.tsx +6 -2
- package/src/widget/components/Pay.tsx +198 -200
- package/src/widget/components/PercentageMaxButtons.tsx +77 -0
- package/src/widget/components/PoolDeposit.tsx +593 -0
- package/src/widget/components/PoolWithdraw.tsx +903 -0
- package/src/widget/components/QuoteDetails.tsx +22 -8
- package/src/widget/components/Receive.tsx +1 -3
- package/src/widget/components/RecipientSelectorButton.tsx +42 -0
- package/src/widget/components/Recipients.tsx +64 -156
- package/src/widget/components/RefundWarning.tsx +5 -1
- package/src/widget/components/RequiredPropsError.tsx +33 -0
- package/src/widget/components/ScreenHeader.tsx +5 -1
- package/src/widget/components/SlippageToleranceSettings.tsx +2 -1
- package/src/widget/components/Swap.tsx +2 -43
- package/src/widget/components/SwapSettings.tsx +3 -15
- package/src/widget/components/TokenImage.tsx +21 -4
- package/src/widget/components/TokenList.tsx +0 -1
- package/src/widget/components/TokenSelector.tsx +2 -1
- package/src/widget/components/TokenSelectorButton.tsx +75 -0
- package/src/widget/components/UserPreferences.tsx +6 -24
- package/src/widget/components/WaasFeeOptions.tsx +331 -0
- package/src/widget/components/WalletConfirmation.tsx +55 -3
- package/src/widget/components/WalletList.tsx +7 -5
- package/src/widget/hooks/useBack.tsx +113 -9
- 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/useInitialRedirect.tsx +70 -0
- package/src/widget/hooks/usePayMessage.tsx +86 -11
- package/src/widget/hooks/useSelectedFeeToken.tsx +10 -16
- package/src/widget/hooks/useSelectedFundMethod.tsx +41 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +10 -0
- package/src/widget/hooks/useSendForm.ts +34 -12
- package/src/widget/hooks/useTokenList.ts +1 -1
- package/src/widget/index.css +27 -0
- package/src/widget/widget.tsx +245 -208
- 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/dist/{style.css → 0xtrails.css} +0 -0
package/src/widget/widget.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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, {
|
|
@@ -9,51 +10,30 @@ import React, {
|
|
|
9
10
|
useContext,
|
|
10
11
|
useEffect,
|
|
11
12
|
useImperativeHandle,
|
|
13
|
+
useMemo,
|
|
12
14
|
useRef,
|
|
13
15
|
useState,
|
|
14
|
-
useMemo,
|
|
15
16
|
} from "react"
|
|
16
17
|
import { createPortal } from "react-dom"
|
|
17
18
|
import type { Chain, WalletClient } from "viem"
|
|
18
|
-
import {
|
|
19
|
-
|
|
19
|
+
import {
|
|
20
|
+
createWalletClient,
|
|
21
|
+
custom,
|
|
22
|
+
encodeFunctionData,
|
|
23
|
+
http,
|
|
24
|
+
isAddress,
|
|
25
|
+
} from "viem"
|
|
20
26
|
import type { Connector } from "wagmi"
|
|
21
27
|
import {
|
|
22
28
|
createConfig,
|
|
23
29
|
createStorage,
|
|
24
30
|
useAccount,
|
|
25
31
|
useConnect,
|
|
32
|
+
useConnections,
|
|
26
33
|
useDisconnect,
|
|
27
34
|
WagmiContext,
|
|
28
35
|
WagmiProvider,
|
|
29
36
|
} from "wagmi"
|
|
30
|
-
import { getChainInfo, getRpcUrl } from "../chains.js"
|
|
31
|
-
import type { TransactionState } from "../transactions.js"
|
|
32
|
-
import type { RelayerEnv, MetaTxnReceipt } from "../relayer.js"
|
|
33
|
-
import type { Theme } from "../theme.js"
|
|
34
|
-
import { ConnectWallet } from "./components/ConnectWallet.js"
|
|
35
|
-
import Footer from "./components/Footer.js"
|
|
36
|
-
import Modal from "./components/Modal.js"
|
|
37
|
-
import Receipt from "./components/Receipt.js"
|
|
38
|
-
import { WalletList } from "./components/WalletList.js"
|
|
39
|
-
import { Pay } from "./components/Pay.js"
|
|
40
|
-
import TokenList from "./components/TokenList.js"
|
|
41
|
-
import TransferPending from "./components/TransferPendingVertical.js"
|
|
42
|
-
import WalletConfirmation from "./components/WalletConfirmation.js"
|
|
43
|
-
import QRCodeDeposit from "./components/QRCodeDeposit.js"
|
|
44
|
-
import { ThemeProvider } from "./components/ThemeProvider.js"
|
|
45
|
-
import { ToastProvider } from "./components/Toast.js"
|
|
46
|
-
import {
|
|
47
|
-
getCommitHash,
|
|
48
|
-
getSequenceNodeGatewayUrl,
|
|
49
|
-
setWalletConnectProjectId,
|
|
50
|
-
setSequenceNodeGatewayUrl,
|
|
51
|
-
getSequenceEnv,
|
|
52
|
-
} from "../config.js"
|
|
53
|
-
import { useRecentTokens } from "./hooks/useRecentTokens.js"
|
|
54
|
-
import { useTargetAmount } from "./hooks/useTargetAmount.js"
|
|
55
|
-
import { getWethAddress } from "../tokens.js"
|
|
56
|
-
import css from "./compiled.css?inline"
|
|
57
37
|
import {
|
|
58
38
|
getAnalytics,
|
|
59
39
|
getSessionId,
|
|
@@ -61,88 +41,117 @@ import {
|
|
|
61
41
|
trackWalletDisconnected,
|
|
62
42
|
trackWidgetScreen,
|
|
63
43
|
} from "../analytics.js"
|
|
64
|
-
import
|
|
65
|
-
import type { SupportedToken } from "../tokens.js"
|
|
44
|
+
import { getAllChains, getChainInfo, getRpcUrl } from "../chains.js"
|
|
66
45
|
import {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
getFullErrorMessage,
|
|
70
|
-
getIsApiError,
|
|
71
|
-
getIsRateLimitedError,
|
|
72
|
-
getPrettifiedErrorMessage,
|
|
73
|
-
} from "../error.js"
|
|
74
|
-
import {
|
|
75
|
-
setSequenceIndexerUrl,
|
|
76
|
-
setSequenceApiUrl,
|
|
77
|
-
setTrailsApiUrl,
|
|
78
|
-
setSequenceProjectAccessKey,
|
|
79
|
-
getSequenceIndexerUrl,
|
|
46
|
+
getCommitHash,
|
|
47
|
+
getDebug,
|
|
80
48
|
getSequenceApiUrl,
|
|
49
|
+
getSequenceEnv,
|
|
50
|
+
getSequenceIndexerUrl,
|
|
51
|
+
getSequenceNodeGatewayUrl,
|
|
52
|
+
getSequenceProjectAccessKey,
|
|
81
53
|
getTrailsApiUrl,
|
|
54
|
+
setDebug,
|
|
55
|
+
setSequenceApiUrl,
|
|
82
56
|
setSequenceEnv,
|
|
57
|
+
setSequenceIndexerUrl,
|
|
58
|
+
setSequenceNodeGatewayUrl,
|
|
59
|
+
setSequenceProjectAccessKey,
|
|
83
60
|
setSlippageTolerance,
|
|
84
|
-
|
|
85
|
-
|
|
61
|
+
setTrailsApiUrl,
|
|
62
|
+
setWalletConnectProjectId,
|
|
86
63
|
} from "../config.js"
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
import
|
|
97
|
-
import WalletConnectionPending from "./components/WalletConnectionPending.js"
|
|
98
|
-
import { AccountIntentTransactionHistory } from "./components/AccountIntentTransactionHistory.js"
|
|
99
|
-
import { AccountSettings } from "./components/AccountSettings.js"
|
|
100
|
-
import { UserPreferences } from "./components/UserPreferences.js"
|
|
64
|
+
import { cssObjectToString } from "../cssUtils.js"
|
|
65
|
+
import {
|
|
66
|
+
getFullErrorMessage,
|
|
67
|
+
getIsApiError,
|
|
68
|
+
getIsBalanceTooLowError,
|
|
69
|
+
getIsRateLimitedError,
|
|
70
|
+
getIsWalletRejectedError,
|
|
71
|
+
getPrettifiedErrorMessage,
|
|
72
|
+
} from "../error.js"
|
|
73
|
+
import { logger } from "../logger.js"
|
|
101
74
|
import type { Mode } from "../mode.js"
|
|
102
|
-
import type { OnCompleteProps } from "./hooks/useSendForm.js"
|
|
103
75
|
import type { Pool } from "../pools.js"
|
|
104
76
|
import { usePools } from "../pools.js"
|
|
105
|
-
import {
|
|
106
|
-
import {
|
|
107
|
-
import {
|
|
108
|
-
import {
|
|
109
|
-
import {
|
|
110
|
-
import {
|
|
111
|
-
import {
|
|
112
|
-
import {
|
|
113
|
-
import {
|
|
114
|
-
import
|
|
115
|
-
import {
|
|
77
|
+
import type { PrepareSendQuote } from "../prepareSend.js"
|
|
78
|
+
import { isValidInteger, isValidNumeric } from "../prices.js"
|
|
79
|
+
import type { MetaTxnReceipt, RelayerEnv } from "../relayer.js"
|
|
80
|
+
import type { Theme } from "../theme.js"
|
|
81
|
+
import type { SupportedToken } from "../tokens.js"
|
|
82
|
+
import { getWethAddress } from "../tokens.js"
|
|
83
|
+
import type { TransactionState } from "../transactions.js"
|
|
84
|
+
import { connectors, useWallets, walletConnectConnector } from "../wallets.js"
|
|
85
|
+
// import { useOpenConnectModal } from "@0xsequence/connect"
|
|
86
|
+
import css from "./compiled.css?inline"
|
|
87
|
+
import { AccountIntentTransactionHistory } from "./components/AccountIntentTransactionHistory.js"
|
|
88
|
+
import { AccountSettings } from "./components/AccountSettings.js"
|
|
116
89
|
import { ChainList } from "./components/ChainList.js"
|
|
90
|
+
import { ConnectWallet } from "./components/ConnectWallet.js"
|
|
117
91
|
import { Disconnect } from "./components/Disconnect.js"
|
|
118
|
-
import {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} from "./
|
|
123
|
-
import
|
|
124
|
-
import {
|
|
125
|
-
import {
|
|
126
|
-
import {
|
|
127
|
-
import
|
|
128
|
-
import {
|
|
129
|
-
import
|
|
130
|
-
import
|
|
92
|
+
import { Earn } from "./components/Earn.js"
|
|
93
|
+
import EarnPools from "./components/EarnPools.js"
|
|
94
|
+
import { ErrorDisplay } from "./components/ErrorDisplay.js"
|
|
95
|
+
import Footer from "./components/Footer.js"
|
|
96
|
+
import { Fund } from "./components/FundSwap.js"
|
|
97
|
+
import FundMethods from "./components/FundMethods.js"
|
|
98
|
+
import { MeshConnectExchanges } from "./components/MeshConnectExchanges.js"
|
|
99
|
+
import { MeshConnectFlow } from "./components/MeshConnectFlow.js"
|
|
100
|
+
import type { MeshConnectProps } from "./components/MeshConnectIframe.js"
|
|
101
|
+
import Modal from "./components/Modal.js"
|
|
102
|
+
import { Pay } from "./components/Pay.js"
|
|
103
|
+
import QRCodeDeposit from "./components/QRCodeDeposit.js"
|
|
104
|
+
import Receipt from "./components/Receipt.js"
|
|
105
|
+
import { Receive } from "./components/Receive.js"
|
|
106
|
+
import { Recipients } from "./components/Recipients.js"
|
|
107
|
+
import { Swap } from "./components/Swap.js"
|
|
108
|
+
import { ThemeProvider } from "./components/ThemeProvider.js"
|
|
131
109
|
import { ThemeSyncer } from "./components/ThemeSyncer.js"
|
|
132
|
-
import {
|
|
133
|
-
import
|
|
110
|
+
import { ToastProvider } from "./components/Toast.js"
|
|
111
|
+
import TokenList from "./components/TokenList.js"
|
|
112
|
+
import TransferPending from "./components/TransferPendingVertical.js"
|
|
113
|
+
import { UserPreferences } from "./components/UserPreferences.js"
|
|
114
|
+
import WalletConfirmation from "./components/WalletConfirmation.js"
|
|
115
|
+
import WalletConnectScreen from "./components/WalletConnect.js"
|
|
116
|
+
import WalletConnectionPending from "./components/WalletConnectionPending.js"
|
|
117
|
+
import { WalletList } from "./components/WalletList.js"
|
|
118
|
+
import { BackProvider, useBack } from "./hooks/useBack.js"
|
|
119
|
+
import { BalanceVisibleProvider } from "./hooks/useBalanceVisible.js"
|
|
120
|
+
import { ChainFilterProvider } from "./hooks/useChainFilter.js"
|
|
121
|
+
import { useCheckout } from "./hooks/useCheckout.js"
|
|
134
122
|
import {
|
|
135
123
|
CurrentScreenProvider,
|
|
136
124
|
useCurrentScreen,
|
|
137
125
|
type Screen,
|
|
138
126
|
} from "./hooks/useCurrentScreen.js"
|
|
139
|
-
import {
|
|
127
|
+
import { useDebugScreens } from "./hooks/useDebugScreens.js"
|
|
140
128
|
import { DefaultTokenSelectionProvider } from "./hooks/useDefaultTokenSelection.js"
|
|
129
|
+
import { DestinationSelectedTokenProvider } from "./hooks/useDestinationSelectedToken.js"
|
|
130
|
+
import { EarnPoolProvider, useEarnPool } from "./hooks/useEarnPool.js"
|
|
131
|
+
import { useInitialRedirect } from "./hooks/useInitialRedirect.js"
|
|
132
|
+
import { ModeProvider } from "./hooks/useMode.js"
|
|
133
|
+
import {
|
|
134
|
+
OriginSelectedTokenProvider as SelectedTokenProvider,
|
|
135
|
+
useOriginSelectedToken as useSelectedToken,
|
|
136
|
+
type Token,
|
|
137
|
+
} from "./hooks/useOriginSelectedToken.js"
|
|
138
|
+
import { PriceImpactWarningProvider } from "./hooks/usePriceImpactWarning.js"
|
|
139
|
+
import { useRecentTokens } from "./hooks/useRecentTokens.js"
|
|
140
|
+
import { SelectedFeeTokenProvider } from "./hooks/useSelectedFeeToken.js"
|
|
141
141
|
import {
|
|
142
142
|
SelectedMeshExchangeProvider,
|
|
143
143
|
useSelectedMeshExchange,
|
|
144
144
|
} from "./hooks/useSelectedMeshExchange.js"
|
|
145
|
-
import {
|
|
145
|
+
import { SelectedRecipientProvider } from "./hooks/useSelectedRecipient.js"
|
|
146
|
+
import type { OnCompleteProps } from "./hooks/useSendForm.js"
|
|
147
|
+
import { SwapAmountProvider } from "./hooks/useSwapAmount.js"
|
|
148
|
+
import { useTargetAmount } from "./hooks/useTargetAmount.js"
|
|
149
|
+
import { ThemeProvider as ThemePreferenceProvider } from "./hooks/useTheme.js"
|
|
150
|
+
import { useWidgetProps, WidgetPropsProvider } from "./hooks/useWidgetProps.js"
|
|
151
|
+
import {
|
|
152
|
+
SelectedFundMethodProvider,
|
|
153
|
+
useSelectedFundMethod,
|
|
154
|
+
} from "./hooks/useSelectedFundMethod.js"
|
|
146
155
|
|
|
147
156
|
export const aaveClient = AaveClient.create()
|
|
148
157
|
|
|
@@ -176,7 +185,6 @@ export type TrailsWidgetProps = {
|
|
|
176
185
|
renderInline?: boolean
|
|
177
186
|
theme?: Theme
|
|
178
187
|
mode?: Mode
|
|
179
|
-
swapMode?: "simple" | "classic"
|
|
180
188
|
walletOptions?: string[]
|
|
181
189
|
onOriginConfirmation?: (data: {
|
|
182
190
|
txHash: string
|
|
@@ -204,6 +212,7 @@ export type TrailsWidgetProps = {
|
|
|
204
212
|
gasless?: boolean
|
|
205
213
|
buttonText?: string
|
|
206
214
|
customCss?: string | Record<string, string>
|
|
215
|
+
disableCss?: boolean
|
|
207
216
|
quoteProvider?: string
|
|
208
217
|
slippageTolerance?: number | string
|
|
209
218
|
priceImpactWarningThresholdBps?: number
|
|
@@ -440,6 +449,26 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
440
449
|
hideDisconnect,
|
|
441
450
|
} = useWidgetProps()
|
|
442
451
|
const { address, isConnected, chainId, connector } = useAccount()
|
|
452
|
+
// const { setOpenConnectModal } = useOpenConnectModal()
|
|
453
|
+
|
|
454
|
+
// Helper function to detect if the current connector is a Sequence wallet
|
|
455
|
+
const isSequenceWallet = useMemo(() => {
|
|
456
|
+
if (!connector) return false
|
|
457
|
+
const connectorName = connector.name?.toLowerCase() || ""
|
|
458
|
+
const connectorId = connector.id?.toLowerCase() || ""
|
|
459
|
+
const isSequence =
|
|
460
|
+
connectorName.includes("sequence") || connectorId.includes("sequence")
|
|
461
|
+
|
|
462
|
+
console.log("[trails-sdk] Sequence wallet detection:", {
|
|
463
|
+
connectorName,
|
|
464
|
+
connectorId,
|
|
465
|
+
isSequence,
|
|
466
|
+
connector: connector.name,
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
return isSequence
|
|
470
|
+
}, [connector])
|
|
471
|
+
const connections = useConnections()
|
|
443
472
|
const { disconnectAsync } = useDisconnect()
|
|
444
473
|
const { recentTokens, addRecentToken } = useRecentTokens(address)
|
|
445
474
|
const { wallets: allWallets } = useWallets()
|
|
@@ -449,15 +478,22 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
449
478
|
const [currentMode, setCurrentMode] = useState<Mode>(mode)
|
|
450
479
|
const { currentScreen, setCurrentScreen } = useCurrentScreen()
|
|
451
480
|
const {
|
|
452
|
-
goBack
|
|
481
|
+
goBack,
|
|
453
482
|
clearHistory,
|
|
454
483
|
isNavigatingBack,
|
|
455
|
-
|
|
484
|
+
setCurrentScreenWithBack,
|
|
485
|
+
getPreviousScreen,
|
|
456
486
|
} = useBack()
|
|
487
|
+
|
|
488
|
+
// Wrapper function that clears errors when going back
|
|
489
|
+
const handleBack = () => {
|
|
490
|
+
setError(null)
|
|
491
|
+
goBack?.()
|
|
492
|
+
}
|
|
457
493
|
const [previousAddress, setPreviousAddress] = useState<string | undefined>(
|
|
458
494
|
address,
|
|
459
495
|
)
|
|
460
|
-
const
|
|
496
|
+
const { selectedFundMethod, setSelectedFundMethod } = useSelectedFundMethod()
|
|
461
497
|
const { selectedPool, setSelectedPool } = useEarnPool()
|
|
462
498
|
const [selectedWalletId, setSelectedWalletId] = useState<string | null>(
|
|
463
499
|
() => {
|
|
@@ -514,6 +550,24 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
514
550
|
}
|
|
515
551
|
}, [])
|
|
516
552
|
|
|
553
|
+
// Update currentMode when mode prop changes
|
|
554
|
+
useEffect(() => {
|
|
555
|
+
setCurrentMode(mode)
|
|
556
|
+
|
|
557
|
+
// If connected, navigate to the appropriate screen for the new mode
|
|
558
|
+
if (isConnected) {
|
|
559
|
+
const newScreen = getInitialScreenForMode(mode)
|
|
560
|
+
setCurrentScreen(newScreen)
|
|
561
|
+
}
|
|
562
|
+
}, [mode, isConnected, setCurrentScreen, getInitialScreenForMode])
|
|
563
|
+
|
|
564
|
+
// Use the simple initial redirect hook
|
|
565
|
+
const { hasConnectedBefore } = useInitialRedirect(
|
|
566
|
+
isConnected,
|
|
567
|
+
currentMode,
|
|
568
|
+
getInitialScreenForMode,
|
|
569
|
+
)
|
|
570
|
+
|
|
517
571
|
// Set proper initial screen based on connection state and mode
|
|
518
572
|
useEffect(() => {
|
|
519
573
|
if (isInitialScreenSet) {
|
|
@@ -521,8 +575,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
521
575
|
}
|
|
522
576
|
|
|
523
577
|
let properInitialScreen: Screen = "connect"
|
|
578
|
+
|
|
524
579
|
if (isConnected) {
|
|
580
|
+
// For initial load, always go to the appropriate mode screen
|
|
525
581
|
properInitialScreen = getInitialScreenForMode(currentMode)
|
|
582
|
+
logger.console.log(
|
|
583
|
+
"[trails-sdk] Initial load with connected wallet, going to mode screen:",
|
|
584
|
+
properInitialScreen,
|
|
585
|
+
)
|
|
526
586
|
} else if (currentMode === "receive") {
|
|
527
587
|
properInitialScreen = "receive"
|
|
528
588
|
}
|
|
@@ -797,76 +857,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
797
857
|
isConnected,
|
|
798
858
|
})
|
|
799
859
|
|
|
800
|
-
//
|
|
801
|
-
const [alreadyRedirectedToTokens, setAlreadyRedirectedToTokens] =
|
|
802
|
-
useState(false)
|
|
803
|
-
|
|
804
|
-
// Update screen based on connection state and mode
|
|
860
|
+
// Simple post-connection navigation - let the hook handle the logic
|
|
805
861
|
useEffect(() => {
|
|
806
862
|
if (isNavigatingBack) {
|
|
807
863
|
return
|
|
808
864
|
}
|
|
809
|
-
if (isConnected) {
|
|
810
|
-
if (
|
|
811
|
-
currentScreen === "connect" ||
|
|
812
|
-
currentScreen === "wallet-list" ||
|
|
813
|
-
currentScreen === "wallet-connection-pending"
|
|
814
|
-
) {
|
|
815
|
-
if (!alreadyRedirectedToTokens) {
|
|
816
|
-
setAlreadyRedirectedToTokens(true)
|
|
817
|
-
const history = getHistory()
|
|
818
|
-
logger.console.log(
|
|
819
|
-
"[trails-sdk] Post-connection navigation triggered",
|
|
820
|
-
{
|
|
821
|
-
currentScreen,
|
|
822
|
-
alreadyRedirectedToTokens,
|
|
823
|
-
isConnected,
|
|
824
|
-
currentMode,
|
|
825
|
-
history,
|
|
826
|
-
},
|
|
827
|
-
)
|
|
828
|
-
|
|
829
|
-
// Check if we came from account-settings -> wallet-list pattern
|
|
830
|
-
// Look for this pattern in the last 4-5 screens to handle any intermediate screens
|
|
831
|
-
const historyLength = history.length
|
|
832
|
-
logger.console.log("[trails-sdk] Full navigation history:", history)
|
|
833
|
-
|
|
834
|
-
// Iterate from older to newer screens to find the pattern
|
|
835
|
-
let foundAccountSettings = false
|
|
836
|
-
let foundWalletListAfterAccountSettings = false
|
|
837
|
-
|
|
838
|
-
for (
|
|
839
|
-
let i = Math.max(0, historyLength - 5);
|
|
840
|
-
i < historyLength - 1;
|
|
841
|
-
i++
|
|
842
|
-
) {
|
|
843
|
-
if (history[i] === "account-settings") {
|
|
844
|
-
foundAccountSettings = true
|
|
845
|
-
}
|
|
846
|
-
if (history[i] === "wallet-list" && foundAccountSettings) {
|
|
847
|
-
foundWalletListAfterAccountSettings = true
|
|
848
|
-
break // Found the pattern, no need to continue
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
if (foundAccountSettings && foundWalletListAfterAccountSettings) {
|
|
853
|
-
logger.console.log(
|
|
854
|
-
"[trails-sdk] Came from account-settings -> wallet-list flow, returning to account-settings",
|
|
855
|
-
)
|
|
856
|
-
setCurrentScreen("account-settings")
|
|
857
|
-
return
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
console.log(
|
|
861
|
-
"[trails-sdk] Using default navigation for mode:",
|
|
862
|
-
currentMode,
|
|
863
|
-
)
|
|
864
865
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
} else {
|
|
866
|
+
// Handle disconnection
|
|
867
|
+
if (!isConnected) {
|
|
870
868
|
if (
|
|
871
869
|
currentScreen !== "connect" &&
|
|
872
870
|
currentScreen !== "wallet-connect" &&
|
|
@@ -879,25 +877,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
879
877
|
}, 0)
|
|
880
878
|
}
|
|
881
879
|
}
|
|
882
|
-
}, [
|
|
883
|
-
isConnected,
|
|
884
|
-
currentScreen,
|
|
885
|
-
alreadyRedirectedToTokens,
|
|
886
|
-
currentMode,
|
|
887
|
-
isNavigatingBack,
|
|
888
|
-
setCurrentScreen,
|
|
889
|
-
getHistory,
|
|
890
|
-
getInitialScreenForMode,
|
|
891
|
-
])
|
|
892
|
-
|
|
893
|
-
useEffect(() => {
|
|
894
|
-
if (
|
|
895
|
-
currentScreen === "wallet-connection-pending" &&
|
|
896
|
-
alreadyRedirectedToTokens
|
|
897
|
-
) {
|
|
898
|
-
setAlreadyRedirectedToTokens(false)
|
|
899
|
-
}
|
|
900
|
-
}, [currentScreen, alreadyRedirectedToTokens])
|
|
880
|
+
}, [isConnected, currentScreen, isNavigatingBack, setCurrentScreen])
|
|
901
881
|
|
|
902
882
|
// Auto-detect mode changes and switch screens accordingly
|
|
903
883
|
useEffect(() => {
|
|
@@ -1003,13 +983,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1003
983
|
setError(null)
|
|
1004
984
|
setIsConnecting(true)
|
|
1005
985
|
|
|
1006
|
-
// Handle special case for wallet-list screen
|
|
1007
|
-
if (walletId === "wallet-list") {
|
|
1008
|
-
setCurrentScreen("wallet-list")
|
|
1009
|
-
setIsConnecting(false)
|
|
1010
|
-
return
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
986
|
const config = allWallets.find((w) => w.id === walletId)
|
|
1014
987
|
if (!config) {
|
|
1015
988
|
setError(`No configuration found for wallet: ${walletId}`)
|
|
@@ -1020,6 +993,15 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1020
993
|
"[trails-sdk] Initiating connection to wallet",
|
|
1021
994
|
walletId,
|
|
1022
995
|
)
|
|
996
|
+
|
|
997
|
+
// Handle sequence-waas wallet using the openConnectModal hook
|
|
998
|
+
if (walletId === "sequence-waas") {
|
|
999
|
+
logger.console.log("[trails-sdk] Opening Sequence WaaS connect modal")
|
|
1000
|
+
// setOpenConnectModal(true)
|
|
1001
|
+
// setIsConnecting(false)
|
|
1002
|
+
return
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1023
1005
|
if (config.connector !== walletConnectConnector) {
|
|
1024
1006
|
logger.console.log(
|
|
1025
1007
|
"[trails-sdk] Initiating connection to walletId",
|
|
@@ -1031,6 +1013,26 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1031
1013
|
)
|
|
1032
1014
|
// Set the last clicked wallet after successful connection
|
|
1033
1015
|
saveLastClickedWallet(walletId)
|
|
1016
|
+
|
|
1017
|
+
// Check if this is the first wallet connection
|
|
1018
|
+
if (!hasConnectedBefore) {
|
|
1019
|
+
// First connection - go to initial screen for the mode
|
|
1020
|
+
const initialScreen = getInitialScreenForMode(currentMode)
|
|
1021
|
+
logger.console.log(
|
|
1022
|
+
"[trails-sdk] First wallet connection, going to initial screen:",
|
|
1023
|
+
initialScreen,
|
|
1024
|
+
)
|
|
1025
|
+
setCurrentScreen(initialScreen)
|
|
1026
|
+
} else {
|
|
1027
|
+
// Subsequent connection - go to account-settings
|
|
1028
|
+
logger.console.log(
|
|
1029
|
+
"[trails-sdk] Subsequent wallet connection, going to account-settings",
|
|
1030
|
+
)
|
|
1031
|
+
setCurrentScreenWithBack(
|
|
1032
|
+
"account-settings",
|
|
1033
|
+
getInitialScreenForMode(currentMode),
|
|
1034
|
+
)
|
|
1035
|
+
}
|
|
1034
1036
|
} else if (config.connector === walletConnectConnector) {
|
|
1035
1037
|
// Store the current connector as previous before switching to WalletConnect
|
|
1036
1038
|
if (connector && connector.name !== "WalletConnect") {
|
|
@@ -1055,8 +1057,31 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1055
1057
|
setError(null)
|
|
1056
1058
|
|
|
1057
1059
|
try {
|
|
1060
|
+
// Disconnect all connected wallets
|
|
1061
|
+
logger.console.log(
|
|
1062
|
+
"[trails-sdk] Disconnecting all connected wallets:",
|
|
1063
|
+
connections.length,
|
|
1064
|
+
)
|
|
1065
|
+
|
|
1066
|
+
// Disconnect each connection
|
|
1067
|
+
for (const connection of connections) {
|
|
1068
|
+
try {
|
|
1069
|
+
await connection.connector.disconnect()
|
|
1070
|
+
logger.console.log(
|
|
1071
|
+
"[trails-sdk] Disconnected wallet:",
|
|
1072
|
+
connection.connector.name,
|
|
1073
|
+
)
|
|
1074
|
+
} catch (error) {
|
|
1075
|
+
logger.console.error(
|
|
1076
|
+
"[trails-sdk] Failed to disconnect wallet:",
|
|
1077
|
+
connection.connector.name,
|
|
1078
|
+
error,
|
|
1079
|
+
)
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
// Also call the main disconnect to ensure cleanup
|
|
1058
1084
|
await disconnectAsync()
|
|
1059
|
-
setAlreadyRedirectedToTokens(false)
|
|
1060
1085
|
trackWalletDisconnected()
|
|
1061
1086
|
} catch (error) {
|
|
1062
1087
|
logger.console.error("[trails-sdk] Failed to disconnect:", error)
|
|
@@ -1180,9 +1205,9 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1180
1205
|
setTransactionStates([])
|
|
1181
1206
|
setPrepareSendQuote(null)
|
|
1182
1207
|
setTotalCompletionSeconds(null)
|
|
1183
|
-
setAlreadyRedirectedToTokens(false)
|
|
1184
1208
|
clearHistory()
|
|
1185
1209
|
}, [
|
|
1210
|
+
setSelectedFundMethod,
|
|
1186
1211
|
setDestinationTxHash,
|
|
1187
1212
|
setDestinationChainId,
|
|
1188
1213
|
setTransactionStates,
|
|
@@ -1535,7 +1560,12 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1535
1560
|
setCurrentScreen("wallet-connect")
|
|
1536
1561
|
} else {
|
|
1537
1562
|
saveLastClickedWallet(walletId)
|
|
1538
|
-
|
|
1563
|
+
// Preserve the existing back route from the navigation stack
|
|
1564
|
+
const backRoute = getPreviousScreen()
|
|
1565
|
+
setCurrentScreenWithBack(
|
|
1566
|
+
"wallet-connection-pending",
|
|
1567
|
+
backRoute || undefined,
|
|
1568
|
+
)
|
|
1539
1569
|
// Auto-trigger connection
|
|
1540
1570
|
setTimeout(() => {
|
|
1541
1571
|
handleWalletConnect(walletId)
|
|
@@ -1587,7 +1617,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1587
1617
|
<Pay
|
|
1588
1618
|
selectedToken={selectedToken}
|
|
1589
1619
|
onSend={handleOnSend}
|
|
1590
|
-
onBack={handleBack}
|
|
1591
1620
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1592
1621
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1593
1622
|
onComplete={handleTransferComplete}
|
|
@@ -1612,6 +1641,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1612
1641
|
selectedPool ? generatedCalldata : toCalldata || undefined
|
|
1613
1642
|
}
|
|
1614
1643
|
walletClient={walletClient}
|
|
1644
|
+
isSequenceWallet={isSequenceWallet}
|
|
1615
1645
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1616
1646
|
onError={handleSendError}
|
|
1617
1647
|
paymasterUrls={paymasterUrls}
|
|
@@ -1659,8 +1689,8 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1659
1689
|
case "fund-form":
|
|
1660
1690
|
return walletClient?.account ? (
|
|
1661
1691
|
<Fund
|
|
1692
|
+
selectedToken={selectedToken}
|
|
1662
1693
|
onSend={handleOnSend}
|
|
1663
|
-
onBack={handleBack}
|
|
1664
1694
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1665
1695
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1666
1696
|
onComplete={handleTransferComplete}
|
|
@@ -1671,6 +1701,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1671
1701
|
toToken={toToken || undefined}
|
|
1672
1702
|
toCalldata={toCalldata || undefined}
|
|
1673
1703
|
walletClient={walletClient}
|
|
1704
|
+
isSequenceWallet={isSequenceWallet}
|
|
1674
1705
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1675
1706
|
onError={handleSendError}
|
|
1676
1707
|
paymasterUrls={paymasterUrls}
|
|
@@ -1766,10 +1797,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1766
1797
|
logger.console.log(
|
|
1767
1798
|
"[trails-sdk] Regular wallet selected, going to wallet-connection-pending",
|
|
1768
1799
|
)
|
|
1769
|
-
//
|
|
1770
|
-
setAlreadyRedirectedToTokens(false)
|
|
1800
|
+
// Don't reset the redirect flag - user has already been through initial flow
|
|
1771
1801
|
setTimeout(() => {
|
|
1772
|
-
|
|
1802
|
+
// Preserve the existing back route from the navigation stack
|
|
1803
|
+
const backRoute = getPreviousScreen()
|
|
1804
|
+
setCurrentScreenWithBack(
|
|
1805
|
+
"wallet-connection-pending",
|
|
1806
|
+
backRoute || undefined,
|
|
1807
|
+
)
|
|
1773
1808
|
}, 100)
|
|
1774
1809
|
// Auto-trigger connection
|
|
1775
1810
|
setTimeout(() => {
|
|
@@ -1788,7 +1823,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1788
1823
|
case "earn":
|
|
1789
1824
|
return walletClient?.account ? (
|
|
1790
1825
|
<Earn
|
|
1791
|
-
onBack={handleBack}
|
|
1792
1826
|
onContinue={() => setCurrentScreen("send-form")}
|
|
1793
1827
|
account={walletClient.account}
|
|
1794
1828
|
walletClient={walletClient}
|
|
@@ -1829,7 +1863,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1829
1863
|
return walletClient?.account ? (
|
|
1830
1864
|
<Swap
|
|
1831
1865
|
onSend={handleOnSend}
|
|
1832
|
-
onBack={handleBack}
|
|
1833
1866
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1834
1867
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1835
1868
|
onComplete={handleTransferComplete}
|
|
@@ -1841,6 +1874,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1841
1874
|
toToken={toToken || undefined}
|
|
1842
1875
|
toCalldata={toCalldata || undefined}
|
|
1843
1876
|
walletClient={walletClient}
|
|
1877
|
+
isSequenceWallet={isSequenceWallet}
|
|
1844
1878
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1845
1879
|
onError={handleSendError}
|
|
1846
1880
|
paymasterUrls={paymasterUrls}
|
|
@@ -1864,7 +1898,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1864
1898
|
return (
|
|
1865
1899
|
<Receive
|
|
1866
1900
|
accountAddress={toAddress || ""}
|
|
1867
|
-
onBack={handleBack}
|
|
1868
1901
|
isConnected={isConnected}
|
|
1869
1902
|
onConnectWallet={() => setCurrentScreen("connect")}
|
|
1870
1903
|
onPay={() => setCurrentScreen("send-form")}
|
|
@@ -1916,6 +1949,12 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1916
1949
|
getInitialScreenForMode={getInitialScreenForMode}
|
|
1917
1950
|
/>
|
|
1918
1951
|
)
|
|
1952
|
+
case "home": {
|
|
1953
|
+
// Redirect to the appropriate screen for the current mode
|
|
1954
|
+
const homeScreen = getInitialScreenForMode(currentMode)
|
|
1955
|
+
setCurrentScreen(homeScreen)
|
|
1956
|
+
return null
|
|
1957
|
+
}
|
|
1919
1958
|
default:
|
|
1920
1959
|
return null
|
|
1921
1960
|
}
|
|
@@ -2045,8 +2084,8 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2045
2084
|
<SwapAmountProvider>
|
|
2046
2085
|
<ChainFilterProvider>
|
|
2047
2086
|
<BalanceVisibleProvider>
|
|
2048
|
-
<
|
|
2049
|
-
<
|
|
2087
|
+
<ThemePreferenceProvider>
|
|
2088
|
+
<SelectedFundMethodProvider>
|
|
2050
2089
|
<ThemeSyncer />
|
|
2051
2090
|
<EarnPoolProvider>
|
|
2052
2091
|
<SelectedMeshExchangeProvider>
|
|
@@ -2055,8 +2094,8 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2055
2094
|
</DefaultTokenSelectionProvider>
|
|
2056
2095
|
</SelectedMeshExchangeProvider>
|
|
2057
2096
|
</EarnPoolProvider>
|
|
2058
|
-
</
|
|
2059
|
-
</
|
|
2097
|
+
</SelectedFundMethodProvider>
|
|
2098
|
+
</ThemePreferenceProvider>
|
|
2060
2099
|
</BalanceVisibleProvider>
|
|
2061
2100
|
</ChainFilterProvider>
|
|
2062
2101
|
</SwapAmountProvider>
|
|
@@ -2083,7 +2122,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2083
2122
|
logger.console.warn("appId is deprecated. Use projectAccessKey instead.")
|
|
2084
2123
|
setSequenceProjectAccessKey(props.appId)
|
|
2085
2124
|
}
|
|
2086
|
-
if (props.sequenceEnv) {
|
|
2125
|
+
if (props.sequenceEnv && props.sequenceEnv !== getSequenceEnv()) {
|
|
2087
2126
|
logger.console.log("props.sequenceEnv", props.sequenceEnv)
|
|
2088
2127
|
setSequenceEnv(props.sequenceEnv)
|
|
2089
2128
|
}
|
|
@@ -2121,7 +2160,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2121
2160
|
logger.console.log("props.slippageTolerance", props.slippageTolerance)
|
|
2122
2161
|
setSlippageTolerance(String(props.slippageTolerance))
|
|
2123
2162
|
}
|
|
2124
|
-
if (typeof props.debug === "boolean") {
|
|
2163
|
+
if (typeof props.debug === "boolean" && props.debug === getDebug()) {
|
|
2125
2164
|
logger.console.log("props.debug", props.debug)
|
|
2126
2165
|
setDebug(props.debug)
|
|
2127
2166
|
}
|
|
@@ -2190,12 +2229,6 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2190
2229
|
},
|
|
2191
2230
|
}
|
|
2192
2231
|
|
|
2193
|
-
logger.console.log("[trails-sdk] sequenceConfig", sequenceConfig)
|
|
2194
|
-
logger.console.log(
|
|
2195
|
-
"[trails-sdk] props.decoupleWagmi",
|
|
2196
|
-
props.decoupleWagmi,
|
|
2197
|
-
)
|
|
2198
|
-
|
|
2199
2232
|
if (props.decoupleWagmi) {
|
|
2200
2233
|
return (
|
|
2201
2234
|
<AaveProvider client={aaveClient}>
|
|
@@ -2252,6 +2285,10 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2252
2285
|
return props.customCss
|
|
2253
2286
|
}, [props.customCss])
|
|
2254
2287
|
|
|
2288
|
+
if (props.disableCss) {
|
|
2289
|
+
return <StrictMode>{content}</StrictMode>
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2255
2292
|
return (
|
|
2256
2293
|
<ShadowPortal customCss={customCss}>
|
|
2257
2294
|
<StrictMode>{content}</StrictMode>
|