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
package/src/mutations.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query"
|
|
2
|
+
import type { Intent, DepositSignature } from "@0xsequence/trails-api"
|
|
3
|
+
import { useTrailsClient } from "./trailsClient.js"
|
|
4
|
+
import { logger } from "./logger.js"
|
|
5
|
+
import { getFullErrorMessage } from "./error.js"
|
|
6
|
+
import {
|
|
7
|
+
trackIntentCommitStarted,
|
|
8
|
+
trackIntentCommitCompleted,
|
|
9
|
+
trackIntentCommitError,
|
|
10
|
+
} from "./analytics.js"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Hook for committing an intent to the Trails API
|
|
14
|
+
* Wraps trailsClient.commitIntent with mutation state and analytics tracking
|
|
15
|
+
*/
|
|
16
|
+
export function useCommitIntent() {
|
|
17
|
+
const trailsClient = useTrailsClient()
|
|
18
|
+
|
|
19
|
+
return useMutation({
|
|
20
|
+
mutationFn: async (intent: Intent) => {
|
|
21
|
+
logger.console.log("[trails-sdk] useCommitIntent: Starting commit", {
|
|
22
|
+
intentId: intent.intentId,
|
|
23
|
+
originIntentAddress: intent.originIntentAddress,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const originChainIdStr = intent.calls[0]?.chainId
|
|
27
|
+
const destinationChainIdStr = intent.calls[1]?.chainId
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
// Track intent commit start
|
|
31
|
+
trackIntentCommitStarted({
|
|
32
|
+
intentAddress: intent.originIntentAddress,
|
|
33
|
+
userAddress: intent.ownerAddress,
|
|
34
|
+
originChainId: originChainIdStr
|
|
35
|
+
? Number(originChainIdStr)
|
|
36
|
+
: undefined,
|
|
37
|
+
destinationChainId: destinationChainIdStr
|
|
38
|
+
? Number(destinationChainIdStr)
|
|
39
|
+
: undefined,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// Commit the intent
|
|
43
|
+
const response = await trailsClient.commitIntent({ intent })
|
|
44
|
+
|
|
45
|
+
logger.console.log("[trails-sdk] useCommitIntent: Commit successful", {
|
|
46
|
+
intentId: intent.intentId,
|
|
47
|
+
response,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Track successful intent commit
|
|
51
|
+
trackIntentCommitCompleted({
|
|
52
|
+
intentAddress: intent.originIntentAddress,
|
|
53
|
+
userAddress: intent.ownerAddress,
|
|
54
|
+
originChainId: originChainIdStr
|
|
55
|
+
? Number(originChainIdStr)
|
|
56
|
+
: undefined,
|
|
57
|
+
destinationChainId: destinationChainIdStr
|
|
58
|
+
? Number(destinationChainIdStr)
|
|
59
|
+
: undefined,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
return response
|
|
63
|
+
} catch (error) {
|
|
64
|
+
// Track intent commit error
|
|
65
|
+
trackIntentCommitError({
|
|
66
|
+
error: getFullErrorMessage(error),
|
|
67
|
+
userAddress: intent.ownerAddress,
|
|
68
|
+
intentAddress: intent.originIntentAddress,
|
|
69
|
+
originChainId: originChainIdStr
|
|
70
|
+
? Number(originChainIdStr)
|
|
71
|
+
: undefined,
|
|
72
|
+
destinationChainId: destinationChainIdStr
|
|
73
|
+
? Number(destinationChainIdStr)
|
|
74
|
+
: undefined,
|
|
75
|
+
})
|
|
76
|
+
throw error
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Hook for executing an intent
|
|
84
|
+
* Wraps trailsClient.executeIntent with mutation state and analytics tracking
|
|
85
|
+
*/
|
|
86
|
+
export function useExecuteIntent() {
|
|
87
|
+
const trailsClient = useTrailsClient()
|
|
88
|
+
|
|
89
|
+
return useMutation({
|
|
90
|
+
mutationFn: async ({
|
|
91
|
+
intentId,
|
|
92
|
+
depositTransactionHash,
|
|
93
|
+
depositSignature,
|
|
94
|
+
}: {
|
|
95
|
+
intentId: string
|
|
96
|
+
depositTransactionHash?: string
|
|
97
|
+
depositSignature?: DepositSignature
|
|
98
|
+
}) => {
|
|
99
|
+
logger.console.log("[trails-sdk] useExecuteIntent: Starting execution", {
|
|
100
|
+
intentId,
|
|
101
|
+
depositTransactionHash,
|
|
102
|
+
hasDepositSignature: !!depositSignature,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// Validate that we have either traditional or gasless deposit params
|
|
106
|
+
if (!depositTransactionHash && !depositSignature) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
"[trails-sdk] Either depositTransactionHash or depositSignature must be provided",
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const response = await trailsClient.executeIntent({
|
|
113
|
+
intentId,
|
|
114
|
+
depositTransactionHash,
|
|
115
|
+
depositSignature,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
logger.console.log(
|
|
119
|
+
"[trails-sdk] useExecuteIntent: Execution successful",
|
|
120
|
+
{
|
|
121
|
+
intentId,
|
|
122
|
+
response,
|
|
123
|
+
},
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
return response
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
}
|
package/src/preconditions.ts
CHANGED
|
@@ -1,38 +1,35 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TransactionPrecondition } from "@0xsequence/trails-api"
|
|
2
|
+
|
|
3
|
+
// Backward compatibility alias
|
|
4
|
+
export type IntentPrecondition = TransactionPrecondition
|
|
2
5
|
|
|
3
6
|
export function findPreconditionAddresses(
|
|
4
|
-
preconditions:
|
|
7
|
+
preconditions: TransactionPrecondition[],
|
|
5
8
|
originChainId: number,
|
|
6
9
|
destinationChainId: number,
|
|
7
10
|
): { originAddress?: string; destinationAddress?: string } {
|
|
8
11
|
const origin = preconditions.find(
|
|
9
|
-
(p) => p.chainId === originChainId
|
|
12
|
+
(p) => p.chainId === originChainId && p.ownerAddress,
|
|
10
13
|
)
|
|
11
14
|
const destination = preconditions.find(
|
|
12
|
-
(p) => p.chainId === destinationChainId
|
|
15
|
+
(p) => p.chainId === destinationChainId && p.ownerAddress,
|
|
13
16
|
)
|
|
14
17
|
|
|
15
18
|
return {
|
|
16
|
-
originAddress: origin?.
|
|
17
|
-
destinationAddress: destination?.
|
|
19
|
+
originAddress: origin?.ownerAddress,
|
|
20
|
+
destinationAddress: destination?.ownerAddress,
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export function findChainAndAddressesFromPreconditions(
|
|
22
|
-
preconditions:
|
|
25
|
+
preconditions: TransactionPrecondition[],
|
|
23
26
|
): { chainId: number; address: string }[] {
|
|
24
27
|
const addressesFromPreconditions: { chainId: number; address: string }[] = []
|
|
25
28
|
preconditions.forEach((p) => {
|
|
26
|
-
if (
|
|
27
|
-
(p.type === "erc20-balance" ||
|
|
28
|
-
p.type === "native-balance" ||
|
|
29
|
-
p.type === "transfer-native") &&
|
|
30
|
-
p.data?.address &&
|
|
31
|
-
p.chainId
|
|
32
|
-
) {
|
|
29
|
+
if (p.type === "tokenMinBalance" && p.ownerAddress && p.chainId) {
|
|
33
30
|
addressesFromPreconditions.push({
|
|
34
|
-
chainId:
|
|
35
|
-
address: p.
|
|
31
|
+
chainId: p.chainId,
|
|
32
|
+
address: p.ownerAddress,
|
|
36
33
|
})
|
|
37
34
|
}
|
|
38
35
|
})
|
|
@@ -40,13 +37,11 @@ export function findChainAndAddressesFromPreconditions(
|
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
export function findFirstPreconditionForChainId(
|
|
43
|
-
preconditions:
|
|
40
|
+
preconditions: TransactionPrecondition[],
|
|
44
41
|
chainId: number,
|
|
45
|
-
):
|
|
42
|
+
): TransactionPrecondition | null {
|
|
46
43
|
const precondition = preconditions.find(
|
|
47
|
-
(p) =>
|
|
48
|
-
(p.type === "erc20-balance" || p.type === "native-balance") &&
|
|
49
|
-
p.chainId === chainId?.toString(),
|
|
44
|
+
(p) => p.type === "tokenMinBalance" && p.chainId === chainId,
|
|
50
45
|
)
|
|
51
46
|
return precondition ?? null
|
|
52
47
|
}
|