0xtrails 0.1.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aave.d.ts.map +1 -1
- package/dist/analytics.d.ts +11 -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/{proxyCaller.d.ts → balanceInjector.d.ts} +5 -4
- package/dist/balanceInjector.d.ts.map +1 -0
- package/dist/{ccip-D3gTQONK.js → ccip-D6ToCrWc.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 +17 -3
- 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/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/{index-CnUM7lKf.js → index-BqgeTLL8.js} +34072 -30146
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +411 -400
- package/dist/intentEntrypoint.d.ts +96 -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 +8 -2
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +1 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/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/transactions.d.ts +8 -0
- 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/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/Fund.d.ts +44 -0
- package/dist/widget/components/Fund.d.ts.map +1 -0
- package/dist/widget/components/Identicon.d.ts +9 -0
- package/dist/widget/components/Identicon.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/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/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/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/useSelectedRecipient.d.ts +12 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +2 -0
- 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 +29 -28
- package/src/aave.ts +6 -1
- package/src/analytics.ts +103 -53
- package/src/apiClient.ts +1 -1
- package/src/{proxyCaller.ts → balanceInjector.ts} +22 -17
- package/src/cctp.ts +6 -2
- package/src/cctpqueue.ts +7 -7
- package/src/chains.ts +8 -0
- package/src/config.ts +40 -9
- package/src/constants.ts +11 -8
- package/src/contractUtils.ts +33 -2
- package/src/customChains.ts +24 -0
- package/src/index.ts +11 -1
- package/src/intentEntrypoint.ts +253 -0
- package/src/intents.ts +87 -54
- package/src/metaTxnMonitor.ts +1 -0
- package/src/morpho.ts +13 -2
- package/src/pools.ts +68 -86
- package/src/prepareSend.ts +437 -207
- package/src/prices.ts +51 -7
- package/src/relaySdk.ts +6 -4
- package/src/relayer.ts +2 -0
- package/src/toast.ts +110 -0
- package/src/tokenBalances.ts +112 -20
- package/src/tokens.ts +70 -7
- package/src/trails.ts +80 -77
- package/src/trailsClient.ts +45 -0
- package/src/transactions.ts +27 -35
- 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 +96 -0
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +10 -20
- package/src/widget/components/ClassicSwap.tsx +923 -0
- package/src/widget/components/ConfigDisplay.tsx +8 -5
- package/src/widget/components/ConnectedWallets.tsx +260 -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 +108 -116
- package/src/widget/components/EarnPools.tsx +2 -4
- package/src/widget/components/EarnPoolsFilters.tsx +6 -6
- package/src/widget/components/Fund.tsx +1245 -0
- package/src/widget/components/FundMethods.tsx +1 -1
- package/src/widget/components/FundSendForm.tsx +1 -1
- package/src/widget/components/Identicon.tsx +158 -0
- package/src/widget/components/Pay.tsx +1088 -0
- package/src/widget/components/PaySendForm.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +1 -1
- 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 +3 -3
- package/src/widget/components/TransactionDetails.tsx +153 -13
- package/src/widget/components/TruncatedAddress.tsx +5 -1
- package/src/widget/components/UserPreferences.tsx +156 -0
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/hooks/useBalanceVisible.tsx +40 -2
- package/src/widget/hooks/useCheckout.ts +13 -0
- package/src/widget/hooks/useCurrentScreen.tsx +3 -0
- package/src/widget/hooks/useDebugScreens.ts +12 -2
- package/src/widget/hooks/useDefaultTokenSelection.tsx +475 -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/useSelectedRecipient.tsx +48 -0
- package/src/widget/hooks/useSendForm.ts +179 -26
- 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 +164 -68
- package/dist/address.d.ts +0 -2
- package/dist/address.d.ts.map +0 -1
- 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,13 @@ import {
|
|
|
112
121
|
useOriginSelectedToken as useSelectedToken,
|
|
113
122
|
} from "./hooks/useOriginSelectedToken.js"
|
|
114
123
|
import { DestinationSelectedTokenProvider } from "./hooks/useDestinationSelectedToken.js"
|
|
124
|
+
import { SelectedRecipientProvider } from "./hooks/useSelectedRecipient.js"
|
|
125
|
+
import { SwapAmountProvider } from "./hooks/useSwapAmount.js"
|
|
115
126
|
import { ChainFilterProvider } from "./hooks/useChainFilter.js"
|
|
116
127
|
import { BalanceVisibleProvider } from "./hooks/useBalanceVisible.js"
|
|
128
|
+
import { SwapSettingsProvider } from "./hooks/useSwapSettings.js"
|
|
129
|
+
import { ThemeProvider as ThemePreferenceProvider } from "./hooks/useTheme.js"
|
|
130
|
+
import { ThemeSyncer } from "./components/ThemeSyncer.js"
|
|
117
131
|
import { EarnPoolProvider, useEarnPool } from "./hooks/useEarnPool.js"
|
|
118
132
|
import { WidgetPropsProvider, useWidgetProps } from "./hooks/useWidgetProps.js"
|
|
119
133
|
import {
|
|
@@ -122,6 +136,7 @@ import {
|
|
|
122
136
|
type Screen,
|
|
123
137
|
} from "./hooks/useCurrentScreen.js"
|
|
124
138
|
import { BackProvider, useBack } from "./hooks/useBack.js"
|
|
139
|
+
import { DefaultTokenSelectionProvider } from "./hooks/useDefaultTokenSelection.js"
|
|
125
140
|
|
|
126
141
|
export const aaveClient = AaveClient.create()
|
|
127
142
|
|
|
@@ -143,6 +158,7 @@ export type TrailsWidgetProps = {
|
|
|
143
158
|
projectAccessKey?: string
|
|
144
159
|
sequenceIndexerUrl?: string | null
|
|
145
160
|
sequenceApiUrl?: string | null
|
|
161
|
+
trailsApiUrl?: string | null
|
|
146
162
|
sequenceNodeGatewayUrl?: string | null
|
|
147
163
|
sequenceEnv?: RelayerEnv
|
|
148
164
|
toAddress?: string | null
|
|
@@ -174,6 +190,8 @@ export type TrailsWidgetProps = {
|
|
|
174
190
|
sessionId: string
|
|
175
191
|
transactionStates: TransactionState[]
|
|
176
192
|
}) => void
|
|
193
|
+
onOpen?: () => void
|
|
194
|
+
onClose?: () => void
|
|
177
195
|
|
|
178
196
|
walletConnectProjectId?: string
|
|
179
197
|
paymasterUrls?: Array<{ chainId: number; url: string }>
|
|
@@ -189,6 +207,12 @@ export type TrailsWidgetProps = {
|
|
|
189
207
|
wagmiConnectors?: Connector[]
|
|
190
208
|
debug?: boolean
|
|
191
209
|
hideDisconnect?: boolean
|
|
210
|
+
toast?: boolean
|
|
211
|
+
appName?: string
|
|
212
|
+
appUrl?: string
|
|
213
|
+
appImageUrl?: string
|
|
214
|
+
appDescription?: string
|
|
215
|
+
payMessage?: string
|
|
192
216
|
}
|
|
193
217
|
|
|
194
218
|
export interface TrailsWidgetRef {
|
|
@@ -397,6 +421,8 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
397
421
|
onCheckoutComplete,
|
|
398
422
|
onCheckoutError,
|
|
399
423
|
onCheckoutStatusUpdate,
|
|
424
|
+
onOpen,
|
|
425
|
+
onClose,
|
|
400
426
|
paymasterUrls,
|
|
401
427
|
gasless,
|
|
402
428
|
buttonText,
|
|
@@ -466,17 +492,24 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
466
492
|
return
|
|
467
493
|
}
|
|
468
494
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
495
|
+
let properInitialScreen: Screen = "connect"
|
|
496
|
+
if (isConnected) {
|
|
497
|
+
if (currentMode === "swap") {
|
|
498
|
+
properInitialScreen = "swap"
|
|
499
|
+
} else if (currentMode === "receive") {
|
|
500
|
+
properInitialScreen = "receive"
|
|
501
|
+
} else if (currentMode === "earn") {
|
|
502
|
+
properInitialScreen = "earn"
|
|
503
|
+
} else if (currentMode === "fund") {
|
|
504
|
+
properInitialScreen = "fund-form"
|
|
505
|
+
} else if (currentMode === "pay") {
|
|
506
|
+
properInitialScreen = "send-form"
|
|
507
|
+
} else {
|
|
508
|
+
properInitialScreen = "tokens"
|
|
509
|
+
}
|
|
510
|
+
} else if (currentMode === "receive") {
|
|
511
|
+
properInitialScreen = "receive"
|
|
512
|
+
}
|
|
480
513
|
|
|
481
514
|
// Only update if the current screen is still the default
|
|
482
515
|
if (currentScreen === "connect" || currentScreen === "receive") {
|
|
@@ -625,7 +658,11 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
625
658
|
toChainId?: number | string | null,
|
|
626
659
|
toToken?: string | null,
|
|
627
660
|
) => {
|
|
628
|
-
|
|
661
|
+
// Only fetch pools when mode is "earn" or "fund"
|
|
662
|
+
const shouldFetchPools = mode === "earn" || mode === "fund"
|
|
663
|
+
const { data: pools, loading: poolsLoading } = usePools({
|
|
664
|
+
enabled: shouldFetchPools,
|
|
665
|
+
})
|
|
629
666
|
|
|
630
667
|
useEffect(() => {
|
|
631
668
|
if (
|
|
@@ -761,11 +798,20 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
761
798
|
if (!alreadyRedirectedToTokens) {
|
|
762
799
|
setAlreadyRedirectedToTokens(true)
|
|
763
800
|
logger.console.log(
|
|
764
|
-
"[trails-sdk]
|
|
765
|
-
|
|
801
|
+
"[trails-sdk] Post-connection navigation triggered",
|
|
802
|
+
{
|
|
803
|
+
currentScreen,
|
|
804
|
+
alreadyRedirectedToTokens,
|
|
805
|
+
isConnected,
|
|
806
|
+
currentMode,
|
|
807
|
+
},
|
|
766
808
|
)
|
|
767
809
|
// Route to appropriate screen based on mode
|
|
768
|
-
if (currentMode === "
|
|
810
|
+
if (currentMode === "fund") {
|
|
811
|
+
setCurrentScreen("fund-form")
|
|
812
|
+
} else if (currentMode === "pay") {
|
|
813
|
+
setCurrentScreen("send-form")
|
|
814
|
+
} else if (currentMode === "swap") {
|
|
769
815
|
setCurrentScreen("swap")
|
|
770
816
|
} else if (currentMode === "receive") {
|
|
771
817
|
setCurrentScreen("receive")
|
|
@@ -827,6 +873,17 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
827
873
|
})
|
|
828
874
|
}, [currentScreen, address])
|
|
829
875
|
|
|
876
|
+
// Identify user with Databeat whenever address changes
|
|
877
|
+
useEffect(() => {
|
|
878
|
+
const analytics = getAnalytics()
|
|
879
|
+
if (address) {
|
|
880
|
+
analytics.identifyUser({ address })
|
|
881
|
+
} else {
|
|
882
|
+
// Unidentify when wallet is disconnected
|
|
883
|
+
analytics.unidentifyUser()
|
|
884
|
+
}
|
|
885
|
+
}, [address])
|
|
886
|
+
|
|
830
887
|
useEffect(() => {
|
|
831
888
|
if (!address || !chainId || !connector?.name) {
|
|
832
889
|
return
|
|
@@ -950,6 +1007,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
950
1007
|
try {
|
|
951
1008
|
await disconnectAsync()
|
|
952
1009
|
setAlreadyRedirectedToTokens(false)
|
|
1010
|
+
trackWalletDisconnected()
|
|
953
1011
|
} catch (error) {
|
|
954
1012
|
logger.console.error("[trails-sdk] Failed to disconnect:", error)
|
|
955
1013
|
}
|
|
@@ -1027,12 +1085,13 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1027
1085
|
const handleTrackToken = (token: Token) => {
|
|
1028
1086
|
// Track the token in recent tokens
|
|
1029
1087
|
const chainInfo = getChainInfo(token.chainId)
|
|
1088
|
+
const decimals = token.contractInfo?.decimals || (token as any).decimals
|
|
1030
1089
|
const supportedToken: SupportedToken = {
|
|
1031
1090
|
id: `${token.symbol}-${chainInfo?.name || token.chainId}`,
|
|
1032
1091
|
symbol: token.symbol,
|
|
1033
1092
|
name: token.name,
|
|
1034
1093
|
contractAddress: token.contractAddress,
|
|
1035
|
-
decimals
|
|
1094
|
+
decimals,
|
|
1036
1095
|
chainId: token.chainId,
|
|
1037
1096
|
chainName: chainInfo?.name || `Chain ${token.chainId}`,
|
|
1038
1097
|
imageUrl: token.imageUrl,
|
|
@@ -1089,27 +1148,28 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1089
1148
|
clearHistory,
|
|
1090
1149
|
])
|
|
1091
1150
|
|
|
1151
|
+
const handleOpenModal = useCallback(() => {
|
|
1152
|
+
setIsModalOpen(true)
|
|
1153
|
+
onOpen?.()
|
|
1154
|
+
}, [onOpen])
|
|
1155
|
+
|
|
1156
|
+
const handleCloseModal = useCallback(() => {
|
|
1157
|
+
setIsModalOpen(false)
|
|
1158
|
+
resetState()
|
|
1159
|
+
onClose?.()
|
|
1160
|
+
}, [resetState, onClose])
|
|
1161
|
+
|
|
1092
1162
|
// Expose modal control methods via ref
|
|
1093
1163
|
useImperativeHandle(
|
|
1094
1164
|
ref,
|
|
1095
1165
|
() => ({
|
|
1096
|
-
openModal:
|
|
1097
|
-
|
|
1098
|
-
},
|
|
1099
|
-
closeModal: () => {
|
|
1100
|
-
setIsModalOpen(false)
|
|
1101
|
-
resetState()
|
|
1102
|
-
},
|
|
1166
|
+
openModal: handleOpenModal,
|
|
1167
|
+
closeModal: handleCloseModal,
|
|
1103
1168
|
isModalOpen,
|
|
1104
1169
|
}),
|
|
1105
|
-
[isModalOpen,
|
|
1170
|
+
[isModalOpen, handleOpenModal, handleCloseModal],
|
|
1106
1171
|
)
|
|
1107
1172
|
|
|
1108
|
-
const handleCloseModal = () => {
|
|
1109
|
-
setIsModalOpen(false)
|
|
1110
|
-
resetState()
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
1173
|
function handleWalletConfirmComplete() {
|
|
1114
1174
|
setCurrentScreen("pending")
|
|
1115
1175
|
}
|
|
@@ -1411,14 +1471,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1411
1471
|
}
|
|
1412
1472
|
}
|
|
1413
1473
|
|
|
1414
|
-
const {
|
|
1415
|
-
amountUsd: targetAmountUsd,
|
|
1416
|
-
amountUsdFormatted: targetAmountUsdFormatted,
|
|
1417
|
-
} = useAmountUsd({
|
|
1418
|
-
amount: toAmount,
|
|
1419
|
-
token: toToken,
|
|
1420
|
-
chainId: Number(toChainId),
|
|
1421
|
-
})
|
|
1474
|
+
const { targetAmountUsd, targetAmountUsdFormatted } = useTargetAmount()
|
|
1422
1475
|
|
|
1423
1476
|
const renderScreenContent = () => {
|
|
1424
1477
|
switch (currentScreen) {
|
|
@@ -1482,14 +1535,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1482
1535
|
/>
|
|
1483
1536
|
)
|
|
1484
1537
|
case "send-form":
|
|
1485
|
-
return
|
|
1486
|
-
<
|
|
1538
|
+
return walletClient?.account ? (
|
|
1539
|
+
<Pay
|
|
1540
|
+
selectedToken={selectedToken}
|
|
1487
1541
|
onSend={handleOnSend}
|
|
1488
1542
|
onBack={handleBack}
|
|
1489
1543
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1490
1544
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1491
1545
|
onComplete={handleTransferComplete}
|
|
1492
|
-
selectedToken={selectedToken}
|
|
1493
1546
|
account={walletClient.account}
|
|
1494
1547
|
toRecipient={
|
|
1495
1548
|
selectedPool
|
|
@@ -1545,8 +1598,10 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1545
1598
|
setGeneratedCalldata(undefined)
|
|
1546
1599
|
}
|
|
1547
1600
|
}}
|
|
1548
|
-
selectedPool={selectedPool}
|
|
1549
1601
|
checkoutOnHandlers={checkoutOnHandlers}
|
|
1602
|
+
recentTokens={recentTokens}
|
|
1603
|
+
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1604
|
+
onTrackToken={handleTrackToken}
|
|
1550
1605
|
/>
|
|
1551
1606
|
) : (
|
|
1552
1607
|
<div className="text-center p-4 rounded-lg text-gray-600 bg-gray-50 dark:text-gray-300 dark:bg-gray-800">
|
|
@@ -1554,30 +1609,32 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1554
1609
|
</div>
|
|
1555
1610
|
)
|
|
1556
1611
|
case "fund-form":
|
|
1557
|
-
return
|
|
1558
|
-
<
|
|
1612
|
+
return walletClient?.account ? (
|
|
1613
|
+
<Fund
|
|
1559
1614
|
onSend={handleOnSend}
|
|
1560
1615
|
onBack={handleBack}
|
|
1561
1616
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
1562
1617
|
onConfirm={() => setCurrentScreen("pending")}
|
|
1563
1618
|
onComplete={handleTransferComplete}
|
|
1564
|
-
selectedToken={selectedToken}
|
|
1565
1619
|
account={walletClient.account}
|
|
1566
1620
|
toAmount={toAmount || undefined}
|
|
1567
1621
|
toRecipient={toAddress || undefined}
|
|
1568
1622
|
toChainId={toChainId ? Number(toChainId) : undefined}
|
|
1569
1623
|
toToken={toToken || undefined}
|
|
1624
|
+
toCalldata={toCalldata || undefined}
|
|
1570
1625
|
walletClient={walletClient}
|
|
1571
1626
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1572
1627
|
onError={handleSendError}
|
|
1573
1628
|
paymasterUrls={paymasterUrls}
|
|
1574
1629
|
gasless={gasless}
|
|
1575
1630
|
setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
|
|
1576
|
-
toCalldata={toCalldata || undefined}
|
|
1577
1631
|
quoteProvider={quoteProvider}
|
|
1578
1632
|
fundMethod={selectedFundMethod}
|
|
1579
1633
|
onNavigateToMeshConnect={handleNavigateToMeshConnect}
|
|
1580
1634
|
checkoutOnHandlers={checkoutOnHandlers}
|
|
1635
|
+
recentTokens={recentTokens}
|
|
1636
|
+
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1637
|
+
onTrackToken={handleTrackToken}
|
|
1581
1638
|
/>
|
|
1582
1639
|
) : (
|
|
1583
1640
|
<div className="text-center p-4 rounded-lg text-gray-600 bg-gray-50 dark:text-gray-300 dark:bg-gray-800">
|
|
@@ -1642,15 +1699,29 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1642
1699
|
<WalletList
|
|
1643
1700
|
onBack={handleBack}
|
|
1644
1701
|
onWalletSelect={(walletId) => {
|
|
1702
|
+
console.log(
|
|
1703
|
+
"[trails-sdk] Wallet selected from wallet-list:",
|
|
1704
|
+
walletId,
|
|
1705
|
+
)
|
|
1645
1706
|
if (
|
|
1646
1707
|
allWallets.find((w) => w.id === walletId)?.connector ===
|
|
1647
1708
|
walletConnectConnector
|
|
1648
1709
|
) {
|
|
1649
1710
|
saveLastClickedWallet(walletId)
|
|
1711
|
+
console.log(
|
|
1712
|
+
"[trails-sdk] WalletConnect selected, going to wallet-connect screen",
|
|
1713
|
+
)
|
|
1650
1714
|
setCurrentScreen("wallet-connect")
|
|
1651
1715
|
} else {
|
|
1652
1716
|
saveLastClickedWallet(walletId)
|
|
1653
|
-
|
|
1717
|
+
console.log(
|
|
1718
|
+
"[trails-sdk] Regular wallet selected, going to wallet-connection-pending",
|
|
1719
|
+
)
|
|
1720
|
+
// Reset the redirect flag to prevent immediate navigation
|
|
1721
|
+
setAlreadyRedirectedToTokens(false)
|
|
1722
|
+
setTimeout(() => {
|
|
1723
|
+
setCurrentScreen("wallet-connection-pending")
|
|
1724
|
+
}, 100)
|
|
1654
1725
|
// Auto-trigger connection
|
|
1655
1726
|
setTimeout(() => {
|
|
1656
1727
|
handleWalletConnect(walletId)
|
|
@@ -1774,8 +1845,14 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1774
1845
|
onBack={handleBack}
|
|
1775
1846
|
/>
|
|
1776
1847
|
)
|
|
1848
|
+
case "account-settings":
|
|
1849
|
+
return <AccountSettings onBack={handleBack} />
|
|
1850
|
+
case "user-preferences":
|
|
1851
|
+
return <UserPreferences onBack={handleBack} />
|
|
1777
1852
|
case "chain-list":
|
|
1778
1853
|
return <ChainList onBack={() => setCurrentScreen("tokens")} />
|
|
1854
|
+
case "recipients":
|
|
1855
|
+
return <Recipients onBack={handleBack} />
|
|
1779
1856
|
case "disconnect":
|
|
1780
1857
|
return (
|
|
1781
1858
|
<Disconnect
|
|
@@ -1865,7 +1942,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1865
1942
|
<motion.button
|
|
1866
1943
|
whileHover={{ scale: 1.02 }}
|
|
1867
1944
|
whileTap={{ scale: 0.98 }}
|
|
1868
|
-
onClick={
|
|
1945
|
+
onClick={handleOpenModal}
|
|
1869
1946
|
className="trails-modal-button cursor-pointer font-semibold py-3 px-6 trails-font"
|
|
1870
1947
|
>
|
|
1871
1948
|
{buttonText || defaultButtonText}
|
|
@@ -1875,7 +1952,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1875
1952
|
whileHover={{ scale: 1.02 }}
|
|
1876
1953
|
whileTap={{ scale: 0.98 }}
|
|
1877
1954
|
className="flex flex-col items-center justify-center"
|
|
1878
|
-
onClick={
|
|
1955
|
+
onClick={handleOpenModal}
|
|
1879
1956
|
>
|
|
1880
1957
|
{children}
|
|
1881
1958
|
</motion.div>
|
|
@@ -1902,21 +1979,34 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
1902
1979
|
|
|
1903
1980
|
return (
|
|
1904
1981
|
<WidgetPropsProvider props={props}>
|
|
1905
|
-
<
|
|
1906
|
-
<
|
|
1907
|
-
<
|
|
1908
|
-
<
|
|
1909
|
-
<
|
|
1910
|
-
<
|
|
1911
|
-
<
|
|
1912
|
-
<
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1982
|
+
<ToastProvider>
|
|
1983
|
+
<CurrentScreenProvider initialScreen={initialScreen}>
|
|
1984
|
+
<BackProvider>
|
|
1985
|
+
<SelectedTokenProvider>
|
|
1986
|
+
<DestinationSelectedTokenProvider>
|
|
1987
|
+
<SelectedRecipientProvider>
|
|
1988
|
+
<SwapAmountProvider>
|
|
1989
|
+
<ChainFilterProvider>
|
|
1990
|
+
<BalanceVisibleProvider>
|
|
1991
|
+
<SwapSettingsProvider>
|
|
1992
|
+
<ThemePreferenceProvider>
|
|
1993
|
+
<ThemeSyncer />
|
|
1994
|
+
<EarnPoolProvider>
|
|
1995
|
+
<DefaultTokenSelectionProvider>
|
|
1996
|
+
<WidgetContent ref={ref} />
|
|
1997
|
+
</DefaultTokenSelectionProvider>
|
|
1998
|
+
</EarnPoolProvider>
|
|
1999
|
+
</ThemePreferenceProvider>
|
|
2000
|
+
</SwapSettingsProvider>
|
|
2001
|
+
</BalanceVisibleProvider>
|
|
2002
|
+
</ChainFilterProvider>
|
|
2003
|
+
</SwapAmountProvider>
|
|
2004
|
+
</SelectedRecipientProvider>
|
|
2005
|
+
</DestinationSelectedTokenProvider>
|
|
2006
|
+
</SelectedTokenProvider>
|
|
2007
|
+
</BackProvider>
|
|
2008
|
+
</CurrentScreenProvider>
|
|
2009
|
+
</ToastProvider>
|
|
1920
2010
|
</WidgetPropsProvider>
|
|
1921
2011
|
)
|
|
1922
2012
|
},
|
|
@@ -1946,6 +2036,9 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
1946
2036
|
if (props.sequenceApiUrl) {
|
|
1947
2037
|
setSequenceApiUrl(props.sequenceApiUrl)
|
|
1948
2038
|
}
|
|
2039
|
+
if (props.trailsApiUrl) {
|
|
2040
|
+
setTrailsApiUrl(props.trailsApiUrl)
|
|
2041
|
+
}
|
|
1949
2042
|
if (props.sequenceNodeGatewayUrl) {
|
|
1950
2043
|
setSequenceNodeGatewayUrl(props.sequenceNodeGatewayUrl)
|
|
1951
2044
|
}
|
|
@@ -1963,6 +2056,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
1963
2056
|
props.projectAccessKey,
|
|
1964
2057
|
props.sequenceIndexerUrl,
|
|
1965
2058
|
props.sequenceApiUrl,
|
|
2059
|
+
props.trailsApiUrl,
|
|
1966
2060
|
props.sequenceNodeGatewayUrl,
|
|
1967
2061
|
props.sequenceEnv,
|
|
1968
2062
|
props.walletConnectProjectId,
|
|
@@ -1971,7 +2065,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
1971
2065
|
])
|
|
1972
2066
|
|
|
1973
2067
|
const wagmiConfig = React.useMemo(() => {
|
|
1974
|
-
const chains =
|
|
2068
|
+
const chains = getAllChains() as any
|
|
1975
2069
|
const baseConfig = {
|
|
1976
2070
|
chains,
|
|
1977
2071
|
transports: (chains as Array<Chain>).reduce((acc, chain) => {
|
|
@@ -2023,12 +2117,14 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2023
2117
|
props.appId ||
|
|
2024
2118
|
getSequenceProjectAccessKey(),
|
|
2025
2119
|
env: {
|
|
2120
|
+
env: props.sequenceEnv || getSequenceEnv(),
|
|
2026
2121
|
indexerUrl: props.sequenceIndexerUrl || getSequenceIndexerUrl(),
|
|
2027
2122
|
indexerGatewayUrl:
|
|
2028
2123
|
props.sequenceIndexerUrl || getSequenceIndexerUrl(),
|
|
2029
2124
|
nodeGatewayUrl:
|
|
2030
2125
|
props.sequenceNodeGatewayUrl || getSequenceNodeGatewayUrl(),
|
|
2031
2126
|
apiUrl: props.sequenceApiUrl || getSequenceApiUrl(),
|
|
2127
|
+
trailsApiUrl: props.trailsApiUrl || getTrailsApiUrl(),
|
|
2032
2128
|
},
|
|
2033
2129
|
}
|
|
2034
2130
|
|
package/dist/address.d.ts
DELETED
package/dist/address.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAI,UAK1D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxyCaller.d.ts","sourceRoot":"","sources":["../src/proxyCaller.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kCAAkC,kFACsB,CAAA;AA4BrE,wBAAgB,yBAAyB,CAAC,EACxC,KAAK,EACL,MAAM,EACN,QAAQ,EACR,YAAY,GACb,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;CACrB,iBAUA;AAED,wBAAgB,mCAAmC,CAAC,EAClD,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,MAAM,EACN,kBAAkB,EAClB,uBAAuB,GACxB,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,EAAE,MAAM,CAAA;IAC1B,uBAAuB,EAAE,MAAM,CAAA;CAChC,GAAG;IAAE,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAyCxE"}
|