0xtrails 0.2.6 → 0.4.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 +2 -0
- package/dist/aave.d.ts.map +1 -1
- package/dist/{ccip-Xjh9d1gb.js → ccip-BpQGQiWq.js} +7 -7
- package/dist/config.d.ts +0 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +4 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/fees.d.ts +2 -2
- package/dist/fees.d.ts.map +1 -1
- package/dist/{index-BnhdZ8Ho.js → index-DsJM5F-V.js} +46084 -48697
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +741 -923
- package/dist/intentReceiptMonitor.d.ts +24 -0
- package/dist/intentReceiptMonitor.d.ts.map +1 -0
- package/dist/intentReceiptPoller.d.ts +69 -0
- package/dist/intentReceiptPoller.d.ts.map +1 -0
- package/dist/intents.d.ts +15 -11
- package/dist/intents.d.ts.map +1 -1
- package/dist/morpho.d.ts +6 -5
- package/dist/morpho.d.ts.map +1 -1
- package/dist/mutations.d.ts +16 -0
- package/dist/mutations.d.ts.map +1 -0
- package/dist/preconditions.d.ts +5 -4
- package/dist/preconditions.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +5 -190
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +9 -6
- package/dist/prices.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -16
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +17 -13
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/trails.d.ts +24 -40
- package/dist/trails.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +5 -6
- package/dist/trailsClient.d.ts.map +1 -1
- package/dist/transactionIntent/constants.d.ts +7 -0
- package/dist/transactionIntent/constants.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +44 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/index.d.ts +4 -0
- package/dist/transactionIntent/deposits/index.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/execution/index.d.ts +2 -0
- package/dist/transactionIntent/execution/index.d.ts.map +1 -0
- package/dist/transactionIntent/execution/transactionState.d.ts +5 -0
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts +82 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/index.d.ts +4 -0
- package/dist/transactionIntent/handlers/index.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +62 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +72 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -0
- package/dist/transactionIntent/index.d.ts +9 -0
- package/dist/transactionIntent/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts +17 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -0
- package/dist/transactionIntent/quote/index.d.ts +4 -0
- package/dist/transactionIntent/quote/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts +34 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +5 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/types.d.ts +131 -0
- package/dist/transactionIntent/types.d.ts.map +1 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts +18 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts.map +1 -0
- package/dist/transactionIntent/utils/index.d.ts +4 -0
- package/dist/transactionIntent/utils/index.d.ts.map +1 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts +10 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts +3 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/validators.d.ts +6 -0
- package/dist/transactionIntent/validators.d.ts.map +1 -0
- package/dist/transactions.d.ts +2 -1
- package/dist/transactions.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +0 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DynamicSizeInputField.d.ts +13 -0
- package/dist/widget/components/DynamicSizeInputField.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts +0 -1
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/FeeOptions.d.ts +5 -13
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +0 -1
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSwap.d.ts +0 -1
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +0 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +0 -1
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +0 -18
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts +1 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +0 -1
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +2 -2
- package/dist/widget/hooks/useCheckout.d.ts +17 -4
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +3 -4
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +3 -4
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts +25 -0
- package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +1 -0
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts +12 -7
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +21 -23
- package/src/aave.ts +54 -1
- package/src/config.ts +57 -58
- package/src/constants.ts +8 -9
- package/src/error.ts +21 -3
- package/src/fees.ts +53 -42
- package/src/index.ts +35 -13
- package/src/intentReceiptMonitor.ts +102 -0
- package/src/intentReceiptPoller.ts +299 -0
- package/src/intents.ts +206 -172
- package/src/morpho.ts +58 -9
- package/src/mutations.ts +129 -0
- package/src/preconditions.ts +16 -21
- package/src/prepareSend.ts +80 -4514
- package/src/prices.ts +26 -22
- package/src/relaySdk.ts +2 -2
- package/src/sequenceWallet.ts +6 -73
- package/src/tokenBalances.ts +175 -69
- package/src/trails.ts +230 -722
- package/src/trailsClient.ts +10 -23
- package/src/transactionIntent/constants.ts +11 -0
- package/src/transactionIntent/deposits/depositOrchestrator.ts +210 -0
- package/src/transactionIntent/deposits/gaslessDeposit.ts +588 -0
- package/src/transactionIntent/deposits/index.ts +3 -0
- package/src/transactionIntent/deposits/standardDeposit.ts +379 -0
- package/src/transactionIntent/execution/index.ts +1 -0
- package/src/transactionIntent/execution/transactionState.ts +35 -0
- package/src/transactionIntent/handlers/crossChain.ts +1707 -0
- package/src/transactionIntent/handlers/index.ts +3 -0
- package/src/transactionIntent/handlers/sameChainDifferentToken.ts +323 -0
- package/src/transactionIntent/handlers/sameChainSameToken.ts +712 -0
- package/src/transactionIntent/index.ts +9 -0
- package/src/transactionIntent/quote/feeExtractors.ts +81 -0
- package/src/transactionIntent/quote/index.ts +3 -0
- package/src/transactionIntent/quote/normalizeQuote.ts +367 -0
- package/src/transactionIntent/quote/quoteHelpers.ts +53 -0
- package/src/transactionIntent/types.ts +157 -0
- package/src/transactionIntent/utils/balanceChecker.ts +96 -0
- package/src/transactionIntent/utils/index.ts +3 -0
- package/src/transactionIntent/utils/lifiHelpers.ts +68 -0
- package/src/transactionIntent/utils/testnetHelpers.ts +10 -0
- package/src/transactionIntent/validators.ts +57 -0
- package/src/transactions.ts +36 -53
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountIntentTransactionHistory.tsx +36 -36
- package/src/widget/components/AccountSettings.tsx +23 -6
- package/src/widget/components/ClassicSwap.tsx +28 -53
- package/src/widget/components/ConfigDisplay.tsx +0 -11
- package/src/widget/components/ConnectedWallets.tsx +30 -4
- package/src/widget/components/DynamicSizeInputField.tsx +109 -0
- package/src/widget/components/Earn.tsx +0 -16
- package/src/widget/components/FeeBreakdown.tsx +3 -3
- package/src/widget/components/FeeOption.tsx +2 -2
- package/src/widget/components/FeeOptions.tsx +151 -112
- package/src/widget/components/Fund.tsx +0 -3
- package/src/widget/components/FundMethods.tsx +4 -3
- package/src/widget/components/FundSwap.tsx +0 -1
- package/src/widget/components/Pay.tsx +11 -16
- package/src/widget/components/PoolDeposit.tsx +35 -32
- package/src/widget/components/PoolWithdraw.tsx +153 -256
- package/src/widget/components/QuoteDetails.tsx +899 -494
- package/src/widget/components/Swap.tsx +0 -1
- package/src/widget/components/TransferPendingVertical.tsx +12 -8
- package/src/widget/components/WaasFeeOptions.tsx +23 -7
- package/src/widget/components/WalletConfirmation.tsx +1 -1
- package/src/widget/hooks/useAmountUsd.ts +9 -9
- package/src/widget/hooks/useCheckout.ts +97 -9
- package/src/widget/hooks/useDefaultTokenSelection.tsx +27 -21
- package/src/widget/hooks/useQuote.ts +86 -33
- package/src/widget/hooks/useSelectedFeeToken.tsx +32 -37
- package/src/widget/hooks/useSendForm.ts +37 -47
- package/src/widget/hooks/useTokenList.ts +34 -26
- package/src/widget/hooks/useWalletConnectionContext.tsx +128 -0
- package/src/widget/widget.tsx +197 -207
- package/dist/apiClient.d.ts +0 -9
- package/dist/apiClient.d.ts.map +0 -1
- package/dist/intentEntrypoint.d.ts +0 -114
- package/dist/intentEntrypoint.d.ts.map +0 -1
- package/dist/metaTxnMonitor.d.ts +0 -15
- package/dist/metaTxnMonitor.d.ts.map +0 -1
- package/dist/metaTxns.d.ts +0 -11
- package/dist/metaTxns.d.ts.map +0 -1
- package/dist/relayer.d.ts +0 -43
- package/dist/relayer.d.ts.map +0 -1
- package/src/apiClient.ts +0 -35
- package/src/intentEntrypoint.ts +0 -203
- package/src/metaTxnMonitor.ts +0 -171
- package/src/metaTxns.ts +0 -45
- package/src/relayer.ts +0 -289
package/src/widget/widget.tsx
CHANGED
|
@@ -17,13 +17,7 @@ import React, {
|
|
|
17
17
|
} from "react"
|
|
18
18
|
import { createPortal } from "react-dom"
|
|
19
19
|
import type { Chain, WalletClient } from "viem"
|
|
20
|
-
import {
|
|
21
|
-
createWalletClient,
|
|
22
|
-
custom,
|
|
23
|
-
encodeFunctionData,
|
|
24
|
-
http,
|
|
25
|
-
isAddress,
|
|
26
|
-
} from "viem"
|
|
20
|
+
import { createWalletClient, custom, http, isAddress } from "viem"
|
|
27
21
|
import type { Connector } from "wagmi"
|
|
28
22
|
import {
|
|
29
23
|
createConfig,
|
|
@@ -32,6 +26,7 @@ import {
|
|
|
32
26
|
useConnect,
|
|
33
27
|
useConnections,
|
|
34
28
|
useDisconnect,
|
|
29
|
+
useSwitchAccount,
|
|
35
30
|
WagmiContext,
|
|
36
31
|
WagmiProvider,
|
|
37
32
|
} from "wagmi"
|
|
@@ -46,15 +41,10 @@ import { getAllChains, getChainInfo, getRpcUrl } from "../chains.js"
|
|
|
46
41
|
import {
|
|
47
42
|
getCommitHash,
|
|
48
43
|
getDebug,
|
|
49
|
-
getSequenceApiUrl,
|
|
50
|
-
getSequenceEnv,
|
|
51
44
|
getSequenceIndexerUrl,
|
|
52
45
|
getSequenceNodeGatewayUrl,
|
|
53
|
-
getSequenceProjectAccessKey,
|
|
54
46
|
getTrailsApiUrl,
|
|
55
47
|
setDebug,
|
|
56
|
-
setSequenceApiUrl,
|
|
57
|
-
setSequenceEnv,
|
|
58
48
|
setSequenceIndexerUrl,
|
|
59
49
|
setSequenceNodeGatewayUrl,
|
|
60
50
|
setSequenceProjectAccessKey,
|
|
@@ -68,7 +58,7 @@ import {
|
|
|
68
58
|
getIsApiError,
|
|
69
59
|
getIsBalanceTooLowError,
|
|
70
60
|
getIsRateLimitedError,
|
|
71
|
-
|
|
61
|
+
getIsUserRejectionError,
|
|
72
62
|
getPrettifiedErrorMessage,
|
|
73
63
|
} from "../error.js"
|
|
74
64
|
import { logger } from "../logger.js"
|
|
@@ -77,7 +67,7 @@ import type { Pool } from "../pools.js"
|
|
|
77
67
|
import { usePools } from "../pools.js"
|
|
78
68
|
import type { PrepareSendQuote } from "../prepareSend.js"
|
|
79
69
|
import { isValidInteger, isValidNumeric } from "../prices.js"
|
|
80
|
-
import type { MetaTxnReceipt
|
|
70
|
+
import type { MetaTxnReceipt } from "../transactionIntent/types.js"
|
|
81
71
|
import type { Theme } from "../theme.js"
|
|
82
72
|
import type { SupportedToken } from "../tokens.js"
|
|
83
73
|
import { getWethAddress } from "../tokens.js"
|
|
@@ -125,6 +115,10 @@ import {
|
|
|
125
115
|
useCurrentScreen,
|
|
126
116
|
type Screen,
|
|
127
117
|
} from "./hooks/useCurrentScreen.js"
|
|
118
|
+
import {
|
|
119
|
+
WalletConnectionProvider,
|
|
120
|
+
useWalletConnectionContext,
|
|
121
|
+
} from "./hooks/useWalletConnectionContext.js"
|
|
128
122
|
import { useDebugScreens } from "./hooks/useDebugScreens.js"
|
|
129
123
|
import { DefaultTokenSelectionProvider } from "./hooks/useDefaultTokenSelection.js"
|
|
130
124
|
import { DestinationSelectedTokenProvider } from "./hooks/useDestinationSelectedToken.js"
|
|
@@ -143,7 +137,10 @@ import {
|
|
|
143
137
|
SelectedMeshExchangeProvider,
|
|
144
138
|
useSelectedMeshExchange,
|
|
145
139
|
} from "./hooks/useSelectedMeshExchange.js"
|
|
146
|
-
import {
|
|
140
|
+
import {
|
|
141
|
+
SelectedRecipientProvider,
|
|
142
|
+
useSelectedRecipient,
|
|
143
|
+
} from "./hooks/useSelectedRecipient.js"
|
|
147
144
|
import type { OnCompleteProps } from "./hooks/useSendForm.js"
|
|
148
145
|
import { SwapAmountProvider } from "./hooks/useSwapAmount.js"
|
|
149
146
|
import { useTargetAmount } from "./hooks/useTargetAmount.js"
|
|
@@ -154,6 +151,8 @@ import {
|
|
|
154
151
|
useSelectedFundMethod,
|
|
155
152
|
} from "./hooks/useSelectedFundMethod.js"
|
|
156
153
|
import { DEFAULT_MODE } from "../constants.js"
|
|
154
|
+
import { generateMorphoDepositCalldata } from "../morpho.js"
|
|
155
|
+
import { generateAaveDepositCalldata } from "../aave.js"
|
|
157
156
|
|
|
158
157
|
export const aaveClient = AaveClient.create()
|
|
159
158
|
|
|
@@ -203,13 +202,10 @@ const isValidToToToken = (toToken: string | null | undefined) => {
|
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
export type TrailsWidgetProps = {
|
|
206
|
-
|
|
207
|
-
projectAccessKey?: string
|
|
205
|
+
apiKey: string
|
|
208
206
|
sequenceIndexerUrl?: string | null
|
|
209
|
-
sequenceApiUrl?: string | null
|
|
210
207
|
trailsApiUrl?: string | null
|
|
211
208
|
sequenceNodeGatewayUrl?: string | null
|
|
212
|
-
sequenceEnv?: RelayerEnv
|
|
213
209
|
toAddress?: string | null
|
|
214
210
|
toAmount?: string | null
|
|
215
211
|
toChainId?: number | string | null
|
|
@@ -232,8 +228,14 @@ export type TrailsWidgetProps = {
|
|
|
232
228
|
}) => void
|
|
233
229
|
onCheckoutStart?: (data: { sessionId: string }) => void
|
|
234
230
|
onCheckoutQuote?: (data: { sessionId: string; quote: any }) => void
|
|
231
|
+
onCheckoutSignatureRequest?: (data: { sessionId: string }) => void
|
|
232
|
+
onCheckoutSignatureConfirmed?: (data: { sessionId: string }) => void
|
|
233
|
+
onCheckoutSignatureRejected?: (data: {
|
|
234
|
+
sessionId: string
|
|
235
|
+
error: unknown
|
|
236
|
+
}) => void
|
|
235
237
|
onCheckoutComplete?: (data: { sessionId: string }) => void
|
|
236
|
-
onCheckoutError?: (data: { sessionId: string; error:
|
|
238
|
+
onCheckoutError?: (data: { sessionId: string; error: unknown }) => void
|
|
237
239
|
onCheckoutStatusUpdate?: (data: {
|
|
238
240
|
sessionId: string
|
|
239
241
|
transactionStates: TransactionState[]
|
|
@@ -243,7 +245,6 @@ export type TrailsWidgetProps = {
|
|
|
243
245
|
|
|
244
246
|
walletConnectProjectId?: string
|
|
245
247
|
paymasterUrls?: Array<{ chainId: number; url: string }>
|
|
246
|
-
gasless?: boolean
|
|
247
248
|
buttonText?: string
|
|
248
249
|
customCss?: string | Record<string, string>
|
|
249
250
|
disableCss?: boolean
|
|
@@ -471,13 +472,15 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
471
472
|
onDestinationConfirmation,
|
|
472
473
|
onCheckoutStart,
|
|
473
474
|
onCheckoutQuote,
|
|
475
|
+
onCheckoutSignatureRequest,
|
|
476
|
+
onCheckoutSignatureConfirmed,
|
|
477
|
+
onCheckoutSignatureRejected,
|
|
474
478
|
onCheckoutComplete,
|
|
475
479
|
onCheckoutError,
|
|
476
480
|
onCheckoutStatusUpdate,
|
|
477
481
|
onOpen,
|
|
478
482
|
onClose,
|
|
479
483
|
paymasterUrls,
|
|
480
|
-
gasless,
|
|
481
484
|
buttonText,
|
|
482
485
|
quoteProvider,
|
|
483
486
|
priceImpactWarningThresholdBps,
|
|
@@ -508,6 +511,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
508
511
|
}, [connector])
|
|
509
512
|
const connections = useConnections()
|
|
510
513
|
const { disconnectAsync } = useDisconnect()
|
|
514
|
+
const { switchAccount } = useSwitchAccount()
|
|
511
515
|
|
|
512
516
|
// Check if there are any connected accounts across all connectors
|
|
513
517
|
const isConnected = connections.length > 0
|
|
@@ -520,6 +524,9 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
520
524
|
const { currentScreen, setCurrentScreen } = useCurrentScreen()
|
|
521
525
|
const { goBack, clearHistory, setCurrentScreenWithBack, getPreviousScreen } =
|
|
522
526
|
useBack()
|
|
527
|
+
const { connectionContext, clearConnectionContext, isRecipientSelection } =
|
|
528
|
+
useWalletConnectionContext()
|
|
529
|
+
const { setSelectedRecipient } = useSelectedRecipient()
|
|
523
530
|
|
|
524
531
|
// Wrapper function that clears errors when going back
|
|
525
532
|
const handleBack = () => {
|
|
@@ -870,6 +877,9 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
870
877
|
const { checkoutOnHandlers } = useCheckout({
|
|
871
878
|
onCheckoutStart,
|
|
872
879
|
onCheckoutQuote,
|
|
880
|
+
onCheckoutSignatureRequest,
|
|
881
|
+
onCheckoutSignatureConfirmed,
|
|
882
|
+
onCheckoutSignatureRejected,
|
|
873
883
|
onCheckoutComplete,
|
|
874
884
|
onCheckoutError,
|
|
875
885
|
onCheckoutStatusUpdate,
|
|
@@ -1015,28 +1025,83 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1015
1025
|
}
|
|
1016
1026
|
|
|
1017
1027
|
if (config.connector !== walletConnectConnector) {
|
|
1028
|
+
// Store the current active connector BEFORE connecting new wallet
|
|
1029
|
+
const originalConnector = connector
|
|
1030
|
+
|
|
1018
1031
|
logger.console.log(
|
|
1019
1032
|
"[trails-sdk] Initiating connection to walletId",
|
|
1020
1033
|
walletId,
|
|
1021
1034
|
)
|
|
1022
|
-
await connectAsync({ connector: config.connector })
|
|
1035
|
+
const result = await connectAsync({ connector: config.connector })
|
|
1023
1036
|
logger.console.log(
|
|
1024
1037
|
`[trails-sdk] Successfully connected to ${config.name}`,
|
|
1038
|
+
result,
|
|
1025
1039
|
)
|
|
1026
1040
|
// Set the last clicked wallet after successful connection
|
|
1027
1041
|
saveLastClickedWallet(walletId)
|
|
1028
1042
|
|
|
1029
|
-
// Check
|
|
1030
|
-
if (
|
|
1031
|
-
//
|
|
1032
|
-
logger.console.log(
|
|
1033
|
-
|
|
1043
|
+
// Check the wallet connection context to determine behavior
|
|
1044
|
+
if (isRecipientSelection) {
|
|
1045
|
+
// User connected wallet for recipient selection - switch back to original wallet
|
|
1046
|
+
logger.console.log(
|
|
1047
|
+
"[trails-sdk] Connected wallet for recipient selection, setting as recipient:",
|
|
1048
|
+
result.accounts[0],
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
// Set the newly connected wallet as the recipient
|
|
1052
|
+
if (result.accounts[0]) {
|
|
1053
|
+
setSelectedRecipient(result.accounts[0])
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
// Switch back to the original active wallet (if there was one)
|
|
1057
|
+
if (originalConnector && address) {
|
|
1058
|
+
try {
|
|
1059
|
+
logger.console.log(
|
|
1060
|
+
"[trails-sdk] Switching back to original active wallet:",
|
|
1061
|
+
address,
|
|
1062
|
+
)
|
|
1063
|
+
await switchAccount({ connector: originalConnector })
|
|
1064
|
+
} catch (switchError) {
|
|
1065
|
+
logger.console.error(
|
|
1066
|
+
"[trails-sdk] Failed to switch back to original wallet:",
|
|
1067
|
+
switchError,
|
|
1068
|
+
)
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// Clear the connection context
|
|
1073
|
+
clearConnectionContext()
|
|
1074
|
+
|
|
1075
|
+
// Navigate back to the origin screen (recipients)
|
|
1076
|
+
const originScreen = connectionContext.originScreen
|
|
1077
|
+
if (originScreen) {
|
|
1078
|
+
setCurrentScreen(originScreen)
|
|
1079
|
+
} else {
|
|
1080
|
+
setCurrentScreen("recipients")
|
|
1081
|
+
}
|
|
1034
1082
|
} else {
|
|
1035
|
-
//
|
|
1083
|
+
// Normal connection - switch active wallet and navigate home
|
|
1036
1084
|
logger.console.log(
|
|
1037
|
-
"[trails-sdk]
|
|
1085
|
+
"[trails-sdk] Normal wallet connection, switching active wallet",
|
|
1038
1086
|
)
|
|
1039
|
-
|
|
1087
|
+
|
|
1088
|
+
// Clear the connection context
|
|
1089
|
+
clearConnectionContext()
|
|
1090
|
+
|
|
1091
|
+
// Check if this is the first wallet connection
|
|
1092
|
+
if (!hasConnectedBefore) {
|
|
1093
|
+
// First connection - go to initial screen for the mode
|
|
1094
|
+
logger.console.log(
|
|
1095
|
+
"[trails-sdk] First wallet connection, going home",
|
|
1096
|
+
)
|
|
1097
|
+
goHome()
|
|
1098
|
+
} else {
|
|
1099
|
+
// Subsequent connection - go to home which will route to the appropriate screen
|
|
1100
|
+
logger.console.log(
|
|
1101
|
+
"[trails-sdk] Subsequent wallet connection, going to home",
|
|
1102
|
+
)
|
|
1103
|
+
goHome()
|
|
1104
|
+
}
|
|
1040
1105
|
}
|
|
1041
1106
|
} else if (config.connector === walletConnectConnector) {
|
|
1042
1107
|
// Store the current connector as previous before switching to WalletConnect
|
|
@@ -1099,19 +1164,62 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1099
1164
|
}
|
|
1100
1165
|
}
|
|
1101
1166
|
|
|
1102
|
-
const handleContinue = () => {
|
|
1103
|
-
if
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1167
|
+
const handleContinue = async () => {
|
|
1168
|
+
// Check if this was a recipient selection connection
|
|
1169
|
+
if (isRecipientSelection) {
|
|
1170
|
+
logger.console.log(
|
|
1171
|
+
"[trails-sdk] WalletConnect completed for recipient selection, setting as recipient:",
|
|
1172
|
+
address,
|
|
1173
|
+
)
|
|
1174
|
+
|
|
1175
|
+
// Set the newly connected wallet as the recipient
|
|
1176
|
+
if (address) {
|
|
1177
|
+
setSelectedRecipient(address)
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// Switch back to the original active wallet (if there was one)
|
|
1181
|
+
const originalConnector = connectionContext.originalActiveConnector
|
|
1182
|
+
const originalAddress = connectionContext.originalActiveWalletAddress
|
|
1183
|
+
if (originalConnector && originalAddress) {
|
|
1184
|
+
try {
|
|
1185
|
+
logger.console.log(
|
|
1186
|
+
"[trails-sdk] Switching back to original active wallet after WalletConnect:",
|
|
1187
|
+
originalAddress,
|
|
1188
|
+
)
|
|
1189
|
+
await switchAccount({ connector: originalConnector })
|
|
1190
|
+
} catch (switchError) {
|
|
1191
|
+
logger.console.error(
|
|
1192
|
+
"[trails-sdk] Failed to switch back to original wallet after WalletConnect:",
|
|
1193
|
+
switchError,
|
|
1194
|
+
)
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// Clear the connection context
|
|
1199
|
+
clearConnectionContext()
|
|
1200
|
+
|
|
1201
|
+
// Navigate back to the origin screen (recipients)
|
|
1202
|
+
const originScreen = connectionContext.originScreen
|
|
1203
|
+
if (originScreen) {
|
|
1204
|
+
setCurrentScreen(originScreen)
|
|
1205
|
+
} else {
|
|
1206
|
+
setCurrentScreen("recipients")
|
|
1207
|
+
}
|
|
1113
1208
|
} else {
|
|
1114
|
-
|
|
1209
|
+
// Normal flow - navigate based on mode
|
|
1210
|
+
if (currentMode === "swap") {
|
|
1211
|
+
setCurrentScreen("swap")
|
|
1212
|
+
} else if (currentMode === "receive") {
|
|
1213
|
+
setCurrentScreen("receive")
|
|
1214
|
+
} else if (currentMode === "earn") {
|
|
1215
|
+
setCurrentScreen("earn")
|
|
1216
|
+
} else if (currentMode === "fund") {
|
|
1217
|
+
setCurrentScreen("fund-form")
|
|
1218
|
+
} else if (currentMode === "pay") {
|
|
1219
|
+
setCurrentScreen("send-form")
|
|
1220
|
+
} else {
|
|
1221
|
+
setCurrentScreen("account-settings")
|
|
1222
|
+
}
|
|
1115
1223
|
}
|
|
1116
1224
|
}
|
|
1117
1225
|
|
|
@@ -1273,7 +1381,8 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1273
1381
|
) {
|
|
1274
1382
|
setDestinationTxHash(
|
|
1275
1383
|
lastTransactionState?.transactionHash ||
|
|
1276
|
-
(lastTransactionState as unknown as MetaTxnReceipt)?.txnHash
|
|
1384
|
+
(lastTransactionState as unknown as MetaTxnReceipt)?.txnHash ||
|
|
1385
|
+
"",
|
|
1277
1386
|
)
|
|
1278
1387
|
setDestinationChainId(lastTransactionState?.chainId)
|
|
1279
1388
|
}
|
|
@@ -1345,102 +1454,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1345
1454
|
}
|
|
1346
1455
|
}
|
|
1347
1456
|
|
|
1348
|
-
// Generate deposit calldata for Aave pool
|
|
1349
|
-
const generateAaveDepositCalldata = (pool: Pool, amount: string) => {
|
|
1350
|
-
try {
|
|
1351
|
-
const userAddress =
|
|
1352
|
-
walletClient?.account?.address || walletClient?.account
|
|
1353
|
-
if (!userAddress) {
|
|
1354
|
-
throw new Error("User address not found")
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
// Validate amount
|
|
1358
|
-
if (
|
|
1359
|
-
!amount ||
|
|
1360
|
-
amount === "" ||
|
|
1361
|
-
Number.isNaN(Number(amount)) ||
|
|
1362
|
-
Number(amount) <= 0
|
|
1363
|
-
) {
|
|
1364
|
-
throw new Error("Invalid amount")
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
// Aave V3 Pool contract deposit function
|
|
1368
|
-
// function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)
|
|
1369
|
-
const calldata = encodeFunctionData({
|
|
1370
|
-
abi: [
|
|
1371
|
-
{
|
|
1372
|
-
name: "supply",
|
|
1373
|
-
type: "function",
|
|
1374
|
-
inputs: [
|
|
1375
|
-
{ name: "asset", type: "address" },
|
|
1376
|
-
{ name: "amount", type: "uint256" },
|
|
1377
|
-
{ name: "onBehalfOf", type: "address" },
|
|
1378
|
-
{ name: "referralCode", type: "uint16" },
|
|
1379
|
-
],
|
|
1380
|
-
outputs: [],
|
|
1381
|
-
stateMutability: "nonpayable",
|
|
1382
|
-
},
|
|
1383
|
-
],
|
|
1384
|
-
args: [
|
|
1385
|
-
pool.token.address as `0x${string}`, // asset address
|
|
1386
|
-
BigInt(amount), // amount to deposit
|
|
1387
|
-
userAddress as `0x${string}`, // onBehalfOf (user's address)
|
|
1388
|
-
0, // referralCode (0 for no referral)
|
|
1389
|
-
],
|
|
1390
|
-
})
|
|
1391
|
-
return calldata
|
|
1392
|
-
} catch (error) {
|
|
1393
|
-
logger.console.error("Error generating Aave deposit calldata:", error)
|
|
1394
|
-
return undefined
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
// Generate deposit calldata for Morpho pool
|
|
1399
|
-
const generateMorphoDepositCalldata = (_pool: Pool, amount: string) => {
|
|
1400
|
-
try {
|
|
1401
|
-
const userAddress =
|
|
1402
|
-
walletClient?.account?.address || walletClient?.account
|
|
1403
|
-
if (!userAddress) {
|
|
1404
|
-
throw new Error("User address not found")
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
// Validate amount
|
|
1408
|
-
if (
|
|
1409
|
-
!amount ||
|
|
1410
|
-
amount === "" ||
|
|
1411
|
-
Number.isNaN(Number(amount)) ||
|
|
1412
|
-
Number(amount) <= 0
|
|
1413
|
-
) {
|
|
1414
|
-
throw new Error("Invalid amount")
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
// Morpho Vault deposit function
|
|
1418
|
-
// function deposit(uint256 amount, address receiver)
|
|
1419
|
-
const calldata = encodeFunctionData({
|
|
1420
|
-
abi: [
|
|
1421
|
-
{
|
|
1422
|
-
name: "deposit",
|
|
1423
|
-
type: "function",
|
|
1424
|
-
inputs: [
|
|
1425
|
-
{ name: "amount", type: "uint256" },
|
|
1426
|
-
{ name: "receiver", type: "address" },
|
|
1427
|
-
],
|
|
1428
|
-
outputs: [{ name: "shares", type: "uint256" }],
|
|
1429
|
-
stateMutability: "nonpayable",
|
|
1430
|
-
},
|
|
1431
|
-
],
|
|
1432
|
-
args: [
|
|
1433
|
-
BigInt(amount), // amount to deposit
|
|
1434
|
-
userAddress as `0x${string}`, // receiver (user's address)
|
|
1435
|
-
],
|
|
1436
|
-
})
|
|
1437
|
-
return calldata
|
|
1438
|
-
} catch (error) {
|
|
1439
|
-
logger.console.error("Error generating Morpho deposit calldata:", error)
|
|
1440
|
-
return undefined
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
1457
|
// Generate deposit calldata based on pool protocol
|
|
1445
1458
|
const generateDepositCalldata = (pool: Pool, amount: string) => {
|
|
1446
1459
|
try {
|
|
@@ -1449,11 +1462,15 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1449
1462
|
pool.name,
|
|
1450
1463
|
)
|
|
1451
1464
|
|
|
1465
|
+
if (!walletClient) {
|
|
1466
|
+
throw new Error("Wallet client not found")
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1452
1469
|
switch (pool.protocol.toLowerCase()) {
|
|
1453
1470
|
case "aave":
|
|
1454
|
-
return generateAaveDepositCalldata(pool, amount)
|
|
1471
|
+
return generateAaveDepositCalldata(walletClient, pool, amount)
|
|
1455
1472
|
case "morpho":
|
|
1456
|
-
return generateMorphoDepositCalldata(
|
|
1473
|
+
return generateMorphoDepositCalldata(walletClient, amount)
|
|
1457
1474
|
default:
|
|
1458
1475
|
logger.console.warn(`Unsupported protocol: ${pool.protocol}`)
|
|
1459
1476
|
return undefined
|
|
@@ -1488,7 +1505,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1488
1505
|
logger.console.error("[trails-sdk] Error sending transaction", error)
|
|
1489
1506
|
}
|
|
1490
1507
|
const errorMessage = getFullErrorMessage(error)
|
|
1491
|
-
const isRejected =
|
|
1508
|
+
const isRejected = getIsUserRejectionError(error)
|
|
1492
1509
|
const isBalanceTooLow = getIsBalanceTooLowError(error)
|
|
1493
1510
|
const isApiError = getIsApiError(error)
|
|
1494
1511
|
const isRateLimited = getIsRateLimitedError(error)
|
|
@@ -1587,7 +1604,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1587
1604
|
case "fund-methods":
|
|
1588
1605
|
return (
|
|
1589
1606
|
<FundMethods
|
|
1590
|
-
onBack={
|
|
1607
|
+
onBack={() => goHome()}
|
|
1591
1608
|
onSelectWalletConnect={handleSelectWalletConnect}
|
|
1592
1609
|
onSelectExchangeList={handleSelectExchangeList}
|
|
1593
1610
|
onSelectConnectedAccount={() => {
|
|
@@ -1648,7 +1665,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1648
1665
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1649
1666
|
onError={handleSendError}
|
|
1650
1667
|
paymasterUrls={paymasterUrls}
|
|
1651
|
-
gasless={gasless}
|
|
1652
1668
|
setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
|
|
1653
1669
|
quoteProvider={quoteProvider}
|
|
1654
1670
|
fundMethod={selectedFundMethod}
|
|
@@ -1704,7 +1720,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1704
1720
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1705
1721
|
onError={handleSendError}
|
|
1706
1722
|
paymasterUrls={paymasterUrls}
|
|
1707
|
-
gasless={gasless}
|
|
1708
1723
|
setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
|
|
1709
1724
|
quoteProvider={quoteProvider}
|
|
1710
1725
|
fundMethod={selectedFundMethod}
|
|
@@ -1828,7 +1843,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1828
1843
|
onComplete={handleTransferComplete}
|
|
1829
1844
|
onSend={handleOnSend}
|
|
1830
1845
|
paymasterUrls={paymasterUrls}
|
|
1831
|
-
gasless={gasless}
|
|
1832
1846
|
setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
|
|
1833
1847
|
quoteProvider={quoteProvider}
|
|
1834
1848
|
fundMethod={selectedFundMethod}
|
|
@@ -1869,7 +1883,6 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1869
1883
|
onTransactionStateChange={handleTransactionStateChange}
|
|
1870
1884
|
onError={handleSendError}
|
|
1871
1885
|
paymasterUrls={paymasterUrls}
|
|
1872
|
-
gasless={gasless}
|
|
1873
1886
|
setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
|
|
1874
1887
|
quoteProvider={quoteProvider}
|
|
1875
1888
|
fundMethod={selectedFundMethod}
|
|
@@ -2062,32 +2075,34 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2062
2075
|
<ToastProvider>
|
|
2063
2076
|
<CurrentScreenProvider initialScreen={initialScreen}>
|
|
2064
2077
|
<BackProvider>
|
|
2065
|
-
<
|
|
2066
|
-
<
|
|
2067
|
-
<
|
|
2068
|
-
<
|
|
2069
|
-
<
|
|
2070
|
-
<
|
|
2071
|
-
<
|
|
2072
|
-
<
|
|
2073
|
-
<
|
|
2074
|
-
<
|
|
2075
|
-
|
|
2076
|
-
<
|
|
2077
|
-
<
|
|
2078
|
-
<
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2078
|
+
<WalletConnectionProvider>
|
|
2079
|
+
<SelectedTokenProvider>
|
|
2080
|
+
<DestinationSelectedTokenProvider>
|
|
2081
|
+
<SelectedFeeTokenProvider>
|
|
2082
|
+
<SelectedRecipientProvider>
|
|
2083
|
+
<SwapAmountProvider>
|
|
2084
|
+
<ChainFilterProvider>
|
|
2085
|
+
<BalanceVisibleProvider>
|
|
2086
|
+
<ThemePreferenceProvider>
|
|
2087
|
+
<SelectedFundMethodProvider>
|
|
2088
|
+
<ThemeSyncer />
|
|
2089
|
+
<EarnPoolProvider>
|
|
2090
|
+
<SelectedMeshExchangeProvider>
|
|
2091
|
+
<DefaultTokenSelectionProvider>
|
|
2092
|
+
<WidgetContent ref={ref} />
|
|
2093
|
+
</DefaultTokenSelectionProvider>
|
|
2094
|
+
</SelectedMeshExchangeProvider>
|
|
2095
|
+
</EarnPoolProvider>
|
|
2096
|
+
</SelectedFundMethodProvider>
|
|
2097
|
+
</ThemePreferenceProvider>
|
|
2098
|
+
</BalanceVisibleProvider>
|
|
2099
|
+
</ChainFilterProvider>
|
|
2100
|
+
</SwapAmountProvider>
|
|
2101
|
+
</SelectedRecipientProvider>
|
|
2102
|
+
</SelectedFeeTokenProvider>
|
|
2103
|
+
</DestinationSelectedTokenProvider>
|
|
2104
|
+
</SelectedTokenProvider>
|
|
2105
|
+
</WalletConnectionProvider>
|
|
2091
2106
|
</BackProvider>
|
|
2092
2107
|
</CurrentScreenProvider>
|
|
2093
2108
|
</ToastProvider>
|
|
@@ -2101,28 +2116,16 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2101
2116
|
const sequenceHooksContext = useContext(SequenceHooksContext)
|
|
2102
2117
|
const wagmiContext = useContext(WagmiContext)
|
|
2103
2118
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
}
|
|
2110
|
-
if (props.sequenceEnv && props.sequenceEnv !== getSequenceEnv()) {
|
|
2111
|
-
logger.console.log("props.sequenceEnv", props.sequenceEnv)
|
|
2112
|
-
setSequenceEnv(props.sequenceEnv)
|
|
2113
|
-
}
|
|
2114
|
-
if (props.projectAccessKey) {
|
|
2115
|
-
logger.console.log("props.projectAccessKey", props.projectAccessKey)
|
|
2116
|
-
setSequenceProjectAccessKey(props.projectAccessKey)
|
|
2119
|
+
if (props.apiKey) {
|
|
2120
|
+
logger.console.log("props.apiKey", props.apiKey)
|
|
2121
|
+
setSequenceProjectAccessKey(props.apiKey)
|
|
2122
|
+
} else {
|
|
2123
|
+
throw new Error("apiKey is required")
|
|
2117
2124
|
}
|
|
2118
2125
|
if (props.sequenceIndexerUrl) {
|
|
2119
2126
|
logger.console.log("props.sequenceIndexerUrl", props.sequenceIndexerUrl)
|
|
2120
2127
|
setSequenceIndexerUrl(props.sequenceIndexerUrl)
|
|
2121
2128
|
}
|
|
2122
|
-
if (props.sequenceApiUrl) {
|
|
2123
|
-
logger.console.log("props.sequenceApiUrl", props.sequenceApiUrl)
|
|
2124
|
-
setSequenceApiUrl(props.sequenceApiUrl)
|
|
2125
|
-
}
|
|
2126
2129
|
if (props.trailsApiUrl) {
|
|
2127
2130
|
logger.console.log("props.trailsApiUrl", props.trailsApiUrl)
|
|
2128
2131
|
setTrailsApiUrl(props.trailsApiUrl)
|
|
@@ -2155,10 +2158,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2155
2158
|
const baseConfig = {
|
|
2156
2159
|
chains,
|
|
2157
2160
|
transports: (chains as Array<Chain>).reduce((acc, chain) => {
|
|
2158
|
-
const sequenceRpcUrl = getRpcUrl(
|
|
2159
|
-
chain.id,
|
|
2160
|
-
props.projectAccessKey || props.appId,
|
|
2161
|
-
)
|
|
2161
|
+
const sequenceRpcUrl = getRpcUrl(chain.id, props.apiKey)
|
|
2162
2162
|
return {
|
|
2163
2163
|
...acc,
|
|
2164
2164
|
[chain.id]: sequenceRpcUrl ? http(sequenceRpcUrl) : http(),
|
|
@@ -2181,12 +2181,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2181
2181
|
: connectors,
|
|
2182
2182
|
storage,
|
|
2183
2183
|
})
|
|
2184
|
-
}, [
|
|
2185
|
-
props.projectAccessKey,
|
|
2186
|
-
props.appId,
|
|
2187
|
-
props.decoupleWagmi,
|
|
2188
|
-
props.wagmiConnectors,
|
|
2189
|
-
])
|
|
2184
|
+
}, [props.apiKey, props.decoupleWagmi, props.wagmiConnectors])
|
|
2190
2185
|
|
|
2191
2186
|
// Create content with only the providers that don't exist in parent
|
|
2192
2187
|
const content = (() => {
|
|
@@ -2198,18 +2193,13 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2198
2193
|
|
|
2199
2194
|
const sequenceConfig = {
|
|
2200
2195
|
commitHash: getCommitHash(),
|
|
2201
|
-
projectAccessKey:
|
|
2202
|
-
props.projectAccessKey ||
|
|
2203
|
-
props.appId ||
|
|
2204
|
-
getSequenceProjectAccessKey(),
|
|
2196
|
+
projectAccessKey: props.apiKey,
|
|
2205
2197
|
env: {
|
|
2206
|
-
env: props.sequenceEnv || getSequenceEnv(),
|
|
2207
2198
|
indexerUrl: props.sequenceIndexerUrl || getSequenceIndexerUrl(),
|
|
2208
2199
|
indexerGatewayUrl:
|
|
2209
2200
|
props.sequenceIndexerUrl || getSequenceIndexerUrl(),
|
|
2210
2201
|
nodeGatewayUrl:
|
|
2211
2202
|
props.sequenceNodeGatewayUrl || getSequenceNodeGatewayUrl(),
|
|
2212
|
-
apiUrl: props.sequenceApiUrl || getSequenceApiUrl(),
|
|
2213
2203
|
trailsApiUrl: props.trailsApiUrl || getTrailsApiUrl(),
|
|
2214
2204
|
},
|
|
2215
2205
|
}
|
package/dist/apiClient.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SequenceAPIClient } from '@0xsequence/api';
|
|
2
|
-
export type APIClientConfig = {
|
|
3
|
-
apiUrl?: string;
|
|
4
|
-
projectAccessKey?: string;
|
|
5
|
-
jwt?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function getAPIClient({ apiUrl, projectAccessKey, jwt, }: APIClientConfig): SequenceAPIClient;
|
|
8
|
-
export declare const useAPIClient: (config?: APIClientConfig) => SequenceAPIClient;
|
|
9
|
-
//# sourceMappingURL=apiClient.d.ts.map
|
package/dist/apiClient.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../src/apiClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAInD,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,YAAY,CAAC,EAC3B,MAA4B,EAC5B,gBAAgD,EAChD,GAAG,GACJ,EAAE,eAAe,GAAG,iBAAiB,CAErC;AAED,eAAO,MAAM,YAAY,GAAI,SAAS,eAAe,sBAepD,CAAA"}
|