0xtrails 0.2.5 → 0.3.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/abortController.d.ts +8 -0
- package/dist/abortController.d.ts.map +1 -0
- package/dist/{ccip-CXlshvBY.js → ccip-BMB3uDZt.js} +1 -1
- package/dist/config.d.ts +0 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -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 +19 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/{index-_QuyGrjU.js → index-QXPUrZVv.js} +48719 -50852
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +811 -784
- 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 +7 -258
- 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/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 +6 -3
- package/dist/transactions.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts +4 -0
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts.map +1 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +2 -3
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DynamicInputStyles.d.ts +18 -0
- package/dist/widget/components/DynamicInputStyles.d.ts.map +1 -0
- 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 +2 -3
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/ErrorAnimationIcon.d.ts +2 -0
- package/dist/widget/components/ErrorAnimationIcon.d.ts.map +1 -0
- package/dist/widget/components/FeeBreakdown.d.ts +9 -0
- package/dist/widget/components/FeeBreakdown.d.ts.map +1 -0
- 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 +2 -3
- 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 +2 -3
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Identicon.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -3
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +2 -3
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +3 -3
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +3 -20
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts +2 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +2 -3
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts +11 -0
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts.map +1 -0
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Tooltip.d.ts +9 -0
- package/dist/widget/components/Tooltip.d.ts.map +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +1 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.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 +82 -0
- package/dist/widget/hooks/useQuote.d.ts.map +1 -0
- 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 +5 -6
- 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 +2 -2
- package/dist/widget/widget.d.ts +17 -7
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +19 -21
- package/src/aave.ts +54 -1
- package/src/abortController.ts +35 -0
- package/src/config.ts +57 -58
- package/src/constants.ts +11 -9
- package/src/error.ts +21 -3
- package/src/fees.ts +210 -0
- package/src/index.ts +35 -13
- package/src/intentReceiptMonitor.ts +102 -0
- package/src/intentReceiptPoller.ts +299 -0
- package/src/intents.ts +205 -171
- package/src/morpho.ts +58 -9
- package/src/mutations.ts +129 -0
- package/src/preconditions.ts +16 -21
- package/src/prepareSend.ts +92 -4699
- 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/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 +98 -71
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountIntentTransactionHistory.tsx +36 -36
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
- package/src/widget/components/AccountSettings.tsx +70 -41
- package/src/widget/components/ChainFilterDropdown.tsx +24 -3
- package/src/widget/components/ClassicSwap.tsx +44 -107
- package/src/widget/components/ConfigDisplay.tsx +0 -11
- package/src/widget/components/ConnectWallet.tsx +4 -1
- package/src/widget/components/ConnectedWallets.tsx +51 -25
- package/src/widget/components/DynamicInputStyles.tsx +76 -0
- package/src/widget/components/DynamicSizeInputField.tsx +109 -0
- package/src/widget/components/Earn.tsx +34 -45
- package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
- package/src/widget/components/FeeBreakdown.tsx +155 -0
- package/src/widget/components/FeeOption.tsx +2 -2
- package/src/widget/components/FeeOptions.tsx +151 -112
- package/src/widget/components/Fund.tsx +10 -29
- package/src/widget/components/FundMethods.tsx +4 -3
- package/src/widget/components/FundSwap.tsx +2 -3
- package/src/widget/components/FundingMethodSelectorButton.tsx +24 -14
- package/src/widget/components/Identicon.tsx +164 -95
- package/src/widget/components/MeshConnectExchanges.tsx +2 -15
- package/src/widget/components/Modal.tsx +0 -12
- package/src/widget/components/Pay.tsx +72 -75
- package/src/widget/components/PoolDeposit.tsx +221 -242
- package/src/widget/components/PoolWithdraw.tsx +347 -469
- package/src/widget/components/PriceImpactWarning.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +906 -484
- package/src/widget/components/Receipt.tsx +16 -2
- package/src/widget/components/RecipientSelectorButton.tsx +7 -5
- package/src/widget/components/Recipients.tsx +1 -1
- package/src/widget/components/ScreenHeader.tsx +60 -36
- package/src/widget/components/Swap.tsx +2 -3
- package/src/widget/components/ThemeProvider.tsx +2 -1
- package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
- package/src/widget/components/TokenImage.tsx +1 -1
- package/src/widget/components/TokenSelector.tsx +62 -53
- package/src/widget/components/TokenSelectorButton.tsx +38 -15
- package/src/widget/components/Tooltip.tsx +51 -0
- package/src/widget/components/TransferPendingVertical.tsx +12 -8
- package/src/widget/components/WaasFeeOptions.tsx +139 -4
- package/src/widget/components/WalletConfirmation.tsx +23 -13
- package/src/widget/components/WalletConnect.tsx +93 -29
- 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 +466 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +32 -37
- package/src/widget/hooks/useSendForm.ts +45 -51
- package/src/widget/hooks/useTokenList.ts +34 -26
- package/src/widget/hooks/useWalletConnectionContext.tsx +128 -0
- package/src/widget/widget.tsx +365 -390
- 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
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
zeroAddress,
|
|
11
11
|
} from "viem"
|
|
12
12
|
import { useAccount } from "wagmi"
|
|
13
|
-
import { useAPIClient } from "../../apiClient.js"
|
|
14
13
|
import { getChainInfo, useSupportedChains } from "../../chains.js"
|
|
15
14
|
import { getFullErrorMessage, getPrettifiedErrorMessage } from "../../error.js"
|
|
16
15
|
import {
|
|
@@ -18,11 +17,11 @@ import {
|
|
|
18
17
|
TradeType,
|
|
19
18
|
type PrepareSendReturn,
|
|
20
19
|
type PrepareSendQuote,
|
|
20
|
+
type SelectedFeeToken,
|
|
21
21
|
} from "../../prepareSend.js"
|
|
22
22
|
import type { TransactionState } from "../../transactions.js"
|
|
23
23
|
import { getTokenPrice, useTokenPrices, normalizeNumber } from "../../prices.js"
|
|
24
24
|
import { useQueryParams } from "../../queryParams.js"
|
|
25
|
-
import { getRelayer } from "../../relayer.js"
|
|
26
25
|
import {
|
|
27
26
|
formatRawAmount,
|
|
28
27
|
formatUsdAmountDisplay,
|
|
@@ -84,19 +83,18 @@ export type OnCompleteProps = {
|
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
export type UseSendProps = {
|
|
87
|
-
account
|
|
86
|
+
account?: Account
|
|
88
87
|
toAmount?: string
|
|
89
88
|
toRecipient?: string
|
|
90
89
|
toChainId?: number
|
|
91
90
|
toToken?: string
|
|
92
91
|
toCalldata?: string
|
|
93
92
|
refundAddress?: string
|
|
94
|
-
walletClient
|
|
93
|
+
walletClient?: WalletClient
|
|
95
94
|
onTransactionStateChange: (transactionStates: TransactionState[]) => void
|
|
96
95
|
onError: (error: Error | string | null) => void
|
|
97
96
|
onWaitingForWalletConfirm: (quote: PrepareSendQuote) => void
|
|
98
97
|
paymasterUrls?: PaymasterUrl[]
|
|
99
|
-
gasless?: boolean
|
|
100
98
|
onSend: (amount: string, recipient: string) => void
|
|
101
99
|
onConfirm: () => void
|
|
102
100
|
onComplete: (result: OnCompleteProps) => void
|
|
@@ -165,7 +163,7 @@ export type UseSendReturn = {
|
|
|
165
163
|
destTokenPrices: TokenPrice[] | null
|
|
166
164
|
sourceTokenPrices: TokenPrice[] | null
|
|
167
165
|
selectedToken?: Token
|
|
168
|
-
selectedFeeToken:
|
|
166
|
+
selectedFeeToken: SelectedFeeToken | undefined
|
|
169
167
|
setIsChainDropdownOpen: (isOpen: boolean) => void
|
|
170
168
|
setIsTokenDropdownOpen: (isOpen: boolean) => void
|
|
171
169
|
toAmountFormatted: string
|
|
@@ -194,7 +192,6 @@ export function useSendForm({
|
|
|
194
192
|
onError,
|
|
195
193
|
onWaitingForWalletConfirm,
|
|
196
194
|
paymasterUrls,
|
|
197
|
-
gasless,
|
|
198
195
|
selectedToken,
|
|
199
196
|
onSend,
|
|
200
197
|
onConfirm,
|
|
@@ -435,7 +432,6 @@ export function useSendForm({
|
|
|
435
432
|
}
|
|
436
433
|
}, [selectedDestToken, defaultDestToken])
|
|
437
434
|
|
|
438
|
-
const apiClient = useAPIClient()
|
|
439
435
|
const trailsClient = useTrailsClient()
|
|
440
436
|
|
|
441
437
|
// Get user's token balances for balance checking
|
|
@@ -462,8 +458,8 @@ export function useSendForm({
|
|
|
462
458
|
selectedDestToken && destTokenAddress && selectedDestinationChain?.id
|
|
463
459
|
? [
|
|
464
460
|
{
|
|
465
|
-
|
|
466
|
-
|
|
461
|
+
tokenSymbol: selectedDestToken.symbol,
|
|
462
|
+
tokenAddress: destTokenAddress,
|
|
467
463
|
chainId: selectedDestinationChain.id,
|
|
468
464
|
},
|
|
469
465
|
]
|
|
@@ -474,20 +470,20 @@ export function useSendForm({
|
|
|
474
470
|
|
|
475
471
|
const { tokenPrices: destTokenPrices } = useTokenPrices(
|
|
476
472
|
destTokenPricesInput,
|
|
477
|
-
|
|
473
|
+
trailsClient,
|
|
478
474
|
)
|
|
479
475
|
|
|
480
476
|
const { tokenPrices: sourceTokenPrices } = useTokenPrices(
|
|
481
477
|
selectedToken
|
|
482
478
|
? [
|
|
483
479
|
{
|
|
484
|
-
|
|
485
|
-
|
|
480
|
+
tokenSymbol: selectedToken.symbol,
|
|
481
|
+
tokenAddress: selectedToken.contractAddress,
|
|
486
482
|
chainId: selectedToken.chainId,
|
|
487
483
|
},
|
|
488
484
|
]
|
|
489
485
|
: [],
|
|
490
|
-
|
|
486
|
+
trailsClient,
|
|
491
487
|
)
|
|
492
488
|
|
|
493
489
|
// Update selectedChain when toChainId prop changes
|
|
@@ -569,7 +565,7 @@ export function useSendForm({
|
|
|
569
565
|
selectedToken?.balance && selectedToken?.contractInfo?.decimals
|
|
570
566
|
? formatRawAmount(
|
|
571
567
|
selectedToken.balance,
|
|
572
|
-
selectedToken.contractInfo?.decimals
|
|
568
|
+
selectedToken.contractInfo?.decimals,
|
|
573
569
|
)
|
|
574
570
|
: "0"
|
|
575
571
|
const balanceUsdDisplay = selectedToken?.balanceUsdFormatted ?? ""
|
|
@@ -579,8 +575,8 @@ export function useSendForm({
|
|
|
579
575
|
const amountUsdDisplay = useMemo(() => {
|
|
580
576
|
const tokenPrice =
|
|
581
577
|
tradeType === TradeType.EXACT_INPUT
|
|
582
|
-
? (sourceTokenPrices?.[0]?.
|
|
583
|
-
: (destTokenPrices?.[0]?.
|
|
578
|
+
? (sourceTokenPrices?.[0]?.priceUsd ?? 0) // For fund form, use source token price
|
|
579
|
+
: (destTokenPrices?.[0]?.priceUsd ?? 0) // For payment form, use dest token price
|
|
584
580
|
const amountUsd = Number(amount) * tokenPrice
|
|
585
581
|
return formatUsdAmountDisplay(amountUsd)
|
|
586
582
|
}, [amount, destTokenPrices, sourceTokenPrices, tradeType])
|
|
@@ -616,6 +612,11 @@ export function useSendForm({
|
|
|
616
612
|
|
|
617
613
|
// Calculate raw amount (in wei/smallest unit)
|
|
618
614
|
const amountRaw = useMemo(() => {
|
|
615
|
+
// Skip validation during initialization when no tokens are selected
|
|
616
|
+
if (!selectedToken && !selectedDestToken) {
|
|
617
|
+
return "0"
|
|
618
|
+
}
|
|
619
|
+
|
|
619
620
|
if (
|
|
620
621
|
!amount &&
|
|
621
622
|
!(selectedToken?.contractInfo?.decimals || selectedDestToken?.decimals)
|
|
@@ -687,6 +688,7 @@ export function useSendForm({
|
|
|
687
688
|
const getQuote = useCallback(async () => {
|
|
688
689
|
// Only get quote if all required inputs are present
|
|
689
690
|
if (
|
|
691
|
+
!account ||
|
|
690
692
|
!amount ||
|
|
691
693
|
!destinationTokenAddress ||
|
|
692
694
|
!isValidRecipient ||
|
|
@@ -719,12 +721,6 @@ export function useSendForm({
|
|
|
719
721
|
setError(null)
|
|
720
722
|
setQuoteError(null)
|
|
721
723
|
|
|
722
|
-
const originRelayer = getRelayer(undefined, selectedToken.chainId)
|
|
723
|
-
const destinationRelayer = getRelayer(
|
|
724
|
-
undefined,
|
|
725
|
-
selectedDestinationChain.id,
|
|
726
|
-
)
|
|
727
|
-
|
|
728
724
|
const sourceTokenDecimals = selectedToken.contractInfo?.decimals
|
|
729
725
|
const destinationTokenDecimals = selectedDestToken.decimals
|
|
730
726
|
|
|
@@ -742,12 +738,16 @@ export function useSendForm({
|
|
|
742
738
|
}
|
|
743
739
|
|
|
744
740
|
let sourceTokenPriceUsd = selectedToken.tokenPriceUsd ?? null
|
|
745
|
-
let destinationTokenPriceUsd = destTokenPrices?.[0]?.
|
|
741
|
+
let destinationTokenPriceUsd = destTokenPrices?.[0]?.priceUsd ?? null
|
|
746
742
|
|
|
747
743
|
if (!sourceTokenPriceUsd) {
|
|
748
744
|
try {
|
|
749
|
-
const price = await getTokenPrice(
|
|
750
|
-
|
|
745
|
+
const price = await getTokenPrice(trailsClient, {
|
|
746
|
+
tokenAddress: selectedToken.contractAddress,
|
|
747
|
+
tokenSymbol: selectedToken.symbol,
|
|
748
|
+
chainId: selectedToken.chainId,
|
|
749
|
+
})
|
|
750
|
+
sourceTokenPriceUsd = price?.priceUsd ?? null
|
|
751
751
|
} catch (error) {
|
|
752
752
|
logger.console.error(
|
|
753
753
|
"[trails-sdk] Error getting source token price:",
|
|
@@ -758,12 +758,12 @@ export function useSendForm({
|
|
|
758
758
|
|
|
759
759
|
if (!destinationTokenPriceUsd) {
|
|
760
760
|
try {
|
|
761
|
-
const price = await getTokenPrice(
|
|
762
|
-
|
|
763
|
-
|
|
761
|
+
const price = await getTokenPrice(trailsClient, {
|
|
762
|
+
tokenSymbol: selectedDestToken.symbol,
|
|
763
|
+
tokenAddress: destinationTokenAddress ?? "",
|
|
764
764
|
chainId: selectedDestinationChain.id,
|
|
765
765
|
})
|
|
766
|
-
destinationTokenPriceUsd = price?.
|
|
766
|
+
destinationTokenPriceUsd = price?.priceUsd ?? null
|
|
767
767
|
} catch (error) {
|
|
768
768
|
logger.console.error(
|
|
769
769
|
"[trails-sdk] Error getting destination token price:",
|
|
@@ -801,17 +801,14 @@ export function useSendForm({
|
|
|
801
801
|
} else {
|
|
802
802
|
const originChain = getChainInfo(selectedToken.chainId)
|
|
803
803
|
const nativeTokenSymbol = originChain?.nativeCurrency?.symbol ?? ""
|
|
804
|
-
const nativePrice = await getTokenPrice(
|
|
805
|
-
|
|
806
|
-
|
|
804
|
+
const nativePrice = await getTokenPrice(trailsClient, {
|
|
805
|
+
tokenSymbol: nativeTokenSymbol,
|
|
806
|
+
tokenAddress: zeroAddress,
|
|
807
807
|
chainId: selectedToken.chainId,
|
|
808
808
|
})
|
|
809
|
-
nativeTokenPriceUsd = nativePrice?.
|
|
809
|
+
nativeTokenPriceUsd = nativePrice?.priceUsd ?? 0
|
|
810
810
|
}
|
|
811
811
|
|
|
812
|
-
// Disable gasless for sequence-waas wallet
|
|
813
|
-
const effectiveGasless = walletId === "sequence-waas" ? false : gasless
|
|
814
|
-
|
|
815
812
|
const options = {
|
|
816
813
|
account,
|
|
817
814
|
originTokenAddress: selectedToken.contractAddress,
|
|
@@ -832,10 +829,7 @@ export function useSendForm({
|
|
|
832
829
|
destinationTokenSymbol: selectedDestToken.symbol,
|
|
833
830
|
fee: "0",
|
|
834
831
|
client: walletClient,
|
|
835
|
-
apiClient,
|
|
836
832
|
trailsClient,
|
|
837
|
-
originRelayer,
|
|
838
|
-
destinationRelayer,
|
|
839
833
|
destinationCalldata: toCalldata,
|
|
840
834
|
refundAddress,
|
|
841
835
|
dryMode: isDryMode,
|
|
@@ -848,13 +842,12 @@ export function useSendForm({
|
|
|
848
842
|
paymasterUrls?.find(
|
|
849
843
|
(p) => p.chainId.toString() === selectedToken.chainId.toString(),
|
|
850
844
|
)?.url ?? undefined,
|
|
851
|
-
gasless: effectiveGasless,
|
|
852
845
|
originNativeTokenPriceUsd: nativeTokenPriceUsd,
|
|
853
846
|
quoteProvider: effectiveQuoteProvider,
|
|
854
847
|
mode,
|
|
855
848
|
fundMethod,
|
|
856
849
|
checkoutOnHandlers,
|
|
857
|
-
selectedFeeToken,
|
|
850
|
+
selectedFeeToken: selectedFeeToken ?? undefined,
|
|
858
851
|
walletId,
|
|
859
852
|
}
|
|
860
853
|
|
|
@@ -882,7 +875,6 @@ export function useSendForm({
|
|
|
882
875
|
isDryMode,
|
|
883
876
|
account,
|
|
884
877
|
walletClient,
|
|
885
|
-
apiClient,
|
|
886
878
|
trailsClient,
|
|
887
879
|
selectedDestToken?.decimals,
|
|
888
880
|
recipient,
|
|
@@ -896,10 +888,9 @@ export function useSendForm({
|
|
|
896
888
|
toCalldata,
|
|
897
889
|
refundAddress,
|
|
898
890
|
paymasterUrls,
|
|
899
|
-
gasless,
|
|
900
891
|
handleTransactionStateChange,
|
|
901
892
|
isValidRecipient,
|
|
902
|
-
destTokenPrices?.[0]?.
|
|
893
|
+
destTokenPrices?.[0]?.priceUsd,
|
|
903
894
|
amount,
|
|
904
895
|
selectedDestToken,
|
|
905
896
|
selectedDestinationChain,
|
|
@@ -945,6 +936,7 @@ export function useSendForm({
|
|
|
945
936
|
selectedToken?.chainId,
|
|
946
937
|
selectedToken?.balance,
|
|
947
938
|
selectedToken?.tokenPriceUsd,
|
|
939
|
+
recipient, // Add recipient to trigger quote re-fetch when it changes
|
|
948
940
|
// selectedFeeToken is passed to send() at execution time, not needed here
|
|
949
941
|
])
|
|
950
942
|
|
|
@@ -958,7 +950,8 @@ export function useSendForm({
|
|
|
958
950
|
}, [prepareSendResult, toAmountFormatted])
|
|
959
951
|
|
|
960
952
|
const quotedDestinationAmountDisplay = useMemo(() => {
|
|
961
|
-
|
|
953
|
+
const formattedAmount = formatAmount(quotedDestinationAmount || 0)
|
|
954
|
+
return Number(formattedAmount) === 0 ? "0" : formattedAmount
|
|
962
955
|
}, [quotedDestinationAmount])
|
|
963
956
|
|
|
964
957
|
// Set raw fee options in the hook whenever prepareSendResult changes
|
|
@@ -1077,15 +1070,15 @@ export function useSendForm({
|
|
|
1077
1070
|
)
|
|
1078
1071
|
// Wait for full send to complete
|
|
1079
1072
|
const {
|
|
1080
|
-
|
|
1073
|
+
depositUserTxnReceipt,
|
|
1081
1074
|
originMetaTxnReceipt,
|
|
1082
1075
|
destinationMetaTxnReceipt,
|
|
1083
1076
|
} = await send({
|
|
1084
1077
|
onOriginSend,
|
|
1085
|
-
selectedFeeToken, // Pass current value at execution time
|
|
1078
|
+
selectedFeeToken: selectedFeeToken ?? undefined, // Pass current value at execution time
|
|
1086
1079
|
})
|
|
1087
1080
|
logger.console.log("[trails-sdk] send() completed, receipts:", {
|
|
1088
|
-
|
|
1081
|
+
depositUserTxnReceipt,
|
|
1089
1082
|
originMetaTxnReceipt,
|
|
1090
1083
|
destinationMetaTxnReceipt,
|
|
1091
1084
|
})
|
|
@@ -1158,6 +1151,7 @@ export function useSendForm({
|
|
|
1158
1151
|
|
|
1159
1152
|
// Get button text based on recipient and calldata
|
|
1160
1153
|
const buttonText = useMemo(() => {
|
|
1154
|
+
if (!account?.address) return "Connect your wallet"
|
|
1161
1155
|
if (!selectedToken) return "Select a token"
|
|
1162
1156
|
if (!amount) return "Enter an amount"
|
|
1163
1157
|
if (!selectedDestToken?.symbol) return "Select a token"
|
|
@@ -1251,7 +1245,7 @@ export function useSendForm({
|
|
|
1251
1245
|
amount,
|
|
1252
1246
|
isValidRecipient,
|
|
1253
1247
|
recipient,
|
|
1254
|
-
account
|
|
1248
|
+
account?.address,
|
|
1255
1249
|
selectedDestToken?.symbol,
|
|
1256
1250
|
isWaitingForWalletConfirm,
|
|
1257
1251
|
isSubmitting,
|
|
@@ -1342,7 +1336,7 @@ export function useSendForm({
|
|
|
1342
1336
|
destTokenPrices: destTokenPrices ?? null,
|
|
1343
1337
|
sourceTokenPrices: sourceTokenPrices ?? null,
|
|
1344
1338
|
selectedToken,
|
|
1345
|
-
selectedFeeToken,
|
|
1339
|
+
selectedFeeToken: selectedFeeToken ?? undefined,
|
|
1346
1340
|
setIsChainDropdownOpen,
|
|
1347
1341
|
setIsTokenDropdownOpen,
|
|
1348
1342
|
toAmountFormatted: quotedDestinationAmount,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "../../tokenBalances.js"
|
|
18
18
|
import { getFormatttedTokenName, useSupportedTokens } from "../../tokens.js"
|
|
19
19
|
import { useIndexerGatewayClient } from "../../indexerClient.js"
|
|
20
|
-
import {
|
|
20
|
+
import { useTrailsClient } from "../../trailsClient.js"
|
|
21
21
|
import { useTokenPrices } from "../../prices.js"
|
|
22
22
|
import { logger } from "../../logger.js"
|
|
23
23
|
|
|
@@ -136,7 +136,7 @@ export function useTokenList({
|
|
|
136
136
|
const [searchQuery, setSearchQuery] = useState("")
|
|
137
137
|
const { address } = useAccount()
|
|
138
138
|
const indexerGatewayClient = useIndexerGatewayClient()
|
|
139
|
-
const
|
|
139
|
+
const trailsClient = useTrailsClient()
|
|
140
140
|
const {
|
|
141
141
|
sortedTokens: allSortedTokens,
|
|
142
142
|
isLoadingSortedTokens,
|
|
@@ -160,8 +160,8 @@ export function useTokenList({
|
|
|
160
160
|
|
|
161
161
|
return filteredTokens.map((token: any) => ({
|
|
162
162
|
chainId: token.chainId,
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
tokenAddress: token.contractAddress || zeroAddress,
|
|
164
|
+
tokenSymbol: token.symbol,
|
|
165
165
|
}))
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -169,15 +169,15 @@ export function useTokenList({
|
|
|
169
169
|
|
|
170
170
|
return supportedTokens.map((token: any) => ({
|
|
171
171
|
chainId: token.chainId,
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
tokenAddress: token.contractAddress || zeroAddress,
|
|
173
|
+
tokenSymbol: token.symbol,
|
|
174
174
|
}))
|
|
175
175
|
}, [allSupportedTokens, supportedTokens, fundMethod])
|
|
176
176
|
|
|
177
177
|
const {
|
|
178
178
|
tokenPrices: supportedTokenPrices,
|
|
179
179
|
isLoadingTokenPrices: isLoadingSupportedTokenPrices,
|
|
180
|
-
} = useTokenPrices(supportedTokensForPricing,
|
|
180
|
+
} = useTokenPrices(supportedTokensForPricing, trailsClient)
|
|
181
181
|
|
|
182
182
|
// Determine loading state based on fund method and allSupportedTokens
|
|
183
183
|
const isLoadingTokens =
|
|
@@ -222,7 +222,7 @@ export function useTokenList({
|
|
|
222
222
|
// Find price data for this token
|
|
223
223
|
const priceData = supportedTokenPrices?.find(
|
|
224
224
|
(p: any) =>
|
|
225
|
-
p.token.
|
|
225
|
+
p.token.tokenAddress?.toLowerCase() ===
|
|
226
226
|
(token.contractAddress || zeroAddress).toLowerCase() &&
|
|
227
227
|
p.token.chainId === token.chainId,
|
|
228
228
|
)
|
|
@@ -237,10 +237,11 @@ export function useTokenList({
|
|
|
237
237
|
balance: "0", // No balance info for QR code and exchange modes
|
|
238
238
|
balanceUsd: 0,
|
|
239
239
|
balanceUsdFormatted: "0",
|
|
240
|
-
price:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
price:
|
|
241
|
+
priceData?.priceUsd !== undefined
|
|
242
|
+
? { value: priceData.priceUsd, currency: "USD" }
|
|
243
|
+
: { value: 0, currency: "USD" },
|
|
244
|
+
price24hVol: 0, // Volume data not available in new API
|
|
244
245
|
imageUrl: token.imageUrl,
|
|
245
246
|
symbol: token.symbol,
|
|
246
247
|
isSufficientBalance: true, // Always true for QR code and exchange modes
|
|
@@ -254,10 +255,11 @@ export function useTokenList({
|
|
|
254
255
|
balance: "0", // No balance info for QR code and exchange modes
|
|
255
256
|
balanceUsd: 0,
|
|
256
257
|
balanceUsdFormatted: "0",
|
|
257
|
-
price:
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
price:
|
|
259
|
+
priceData?.priceUsd !== undefined
|
|
260
|
+
? { value: priceData.priceUsd, currency: "USD" }
|
|
261
|
+
: { value: 0, currency: "USD" },
|
|
262
|
+
price24hVol: 0, // Volume data not available in new API
|
|
261
263
|
imageUrl: token.imageUrl,
|
|
262
264
|
contractInfo: {
|
|
263
265
|
decimals: token.decimals,
|
|
@@ -520,8 +522,8 @@ export function useTokenList({
|
|
|
520
522
|
|
|
521
523
|
const filteredTokensFormatted = useMemo(() => {
|
|
522
524
|
// Get base formatted tokens
|
|
523
|
-
const baseFormattedTokens = filteredTokens
|
|
524
|
-
(token: TokenBalanceExtended): TokenFormatted => {
|
|
525
|
+
const baseFormattedTokens = filteredTokens
|
|
526
|
+
.map((token: TokenBalanceExtended): TokenFormatted | null => {
|
|
525
527
|
const isNative =
|
|
526
528
|
!("contractAddress" in token) || token.contractAddress === zeroAddress
|
|
527
529
|
const chainInfo = getChainInfo(token.chainId)
|
|
@@ -544,7 +546,15 @@ export function useTokenList({
|
|
|
544
546
|
)
|
|
545
547
|
const decimals = isNative ? 18 : token.contractInfo?.decimals
|
|
546
548
|
if (!decimals) {
|
|
547
|
-
|
|
549
|
+
logger.console.warn(
|
|
550
|
+
"[trails-sdk] Missing decimals for token, skipping:",
|
|
551
|
+
{
|
|
552
|
+
token: isNative ? token : token.contractInfo,
|
|
553
|
+
chainId: token.chainId,
|
|
554
|
+
isNative,
|
|
555
|
+
},
|
|
556
|
+
)
|
|
557
|
+
return null // Return null to filter out tokens without decimals
|
|
548
558
|
}
|
|
549
559
|
const formattedBalance = formatRawAmount(token.balance, decimals)
|
|
550
560
|
const priceUsd = Number(token.price?.value) ?? 0
|
|
@@ -611,8 +621,8 @@ export function useTokenList({
|
|
|
611
621
|
isSufficientBalance,
|
|
612
622
|
chainName,
|
|
613
623
|
}
|
|
614
|
-
}
|
|
615
|
-
|
|
624
|
+
})
|
|
625
|
+
.filter(Boolean) as TokenFormatted[] // Filter out null values for tokens without decimals
|
|
616
626
|
|
|
617
627
|
// If allSupportedTokens is true, combine with supported tokens
|
|
618
628
|
if (allSupportedTokens) {
|
|
@@ -641,7 +651,7 @@ export function useTokenList({
|
|
|
641
651
|
// Find price data for this supported token
|
|
642
652
|
const priceData = supportedTokenPrices?.find(
|
|
643
653
|
(p: any) =>
|
|
644
|
-
p.token.
|
|
654
|
+
p.token.tokenAddress?.toLowerCase() ===
|
|
645
655
|
(supportedToken.contractAddress || zeroAddress).toLowerCase() &&
|
|
646
656
|
p.token.chainId === supportedToken.chainId,
|
|
647
657
|
)
|
|
@@ -659,10 +669,8 @@ export function useTokenList({
|
|
|
659
669
|
balance: "",
|
|
660
670
|
balanceFormatted: "",
|
|
661
671
|
balanceUsdFormatted: "",
|
|
662
|
-
priceUsd: priceData?.
|
|
663
|
-
price24hVol:
|
|
664
|
-
(priceData as unknown as { price24hVol: { value: number } })
|
|
665
|
-
?.price24hVol?.value || 0, // Add price data for volume sorting
|
|
672
|
+
priceUsd: priceData?.priceUsd || 0,
|
|
673
|
+
price24hVol: 0, // Volume data not available in new API
|
|
666
674
|
isSufficientBalance: true,
|
|
667
675
|
// Use any type to bypass strict type checking for now
|
|
668
676
|
} as any
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useState,
|
|
5
|
+
useCallback,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
} from "react"
|
|
8
|
+
import type { Screen } from "./useCurrentScreen.js"
|
|
9
|
+
import { logger } from "../../logger.js"
|
|
10
|
+
|
|
11
|
+
export type WalletConnectionPurpose =
|
|
12
|
+
| "general" // Default: switch active wallet
|
|
13
|
+
| "recipient-selection" // Don't switch, set as recipient only
|
|
14
|
+
| "fund-method-selection" // Don't switch, use for funding only
|
|
15
|
+
|
|
16
|
+
interface WalletConnectionContextValue {
|
|
17
|
+
purpose: WalletConnectionPurpose
|
|
18
|
+
originScreen: Screen | null
|
|
19
|
+
connectedWalletAddress: string | null
|
|
20
|
+
originalActiveWalletAddress: string | null
|
|
21
|
+
originalActiveConnector: any | null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface WalletConnectionContextType {
|
|
25
|
+
connectionContext: WalletConnectionContextValue
|
|
26
|
+
setConnectionContext: (
|
|
27
|
+
purpose: WalletConnectionPurpose,
|
|
28
|
+
originScreen?: Screen,
|
|
29
|
+
originalActiveWalletAddress?: string,
|
|
30
|
+
originalActiveConnector?: any,
|
|
31
|
+
) => void
|
|
32
|
+
setConnectedWalletAddress: (address: string) => void
|
|
33
|
+
clearConnectionContext: () => void
|
|
34
|
+
isRecipientSelection: boolean
|
|
35
|
+
isFundMethodSelection: boolean
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const WalletConnectionContext =
|
|
39
|
+
createContext<WalletConnectionContextType | null>(null)
|
|
40
|
+
|
|
41
|
+
interface WalletConnectionProviderProps {
|
|
42
|
+
children: ReactNode
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const DEFAULT_CONTEXT: WalletConnectionContextValue = {
|
|
46
|
+
purpose: "general",
|
|
47
|
+
originScreen: null,
|
|
48
|
+
connectedWalletAddress: null,
|
|
49
|
+
originalActiveWalletAddress: null,
|
|
50
|
+
originalActiveConnector: null,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function WalletConnectionProvider({
|
|
54
|
+
children,
|
|
55
|
+
}: WalletConnectionProviderProps) {
|
|
56
|
+
const [connectionContext, setContext] =
|
|
57
|
+
useState<WalletConnectionContextValue>(DEFAULT_CONTEXT)
|
|
58
|
+
|
|
59
|
+
const setConnectionContext = useCallback(
|
|
60
|
+
(
|
|
61
|
+
purpose: WalletConnectionPurpose,
|
|
62
|
+
originScreen?: Screen,
|
|
63
|
+
originalActiveWalletAddress?: string,
|
|
64
|
+
originalActiveConnector?: any,
|
|
65
|
+
) => {
|
|
66
|
+
logger.console.log("[trails-sdk] Setting wallet connection context:", {
|
|
67
|
+
purpose,
|
|
68
|
+
originScreen,
|
|
69
|
+
originalActiveWalletAddress,
|
|
70
|
+
hasOriginalConnector: !!originalActiveConnector,
|
|
71
|
+
})
|
|
72
|
+
setContext({
|
|
73
|
+
purpose,
|
|
74
|
+
originScreen: originScreen || null,
|
|
75
|
+
connectedWalletAddress: null,
|
|
76
|
+
originalActiveWalletAddress: originalActiveWalletAddress || null,
|
|
77
|
+
originalActiveConnector: originalActiveConnector || null,
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
[],
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
const setConnectedWalletAddress = useCallback((address: string) => {
|
|
84
|
+
logger.console.log(
|
|
85
|
+
"[trails-sdk] Setting connected wallet address:",
|
|
86
|
+
address,
|
|
87
|
+
)
|
|
88
|
+
setContext((prev) => ({
|
|
89
|
+
...prev,
|
|
90
|
+
connectedWalletAddress: address,
|
|
91
|
+
}))
|
|
92
|
+
}, [])
|
|
93
|
+
|
|
94
|
+
const clearConnectionContext = useCallback(() => {
|
|
95
|
+
logger.console.log("[trails-sdk] Clearing wallet connection context")
|
|
96
|
+
setContext(DEFAULT_CONTEXT)
|
|
97
|
+
}, [])
|
|
98
|
+
|
|
99
|
+
const isRecipientSelection =
|
|
100
|
+
connectionContext.purpose === "recipient-selection"
|
|
101
|
+
const isFundMethodSelection =
|
|
102
|
+
connectionContext.purpose === "fund-method-selection"
|
|
103
|
+
|
|
104
|
+
const value: WalletConnectionContextType = {
|
|
105
|
+
connectionContext,
|
|
106
|
+
setConnectionContext,
|
|
107
|
+
setConnectedWalletAddress,
|
|
108
|
+
clearConnectionContext,
|
|
109
|
+
isRecipientSelection,
|
|
110
|
+
isFundMethodSelection,
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<WalletConnectionContext.Provider value={value}>
|
|
115
|
+
{children}
|
|
116
|
+
</WalletConnectionContext.Provider>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function useWalletConnectionContext() {
|
|
121
|
+
const context = useContext(WalletConnectionContext)
|
|
122
|
+
if (!context) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
"useWalletConnectionContext must be used within a WalletConnectionProvider",
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
return context
|
|
128
|
+
}
|