0xtrails 0.1.13 → 0.2.1
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.map +1 -1
- package/dist/analytics.d.ts +12 -2
- package/dist/analytics.d.ts.map +1 -1
- package/dist/apiClient.d.ts +1 -1
- package/dist/apiClient.d.ts.map +1 -1
- package/dist/{ccip-D3gTQONK.js → ccip-BbfANth7.js} +12 -12
- package/dist/cctp.d.ts.map +1 -1
- package/dist/cctpqueue.d.ts +3 -3
- package/dist/cctpqueue.d.ts.map +1 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +18 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/contractUtils.d.ts +2 -0
- package/dist/contractUtils.d.ts.map +1 -1
- package/dist/customChains.d.ts +24 -0
- package/dist/customChains.d.ts.map +1 -0
- package/dist/gasless.d.ts +19 -7
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-CnUM7lKf.js → index-WpIVoh3X.js} +36741 -31761
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +405 -394
- package/dist/indexerClient.d.ts +10 -0
- package/dist/indexerClient.d.ts.map +1 -1
- package/dist/intentEntrypoint.d.ts +122 -0
- package/dist/intentEntrypoint.d.ts.map +1 -0
- package/dist/intents.d.ts +5 -3
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/morpho.d.ts.map +1 -1
- package/dist/pools.d.ts +3 -1
- package/dist/pools.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +18 -9
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +1 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/relaySdk.d.ts.map +1 -1
- package/dist/relayer.d.ts.map +1 -1
- package/dist/toast.d.ts +9 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/tokenBalances.d.ts +6 -2
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +6 -5
- package/dist/trails.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +12 -0
- package/dist/trailsClient.d.ts.map +1 -0
- package/dist/trailsRouter.d.ts +22 -0
- package/dist/trailsRouter.d.ts.map +1 -0
- package/dist/transactions.d.ts +8 -1
- 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/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts +7 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -0
- package/dist/widget/components/ChainList.d.ts +0 -1
- package/dist/widget/components/ChainList.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +46 -0
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -0
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts +9 -0
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -0
- package/dist/widget/components/DebugMenu.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
- package/dist/widget/components/DebugToast.d.ts +3 -0
- package/dist/widget/components/DebugToast.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +22 -0
- package/dist/widget/components/FeeOption.d.ts.map +1 -0
- package/dist/widget/components/FeeOptions.d.ts +13 -17
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +44 -0
- package/dist/widget/components/Fund.d.ts.map +1 -0
- package/dist/widget/components/FundMethods.d.ts +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSendForm.d.ts.map +1 -1
- package/dist/widget/components/Identicon.d.ts +9 -0
- package/dist/widget/components/Identicon.d.ts.map +1 -0
- package/dist/widget/components/MeshConnectExchanges.d.ts +5 -2
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectFlow.d.ts +2 -0
- package/dist/widget/components/MeshConnectFlow.d.ts.map +1 -1
- package/dist/widget/components/NativeGasOption.d.ts +12 -0
- package/dist/widget/components/NativeGasOption.d.ts.map +1 -0
- package/dist/widget/components/Pay.d.ts +46 -0
- package/dist/widget/components/Pay.d.ts.map +1 -0
- package/dist/widget/components/PaySendForm.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receive.d.ts.map +1 -1
- package/dist/widget/components/RecentTokens.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts +9 -0
- package/dist/widget/components/Recipients.d.ts.map +1 -0
- package/dist/widget/components/RefundWarning.d.ts +9 -0
- package/dist/widget/components/RefundWarning.d.ts.map +1 -0
- package/dist/widget/components/SimpleSwap.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.d.ts +1 -5
- package/dist/widget/components/SwapSettings.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/ThemeSyncer.d.ts +6 -0
- package/dist/widget/components/ThemeSyncer.d.ts.map +1 -0
- package/dist/widget/components/Toast.d.ts +24 -0
- package/dist/widget/components/Toast.d.ts.map +1 -0
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
- package/dist/widget/components/TruncatedAddress.d.ts +2 -0
- package/dist/widget/components/TruncatedAddress.d.ts.map +1 -1
- package/dist/widget/components/UserPreferences.d.ts +7 -0
- package/dist/widget/components/UserPreferences.d.ts.map +1 -0
- package/dist/widget/hooks/useBack.d.ts +2 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useBalanceVisible.d.ts +1 -0
- package/dist/widget/hooks/useBalanceVisible.d.ts.map +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/useDebugScreens.d.ts +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +54 -0
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -0
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts +34 -0
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -0
- package/dist/widget/hooks/useRecipients.d.ts +17 -0
- package/dist/widget/hooks/useRecipients.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +32 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts +14 -0
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts +12 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +10 -13
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts +13 -0
- package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -0
- package/dist/widget/hooks/useSwapSettings.d.ts +16 -0
- package/dist/widget/hooks/useSwapSettings.d.ts.map +1 -0
- package/dist/widget/hooks/useTargetAmount.d.ts +5 -0
- package/dist/widget/hooks/useTargetAmount.d.ts.map +1 -0
- package/dist/widget/hooks/useTheme.d.ts +14 -0
- package/dist/widget/hooks/useTheme.d.ts.map +1 -0
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +9 -0
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +38 -36
- package/src/aave.ts +6 -1
- package/src/analytics.ts +109 -53
- package/src/apiClient.ts +1 -1
- package/src/cctp.ts +6 -2
- package/src/cctpqueue.ts +7 -7
- package/src/chains.ts +18 -0
- package/src/config.ts +63 -17
- package/src/constants.ts +20 -16
- package/src/contractUtils.ts +33 -2
- package/src/customChains.ts +24 -0
- package/src/gasless.ts +162 -109
- package/src/index.ts +11 -1
- package/src/indexerClient.ts +73 -1
- package/src/intentEntrypoint.ts +218 -0
- package/src/intents.ts +85 -54
- package/src/metaTxnMonitor.ts +1 -0
- package/src/morpho.ts +13 -2
- package/src/pools.ts +68 -86
- package/src/prepareSend.ts +1719 -967
- package/src/prices.ts +51 -7
- package/src/relaySdk.ts +6 -4
- package/src/relayer.ts +6 -3
- package/src/toast.ts +110 -0
- package/src/tokenBalances.ts +112 -20
- package/src/tokens.ts +70 -7
- package/src/trails.ts +81 -80
- package/src/trailsClient.ts +48 -0
- package/src/{proxyCaller.ts → trailsRouter.ts} +25 -20
- package/src/transactions.ts +30 -88
- package/src/umd.tsx +1 -1
- package/src/wallets.ts +2 -1
- package/src/widget/assets/sequence-logo.svg +15 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +18 -159
- package/src/widget/components/AccountIntentTransactionHistory.tsx +346 -63
- package/src/widget/components/AccountSettings.tsx +102 -0
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +10 -20
- package/src/widget/components/ClassicSwap.tsx +921 -0
- package/src/widget/components/ConfigDisplay.tsx +41 -5
- package/src/widget/components/ConnectWallet.tsx +168 -11
- package/src/widget/components/ConnectedWallets.tsx +342 -0
- package/src/widget/components/DebugMenu.tsx +2 -0
- package/src/widget/components/DebugScreensList.tsx +3 -0
- package/src/widget/components/DebugToast.tsx +63 -0
- package/src/widget/components/Earn.tsx +112 -143
- package/src/widget/components/EarnPools.tsx +2 -4
- package/src/widget/components/EarnPoolsFilters.tsx +6 -6
- package/src/widget/components/FeeOption.tsx +78 -0
- package/src/widget/components/FeeOptions.tsx +192 -127
- package/src/widget/components/Fund.tsx +1236 -0
- package/src/widget/components/FundMethods.tsx +4 -4
- package/src/widget/components/FundSendForm.tsx +1 -34
- package/src/widget/components/Identicon.tsx +158 -0
- package/src/widget/components/MeshConnectExchanges.tsx +32 -3
- package/src/widget/components/MeshConnectFlow.tsx +23 -4
- package/src/widget/components/NativeGasOption.tsx +99 -0
- package/src/widget/components/Pay.tsx +1092 -0
- package/src/widget/components/PaySendForm.tsx +1 -38
- package/src/widget/components/QuoteDetails.tsx +1 -30
- package/src/widget/components/Receipt.tsx +1 -1
- package/src/widget/components/Receive.tsx +4 -2
- package/src/widget/components/RecentTokens.tsx +2 -1
- package/src/widget/components/Recipients.tsx +448 -0
- package/src/widget/components/RefundWarning.tsx +61 -0
- package/src/widget/components/ScreenHeader.tsx +1 -1
- package/src/widget/components/SimpleSwap.tsx +74 -58
- package/src/widget/components/Swap.tsx +35 -853
- package/src/widget/components/SwapSettings.tsx +5 -11
- package/src/widget/components/ThemeProvider.tsx +32 -0
- package/src/widget/components/ThemeSyncer.tsx +47 -0
- package/src/widget/components/Toast.tsx +315 -0
- package/src/widget/components/TokenList.tsx +2 -34
- package/src/widget/components/TokenSelector.tsx +14 -3
- package/src/widget/components/TransactionDetails.tsx +153 -13
- package/src/widget/components/TransferPendingVertical.tsx +1 -1
- package/src/widget/components/TruncatedAddress.tsx +5 -1
- package/src/widget/components/UserPreferences.tsx +155 -0
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/hooks/useBack.tsx +4 -0
- package/src/widget/hooks/useBalanceVisible.tsx +40 -2
- package/src/widget/hooks/useCheckout.ts +13 -0
- package/src/widget/hooks/useCurrentScreen.tsx +4 -0
- package/src/widget/hooks/useDebugScreens.ts +12 -2
- package/src/widget/hooks/useDefaultTokenSelection.tsx +471 -0
- package/src/widget/hooks/useIntentTransactionHistory.ts +212 -0
- package/src/widget/hooks/usePayMessage.tsx +370 -0
- package/src/widget/hooks/useRecipients.ts +168 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +299 -0
- package/src/widget/hooks/useSelectedMeshExchange.tsx +46 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +48 -0
- package/src/widget/hooks/useSendForm.ts +257 -49
- package/src/widget/hooks/useSwapAmount.tsx +50 -0
- package/src/widget/hooks/useSwapSettings.tsx +100 -0
- package/src/widget/hooks/useTargetAmount.ts +23 -0
- package/src/widget/hooks/useTheme.tsx +80 -0
- package/src/widget/hooks/useTokenList.ts +20 -11
- package/src/widget/index.css +45 -21
- package/src/widget/widget.tsx +294 -136
- package/dist/address.d.ts +0 -2
- package/dist/address.d.ts.map +0 -1
- package/dist/proxyCaller.d.ts +0 -21
- package/dist/proxyCaller.d.ts.map +0 -1
- package/src/address.ts +0 -6
package/src/widget/widget.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import React, {
|
|
|
16
16
|
import { createPortal } from "react-dom"
|
|
17
17
|
import type { Chain, WalletClient } from "viem"
|
|
18
18
|
import { createWalletClient, custom, http, isAddress } from "viem"
|
|
19
|
-
import
|
|
19
|
+
import { getAllChains } from "../chains.js"
|
|
20
20
|
import type { Connector } from "wagmi"
|
|
21
21
|
import {
|
|
22
22
|
createConfig,
|
|
@@ -36,25 +36,29 @@ import Footer from "./components/Footer.js"
|
|
|
36
36
|
import Modal from "./components/Modal.js"
|
|
37
37
|
import Receipt from "./components/Receipt.js"
|
|
38
38
|
import { WalletList } from "./components/WalletList.js"
|
|
39
|
-
import {
|
|
39
|
+
import { Pay } from "./components/Pay.js"
|
|
40
40
|
import TokenList from "./components/TokenList.js"
|
|
41
41
|
import TransferPending from "./components/TransferPendingVertical.js"
|
|
42
42
|
import WalletConfirmation from "./components/WalletConfirmation.js"
|
|
43
43
|
import QRCodeDeposit from "./components/QRCodeDeposit.js"
|
|
44
44
|
import { ThemeProvider } from "./components/ThemeProvider.js"
|
|
45
|
+
import { ToastProvider } from "./components/Toast.js"
|
|
45
46
|
import {
|
|
46
47
|
getCommitHash,
|
|
47
48
|
getSequenceNodeGatewayUrl,
|
|
48
49
|
setWalletConnectProjectId,
|
|
49
50
|
setSequenceNodeGatewayUrl,
|
|
51
|
+
getSequenceEnv,
|
|
50
52
|
} from "../config.js"
|
|
51
|
-
import { useAmountUsd } from "./hooks/useAmountUsd.js"
|
|
52
53
|
import { useRecentTokens } from "./hooks/useRecentTokens.js"
|
|
54
|
+
import { useTargetAmount } from "./hooks/useTargetAmount.js"
|
|
53
55
|
import { getWethAddress } from "../tokens.js"
|
|
54
56
|
import css from "./compiled.css?inline"
|
|
55
57
|
import {
|
|
58
|
+
getAnalytics,
|
|
56
59
|
getSessionId,
|
|
57
60
|
trackWalletConnected,
|
|
61
|
+
trackWalletDisconnected,
|
|
58
62
|
trackWidgetScreen,
|
|
59
63
|
} from "../analytics.js"
|
|
60
64
|
import type { PrepareSendQuote } from "../prepareSend.js"
|
|
@@ -70,15 +74,18 @@ import {
|
|
|
70
74
|
import {
|
|
71
75
|
setSequenceIndexerUrl,
|
|
72
76
|
setSequenceApiUrl,
|
|
77
|
+
setTrailsApiUrl,
|
|
73
78
|
setSequenceProjectAccessKey,
|
|
74
79
|
getSequenceIndexerUrl,
|
|
75
80
|
getSequenceApiUrl,
|
|
81
|
+
getTrailsApiUrl,
|
|
76
82
|
setSequenceEnv,
|
|
77
83
|
setSlippageTolerance,
|
|
78
84
|
getSequenceProjectAccessKey,
|
|
79
85
|
setDebug,
|
|
80
86
|
} from "../config.js"
|
|
81
|
-
import {
|
|
87
|
+
import { Fund } from "./components/Fund.js"
|
|
88
|
+
import { Recipients } from "./components/Recipients.js"
|
|
82
89
|
import { Swap } from "./components/Swap.js"
|
|
83
90
|
import { Receive } from "./components/Receive.js"
|
|
84
91
|
import { Earn } from "./components/Earn.js"
|
|
@@ -89,6 +96,8 @@ import FundMethods from "./components/FundMethods.js"
|
|
|
89
96
|
import EarnPools from "./components/EarnPools.js"
|
|
90
97
|
import WalletConnectionPending from "./components/WalletConnectionPending.js"
|
|
91
98
|
import { AccountIntentTransactionHistory } from "./components/AccountIntentTransactionHistory.js"
|
|
99
|
+
import { AccountSettings } from "./components/AccountSettings.js"
|
|
100
|
+
import { UserPreferences } from "./components/UserPreferences.js"
|
|
92
101
|
import type { Mode } from "../mode.js"
|
|
93
102
|
import type { OnCompleteProps } from "./hooks/useSendForm.js"
|
|
94
103
|
import type { Pool } from "../pools.js"
|
|
@@ -112,8 +121,14 @@ import {
|
|
|
112
121
|
useOriginSelectedToken as useSelectedToken,
|
|
113
122
|
} from "./hooks/useOriginSelectedToken.js"
|
|
114
123
|
import { DestinationSelectedTokenProvider } from "./hooks/useDestinationSelectedToken.js"
|
|
124
|
+
import { SelectedFeeTokenProvider } from "./hooks/useSelectedFeeToken.js"
|
|
125
|
+
import { SelectedRecipientProvider } from "./hooks/useSelectedRecipient.js"
|
|
126
|
+
import { SwapAmountProvider } from "./hooks/useSwapAmount.js"
|
|
115
127
|
import { ChainFilterProvider } from "./hooks/useChainFilter.js"
|
|
116
128
|
import { BalanceVisibleProvider } from "./hooks/useBalanceVisible.js"
|
|
129
|
+
import { SwapSettingsProvider } from "./hooks/useSwapSettings.js"
|
|
130
|
+
import { ThemeProvider as ThemePreferenceProvider } from "./hooks/useTheme.js"
|
|
131
|
+
import { ThemeSyncer } from "./components/ThemeSyncer.js"
|
|
117
132
|
import { EarnPoolProvider, useEarnPool } from "./hooks/useEarnPool.js"
|
|
118
133
|
import { WidgetPropsProvider, useWidgetProps } from "./hooks/useWidgetProps.js"
|
|
119
134
|
import {
|
|
@@ -122,6 +137,12 @@ import {
|
|
|
122
137
|
type Screen,
|
|
123
138
|
} from "./hooks/useCurrentScreen.js"
|
|
124
139
|
import { BackProvider, useBack } from "./hooks/useBack.js"
|
|
140
|
+
import { DefaultTokenSelectionProvider } from "./hooks/useDefaultTokenSelection.js"
|
|
141
|
+
import {
|
|
142
|
+
SelectedMeshExchangeProvider,
|
|
143
|
+
useSelectedMeshExchange,
|
|
144
|
+
} from "./hooks/useSelectedMeshExchange.js"
|
|
145
|
+
import { MeshConnectExchanges } from "./components/MeshConnectExchanges.js"
|
|
125
146
|
|
|
126
147
|
export const aaveClient = AaveClient.create()
|
|
127
148
|
|
|
@@ -143,6 +164,7 @@ export type TrailsWidgetProps = {
|
|
|
143
164
|
projectAccessKey?: string
|
|
144
165
|
sequenceIndexerUrl?: string | null
|
|
145
166
|
sequenceApiUrl?: string | null
|
|
167
|
+
trailsApiUrl?: string | null
|
|
146
168
|
sequenceNodeGatewayUrl?: string | null
|
|
147
169
|
sequenceEnv?: RelayerEnv
|
|
148
170
|
toAddress?: string | null
|
|
@@ -174,6 +196,8 @@ export type TrailsWidgetProps = {
|
|
|
174
196
|
sessionId: string
|
|
175
197
|
transactionStates: TransactionState[]
|
|
176
198
|
}) => void
|
|
199
|
+
onOpen?: () => void
|
|
200
|
+
onClose?: () => void
|
|
177
201
|
|
|
178
202
|
walletConnectProjectId?: string
|
|
179
203
|
paymasterUrls?: Array<{ chainId: number; url: string }>
|
|
@@ -189,6 +213,12 @@ export type TrailsWidgetProps = {
|
|
|
189
213
|
wagmiConnectors?: Connector[]
|
|
190
214
|
debug?: boolean
|
|
191
215
|
hideDisconnect?: boolean
|
|
216
|
+
toast?: boolean
|
|
217
|
+
appName?: string
|
|
218
|
+
appUrl?: string
|
|
219
|
+
appImageUrl?: string
|
|
220
|
+
appDescription?: string
|
|
221
|
+
payMessage?: string
|
|
192
222
|
}
|
|
193
223
|
|
|
194
224
|
export interface TrailsWidgetRef {
|
|
@@ -397,6 +427,8 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
397
427
|
onCheckoutComplete,
|
|
398
428
|
onCheckoutError,
|
|
399
429
|
onCheckoutStatusUpdate,
|
|
430
|
+
onOpen,
|
|
431
|
+
onClose,
|
|
400
432
|
paymasterUrls,
|
|
401
433
|
gasless,
|
|
402
434
|
buttonText,
|
|
@@ -412,10 +444,16 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
412
444
|
const { recentTokens, addRecentToken } = useRecentTokens(address)
|
|
413
445
|
const { wallets: allWallets } = useWallets()
|
|
414
446
|
const { selectedToken, setSelectedToken } = useSelectedToken()
|
|
447
|
+
const { selectedExchange } = useSelectedMeshExchange()
|
|
415
448
|
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
416
449
|
const [currentMode, setCurrentMode] = useState<Mode>(mode)
|
|
417
450
|
const { currentScreen, setCurrentScreen } = useCurrentScreen()
|
|
418
|
-
const {
|
|
451
|
+
const {
|
|
452
|
+
goBack: handleBack,
|
|
453
|
+
clearHistory,
|
|
454
|
+
isNavigatingBack,
|
|
455
|
+
getHistory,
|
|
456
|
+
} = useBack()
|
|
419
457
|
const [previousAddress, setPreviousAddress] = useState<string | undefined>(
|
|
420
458
|
address,
|
|
421
459
|
)
|
|
@@ -460,23 +498,34 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
460
498
|
const { connectAsync } = useConnect()
|
|
461
499
|
const [isInitialScreenSet, setIsInitialScreenSet] = useState(false)
|
|
462
500
|
|
|
501
|
+
const getInitialScreenForMode = useCallback((mode: Mode) => {
|
|
502
|
+
if (mode === "swap") {
|
|
503
|
+
return "swap"
|
|
504
|
+
} else if (mode === "receive") {
|
|
505
|
+
return "receive"
|
|
506
|
+
} else if (mode === "earn") {
|
|
507
|
+
return "earn"
|
|
508
|
+
} else if (mode === "fund") {
|
|
509
|
+
return "fund-form"
|
|
510
|
+
} else if (mode === "pay") {
|
|
511
|
+
return "send-form"
|
|
512
|
+
} else {
|
|
513
|
+
return "account-settings"
|
|
514
|
+
}
|
|
515
|
+
}, [])
|
|
516
|
+
|
|
463
517
|
// Set proper initial screen based on connection state and mode
|
|
464
518
|
useEffect(() => {
|
|
465
519
|
if (isInitialScreenSet) {
|
|
466
520
|
return
|
|
467
521
|
}
|
|
468
522
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
? "earn"
|
|
476
|
-
: "tokens"
|
|
477
|
-
: currentMode === "receive"
|
|
478
|
-
? "receive"
|
|
479
|
-
: "connect"
|
|
523
|
+
let properInitialScreen: Screen = "connect"
|
|
524
|
+
if (isConnected) {
|
|
525
|
+
properInitialScreen = getInitialScreenForMode(currentMode)
|
|
526
|
+
} else if (currentMode === "receive") {
|
|
527
|
+
properInitialScreen = "receive"
|
|
528
|
+
}
|
|
480
529
|
|
|
481
530
|
// Only update if the current screen is still the default
|
|
482
531
|
if (currentScreen === "connect" || currentScreen === "receive") {
|
|
@@ -494,6 +543,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
494
543
|
currentScreen,
|
|
495
544
|
setCurrentScreen,
|
|
496
545
|
isInitialScreenSet,
|
|
546
|
+
getInitialScreenForMode,
|
|
497
547
|
])
|
|
498
548
|
|
|
499
549
|
const defaultButtonText = useMemo(() => {
|
|
@@ -625,7 +675,11 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
625
675
|
toChainId?: number | string | null,
|
|
626
676
|
toToken?: string | null,
|
|
627
677
|
) => {
|
|
628
|
-
|
|
678
|
+
// Only fetch pools when mode is "earn" or "fund"
|
|
679
|
+
const shouldFetchPools = mode === "earn" || mode === "fund"
|
|
680
|
+
const { data: pools, loading: poolsLoading } = usePools({
|
|
681
|
+
enabled: shouldFetchPools,
|
|
682
|
+
})
|
|
629
683
|
|
|
630
684
|
useEffect(() => {
|
|
631
685
|
if (
|
|
@@ -760,20 +814,56 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
760
814
|
) {
|
|
761
815
|
if (!alreadyRedirectedToTokens) {
|
|
762
816
|
setAlreadyRedirectedToTokens(true)
|
|
817
|
+
const history = getHistory()
|
|
763
818
|
logger.console.log(
|
|
764
|
-
"[trails-sdk]
|
|
765
|
-
|
|
819
|
+
"[trails-sdk] Post-connection navigation triggered",
|
|
820
|
+
{
|
|
821
|
+
currentScreen,
|
|
822
|
+
alreadyRedirectedToTokens,
|
|
823
|
+
isConnected,
|
|
824
|
+
currentMode,
|
|
825
|
+
history,
|
|
826
|
+
},
|
|
766
827
|
)
|
|
767
|
-
|
|
768
|
-
if
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
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
|
|
776
858
|
}
|
|
859
|
+
|
|
860
|
+
console.log(
|
|
861
|
+
"[trails-sdk] Using default navigation for mode:",
|
|
862
|
+
currentMode,
|
|
863
|
+
)
|
|
864
|
+
|
|
865
|
+
const initialScreen = getInitialScreenForMode(currentMode)
|
|
866
|
+
setCurrentScreen(initialScreen)
|
|
777
867
|
}
|
|
778
868
|
}
|
|
779
869
|
} else {
|
|
@@ -796,6 +886,8 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
796
886
|
currentMode,
|
|
797
887
|
isNavigatingBack,
|
|
798
888
|
setCurrentScreen,
|
|
889
|
+
getHistory,
|
|
890
|
+
getInitialScreenForMode,
|
|
799
891
|
])
|
|
800
892
|
|
|
801
893
|
useEffect(() => {
|
|
@@ -827,6 +919,17 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
827
919
|
})
|
|
828
920
|
}, [currentScreen, address])
|
|
829
921
|
|
|
922
|
+
// Identify user with Databeat whenever address changes
|
|
923
|
+
useEffect(() => {
|
|
924
|
+
const analytics = getAnalytics()
|
|
925
|
+
if (address) {
|
|
926
|
+
analytics.identifyUser({ address })
|
|
927
|
+
} else {
|
|
928
|
+
// Unidentify when wallet is disconnected
|
|
929
|
+
analytics.unidentifyUser()
|
|
930
|
+
}
|
|
931
|
+
}, [address])
|
|
932
|
+
|
|
830
933
|
useEffect(() => {
|
|
831
934
|
if (!address || !chainId || !connector?.name) {
|
|
832
935
|
return
|
|
@@ -853,6 +956,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
853
956
|
const screensToReset = [
|
|
854
957
|
"send-form",
|
|
855
958
|
"fund-form",
|
|
959
|
+
"swap",
|
|
856
960
|
"wallet-confirmation",
|
|
857
961
|
"earn",
|
|
858
962
|
"swap",
|
|
@@ -862,7 +966,8 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
862
966
|
logger.console.log(
|
|
863
967
|
"[trails-sdk] Resetting to tokens screen due to account change",
|
|
864
968
|
)
|
|
865
|
-
|
|
969
|
+
const initialScreen = getInitialScreenForMode(currentMode)
|
|
970
|
+
setCurrentScreen(initialScreen)
|
|
866
971
|
setSelectedToken(null)
|
|
867
972
|
setError(null)
|
|
868
973
|
setPrepareSendQuote(null)
|
|
@@ -876,8 +981,10 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
876
981
|
address,
|
|
877
982
|
previousAddress,
|
|
878
983
|
currentScreen,
|
|
984
|
+
currentMode,
|
|
879
985
|
setSelectedToken,
|
|
880
986
|
setCurrentScreen,
|
|
987
|
+
getInitialScreenForMode,
|
|
881
988
|
])
|
|
882
989
|
|
|
883
990
|
// Update generated calldata when amount changes in earn mode
|
|
@@ -950,6 +1057,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
950
1057
|
try {
|
|
951
1058
|
await disconnectAsync()
|
|
952
1059
|
setAlreadyRedirectedToTokens(false)
|
|
1060
|
+
trackWalletDisconnected()
|
|
953
1061
|
} catch (error) {
|
|
954
1062
|
logger.console.error("[trails-sdk] Failed to disconnect:", error)
|
|
955
1063
|
}
|
|
@@ -968,8 +1076,12 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
968
1076
|
setCurrentScreen("receive")
|
|
969
1077
|
} else if (currentMode === "earn") {
|
|
970
1078
|
setCurrentScreen("earn")
|
|
1079
|
+
} else if (currentMode === "fund") {
|
|
1080
|
+
setCurrentScreen("fund-form")
|
|
1081
|
+
} else if (currentMode === "pay") {
|
|
1082
|
+
setCurrentScreen("send-form")
|
|
971
1083
|
} else {
|
|
972
|
-
setCurrentScreen("
|
|
1084
|
+
setCurrentScreen("account-settings")
|
|
973
1085
|
}
|
|
974
1086
|
}
|
|
975
1087
|
|
|
@@ -1027,12 +1139,13 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1027
1139
|
const handleTrackToken = (token: Token) => {
|
|
1028
1140
|
// Track the token in recent tokens
|
|
1029
1141
|
const chainInfo = getChainInfo(token.chainId)
|
|
1142
|
+
const decimals = token.contractInfo?.decimals || (token as any).decimals
|
|
1030
1143
|
const supportedToken: SupportedToken = {
|
|
1031
1144
|
id: `${token.symbol}-${chainInfo?.name || token.chainId}`,
|
|
1032
1145
|
symbol: token.symbol,
|
|
1033
1146
|
name: token.name,
|
|
1034
1147
|
contractAddress: token.contractAddress,
|
|
1035
|
-
decimals
|
|
1148
|
+
decimals,
|
|
1036
1149
|
chainId: token.chainId,
|
|
1037
1150
|
chainName: chainInfo?.name || `Chain ${token.chainId}`,
|
|
1038
1151
|
imageUrl: token.imageUrl,
|
|
@@ -1045,15 +1158,8 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1045
1158
|
}
|
|
1046
1159
|
|
|
1047
1160
|
const handleSendAnother = () => {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
} else if (currentMode === "receive") {
|
|
1051
|
-
setCurrentScreen("receive")
|
|
1052
|
-
} else if (currentMode === "earn") {
|
|
1053
|
-
setCurrentScreen("earn")
|
|
1054
|
-
} else {
|
|
1055
|
-
setCurrentScreen("tokens")
|
|
1056
|
-
}
|
|
1161
|
+
const initialScreen = getInitialScreenForMode(currentMode)
|
|
1162
|
+
setCurrentScreen(initialScreen)
|
|
1057
1163
|
resetState()
|
|
1058
1164
|
}
|
|
1059
1165
|
|
|
@@ -1089,27 +1195,28 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1089
1195
|
clearHistory,
|
|
1090
1196
|
])
|
|
1091
1197
|
|
|
1198
|
+
const handleOpenModal = useCallback(() => {
|
|
1199
|
+
setIsModalOpen(true)
|
|
1200
|
+
onOpen?.()
|
|
1201
|
+
}, [onOpen])
|
|
1202
|
+
|
|
1203
|
+
const handleCloseModal = useCallback(() => {
|
|
1204
|
+
setIsModalOpen(false)
|
|
1205
|
+
resetState()
|
|
1206
|
+
onClose?.()
|
|
1207
|
+
}, [resetState, onClose])
|
|
1208
|
+
|
|
1092
1209
|
// Expose modal control methods via ref
|
|
1093
1210
|
useImperativeHandle(
|
|
1094
1211
|
ref,
|
|
1095
1212
|
() => ({
|
|
1096
|
-
openModal:
|
|
1097
|
-
|
|
1098
|
-
},
|
|
1099
|
-
closeModal: () => {
|
|
1100
|
-
setIsModalOpen(false)
|
|
1101
|
-
resetState()
|
|
1102
|
-
},
|
|
1213
|
+
openModal: handleOpenModal,
|
|
1214
|
+
closeModal: handleCloseModal,
|
|
1103
1215
|
isModalOpen,
|
|
1104
1216
|
}),
|
|
1105
|
-
[isModalOpen,
|
|
1217
|
+
[isModalOpen, handleOpenModal, handleCloseModal],
|
|
1106
1218
|
)
|
|
1107
1219
|
|
|
1108
|
-
const handleCloseModal = () => {
|
|
1109
|
-
setIsModalOpen(false)
|
|
1110
|
-
resetState()
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
1220
|
function handleWalletConfirmComplete() {
|
|
1114
1221
|
setCurrentScreen("pending")
|
|
1115
1222
|
}
|
|
@@ -1328,9 +1435,9 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1328
1435
|
}
|
|
1329
1436
|
}
|
|
1330
1437
|
|
|
1331
|
-
const
|
|
1438
|
+
const handleSelectExchangeList = () => {
|
|
1332
1439
|
setSelectedFundMethod("exchange")
|
|
1333
|
-
setCurrentScreen("
|
|
1440
|
+
setCurrentScreen("mesh-connect-exchanges")
|
|
1334
1441
|
}
|
|
1335
1442
|
|
|
1336
1443
|
const handleNavigateToMeshConnect = (
|
|
@@ -1411,14 +1518,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1411
1518
|
}
|
|
1412
1519
|
}
|
|
1413
1520
|
|
|
1414
|
-
const {
|
|
1415
|
-
amountUsd: targetAmountUsd,
|
|
1416
|
-
amountUsdFormatted: targetAmountUsdFormatted,
|
|
1417
|
-
} = useAmountUsd({
|
|
1418
|
-
amount: toAmount,
|
|
1419
|
-
token: toToken,
|
|
1420
|
-
chainId: Number(toChainId),
|
|
1421
|
-
})
|
|
1521
|
+
const { targetAmountUsd, targetAmountUsdFormatted } = useTargetAmount()
|
|
1422
1522
|
|
|
1423
1523
|
const renderScreenContent = () => {
|
|
1424
1524
|
switch (currentScreen) {
|
|
@@ -1455,14 +1555,15 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1455
1555
|
<FundMethods
|
|
1456
1556
|
onBack={handleBack}
|
|
1457
1557
|
onSelectWalletConnect={handleSelectWalletConnect}
|
|
1458
|
-
|
|
1558
|
+
onSelectExchangeList={handleSelectExchangeList}
|
|
1459
1559
|
onSelectConnectedAccount={() => {
|
|
1460
1560
|
setSelectedFundMethod("connected-account")
|
|
1461
|
-
|
|
1561
|
+
const initialScreen = getInitialScreenForMode(currentMode)
|
|
1562
|
+
setCurrentScreen(initialScreen)
|
|
1462
1563
|
}}
|
|
1463
1564
|
onSelectQrCode={() => {
|
|
1464
1565
|
setSelectedFundMethod("qr-code")
|
|
1465
|
-
setCurrentScreen(
|
|
1566
|
+
setCurrentScreen(getInitialScreenForMode(currentMode))
|
|
1466
1567
|
}}
|
|
1467
1568
|
/>
|
|
1468
1569
|
)
|
|
@@ -1482,14 +1583,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1482
1583
|
/>
|
|
1483
1584
|
)
|
|
1484
1585
|
case "send-form":
|
|
1485
|
-
return
|
|
1486
|
-
<
|
|
1586
|
+
return walletClient?.account ? (
|
|
1587
|
+
<Pay
|
|
1588
|
+
selectedToken={selectedToken}
|
|
1487
1589
|
onSend={handleOnSend}
|
|
1488
1590
|
onBack={handleBack}
|
|
1489
1591
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1490
1592
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1491
1593
|
onComplete={handleTransferComplete}
|
|
1492
|
-
selectedToken={selectedToken}
|
|
1493
1594
|
account={walletClient.account}
|
|
1494
1595
|
toRecipient={
|
|
1495
1596
|
selectedPool
|
|
@@ -1545,8 +1646,10 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1545
1646
|
setGeneratedCalldata(undefined)
|
|
1546
1647
|
}
|
|
1547
1648
|
}}
|
|
1548
|
-
selectedPool={selectedPool}
|
|
1549
1649
|
checkoutOnHandlers={checkoutOnHandlers}
|
|
1650
|
+
recentTokens={recentTokens}
|
|
1651
|
+
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1652
|
+
onTrackToken={handleTrackToken}
|
|
1550
1653
|
/>
|
|
1551
1654
|
) : (
|
|
1552
1655
|
<div className="text-center p-4 rounded-lg text-gray-600 bg-gray-50 dark:text-gray-300 dark:bg-gray-800">
|
|
@@ -1554,30 +1657,32 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1554
1657
|
</div>
|
|
1555
1658
|
)
|
|
1556
1659
|
case "fund-form":
|
|
1557
|
-
return
|
|
1558
|
-
<
|
|
1660
|
+
return walletClient?.account ? (
|
|
1661
|
+
<Fund
|
|
1559
1662
|
onSend={handleOnSend}
|
|
1560
1663
|
onBack={handleBack}
|
|
1561
1664
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1562
1665
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1563
1666
|
onComplete={handleTransferComplete}
|
|
1564
|
-
selectedToken={selectedToken}
|
|
1565
1667
|
account={walletClient.account}
|
|
1566
1668
|
toAmount={toAmount || undefined}
|
|
1567
1669
|
toRecipient={toAddress || undefined}
|
|
1568
1670
|
toChainId={toChainId ? Number(toChainId) : undefined}
|
|
1569
1671
|
toToken={toToken || undefined}
|
|
1672
|
+
toCalldata={toCalldata || undefined}
|
|
1570
1673
|
walletClient={walletClient}
|
|
1571
1674
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1572
1675
|
onError={handleSendError}
|
|
1573
1676
|
paymasterUrls={paymasterUrls}
|
|
1574
1677
|
gasless={gasless}
|
|
1575
1678
|
setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
|
|
1576
|
-
toCalldata={toCalldata || undefined}
|
|
1577
1679
|
quoteProvider={quoteProvider}
|
|
1578
1680
|
fundMethod={selectedFundMethod}
|
|
1579
1681
|
onNavigateToMeshConnect={handleNavigateToMeshConnect}
|
|
1580
1682
|
checkoutOnHandlers={checkoutOnHandlers}
|
|
1683
|
+
recentTokens={recentTokens}
|
|
1684
|
+
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1685
|
+
onTrackToken={handleTrackToken}
|
|
1581
1686
|
/>
|
|
1582
1687
|
) : (
|
|
1583
1688
|
<div className="text-center p-4 rounded-lg text-gray-600 bg-gray-50 dark:text-gray-300 dark:bg-gray-800">
|
|
@@ -1626,6 +1731,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1626
1731
|
toTokenAmount={meshConnectProps?.toTokenAmount}
|
|
1627
1732
|
toChainId={meshConnectProps?.toChainId}
|
|
1628
1733
|
toRecipientAddress={meshConnectProps?.toRecipientAddress}
|
|
1734
|
+
selectedExchange={selectedExchange}
|
|
1629
1735
|
/>
|
|
1630
1736
|
)
|
|
1631
1737
|
case "wallet-connect":
|
|
@@ -1642,15 +1748,29 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1642
1748
|
<WalletList
|
|
1643
1749
|
onBack={handleBack}
|
|
1644
1750
|
onWalletSelect={(walletId) => {
|
|
1751
|
+
logger.console.log(
|
|
1752
|
+
"[trails-sdk] Wallet selected from wallet-list:",
|
|
1753
|
+
walletId,
|
|
1754
|
+
)
|
|
1645
1755
|
if (
|
|
1646
1756
|
allWallets.find((w) => w.id === walletId)?.connector ===
|
|
1647
1757
|
walletConnectConnector
|
|
1648
1758
|
) {
|
|
1649
1759
|
saveLastClickedWallet(walletId)
|
|
1760
|
+
logger.console.log(
|
|
1761
|
+
"[trails-sdk] WalletConnect selected, going to wallet-connect screen",
|
|
1762
|
+
)
|
|
1650
1763
|
setCurrentScreen("wallet-connect")
|
|
1651
1764
|
} else {
|
|
1652
1765
|
saveLastClickedWallet(walletId)
|
|
1653
|
-
|
|
1766
|
+
logger.console.log(
|
|
1767
|
+
"[trails-sdk] Regular wallet selected, going to wallet-connection-pending",
|
|
1768
|
+
)
|
|
1769
|
+
// Reset the redirect flag to prevent immediate navigation
|
|
1770
|
+
setAlreadyRedirectedToTokens(false)
|
|
1771
|
+
setTimeout(() => {
|
|
1772
|
+
setCurrentScreen("wallet-connection-pending")
|
|
1773
|
+
}, 100)
|
|
1654
1774
|
// Auto-trigger connection
|
|
1655
1775
|
setTimeout(() => {
|
|
1656
1776
|
handleWalletConnect(walletId)
|
|
@@ -1747,7 +1867,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1747
1867
|
onBack={handleBack}
|
|
1748
1868
|
isConnected={isConnected}
|
|
1749
1869
|
onConnectWallet={() => setCurrentScreen("connect")}
|
|
1750
|
-
onPay={() => setCurrentScreen("
|
|
1870
|
+
onPay={() => setCurrentScreen("send-form")}
|
|
1751
1871
|
toChainId={toChainId ? Number(toChainId) : undefined}
|
|
1752
1872
|
/>
|
|
1753
1873
|
)
|
|
@@ -1774,8 +1894,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1774
1894
|
onBack={handleBack}
|
|
1775
1895
|
/>
|
|
1776
1896
|
)
|
|
1897
|
+
case "account-settings":
|
|
1898
|
+
return <AccountSettings onBack={handleBack} />
|
|
1899
|
+
case "user-preferences":
|
|
1900
|
+
return <UserPreferences onBack={handleBack} />
|
|
1777
1901
|
case "chain-list":
|
|
1778
1902
|
return <ChainList onBack={() => setCurrentScreen("tokens")} />
|
|
1903
|
+
case "recipients":
|
|
1904
|
+
return <Recipients onBack={handleBack} />
|
|
1779
1905
|
case "disconnect":
|
|
1780
1906
|
return (
|
|
1781
1907
|
<Disconnect
|
|
@@ -1783,6 +1909,13 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1783
1909
|
disconnectHandler={handleWalletDisconnect}
|
|
1784
1910
|
/>
|
|
1785
1911
|
)
|
|
1912
|
+
case "mesh-connect-exchanges":
|
|
1913
|
+
return (
|
|
1914
|
+
<MeshConnectExchanges
|
|
1915
|
+
onBack={handleBack}
|
|
1916
|
+
getInitialScreenForMode={getInitialScreenForMode}
|
|
1917
|
+
/>
|
|
1918
|
+
)
|
|
1786
1919
|
default:
|
|
1787
1920
|
return null
|
|
1788
1921
|
}
|
|
@@ -1865,7 +1998,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1865
1998
|
<motion.button
|
|
1866
1999
|
whileHover={{ scale: 1.02 }}
|
|
1867
2000
|
whileTap={{ scale: 0.98 }}
|
|
1868
|
-
onClick={
|
|
2001
|
+
onClick={handleOpenModal}
|
|
1869
2002
|
className="trails-modal-button cursor-pointer font-semibold py-3 px-6 trails-font"
|
|
1870
2003
|
>
|
|
1871
2004
|
{buttonText || defaultButtonText}
|
|
@@ -1875,7 +2008,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1875
2008
|
whileHover={{ scale: 1.02 }}
|
|
1876
2009
|
whileTap={{ scale: 0.98 }}
|
|
1877
2010
|
className="flex flex-col items-center justify-center"
|
|
1878
|
-
onClick={
|
|
2011
|
+
onClick={handleOpenModal}
|
|
1879
2012
|
>
|
|
1880
2013
|
{children}
|
|
1881
2014
|
</motion.div>
|
|
@@ -1902,21 +2035,38 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
1902
2035
|
|
|
1903
2036
|
return (
|
|
1904
2037
|
<WidgetPropsProvider props={props}>
|
|
1905
|
-
<
|
|
1906
|
-
<
|
|
1907
|
-
<
|
|
1908
|
-
<
|
|
1909
|
-
<
|
|
1910
|
-
<
|
|
1911
|
-
<
|
|
1912
|
-
<
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
2038
|
+
<ToastProvider>
|
|
2039
|
+
<CurrentScreenProvider initialScreen={initialScreen}>
|
|
2040
|
+
<BackProvider>
|
|
2041
|
+
<SelectedTokenProvider>
|
|
2042
|
+
<DestinationSelectedTokenProvider>
|
|
2043
|
+
<SelectedFeeTokenProvider>
|
|
2044
|
+
<SelectedRecipientProvider>
|
|
2045
|
+
<SwapAmountProvider>
|
|
2046
|
+
<ChainFilterProvider>
|
|
2047
|
+
<BalanceVisibleProvider>
|
|
2048
|
+
<SwapSettingsProvider>
|
|
2049
|
+
<ThemePreferenceProvider>
|
|
2050
|
+
<ThemeSyncer />
|
|
2051
|
+
<EarnPoolProvider>
|
|
2052
|
+
<SelectedMeshExchangeProvider>
|
|
2053
|
+
<DefaultTokenSelectionProvider>
|
|
2054
|
+
<WidgetContent ref={ref} />
|
|
2055
|
+
</DefaultTokenSelectionProvider>
|
|
2056
|
+
</SelectedMeshExchangeProvider>
|
|
2057
|
+
</EarnPoolProvider>
|
|
2058
|
+
</ThemePreferenceProvider>
|
|
2059
|
+
</SwapSettingsProvider>
|
|
2060
|
+
</BalanceVisibleProvider>
|
|
2061
|
+
</ChainFilterProvider>
|
|
2062
|
+
</SwapAmountProvider>
|
|
2063
|
+
</SelectedRecipientProvider>
|
|
2064
|
+
</SelectedFeeTokenProvider>
|
|
2065
|
+
</DestinationSelectedTokenProvider>
|
|
2066
|
+
</SelectedTokenProvider>
|
|
2067
|
+
</BackProvider>
|
|
2068
|
+
</CurrentScreenProvider>
|
|
2069
|
+
</ToastProvider>
|
|
1920
2070
|
</WidgetPropsProvider>
|
|
1921
2071
|
)
|
|
1922
2072
|
},
|
|
@@ -1927,51 +2077,57 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
1927
2077
|
const sequenceHooksContext = useContext(SequenceHooksContext)
|
|
1928
2078
|
const wagmiContext = useContext(WagmiContext)
|
|
1929
2079
|
|
|
1930
|
-
|
|
1931
|
-
|
|
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
|
-
|
|
1967
|
-
|
|
1968
|
-
props.walletConnectProjectId
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
2080
|
+
// Set global configuration immediately when component renders
|
|
2081
|
+
// This ensures the config is available before sequenceConfig is created
|
|
2082
|
+
if (props.appId) {
|
|
2083
|
+
logger.console.warn("appId is deprecated. Use projectAccessKey instead.")
|
|
2084
|
+
setSequenceProjectAccessKey(props.appId)
|
|
2085
|
+
}
|
|
2086
|
+
if (props.sequenceEnv) {
|
|
2087
|
+
logger.console.log("props.sequenceEnv", props.sequenceEnv)
|
|
2088
|
+
setSequenceEnv(props.sequenceEnv)
|
|
2089
|
+
}
|
|
2090
|
+
if (props.projectAccessKey) {
|
|
2091
|
+
logger.console.log("props.projectAccessKey", props.projectAccessKey)
|
|
2092
|
+
setSequenceProjectAccessKey(props.projectAccessKey)
|
|
2093
|
+
}
|
|
2094
|
+
if (props.sequenceIndexerUrl) {
|
|
2095
|
+
logger.console.log("props.sequenceIndexerUrl", props.sequenceIndexerUrl)
|
|
2096
|
+
setSequenceIndexerUrl(props.sequenceIndexerUrl)
|
|
2097
|
+
}
|
|
2098
|
+
if (props.sequenceApiUrl) {
|
|
2099
|
+
logger.console.log("props.sequenceApiUrl", props.sequenceApiUrl)
|
|
2100
|
+
setSequenceApiUrl(props.sequenceApiUrl)
|
|
2101
|
+
}
|
|
2102
|
+
if (props.trailsApiUrl) {
|
|
2103
|
+
logger.console.log("props.trailsApiUrl", props.trailsApiUrl)
|
|
2104
|
+
setTrailsApiUrl(props.trailsApiUrl)
|
|
2105
|
+
}
|
|
2106
|
+
if (props.sequenceNodeGatewayUrl) {
|
|
2107
|
+
logger.console.log(
|
|
2108
|
+
"props.sequenceNodeGatewayUrl",
|
|
2109
|
+
props.sequenceNodeGatewayUrl,
|
|
2110
|
+
)
|
|
2111
|
+
setSequenceNodeGatewayUrl(props.sequenceNodeGatewayUrl)
|
|
2112
|
+
}
|
|
2113
|
+
if (props.walletConnectProjectId) {
|
|
2114
|
+
logger.console.log(
|
|
2115
|
+
"props.walletConnectProjectId",
|
|
2116
|
+
props.walletConnectProjectId,
|
|
2117
|
+
)
|
|
2118
|
+
setWalletConnectProjectId(props.walletConnectProjectId)
|
|
2119
|
+
}
|
|
2120
|
+
if (props.slippageTolerance !== undefined) {
|
|
2121
|
+
logger.console.log("props.slippageTolerance", props.slippageTolerance)
|
|
2122
|
+
setSlippageTolerance(String(props.slippageTolerance))
|
|
2123
|
+
}
|
|
2124
|
+
if (typeof props.debug === "boolean") {
|
|
2125
|
+
logger.console.log("props.debug", props.debug)
|
|
2126
|
+
setDebug(props.debug)
|
|
2127
|
+
}
|
|
1972
2128
|
|
|
1973
2129
|
const wagmiConfig = React.useMemo(() => {
|
|
1974
|
-
const chains =
|
|
2130
|
+
const chains = getAllChains() as any
|
|
1975
2131
|
const baseConfig = {
|
|
1976
2132
|
chains,
|
|
1977
2133
|
transports: (chains as Array<Chain>).reduce((acc, chain) => {
|
|
@@ -2023,12 +2179,14 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2023
2179
|
props.appId ||
|
|
2024
2180
|
getSequenceProjectAccessKey(),
|
|
2025
2181
|
env: {
|
|
2182
|
+
env: props.sequenceEnv || getSequenceEnv(),
|
|
2026
2183
|
indexerUrl: props.sequenceIndexerUrl || getSequenceIndexerUrl(),
|
|
2027
2184
|
indexerGatewayUrl:
|
|
2028
2185
|
props.sequenceIndexerUrl || getSequenceIndexerUrl(),
|
|
2029
2186
|
nodeGatewayUrl:
|
|
2030
2187
|
props.sequenceNodeGatewayUrl || getSequenceNodeGatewayUrl(),
|
|
2031
2188
|
apiUrl: props.sequenceApiUrl || getSequenceApiUrl(),
|
|
2189
|
+
trailsApiUrl: props.trailsApiUrl || getTrailsApiUrl(),
|
|
2032
2190
|
},
|
|
2033
2191
|
}
|
|
2034
2192
|
|