0xtrails 0.5.0 → 0.6.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/analytics.d.ts +8 -3
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-DhEkQ6QC.js → ccip-Dw5AN7oU.js} +1 -1
- package/dist/cctp.d.ts +0 -149
- package/dist/cctp.d.ts.map +1 -1
- package/dist/chains.d.ts +28 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/contractUtils.d.ts.map +1 -1
- package/dist/estimate.d.ts.map +1 -1
- package/dist/fees.d.ts.map +1 -1
- package/dist/gasless.d.ts +12 -0
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-MhD2DA7_.js → index-BtVUTbEZ.js} +30984 -38945
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -107
- package/dist/indexerClient.d.ts +2 -2
- package/dist/intents.d.ts +0 -17
- package/dist/intents.d.ts.map +1 -1
- package/dist/mutations.d.ts.map +1 -1
- package/dist/paymasterSend.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +1 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/sendUserOp.d.ts +0 -18
- package/dist/sendUserOp.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +10 -8
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +4 -5
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +4 -5
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +2 -2
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts +2 -2
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/crossChain.d.ts +4 -4
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/index.d.ts +0 -1
- package/dist/transactionIntent/handlers/index.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +4 -34
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +2 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +6 -19
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactionIntent/utils/index.d.ts +0 -1
- package/dist/transactionIntent/utils/index.d.ts.map +1 -1
- package/dist/transactions.d.ts +2 -20
- package/dist/transactions.d.ts.map +1 -1
- package/dist/utils.d.ts +8 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/walletUtils.d.ts +21 -0
- package/dist/walletUtils.d.ts.map +1 -0
- package/dist/wallets.d.ts +33 -240
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +8 -13
- package/dist/widget/components/FeeOption.d.ts.map +1 -1
- package/dist/widget/components/FeeOptions.d.ts +11 -5
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/NativeGasOption.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/QRCodeDeposit.d.ts +5 -0
- package/dist/widget/components/QRCodeDeposit.d.ts.map +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts +13 -0
- package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -0
- package/dist/widget/components/QrCode.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/ScreenHeader.d.ts +1 -1
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/Toast.d.ts.map +1 -1
- package/dist/widget/components/TokenImage.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +15 -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/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts +7 -0
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts.map +1 -0
- package/dist/widget/hooks/useIsSequenceWallet.d.ts +6 -0
- package/dist/widget/hooks/useIsSequenceWallet.d.ts.map +1 -0
- package/dist/widget/hooks/useQuote.d.ts +5 -8
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeOption.d.ts +30 -0
- package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +6 -15
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts +23 -12
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/widget.d.ts +11 -0
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/analytics.ts +53 -21
- package/src/cctp.ts +0 -1016
- package/src/chains.ts +93 -39
- package/src/config.ts +24 -6
- package/src/constants.ts +1 -4
- package/src/contractUtils.ts +6 -6
- package/src/estimate.ts +3 -6
- package/src/fees.ts +5 -10
- package/src/gasless.ts +45 -0
- package/src/index.ts +7 -6
- package/src/indexerClient.ts +2 -2
- package/src/intents.ts +52 -206
- package/src/mutations.ts +3 -2
- package/src/paymasterSend.ts +2 -5
- package/src/prepareSend.ts +9 -12
- package/src/sendUserOp.ts +3 -64
- package/src/tokenBalances.ts +2 -1
- package/src/tokens.ts +62 -133
- package/src/trailsClient.ts +1 -1
- package/src/transactionIntent/deposits/depositOrchestrator.ts +14 -15
- package/src/transactionIntent/deposits/gaslessDeposit.ts +70 -100
- package/src/transactionIntent/deposits/standardDeposit.ts +22 -28
- package/src/transactionIntent/execution/transactionState.ts +2 -2
- package/src/transactionIntent/handlers/crossChain.ts +165 -385
- package/src/transactionIntent/handlers/index.ts +0 -1
- package/src/transactionIntent/handlers/sameChainSameToken.ts +228 -94
- package/src/transactionIntent/quote/normalizeQuote.ts +4 -6
- package/src/transactionIntent/quote/quoteHelpers.ts +35 -3
- package/src/transactionIntent/types.ts +6 -27
- package/src/transactionIntent/utils/index.ts +0 -1
- package/src/transactions.ts +6 -203
- package/src/umd.tsx +1 -3
- package/src/utils.ts +28 -8
- package/src/walletUtils.ts +42 -0
- package/src/wallets.ts +361 -203
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +73 -4
- package/src/widget/components/AccountSettings.tsx +17 -17
- package/src/widget/components/ChainList.tsx +3 -3
- package/src/widget/components/ClassicSwap.tsx +19 -10
- package/src/widget/components/ConfigDisplay.tsx +1 -1
- package/src/widget/components/FeeOption.tsx +63 -20
- package/src/widget/components/FeeOptions.tsx +54 -123
- package/src/widget/components/NativeGasOption.tsx +3 -1
- package/src/widget/components/Pay.tsx +18 -11
- package/src/widget/components/PoolDeposit.tsx +23 -10
- package/src/widget/components/QRCodeDeposit.tsx +50 -30
- package/src/widget/components/QRCodeWalletSelect.tsx +77 -0
- package/src/widget/components/QrCode.tsx +188 -233
- package/src/widget/components/QuoteDetails.tsx +48 -2
- package/src/widget/components/Receipt.tsx +5 -2
- package/src/widget/components/ScreenHeader.tsx +10 -8
- package/src/widget/components/Toast.tsx +10 -0
- package/src/widget/components/TokenImage.tsx +56 -13
- package/src/widget/hooks/useCheckout.ts +71 -0
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDebugScreens.ts +5 -0
- package/src/widget/hooks/useIntentTransactionHistory.ts +788 -418
- package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +43 -0
- package/src/widget/hooks/useIsSequenceWallet.ts +17 -0
- package/src/widget/hooks/useQuote.ts +16 -17
- package/src/widget/hooks/useRecentTokens.ts +2 -1
- package/src/widget/hooks/useSelectedFeeOption.tsx +257 -0
- package/src/widget/hooks/useSendForm.ts +172 -47
- package/src/widget/hooks/useTokenList.ts +15 -2
- package/src/widget/providers/TrailsProvider.tsx +53 -25
- package/src/widget/widget.tsx +119 -48
- package/dist/cctpqueue.d.ts +0 -18
- package/dist/cctpqueue.d.ts.map +0 -1
- package/dist/preconditions.d.ts +0 -12
- package/dist/preconditions.d.ts.map +0 -1
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +0 -62
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +0 -1
- package/dist/transactionIntent/utils/lifiHelpers.d.ts +0 -10
- package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +0 -33
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +0 -1
- package/src/cctpqueue.ts +0 -69
- package/src/preconditions.ts +0 -47
- package/src/transactionIntent/handlers/sameChainDifferentToken.ts +0 -323
- package/src/transactionIntent/utils/lifiHelpers.ts +0 -68
- package/src/widget/hooks/useSelectedFeeToken.tsx +0 -288
package/src/widget/widget.tsx
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
trackWalletConnected,
|
|
36
36
|
trackWalletDisconnected,
|
|
37
37
|
trackWidgetScreen,
|
|
38
|
+
updateProjectAccessKey,
|
|
38
39
|
} from "../analytics.js"
|
|
39
40
|
import { getAllChains, getChainInfo, getRpcUrl } from "../chains.js"
|
|
40
41
|
import { PROD_SEQUENCE_NODE_GATEWAY_URL } from "../constants.js"
|
|
@@ -54,13 +55,21 @@ import type { Pool } from "../pools.js"
|
|
|
54
55
|
import { usePools } from "../pools.js"
|
|
55
56
|
import type { PrepareSendQuote } from "../prepareSend.js"
|
|
56
57
|
import { isValidInteger, isValidNumeric } from "../prices.js"
|
|
57
|
-
import type { MetaTxnReceipt } from "../transactionIntent/types.js"
|
|
58
58
|
import type { Theme } from "../theme.js"
|
|
59
59
|
import type { SupportedToken } from "../tokens.js"
|
|
60
60
|
import { getWethAddress } from "../tokens.js"
|
|
61
|
+
import type { IntentTransaction } from "@0xsequence/trails-api"
|
|
61
62
|
import type { TransactionState } from "../transactions.js"
|
|
62
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
useQRCodeWallets,
|
|
65
|
+
useWallets,
|
|
66
|
+
walletConnectConnector,
|
|
67
|
+
getConnectorsInternal,
|
|
68
|
+
} from "../wallets.js"
|
|
63
69
|
// import { useOpenConnectModal } from "@0xsequence/connect"
|
|
70
|
+
import { generateAaveDepositCalldata } from "../aave.js"
|
|
71
|
+
import { DEFAULT_MODE } from "../constants.js"
|
|
72
|
+
import { generateMorphoDepositCalldata } from "../morpho.js"
|
|
64
73
|
import css from "./compiled.css?inline"
|
|
65
74
|
import { AccountIntentTransactionHistory } from "./components/AccountIntentTransactionHistory.js"
|
|
66
75
|
import { AccountSettings } from "./components/AccountSettings.js"
|
|
@@ -71,14 +80,15 @@ import { Earn } from "./components/Earn.js"
|
|
|
71
80
|
import EarnPools from "./components/EarnPools.js"
|
|
72
81
|
import { ErrorDisplay } from "./components/ErrorDisplay.js"
|
|
73
82
|
import Footer from "./components/Footer.js"
|
|
74
|
-
import { Fund } from "./components/FundSwap.js"
|
|
75
83
|
import FundMethods from "./components/FundMethods.js"
|
|
84
|
+
import { Fund } from "./components/FundSwap.js"
|
|
76
85
|
import { MeshConnectExchanges } from "./components/MeshConnectExchanges.js"
|
|
77
86
|
import { MeshConnectFlow } from "./components/MeshConnectFlow.js"
|
|
78
87
|
import type { MeshConnectProps } from "./components/MeshConnectIframe.js"
|
|
79
88
|
import Modal from "./components/Modal.js"
|
|
80
89
|
import { Pay } from "./components/Pay.js"
|
|
81
90
|
import QRCodeDeposit from "./components/QRCodeDeposit.js"
|
|
91
|
+
import QRCodeWalletSelect from "./components/QRCodeWalletSelect.js"
|
|
82
92
|
import Receipt from "./components/Receipt.js"
|
|
83
93
|
import { Receive } from "./components/Receive.js"
|
|
84
94
|
import { Recipients } from "./components/Recipients.js"
|
|
@@ -102,15 +112,12 @@ import {
|
|
|
102
112
|
useCurrentScreen,
|
|
103
113
|
type Screen,
|
|
104
114
|
} from "./hooks/useCurrentScreen.js"
|
|
105
|
-
import {
|
|
106
|
-
WalletConnectionProvider,
|
|
107
|
-
useWalletConnectionContext,
|
|
108
|
-
} from "./hooks/useWalletConnectionContext.js"
|
|
109
115
|
import { useDebugScreens } from "./hooks/useDebugScreens.js"
|
|
110
116
|
import { DefaultTokenSelectionProvider } from "./hooks/useDefaultTokenSelection.js"
|
|
111
117
|
import { DestinationSelectedTokenProvider } from "./hooks/useDestinationSelectedToken.js"
|
|
112
118
|
import { EarnPoolProvider, useEarnPool } from "./hooks/useEarnPool.js"
|
|
113
119
|
import { useInitialRedirect } from "./hooks/useInitialRedirect.js"
|
|
120
|
+
import { useIsSequenceWallet } from "./hooks/useIsSequenceWallet.js"
|
|
114
121
|
import { ModeProvider } from "./hooks/useMode.js"
|
|
115
122
|
import {
|
|
116
123
|
OriginSelectedTokenProvider as SelectedTokenProvider,
|
|
@@ -119,7 +126,14 @@ import {
|
|
|
119
126
|
} from "./hooks/useOriginSelectedToken.js"
|
|
120
127
|
import { PriceImpactWarningProvider } from "./hooks/usePriceImpactWarning.js"
|
|
121
128
|
import { useRecentTokens } from "./hooks/useRecentTokens.js"
|
|
122
|
-
import {
|
|
129
|
+
import {
|
|
130
|
+
SelectedFeeOptionProvider,
|
|
131
|
+
useSelectedFeeOption,
|
|
132
|
+
} from "./hooks/useSelectedFeeOption.js"
|
|
133
|
+
import {
|
|
134
|
+
SelectedFundMethodProvider,
|
|
135
|
+
useSelectedFundMethod,
|
|
136
|
+
} from "./hooks/useSelectedFundMethod.js"
|
|
123
137
|
import {
|
|
124
138
|
SelectedMeshExchangeProvider,
|
|
125
139
|
useSelectedMeshExchange,
|
|
@@ -132,17 +146,15 @@ import type { OnCompleteProps } from "./hooks/useSendForm.js"
|
|
|
132
146
|
import { SwapAmountProvider } from "./hooks/useSwapAmount.js"
|
|
133
147
|
import { useTargetAmount } from "./hooks/useTargetAmount.js"
|
|
134
148
|
import { ThemeProvider as ThemePreferenceProvider } from "./hooks/useTheme.js"
|
|
135
|
-
import { useWidgetProps, WidgetPropsProvider } from "./hooks/useWidgetProps.js"
|
|
136
149
|
import {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} from "./hooks/
|
|
140
|
-
import {
|
|
141
|
-
import { generateMorphoDepositCalldata } from "../morpho.js"
|
|
142
|
-
import { generateAaveDepositCalldata } from "../aave.js"
|
|
150
|
+
useWalletConnectionContext,
|
|
151
|
+
WalletConnectionProvider,
|
|
152
|
+
} from "./hooks/useWalletConnectionContext.js"
|
|
153
|
+
import { useWidgetProps, WidgetPropsProvider } from "./hooks/useWidgetProps.js"
|
|
143
154
|
import {
|
|
144
155
|
TrailsProvider,
|
|
145
|
-
|
|
156
|
+
useTrails,
|
|
157
|
+
type TrailsProviderProps,
|
|
146
158
|
} from "./providers/TrailsProvider.js"
|
|
147
159
|
|
|
148
160
|
export const aaveClient = AaveClient.create()
|
|
@@ -231,6 +243,15 @@ export type TrailsWidgetProps = {
|
|
|
231
243
|
sessionId: string
|
|
232
244
|
transactionStates: TransactionState[]
|
|
233
245
|
}) => void
|
|
246
|
+
onCheckoutApprovalRequest?: (data: { sessionId: string }) => void
|
|
247
|
+
onCheckoutApprovalConfirmed?: (data: {
|
|
248
|
+
sessionId: string
|
|
249
|
+
transactionHash: `0x${string}`
|
|
250
|
+
}) => void
|
|
251
|
+
onCheckoutApprovalRejected?: (data: {
|
|
252
|
+
sessionId: string
|
|
253
|
+
error: unknown
|
|
254
|
+
}) => void
|
|
234
255
|
onOpen?: () => void
|
|
235
256
|
onClose?: () => void
|
|
236
257
|
|
|
@@ -466,6 +487,9 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
466
487
|
onCheckoutSignatureRequest,
|
|
467
488
|
onCheckoutSignatureConfirmed,
|
|
468
489
|
onCheckoutSignatureRejected,
|
|
490
|
+
onCheckoutApprovalRequest,
|
|
491
|
+
onCheckoutApprovalConfirmed,
|
|
492
|
+
onCheckoutApprovalRejected,
|
|
469
493
|
onCheckoutComplete,
|
|
470
494
|
onCheckoutError,
|
|
471
495
|
onCheckoutStatusUpdate,
|
|
@@ -481,25 +505,12 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
481
505
|
hideDisconnect,
|
|
482
506
|
} = useWidgetProps()
|
|
483
507
|
const { address, chainId, connector } = useAccount()
|
|
508
|
+
const { trailsApiKey } = useTrails()
|
|
509
|
+
const qrCodeWallets = useQRCodeWallets()
|
|
484
510
|
// const { setOpenConnectModal } = useOpenConnectModal()
|
|
485
511
|
|
|
486
|
-
//
|
|
487
|
-
const isSequenceWallet =
|
|
488
|
-
if (!connector) return false
|
|
489
|
-
const connectorName = connector.name?.toLowerCase() || ""
|
|
490
|
-
const connectorId = connector.id?.toLowerCase() || ""
|
|
491
|
-
const isSequence =
|
|
492
|
-
connectorName.includes("sequence") || connectorId.includes("sequence")
|
|
493
|
-
|
|
494
|
-
console.log("[trails-sdk] Sequence wallet detection:", {
|
|
495
|
-
connectorName,
|
|
496
|
-
connectorId,
|
|
497
|
-
isSequence,
|
|
498
|
-
connector: connector.name,
|
|
499
|
-
})
|
|
500
|
-
|
|
501
|
-
return isSequence
|
|
502
|
-
}, [connector])
|
|
512
|
+
// Check if the current connector is a Sequence wallet
|
|
513
|
+
const isSequenceWallet = useIsSequenceWallet()
|
|
503
514
|
const connections = useConnections()
|
|
504
515
|
const { disconnectAsync } = useDisconnect()
|
|
505
516
|
const { switchAccount } = useSwitchAccount()
|
|
@@ -555,6 +566,7 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
555
566
|
const [error, setError] = useState<string | null>(null)
|
|
556
567
|
const [prepareSendQuote, setPrepareSendQuote] =
|
|
557
568
|
useState<PrepareSendQuote | null>(null)
|
|
569
|
+
const [qrCodeWalletId, setQrCodeWalletId] = useState<string | null>(null)
|
|
558
570
|
const [previousConnector, setPreviousConnector] = useState<Connector | null>(
|
|
559
571
|
null,
|
|
560
572
|
)
|
|
@@ -871,11 +883,16 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
871
883
|
onCheckoutSignatureRequest,
|
|
872
884
|
onCheckoutSignatureConfirmed,
|
|
873
885
|
onCheckoutSignatureRejected,
|
|
886
|
+
onCheckoutApprovalRequest,
|
|
887
|
+
onCheckoutApprovalConfirmed,
|
|
888
|
+
onCheckoutApprovalRejected,
|
|
874
889
|
onCheckoutComplete,
|
|
875
890
|
onCheckoutError,
|
|
876
891
|
onCheckoutStatusUpdate,
|
|
877
892
|
})
|
|
878
893
|
|
|
894
|
+
const { clearSelectedFeeOption } = useSelectedFeeOption()
|
|
895
|
+
|
|
879
896
|
// Use the debug screens hook
|
|
880
897
|
const { handleDebugScreenSelect } = useDebugScreens({
|
|
881
898
|
setCurrentScreen,
|
|
@@ -912,6 +929,13 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
912
929
|
})
|
|
913
930
|
}, [currentScreen, address])
|
|
914
931
|
|
|
932
|
+
// Update analytics project access key when it changes
|
|
933
|
+
useEffect(() => {
|
|
934
|
+
if (trailsApiKey) {
|
|
935
|
+
updateProjectAccessKey(trailsApiKey)
|
|
936
|
+
}
|
|
937
|
+
}, [trailsApiKey])
|
|
938
|
+
|
|
915
939
|
// Identify user with Databeat whenever address changes
|
|
916
940
|
useEffect(() => {
|
|
917
941
|
const analytics = getAnalytics()
|
|
@@ -1310,6 +1334,8 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1310
1334
|
setPrepareSendQuote(null)
|
|
1311
1335
|
setTotalCompletionSeconds(null)
|
|
1312
1336
|
clearHistory()
|
|
1337
|
+
// Reset selected fee token for new checkout
|
|
1338
|
+
clearSelectedFeeOption()
|
|
1313
1339
|
}, [
|
|
1314
1340
|
setSelectedFundMethod,
|
|
1315
1341
|
setDestinationTxHash,
|
|
@@ -1321,8 +1347,16 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1321
1347
|
setSelectedPool,
|
|
1322
1348
|
setCurrentScreen,
|
|
1323
1349
|
clearHistory,
|
|
1350
|
+
clearSelectedFeeOption,
|
|
1324
1351
|
])
|
|
1325
1352
|
|
|
1353
|
+
// Update the currentScreen state when when the widget receives an updated 'mode' prop passed in by the consuming app.
|
|
1354
|
+
// This allows the widget to change modes without remounting the component.
|
|
1355
|
+
useEffect(() => {
|
|
1356
|
+
const initialScreen = getInitialScreenForMode(currentMode)
|
|
1357
|
+
setCurrentScreen(initialScreen)
|
|
1358
|
+
}, [currentMode, getInitialScreenForMode, setCurrentScreen])
|
|
1359
|
+
|
|
1326
1360
|
const handleOpenModal = useCallback(() => {
|
|
1327
1361
|
setIsModalOpen(true)
|
|
1328
1362
|
onOpen?.()
|
|
@@ -1354,6 +1388,11 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1354
1388
|
}
|
|
1355
1389
|
|
|
1356
1390
|
function handleTransferComplete({ transactionStates }: OnCompleteProps) {
|
|
1391
|
+
logger.console.log(
|
|
1392
|
+
"[trails-sdk] handleTransferComplete called",
|
|
1393
|
+
transactionStates,
|
|
1394
|
+
)
|
|
1395
|
+
|
|
1357
1396
|
const firstTransactionState = transactionStates[0]
|
|
1358
1397
|
const lastTransactionState = transactionStates[transactionStates.length - 1]
|
|
1359
1398
|
|
|
@@ -1367,12 +1406,12 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1367
1406
|
|
|
1368
1407
|
if (
|
|
1369
1408
|
lastTransactionState?.transactionHash ||
|
|
1370
|
-
((lastTransactionState as unknown as
|
|
1409
|
+
((lastTransactionState as unknown as IntentTransaction)?.txnHash &&
|
|
1371
1410
|
lastTransactionState?.chainId)
|
|
1372
1411
|
) {
|
|
1373
1412
|
setDestinationTxHash(
|
|
1374
1413
|
lastTransactionState?.transactionHash ||
|
|
1375
|
-
(lastTransactionState as unknown as
|
|
1414
|
+
(lastTransactionState as unknown as IntentTransaction)?.txnHash ||
|
|
1376
1415
|
"",
|
|
1377
1416
|
)
|
|
1378
1417
|
setDestinationChainId(lastTransactionState?.chainId)
|
|
@@ -1529,13 +1568,13 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1529
1568
|
|
|
1530
1569
|
const handleWaitingForWalletConfirm = (quote: PrepareSendQuote) => {
|
|
1531
1570
|
setShowWalletConfirmRetry(false)
|
|
1532
|
-
|
|
1571
|
+
setPrepareSendQuote(quote ?? null)
|
|
1572
|
+
// Navigate to QR wallet selection when using QR code funding method
|
|
1533
1573
|
if (selectedFundMethod === "qr-code") {
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
setCurrentScreen("wallet-confirmation")
|
|
1574
|
+
setCurrentScreenWithBack("qr-code-wallet-select", currentScreen)
|
|
1575
|
+
return
|
|
1537
1576
|
}
|
|
1538
|
-
|
|
1577
|
+
setCurrentScreen("wallet-confirmation")
|
|
1539
1578
|
}
|
|
1540
1579
|
|
|
1541
1580
|
async function handleWalletConfirmRetry() {
|
|
@@ -1626,6 +1665,11 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1626
1665
|
case "send-form":
|
|
1627
1666
|
return (
|
|
1628
1667
|
<Pay
|
|
1668
|
+
onBack={
|
|
1669
|
+
currentMode === "receive"
|
|
1670
|
+
? () => setCurrentScreen("receive")
|
|
1671
|
+
: undefined
|
|
1672
|
+
}
|
|
1629
1673
|
selectedToken={selectedToken}
|
|
1630
1674
|
onSend={handleOnSend}
|
|
1631
1675
|
onWaitingForWalletConfirm={handleWaitingForWalletConfirm}
|
|
@@ -1731,15 +1775,37 @@ const WidgetContent = forwardRef<TrailsWidgetRef>((_, ref) => {
|
|
|
1731
1775
|
quote={prepareSendQuote}
|
|
1732
1776
|
/>
|
|
1733
1777
|
)
|
|
1778
|
+
case "qr-code-wallet-select":
|
|
1779
|
+
return (
|
|
1780
|
+
<QRCodeWalletSelect
|
|
1781
|
+
onBack={handleBack}
|
|
1782
|
+
onSelect={(walletId) => {
|
|
1783
|
+
setQrCodeWalletId(walletId)
|
|
1784
|
+
setCurrentScreen("qr-code-deposit")
|
|
1785
|
+
}}
|
|
1786
|
+
selectedWalletId={qrCodeWalletId}
|
|
1787
|
+
/>
|
|
1788
|
+
)
|
|
1734
1789
|
case "qr-code-deposit":
|
|
1735
|
-
return
|
|
1790
|
+
return (
|
|
1791
|
+
<QRCodeDeposit
|
|
1792
|
+
onBack={() => setCurrentScreen("qr-code-wallet-select")}
|
|
1793
|
+
onChangeWallet={() => setCurrentScreen("qr-code-wallet-select")}
|
|
1794
|
+
quote={prepareSendQuote}
|
|
1795
|
+
selectedWalletId={qrCodeWalletId}
|
|
1796
|
+
walletOptions={qrCodeWallets}
|
|
1797
|
+
/>
|
|
1798
|
+
)
|
|
1736
1799
|
case "pending":
|
|
1737
1800
|
return (
|
|
1738
1801
|
<TransferPending
|
|
1739
1802
|
onElapsedTime={handleElapsedTime}
|
|
1740
1803
|
transactionStates={transactionStates}
|
|
1741
1804
|
quote={prepareSendQuote}
|
|
1742
|
-
onContinue={() =>
|
|
1805
|
+
onContinue={() => {
|
|
1806
|
+
logger.console.log("[trails-sdk] onContinue called")
|
|
1807
|
+
setCurrentScreen("receipt")
|
|
1808
|
+
}}
|
|
1743
1809
|
/>
|
|
1744
1810
|
)
|
|
1745
1811
|
case "receipt":
|
|
@@ -2069,7 +2135,7 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2069
2135
|
<WalletConnectionProvider>
|
|
2070
2136
|
<SelectedTokenProvider>
|
|
2071
2137
|
<DestinationSelectedTokenProvider>
|
|
2072
|
-
<
|
|
2138
|
+
<SelectedFeeOptionProvider>
|
|
2073
2139
|
<SelectedRecipientProvider>
|
|
2074
2140
|
<SwapAmountProvider>
|
|
2075
2141
|
<ChainFilterProvider>
|
|
@@ -2090,7 +2156,7 @@ const WidgetInner = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2090
2156
|
</ChainFilterProvider>
|
|
2091
2157
|
</SwapAmountProvider>
|
|
2092
2158
|
</SelectedRecipientProvider>
|
|
2093
|
-
</
|
|
2159
|
+
</SelectedFeeOptionProvider>
|
|
2094
2160
|
</DestinationSelectedTokenProvider>
|
|
2095
2161
|
</SelectedTokenProvider>
|
|
2096
2162
|
</WalletConnectionProvider>
|
|
@@ -2136,11 +2202,15 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2136
2202
|
})
|
|
2137
2203
|
: undefined
|
|
2138
2204
|
|
|
2205
|
+
// Note: We can't use useConnectors hook here since this is in useMemo
|
|
2206
|
+
// So we'll create connectors directly with the apiKey
|
|
2207
|
+
const connectors = Array.isArray(props.wagmiConnectors)
|
|
2208
|
+
? props.wagmiConnectors
|
|
2209
|
+
: getConnectorsInternal(props.apiKey)
|
|
2210
|
+
|
|
2139
2211
|
return createConfig({
|
|
2140
2212
|
...baseConfig,
|
|
2141
|
-
connectors
|
|
2142
|
-
? props.wagmiConnectors
|
|
2143
|
-
: connectors,
|
|
2213
|
+
connectors,
|
|
2144
2214
|
storage,
|
|
2145
2215
|
})
|
|
2146
2216
|
}, [
|
|
@@ -2150,7 +2220,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2150
2220
|
props.sequenceNodeGatewayUrl,
|
|
2151
2221
|
])
|
|
2152
2222
|
|
|
2153
|
-
const trailsConfig:
|
|
2223
|
+
const trailsConfig: TrailsProviderProps["config"] = {
|
|
2154
2224
|
trailsApiKey: props.apiKey,
|
|
2155
2225
|
trailsApiUrl: props.trailsApiUrl,
|
|
2156
2226
|
sequenceIndexerUrl: props.sequenceIndexerUrl,
|
|
@@ -2159,6 +2229,7 @@ export const TrailsWidget = forwardRef<TrailsWidgetRef, TrailsWidgetProps>(
|
|
|
2159
2229
|
slippageTolerance: props.slippageTolerance
|
|
2160
2230
|
? String(props.slippageTolerance)
|
|
2161
2231
|
: undefined,
|
|
2232
|
+
debug: props.debug,
|
|
2162
2233
|
}
|
|
2163
2234
|
|
|
2164
2235
|
// Create content with only the providers that don't exist in parent
|
package/dist/cctpqueue.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { TrailsClient } from './trailsClient.js';
|
|
2
|
-
type CctpQueueCapable = {
|
|
3
|
-
queueCCTPTransfer: (args: {
|
|
4
|
-
sourceTxHash?: string;
|
|
5
|
-
metaTxHash?: string;
|
|
6
|
-
sourceChainId: number;
|
|
7
|
-
destinationChainId: number;
|
|
8
|
-
}, headers?: object, signal?: AbortSignal) => Promise<unknown>;
|
|
9
|
-
};
|
|
10
|
-
export declare function hasCctpQueue(client: unknown): client is CctpQueueCapable;
|
|
11
|
-
export declare function queueCCTPTransfer({ trailsClient, sourceTxHash, sourceChainId, destinationChainId, }: {
|
|
12
|
-
trailsClient: TrailsClient;
|
|
13
|
-
sourceTxHash: string;
|
|
14
|
-
sourceChainId: number;
|
|
15
|
-
destinationChainId: number;
|
|
16
|
-
}): Promise<void>;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=cctpqueue.d.ts.map
|
package/dist/cctpqueue.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cctpqueue.d.ts","sourceRoot":"","sources":["../src/cctpqueue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,KAAK,gBAAgB,GAAG;IACtB,iBAAiB,EAAE,CACjB,IAAI,EAAE;QACJ,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,aAAa,EAAE,MAAM,CAAA;QACrB,kBAAkB,EAAE,MAAM,CAAA;KAC3B,EACD,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,OAAO,CAAC,CAAA;CACtB,CAAA;AAwBD,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,gBAAgB,CAGxE;AAED,wBAAsB,iBAAiB,CAAC,EACtC,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,kBAAkB,GACnB,EAAE;IACD,YAAY,EAAE,YAAY,CAAA;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;CAC3B,GAAG,OAAO,CAAC,IAAI,CAAC,CAchB"}
|
package/dist/preconditions.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TransactionPrecondition } from '@0xsequence/trails-api';
|
|
2
|
-
export type IntentPrecondition = TransactionPrecondition;
|
|
3
|
-
export declare function findPreconditionAddresses(preconditions: TransactionPrecondition[], originChainId: number, destinationChainId: number): {
|
|
4
|
-
originAddress?: string;
|
|
5
|
-
destinationAddress?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function findChainAndAddressesFromPreconditions(preconditions: TransactionPrecondition[]): {
|
|
8
|
-
chainId: number;
|
|
9
|
-
address: string;
|
|
10
|
-
}[];
|
|
11
|
-
export declare function findFirstPreconditionForChainId(preconditions: TransactionPrecondition[], chainId: number): TransactionPrecondition | null;
|
|
12
|
-
//# sourceMappingURL=preconditions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preconditions.d.ts","sourceRoot":"","sources":["../src/preconditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAGrE,MAAM,MAAM,kBAAkB,GAAG,uBAAuB,CAAA;AAExD,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,uBAAuB,EAAE,EACxC,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,MAAM,GACzB;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,CAYzD;AAED,wBAAgB,sCAAsC,CACpD,aAAa,EAAE,uBAAuB,EAAE,GACvC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAWxC;AAED,wBAAgB,+BAA+B,CAC7C,aAAa,EAAE,uBAAuB,EAAE,EACxC,OAAO,EAAE,MAAM,GACd,uBAAuB,GAAG,IAAI,CAKhC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Account, PublicClient, WalletClient } from 'viem';
|
|
2
|
-
import { TransactionState } from '../../transactions.js';
|
|
3
|
-
import { PrepareSendReturn, TradeType } from '../types.js';
|
|
4
|
-
/**
|
|
5
|
-
* @description
|
|
6
|
-
* This handler manages same-chain token swaps (e.g., ETH to WETH on the same chain).
|
|
7
|
-
* It leverages the Relay SDK for quote and transaction execution.
|
|
8
|
-
*
|
|
9
|
-
* Key characteristics:
|
|
10
|
-
* - Uses Relay SDK directly for quote fetching and transaction execution
|
|
11
|
-
* - Single transaction leg (swap on origin chain)
|
|
12
|
-
* - No cross-chain bridging required
|
|
13
|
-
* - Supports various token pair combinations on the same chain
|
|
14
|
-
*
|
|
15
|
-
* Transaction Flow:
|
|
16
|
-
* 1. Fetch quote via getRelaySDKQuote (Relay SDK API)
|
|
17
|
-
* 2. Create intent via createIntent (Intent object created)
|
|
18
|
-
* 3. Execute swap via executeSimpleRelayTransaction (User submits swap transaction)
|
|
19
|
-
* 4. Monitor via waitIntentReceipt API for transaction completion
|
|
20
|
-
* 5. Update transaction state and invoke callbacks
|
|
21
|
-
*
|
|
22
|
-
* Relay SDK Integration:
|
|
23
|
-
* - Direct integration with Relay SDK for quote and transaction submission
|
|
24
|
-
* - Transaction hash extracted via getTxHashFromRelayResult
|
|
25
|
-
* - Receipt polling via Trails API for consistent monitoring
|
|
26
|
-
*
|
|
27
|
-
* Error Handling:
|
|
28
|
-
* - Balance validation before transaction submission
|
|
29
|
-
* - Chain switching if user is on wrong network
|
|
30
|
-
* - Relay SDK error handling with proper error propagation
|
|
31
|
-
* - Checkout error callbacks for UI feedback
|
|
32
|
-
*
|
|
33
|
-
* State Management:
|
|
34
|
-
* - transactionStates[0]: Swap transaction
|
|
35
|
-
* - Updates propagated via onTransactionStateChange callback
|
|
36
|
-
* - Analytics tracking for payment completion or errors
|
|
37
|
-
*/
|
|
38
|
-
export declare function handleSameChainDifferentToken({ originTokenAddress, originTokenDecimals, swapAmount, destinationTokenAddress, destinationTokenDecimals, destinationCalldata, recipient, originChainId, walletClient, publicClient, account, tradeType, slippageTolerance, onTransactionStateChange, transactionStates, sourceTokenPriceUsd, destinationTokenPriceUsd, originNativeTokenPriceUsd, mode, fundMethod, originTokenSymbol, destinationTokenSymbol, }: {
|
|
39
|
-
originTokenAddress: string;
|
|
40
|
-
originTokenDecimals: number;
|
|
41
|
-
swapAmount: string;
|
|
42
|
-
destinationTokenAddress: string;
|
|
43
|
-
destinationTokenDecimals: number;
|
|
44
|
-
destinationCalldata?: string;
|
|
45
|
-
recipient: string;
|
|
46
|
-
originChainId: number;
|
|
47
|
-
walletClient: WalletClient;
|
|
48
|
-
publicClient: PublicClient;
|
|
49
|
-
account: Account;
|
|
50
|
-
tradeType?: TradeType;
|
|
51
|
-
slippageTolerance?: string;
|
|
52
|
-
onTransactionStateChange: (transactionStates: TransactionState[]) => void;
|
|
53
|
-
transactionStates: TransactionState[];
|
|
54
|
-
sourceTokenPriceUsd?: number | null;
|
|
55
|
-
destinationTokenPriceUsd?: number | null;
|
|
56
|
-
originNativeTokenPriceUsd?: number | null;
|
|
57
|
-
mode?: "pay" | "fund" | "earn" | "swap" | "receive";
|
|
58
|
-
fundMethod?: string;
|
|
59
|
-
originTokenSymbol: string;
|
|
60
|
-
destinationTokenSymbol: string;
|
|
61
|
-
}): Promise<PrepareSendReturn>;
|
|
62
|
-
//# sourceMappingURL=sameChainDifferentToken.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sameChainDifferentToken.d.ts","sourceRoot":"","sources":["../../../src/transactionIntent/handlers/sameChainDifferentToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAc,SAAS,EAAE,MAAM,aAAa,CAAA;AAuB3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,SAAuC,EACvC,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,sBAAsB,GACvB,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAA;IAC1B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,wBAAwB,EAAE,MAAM,CAAA;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,YAAY,CAAA;IAC1B,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,wBAAwB,EAAE,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,IAAI,CAAA;IACzE,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnC,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxC,yBAAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzC,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACnD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iBAAiB,EAAE,MAAM,CAAA;IACzB,sBAAsB,EAAE,MAAM,CAAA;CAC/B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwN7B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function getNeedsLifiNativeFee({ originTokenAddress, destinationTokenAmount, destinationTokenDecimals, sourceTokenDecimals, sourceTokenPriceUsd, destinationTokenPriceUsd, depositAmount, }: {
|
|
2
|
-
originTokenAddress: string;
|
|
3
|
-
destinationTokenAmount: string;
|
|
4
|
-
destinationTokenDecimals: number;
|
|
5
|
-
sourceTokenDecimals: number;
|
|
6
|
-
sourceTokenPriceUsd: number | null;
|
|
7
|
-
destinationTokenPriceUsd: number | null;
|
|
8
|
-
depositAmount: string;
|
|
9
|
-
}): boolean;
|
|
10
|
-
//# sourceMappingURL=lifiHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lifiHelpers.d.ts","sourceRoot":"","sources":["../../../src/transactionIntent/utils/lifiHelpers.ts"],"names":[],"mappings":"AAMA,wBAAgB,qBAAqB,CAAC,EACpC,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,GACd,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAA;IAC1B,sBAAsB,EAAE,MAAM,CAAA;IAC9B,wBAAwB,EAAE,MAAM,CAAA;IAChC,mBAAmB,EAAE,MAAM,CAAA;IAC3B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC,aAAa,EAAE,MAAM,CAAA;CACtB,GAAG,OAAO,CA6CV"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { default as React, ReactNode } from 'react';
|
|
2
|
-
export interface FeeOption {
|
|
3
|
-
tokenAddress: string;
|
|
4
|
-
tokenSymbol: string;
|
|
5
|
-
tokenDecimals: number;
|
|
6
|
-
amount: string;
|
|
7
|
-
amountUSD: number;
|
|
8
|
-
notEnoughBalance?: boolean;
|
|
9
|
-
tokenImageUrl?: string;
|
|
10
|
-
chainId?: number;
|
|
11
|
-
amountUsdDisplay?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface TokenWithBalance {
|
|
14
|
-
chainId: number;
|
|
15
|
-
contractAddress?: string;
|
|
16
|
-
balance?: string;
|
|
17
|
-
imageUrl?: string;
|
|
18
|
-
}
|
|
19
|
-
interface SelectedFeeTokenContextType {
|
|
20
|
-
selectedFeeToken: FeeOption | null;
|
|
21
|
-
setSelectedFeeToken: (token: FeeOption | null) => void;
|
|
22
|
-
clearSelectedFeeToken: () => void;
|
|
23
|
-
processedFeeOptions: FeeOption[];
|
|
24
|
-
setRawFeeOptions: (feeOptions: any[] | null | undefined, originChainId: number | undefined, availableTokens: TokenWithBalance[]) => void;
|
|
25
|
-
}
|
|
26
|
-
interface SelectedFeeTokenProviderProps {
|
|
27
|
-
children: ReactNode;
|
|
28
|
-
initialToken?: FeeOption | null;
|
|
29
|
-
}
|
|
30
|
-
export declare const SelectedFeeTokenProvider: React.FC<SelectedFeeTokenProviderProps>;
|
|
31
|
-
export declare const useSelectedFeeToken: () => SelectedFeeTokenContextType;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=useSelectedFeeToken.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectedFeeToken.d.ts","sourceRoot":"","sources":["../../../src/widget/hooks/useSelectedFeeToken.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAiBd,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAGD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,2BAA2B;IACnC,gBAAgB,EAAE,SAAS,GAAG,IAAI,CAAA;IAClC,mBAAmB,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAA;IACtD,qBAAqB,EAAE,MAAM,IAAI,CAAA;IACjC,mBAAmB,EAAE,SAAS,EAAE,CAAA;IAChC,gBAAgB,EAAE,CAChB,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,EACpC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,eAAe,EAAE,gBAAgB,EAAE,KAChC,IAAI,CAAA;CACV;AAMD,UAAU,6BAA6B;IACrC,QAAQ,EAAE,SAAS,CAAA;IACnB,YAAY,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;CAChC;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAC7C,6BAA6B,CAgN9B,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAO,2BAUtC,CAAA"}
|
package/src/cctpqueue.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { getConfig } from "./config.js"
|
|
2
|
-
import type { TrailsClient } from "./trailsClient.js"
|
|
3
|
-
|
|
4
|
-
// Narrow API client to one that supports queueing CCTP transfers without using 'any'
|
|
5
|
-
type CctpQueueCapable = {
|
|
6
|
-
queueCCTPTransfer: (
|
|
7
|
-
args: {
|
|
8
|
-
sourceTxHash?: string
|
|
9
|
-
metaTxHash?: string
|
|
10
|
-
sourceChainId: number
|
|
11
|
-
destinationChainId: number
|
|
12
|
-
},
|
|
13
|
-
headers?: object,
|
|
14
|
-
signal?: AbortSignal,
|
|
15
|
-
) => Promise<unknown>
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const fallbackQueueCCTPTransfer = async (args: {
|
|
19
|
-
sourceTxHash?: string
|
|
20
|
-
metaTxHash?: string
|
|
21
|
-
sourceChainId: number
|
|
22
|
-
destinationChainId: number
|
|
23
|
-
}): Promise<void> => {
|
|
24
|
-
const apiUrl = getConfig("trailsApiUrl")
|
|
25
|
-
if (!apiUrl) {
|
|
26
|
-
throw new Error("trailsApiUrl is required for CCTP queue transfer")
|
|
27
|
-
}
|
|
28
|
-
const accessKey = getConfig("trailsApiKey")
|
|
29
|
-
const headers: { [key: string]: string } = {
|
|
30
|
-
"Content-Type": "application/json",
|
|
31
|
-
}
|
|
32
|
-
if (accessKey) headers["X-Access-Key"] = accessKey
|
|
33
|
-
await fetch(`${apiUrl.replace(/\/*$/, "")}/rpc/API/QueueCCTPTransfer`, {
|
|
34
|
-
method: "POST",
|
|
35
|
-
headers,
|
|
36
|
-
body: JSON.stringify(args),
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function hasCctpQueue(client: unknown): client is CctpQueueCapable {
|
|
41
|
-
const maybe = client as { queueCCTPTransfer?: unknown } | null | undefined
|
|
42
|
-
return typeof maybe?.queueCCTPTransfer === "function"
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export async function queueCCTPTransfer({
|
|
46
|
-
trailsClient,
|
|
47
|
-
sourceTxHash,
|
|
48
|
-
sourceChainId,
|
|
49
|
-
destinationChainId,
|
|
50
|
-
}: {
|
|
51
|
-
trailsClient: TrailsClient
|
|
52
|
-
sourceTxHash: string
|
|
53
|
-
sourceChainId: number
|
|
54
|
-
destinationChainId: number
|
|
55
|
-
}): Promise<void> {
|
|
56
|
-
if (hasCctpQueue(trailsClient)) {
|
|
57
|
-
await trailsClient.queueCCTPTransfer({
|
|
58
|
-
sourceTxHash,
|
|
59
|
-
sourceChainId,
|
|
60
|
-
destinationChainId,
|
|
61
|
-
})
|
|
62
|
-
} else {
|
|
63
|
-
await fallbackQueueCCTPTransfer({
|
|
64
|
-
sourceTxHash,
|
|
65
|
-
sourceChainId,
|
|
66
|
-
destinationChainId,
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
}
|
package/src/preconditions.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { TransactionPrecondition } from "@0xsequence/trails-api"
|
|
2
|
-
|
|
3
|
-
// Backward compatibility alias
|
|
4
|
-
export type IntentPrecondition = TransactionPrecondition
|
|
5
|
-
|
|
6
|
-
export function findPreconditionAddresses(
|
|
7
|
-
preconditions: TransactionPrecondition[],
|
|
8
|
-
originChainId: number,
|
|
9
|
-
destinationChainId: number,
|
|
10
|
-
): { originAddress?: string; destinationAddress?: string } {
|
|
11
|
-
const origin = preconditions.find(
|
|
12
|
-
(p) => p.chainId === originChainId && p.ownerAddress,
|
|
13
|
-
)
|
|
14
|
-
const destination = preconditions.find(
|
|
15
|
-
(p) => p.chainId === destinationChainId && p.ownerAddress,
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
originAddress: origin?.ownerAddress,
|
|
20
|
-
destinationAddress: destination?.ownerAddress,
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function findChainAndAddressesFromPreconditions(
|
|
25
|
-
preconditions: TransactionPrecondition[],
|
|
26
|
-
): { chainId: number; address: string }[] {
|
|
27
|
-
const addressesFromPreconditions: { chainId: number; address: string }[] = []
|
|
28
|
-
preconditions.forEach((p) => {
|
|
29
|
-
if (p.type === "tokenMinBalance" && p.ownerAddress && p.chainId) {
|
|
30
|
-
addressesFromPreconditions.push({
|
|
31
|
-
chainId: p.chainId,
|
|
32
|
-
address: p.ownerAddress,
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
return addressesFromPreconditions
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function findFirstPreconditionForChainId(
|
|
40
|
-
preconditions: TransactionPrecondition[],
|
|
41
|
-
chainId: number,
|
|
42
|
-
): TransactionPrecondition | null {
|
|
43
|
-
const precondition = preconditions.find(
|
|
44
|
-
(p) => p.type === "tokenMinBalance" && p.chainId === chainId,
|
|
45
|
-
)
|
|
46
|
-
return precondition ?? null
|
|
47
|
-
}
|