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/dist/apiClient.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SequenceAPIClient } from '@0xsequence/api';
|
|
2
|
-
export type APIClientConfig = {
|
|
3
|
-
apiUrl?: string;
|
|
4
|
-
projectAccessKey?: string;
|
|
5
|
-
jwt?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function getAPIClient({ apiUrl, projectAccessKey, jwt, }: APIClientConfig): SequenceAPIClient;
|
|
8
|
-
export declare const useAPIClient: (config?: APIClientConfig) => SequenceAPIClient;
|
|
9
|
-
//# sourceMappingURL=apiClient.d.ts.map
|
package/dist/apiClient.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../src/apiClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAInD,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,YAAY,CAAC,EAC3B,MAA4B,EAC5B,gBAAgD,EAChD,GAAG,GACJ,EAAE,eAAe,GAAG,iBAAiB,CAErC;AAED,eAAO,MAAM,YAAY,GAAI,SAAS,eAAe,sBAepD,CAAA"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { Account, WalletClient, Hex, Address, PublicClient } from 'viem';
|
|
2
|
-
import { TrailsAPIClient } from '@0xsequence/trails-api';
|
|
3
|
-
export type IntentEntrypointDepositParams = {
|
|
4
|
-
userAddress: Address;
|
|
5
|
-
tokenAddress: Address;
|
|
6
|
-
amount: bigint | string;
|
|
7
|
-
intentAddress: Address;
|
|
8
|
-
chainId: number;
|
|
9
|
-
deadline?: number;
|
|
10
|
-
usePermit?: boolean;
|
|
11
|
-
permitDeadline?: number;
|
|
12
|
-
};
|
|
13
|
-
export type IntentEntrypointDepositResult = {
|
|
14
|
-
depositWalletAddress: Address;
|
|
15
|
-
metaTxn: {
|
|
16
|
-
id: string;
|
|
17
|
-
chainId: string;
|
|
18
|
-
contract: string;
|
|
19
|
-
input: string;
|
|
20
|
-
walletAddress: string;
|
|
21
|
-
};
|
|
22
|
-
feeQuote: string;
|
|
23
|
-
entrypointAddress: Address;
|
|
24
|
-
};
|
|
25
|
-
export type IntentEntrypointFeeOptionsParams = {
|
|
26
|
-
userAddress: Address;
|
|
27
|
-
tokenAddress: Address;
|
|
28
|
-
amount: string;
|
|
29
|
-
intentAddress: Address;
|
|
30
|
-
chainID: number;
|
|
31
|
-
};
|
|
32
|
-
export type FeeOption = {
|
|
33
|
-
tokenAddress: string;
|
|
34
|
-
tokenSymbol: string;
|
|
35
|
-
tokenDecimals: number;
|
|
36
|
-
amount: string;
|
|
37
|
-
amountUSD: number;
|
|
38
|
-
feeCollector: string;
|
|
39
|
-
};
|
|
40
|
-
export type GasEstimate = {
|
|
41
|
-
totalGas: number;
|
|
42
|
-
gasPrice: string;
|
|
43
|
-
nativeCost: string;
|
|
44
|
-
nativeCostUSD: number;
|
|
45
|
-
};
|
|
46
|
-
export type IntentEntrypointFeeOptionsResult = {
|
|
47
|
-
gasEstimate: GasEstimate;
|
|
48
|
-
feeOptions: FeeOption[];
|
|
49
|
-
expiresAt: number;
|
|
50
|
-
feeCollector: string;
|
|
51
|
-
};
|
|
52
|
-
export type GaslessDepositOptions = {
|
|
53
|
-
trailsClient: TrailsAPIClient;
|
|
54
|
-
walletClient: WalletClient;
|
|
55
|
-
publicClient: PublicClient;
|
|
56
|
-
account: Account;
|
|
57
|
-
tokenAddress: Address;
|
|
58
|
-
amount: bigint | string;
|
|
59
|
-
intentAddress: Address;
|
|
60
|
-
chainId: number;
|
|
61
|
-
deadline?: number;
|
|
62
|
-
usePermit?: boolean;
|
|
63
|
-
onStatusUpdate?: (status: DepositStatus) => void;
|
|
64
|
-
};
|
|
65
|
-
export declare enum DepositStatus {
|
|
66
|
-
PREPARING = "preparing",
|
|
67
|
-
SIGNING = "signing",
|
|
68
|
-
SUBMITTING = "submitting",
|
|
69
|
-
PENDING = "pending",
|
|
70
|
-
CONFIRMED = "confirmed",
|
|
71
|
-
FAILED = "failed"
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Inject signatures into the meta transaction calldata
|
|
75
|
-
* This updates the placeholder signature values in the Intent Entrypoint call
|
|
76
|
-
*
|
|
77
|
-
* TODO: Implement this function to properly update nested calldata
|
|
78
|
-
* This would require:
|
|
79
|
-
* 1. Decode the guest module execdata
|
|
80
|
-
* 2. Find the Intent Entrypoint call
|
|
81
|
-
* 3. Replace its calldata with properly signed version
|
|
82
|
-
* 4. Re-encode the guest module execdata
|
|
83
|
-
*
|
|
84
|
-
* For reference, the signed calldata can be generated using:
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const { v, r, s } = splitSignature(signatures.intent)
|
|
87
|
-
* const depositCalldata = encodeFunctionData({
|
|
88
|
-
* abi: INTENT_ENTRYPOINT_ABI,
|
|
89
|
-
* functionName: "depositToIntent",
|
|
90
|
-
* args: [userAddress, tokenAddress, amount, intentAddress, deadline, v, r, s],
|
|
91
|
-
* })
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
/**
|
|
95
|
-
* Split a signature into v, r, s components
|
|
96
|
-
* TODO: Use this when implementing calldata injection
|
|
97
|
-
*/
|
|
98
|
-
export declare function splitSignature(signature: Hex): {
|
|
99
|
-
v: number;
|
|
100
|
-
r: Hex;
|
|
101
|
-
s: Hex;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Get fee options for intent entrypoint deposits
|
|
105
|
-
*/
|
|
106
|
-
export declare function getIntentEntrypointFeeOptions({ trailsClient, userAddress, tokenAddress, amount, intentAddress, chainId, }: {
|
|
107
|
-
trailsClient: TrailsAPIClient;
|
|
108
|
-
userAddress: Address;
|
|
109
|
-
tokenAddress: Address;
|
|
110
|
-
amount: bigint | string;
|
|
111
|
-
intentAddress: Address;
|
|
112
|
-
chainId: number;
|
|
113
|
-
}): Promise<IntentEntrypointFeeOptionsResult>;
|
|
114
|
-
//# sourceMappingURL=intentEntrypoint.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intentEntrypoint.d.ts","sourceRoot":"","sources":["../src/intentEntrypoint.ts"],"names":[],"mappings":"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"}
|
package/dist/metaTxnMonitor.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { RelayerOperationStatus } from './relayer.js';
|
|
2
|
-
import { Relayer } from '@0xsequence/relayer';
|
|
3
|
-
export type MetaTxn = {
|
|
4
|
-
id: string;
|
|
5
|
-
chainId: string;
|
|
6
|
-
contract?: string | undefined;
|
|
7
|
-
input?: string | undefined;
|
|
8
|
-
walletAddress?: string | undefined;
|
|
9
|
-
};
|
|
10
|
-
export type MetaTxnStatus = {
|
|
11
|
-
[key: string]: RelayerOperationStatus;
|
|
12
|
-
};
|
|
13
|
-
export declare const getMetaTxStatus: (relayer: Relayer.RpcRelayer, metaTxId: string, chainId: number) => Promise<RelayerOperationStatus>;
|
|
14
|
-
export declare const useMetaTxnsMonitor: (metaTxns: MetaTxn[] | undefined, getRelayer: (chainId: number) => Relayer.RpcRelayer) => MetaTxnStatus;
|
|
15
|
-
//# sourceMappingURL=metaTxnMonitor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metaTxnMonitor.d.ts","sourceRoot":"","sources":["../src/metaTxnMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,sBAAsB,EAEvB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAMlD,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB,CAAA;CACtC,CAAA;AAID,eAAO,MAAM,eAAe,GAC1B,SAAS,OAAO,CAAC,UAAU,EAC3B,UAAU,MAAM,EAChB,SAAS,MAAM,KACd,OAAO,CAAC,sBAAsB,CAEhC,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC7B,UAAU,OAAO,EAAE,GAAG,SAAS,EAC/B,YAAY,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,kBAqIpD,CAAA"}
|
package/dist/metaTxns.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Relayer } from '@0xsequence/relayer';
|
|
2
|
-
import { IntentPrecondition } from '@0xsequence/trails-api';
|
|
3
|
-
import { Hex } from 'viem';
|
|
4
|
-
import { MetaTxn } from './metaTxnMonitor.js';
|
|
5
|
-
export declare function relayerSendMetaTx(relayer: Relayer.RpcRelayer, metaTx: MetaTxn, preconditions: IntentPrecondition[], feeQuote?: Relayer.FeeQuote): Promise<Hex>;
|
|
6
|
-
export declare function getMetaTxnReceipt(relayer: Relayer.RpcRelayer, metaTxId: string, chainId: number): Promise<{
|
|
7
|
-
receipt: {
|
|
8
|
-
status: "confirmed" | "failed" | "pending";
|
|
9
|
-
};
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=metaTxns.d.ts.map
|
package/dist/metaTxns.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metaTxns.d.ts","sourceRoot":"","sources":["../src/metaTxns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,CAAC,UAAU,EAC3B,MAAM,EAAE,OAAO,EACf,aAAa,EAAE,kBAAkB,EAAE,EACnC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,GAC1B,OAAO,CAAC,GAAG,CAAC,CAWd;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,CAAC,UAAU,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,OAAO,EAAE;QAAE,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAA;KAAE,CAAA;CAAE,CAAC,CAgBtE"}
|
package/dist/relayer.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Relayer } from '@0xsequence/relayer';
|
|
2
|
-
export interface MetaTxnReceiptLog {
|
|
3
|
-
address: string;
|
|
4
|
-
topics: Array<string>;
|
|
5
|
-
data: string;
|
|
6
|
-
}
|
|
7
|
-
export interface MetaTxnReceipt {
|
|
8
|
-
id: string;
|
|
9
|
-
status: string;
|
|
10
|
-
revertReason?: string;
|
|
11
|
-
index: number;
|
|
12
|
-
logs: Array<MetaTxnReceiptLog>;
|
|
13
|
-
receipts: Array<MetaTxnReceipt>;
|
|
14
|
-
blockNumber: string;
|
|
15
|
-
txnHash: string;
|
|
16
|
-
txnReceipt: string;
|
|
17
|
-
}
|
|
18
|
-
export type RelayerOperationStatus = Relayer.OperationStatus;
|
|
19
|
-
export type RelayerOperationFailedStatus = Relayer.OperationFailedStatus;
|
|
20
|
-
export type RelayerOperationPendingStatus = Relayer.OperationPendingStatus;
|
|
21
|
-
export type RelayerOperationConfirmedStatus = Relayer.OperationConfirmedStatus;
|
|
22
|
-
export type RelayerOperationUnknownStatus = Relayer.OperationUnknownStatus;
|
|
23
|
-
export type RelayerConfig = {
|
|
24
|
-
hostname: string;
|
|
25
|
-
chainId: number;
|
|
26
|
-
rpcUrl: string;
|
|
27
|
-
};
|
|
28
|
-
export type RelayerEnv = "local" | "cors-anywhere" | "dev" | "prod";
|
|
29
|
-
export type RelayerEnvConfig = {
|
|
30
|
-
env?: RelayerEnv;
|
|
31
|
-
};
|
|
32
|
-
export type { Relayer };
|
|
33
|
-
export declare function getRelayerLocalhostUrl(chainId: number): string;
|
|
34
|
-
export declare function getRelayerChainIdToSlug(chainId: number): string;
|
|
35
|
-
export declare function getBackupRelayer(chainId: number): Relayer.RpcRelayer | undefined;
|
|
36
|
-
export declare function getRelayerUrl(config: RelayerEnvConfig | undefined, chainId: number): string;
|
|
37
|
-
export declare function getRelayer(config: RelayerEnvConfig | undefined, chainId: number): Relayer.RpcRelayer;
|
|
38
|
-
export declare function useRelayers(config?: RelayerEnvConfig): {
|
|
39
|
-
relayers: Map<number, Relayer.RpcRelayer>;
|
|
40
|
-
getRelayer: (chainId: number) => Relayer.RpcRelayer;
|
|
41
|
-
getBackupRelayer: (chainId: number) => Relayer.RpcRelayer | undefined;
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=relayer.d.ts.map
|
package/dist/relayer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relayer.d.ts","sourceRoot":"","sources":["../src/relayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AA4B7C,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAC9B,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAA;AAC5D,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,qBAAqB,CAAA;AACxE,MAAM,MAAM,6BAA6B,GAAG,OAAO,CAAC,sBAAsB,CAAA;AAC1E,MAAM,MAAM,+BAA+B,GAAG,OAAO,CAAC,wBAAwB,CAAA;AAC9E,MAAM,MAAM,6BAA6B,GAAG,OAAO,CAAC,sBAAsB,CAAA;AAE1E,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,KAAK,GAAG,MAAM,CAAA;AAEnE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CAAC,EAAE,UAAU,CAAA;CACjB,CAAA;AAED,YAAY,EAAE,OAAO,EAAE,CAAA;AAiCvB,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAoBD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,GAAG,SAAS,CAgBhC;AAGD,wBAAgB,aAAa,CAC3B,MAAM,EAAE,gBAAgB,YAEvB,EACD,OAAO,EAAE,MAAM,GACd,MAAM,CAoCR;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,gBAAgB,YAEvB,EACD,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAgEpB;AAED,wBAAgB,WAAW,CACzB,MAAM,GAAE,gBAEP,GACA;IACD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;IACzC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAA;IACnD,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAA;CACtE,CAsBA"}
|
package/src/apiClient.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useConfig } from "@0xsequence/hooks"
|
|
2
|
-
import { SequenceAPIClient } from "@0xsequence/api"
|
|
3
|
-
import { useMemo } from "react"
|
|
4
|
-
import { getSequenceApiUrl, getSequenceProjectAccessKey } from "./config.js"
|
|
5
|
-
|
|
6
|
-
export type APIClientConfig = {
|
|
7
|
-
apiUrl?: string
|
|
8
|
-
projectAccessKey?: string
|
|
9
|
-
jwt?: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function getAPIClient({
|
|
13
|
-
apiUrl = getSequenceApiUrl(),
|
|
14
|
-
projectAccessKey = getSequenceProjectAccessKey(),
|
|
15
|
-
jwt,
|
|
16
|
-
}: APIClientConfig): SequenceAPIClient {
|
|
17
|
-
return new SequenceAPIClient(apiUrl as string, projectAccessKey, jwt)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const useAPIClient = (config?: APIClientConfig) => {
|
|
21
|
-
const { projectAccessKey, jwt, env } = useConfig()
|
|
22
|
-
|
|
23
|
-
const apiClient = useMemo(() => {
|
|
24
|
-
return getAPIClient({
|
|
25
|
-
apiUrl: getSequenceApiUrl() ?? config?.apiUrl ?? env.apiUrl,
|
|
26
|
-
projectAccessKey:
|
|
27
|
-
getSequenceProjectAccessKey() ??
|
|
28
|
-
config?.projectAccessKey ??
|
|
29
|
-
projectAccessKey,
|
|
30
|
-
jwt: config?.jwt ?? jwt,
|
|
31
|
-
})
|
|
32
|
-
}, [projectAccessKey, jwt, env.apiUrl, config])
|
|
33
|
-
|
|
34
|
-
return apiClient
|
|
35
|
-
}
|
package/src/intentEntrypoint.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import type { Account, WalletClient, Hex, Address, PublicClient } from "viem"
|
|
2
|
-
import type { TrailsAPIClient } from "@0xsequence/trails-api"
|
|
3
|
-
|
|
4
|
-
// Intent Entrypoint ABI (partial - only the functions we need)
|
|
5
|
-
// TODO: Uncomment and use when implementing calldata injection
|
|
6
|
-
/* const INTENT_ENTRYPOINT_ABI = [
|
|
7
|
-
{
|
|
8
|
-
name: "depositToIntent",
|
|
9
|
-
type: "function",
|
|
10
|
-
stateMutability: "nonpayable",
|
|
11
|
-
inputs: [
|
|
12
|
-
{ name: "user", type: "address" },
|
|
13
|
-
{ name: "token", type: "address" },
|
|
14
|
-
{ name: "amount", type: "uint256" },
|
|
15
|
-
{ name: "intentAddress", type: "address" },
|
|
16
|
-
{ name: "deadline", type: "uint256" },
|
|
17
|
-
{ name: "sigV", type: "uint8" },
|
|
18
|
-
{ name: "sigR", type: "bytes32" },
|
|
19
|
-
{ name: "sigS", type: "bytes32" },
|
|
20
|
-
],
|
|
21
|
-
outputs: [],
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "depositToIntentWithPermit",
|
|
25
|
-
type: "function",
|
|
26
|
-
stateMutability: "nonpayable",
|
|
27
|
-
inputs: [
|
|
28
|
-
{ name: "user", type: "address" },
|
|
29
|
-
{ name: "token", type: "address" },
|
|
30
|
-
{ name: "amount", type: "uint256" },
|
|
31
|
-
{ name: "permitAmount", type: "uint256" },
|
|
32
|
-
{ name: "intentAddress", type: "address" },
|
|
33
|
-
{ name: "deadline", type: "uint256" },
|
|
34
|
-
{ name: "permitV", type: "uint8" },
|
|
35
|
-
{ name: "permitR", type: "bytes32" },
|
|
36
|
-
{ name: "permitS", type: "bytes32" },
|
|
37
|
-
{ name: "sigV", type: "uint8" },
|
|
38
|
-
{ name: "sigR", type: "bytes32" },
|
|
39
|
-
{ name: "sigS", type: "bytes32" },
|
|
40
|
-
],
|
|
41
|
-
outputs: [],
|
|
42
|
-
},
|
|
43
|
-
] as const */
|
|
44
|
-
|
|
45
|
-
// Note: EIP-712 typed data signing has been replaced with raw message signing
|
|
46
|
-
// The backend generates the EIP-712 hash and the client signs it as a raw message
|
|
47
|
-
// This simplifies the flow and avoids wallet compatibility issues
|
|
48
|
-
|
|
49
|
-
export type IntentEntrypointDepositParams = {
|
|
50
|
-
userAddress: Address
|
|
51
|
-
tokenAddress: Address
|
|
52
|
-
amount: bigint | string
|
|
53
|
-
intentAddress: Address
|
|
54
|
-
chainId: number
|
|
55
|
-
deadline?: number // Unix timestamp, defaults to 1 hour from now
|
|
56
|
-
usePermit?: boolean
|
|
57
|
-
permitDeadline?: number
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type IntentEntrypointDepositResult = {
|
|
61
|
-
depositWalletAddress: Address
|
|
62
|
-
metaTxn: {
|
|
63
|
-
id: string
|
|
64
|
-
chainId: string
|
|
65
|
-
contract: string
|
|
66
|
-
input: string
|
|
67
|
-
walletAddress: string
|
|
68
|
-
}
|
|
69
|
-
feeQuote: string
|
|
70
|
-
entrypointAddress: Address
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export type IntentEntrypointFeeOptionsParams = {
|
|
74
|
-
userAddress: Address
|
|
75
|
-
tokenAddress: Address
|
|
76
|
-
amount: string
|
|
77
|
-
intentAddress: Address
|
|
78
|
-
chainID: number
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type FeeOption = {
|
|
82
|
-
tokenAddress: string
|
|
83
|
-
tokenSymbol: string
|
|
84
|
-
tokenDecimals: number
|
|
85
|
-
amount: string
|
|
86
|
-
amountUSD: number
|
|
87
|
-
feeCollector: string
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export type GasEstimate = {
|
|
91
|
-
totalGas: number
|
|
92
|
-
gasPrice: string
|
|
93
|
-
nativeCost: string
|
|
94
|
-
nativeCostUSD: number
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type IntentEntrypointFeeOptionsResult = {
|
|
98
|
-
gasEstimate: GasEstimate
|
|
99
|
-
feeOptions: FeeOption[]
|
|
100
|
-
expiresAt: number
|
|
101
|
-
feeCollector: string
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export type GaslessDepositOptions = {
|
|
105
|
-
trailsClient: TrailsAPIClient
|
|
106
|
-
walletClient: WalletClient
|
|
107
|
-
publicClient: PublicClient
|
|
108
|
-
account: Account
|
|
109
|
-
tokenAddress: Address
|
|
110
|
-
amount: bigint | string
|
|
111
|
-
intentAddress: Address
|
|
112
|
-
chainId: number
|
|
113
|
-
deadline?: number
|
|
114
|
-
usePermit?: boolean
|
|
115
|
-
onStatusUpdate?: (status: DepositStatus) => void
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export enum DepositStatus {
|
|
119
|
-
PREPARING = "preparing",
|
|
120
|
-
SIGNING = "signing",
|
|
121
|
-
SUBMITTING = "submitting",
|
|
122
|
-
PENDING = "pending",
|
|
123
|
-
CONFIRMED = "confirmed",
|
|
124
|
-
FAILED = "failed",
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Inject signatures into the meta transaction calldata
|
|
129
|
-
* This updates the placeholder signature values in the Intent Entrypoint call
|
|
130
|
-
*
|
|
131
|
-
* TODO: Implement this function to properly update nested calldata
|
|
132
|
-
* This would require:
|
|
133
|
-
* 1. Decode the guest module execdata
|
|
134
|
-
* 2. Find the Intent Entrypoint call
|
|
135
|
-
* 3. Replace its calldata with properly signed version
|
|
136
|
-
* 4. Re-encode the guest module execdata
|
|
137
|
-
*
|
|
138
|
-
* For reference, the signed calldata can be generated using:
|
|
139
|
-
* ```typescript
|
|
140
|
-
* const { v, r, s } = splitSignature(signatures.intent)
|
|
141
|
-
* const depositCalldata = encodeFunctionData({
|
|
142
|
-
* abi: INTENT_ENTRYPOINT_ABI,
|
|
143
|
-
* functionName: "depositToIntent",
|
|
144
|
-
* args: [userAddress, tokenAddress, amount, intentAddress, deadline, v, r, s],
|
|
145
|
-
* })
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Split a signature into v, r, s components
|
|
151
|
-
* TODO: Use this when implementing calldata injection
|
|
152
|
-
*/
|
|
153
|
-
export function splitSignature(signature: Hex): {
|
|
154
|
-
v: number
|
|
155
|
-
r: Hex
|
|
156
|
-
s: Hex
|
|
157
|
-
} {
|
|
158
|
-
// Remove 0x prefix if present
|
|
159
|
-
const sig = signature.startsWith("0x") ? signature.slice(2) : signature
|
|
160
|
-
|
|
161
|
-
if (sig.length !== 130) {
|
|
162
|
-
throw new Error(`Invalid signature length: ${sig.length}`)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const r = `0x${sig.slice(0, 64)}` as Hex
|
|
166
|
-
const s = `0x${sig.slice(64, 128)}` as Hex
|
|
167
|
-
const v = parseInt(sig.slice(128, 130), 16)
|
|
168
|
-
|
|
169
|
-
return { v, r, s }
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Get fee options for intent entrypoint deposits
|
|
174
|
-
*/
|
|
175
|
-
export async function getIntentEntrypointFeeOptions({
|
|
176
|
-
trailsClient,
|
|
177
|
-
userAddress,
|
|
178
|
-
tokenAddress,
|
|
179
|
-
amount,
|
|
180
|
-
intentAddress,
|
|
181
|
-
chainId,
|
|
182
|
-
}: {
|
|
183
|
-
trailsClient: TrailsAPIClient
|
|
184
|
-
userAddress: Address
|
|
185
|
-
tokenAddress: Address
|
|
186
|
-
amount: bigint | string
|
|
187
|
-
intentAddress: Address
|
|
188
|
-
chainId: number
|
|
189
|
-
}): Promise<IntentEntrypointFeeOptionsResult> {
|
|
190
|
-
const params: IntentEntrypointFeeOptionsParams = {
|
|
191
|
-
userAddress,
|
|
192
|
-
tokenAddress,
|
|
193
|
-
amount: amount.toString(),
|
|
194
|
-
intentAddress,
|
|
195
|
-
chainID: chainId,
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const response = await trailsClient.getIntentEntrypointDepositFeeOptions({
|
|
199
|
-
params,
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
return response.result
|
|
203
|
-
}
|
package/src/metaTxnMonitor.ts
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
RelayerOperationConfirmedStatus,
|
|
3
|
-
RelayerOperationFailedStatus,
|
|
4
|
-
RelayerOperationPendingStatus,
|
|
5
|
-
RelayerOperationStatus,
|
|
6
|
-
RelayerOperationUnknownStatus,
|
|
7
|
-
} from "./relayer.js"
|
|
8
|
-
import type { Relayer } from "@0xsequence/relayer"
|
|
9
|
-
import { type Query, useQueries } from "@tanstack/react-query"
|
|
10
|
-
import { useMemo } from "react"
|
|
11
|
-
import type { Hex } from "viem"
|
|
12
|
-
import { logger } from "./logger.js"
|
|
13
|
-
|
|
14
|
-
export type MetaTxn = {
|
|
15
|
-
id: string
|
|
16
|
-
chainId: string
|
|
17
|
-
contract?: string | undefined
|
|
18
|
-
input?: string | undefined
|
|
19
|
-
walletAddress?: string | undefined
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type MetaTxnStatus = {
|
|
23
|
-
[key: string]: RelayerOperationStatus
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const POLL_INTERVAL = 3_000 // 3 seconds
|
|
27
|
-
|
|
28
|
-
export const getMetaTxStatus = async (
|
|
29
|
-
relayer: Relayer.RpcRelayer,
|
|
30
|
-
metaTxId: string,
|
|
31
|
-
chainId: number,
|
|
32
|
-
): Promise<RelayerOperationStatus> => {
|
|
33
|
-
return relayer.status(metaTxId as `0x${string}`, chainId)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const useMetaTxnsMonitor = (
|
|
37
|
-
metaTxns: MetaTxn[] | undefined,
|
|
38
|
-
getRelayer: (chainId: number) => Relayer.RpcRelayer,
|
|
39
|
-
) => {
|
|
40
|
-
const results = useQueries({
|
|
41
|
-
queries: (metaTxns || []).map((metaTxn) => {
|
|
42
|
-
const opHashToPoll = metaTxn.id as Hex
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
queryKey: ["metaTxnStatus", metaTxn.chainId, metaTxn.id],
|
|
46
|
-
queryFn: async (): Promise<RelayerOperationStatus> => {
|
|
47
|
-
const relayer = getRelayer(parseInt(metaTxn.chainId, 10))
|
|
48
|
-
|
|
49
|
-
if (!opHashToPoll) {
|
|
50
|
-
return {
|
|
51
|
-
status: "failed",
|
|
52
|
-
reason: "Missing operation hash for monitoring.",
|
|
53
|
-
} as RelayerOperationFailedStatus
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!relayer) {
|
|
57
|
-
return {
|
|
58
|
-
status: "failed",
|
|
59
|
-
reason: `Relayer not available for chain ${metaTxn.chainId}.`,
|
|
60
|
-
} as RelayerOperationFailedStatus
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const opStatus = await relayer.status(
|
|
64
|
-
opHashToPoll,
|
|
65
|
-
Number(metaTxn.chainId),
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
let newStatusEntry: RelayerOperationStatus
|
|
69
|
-
|
|
70
|
-
if (opStatus.status === "confirmed") {
|
|
71
|
-
newStatusEntry = {
|
|
72
|
-
status: "confirmed",
|
|
73
|
-
transactionHash: opStatus.transactionHash,
|
|
74
|
-
data: opStatus.data,
|
|
75
|
-
} as RelayerOperationConfirmedStatus
|
|
76
|
-
} else if (opStatus.status === "failed") {
|
|
77
|
-
newStatusEntry = {
|
|
78
|
-
status: "failed",
|
|
79
|
-
reason: opStatus.reason,
|
|
80
|
-
data: opStatus.data,
|
|
81
|
-
} as RelayerOperationFailedStatus
|
|
82
|
-
} else if (opStatus.status === "pending") {
|
|
83
|
-
newStatusEntry = {
|
|
84
|
-
status: "pending",
|
|
85
|
-
} as RelayerOperationPendingStatus
|
|
86
|
-
} else if (opStatus.status === "unknown") {
|
|
87
|
-
newStatusEntry = {
|
|
88
|
-
status: "unknown",
|
|
89
|
-
} as RelayerOperationUnknownStatus
|
|
90
|
-
} else {
|
|
91
|
-
const originalStatus = (opStatus as any).status as string
|
|
92
|
-
logger.console.warn(
|
|
93
|
-
`[trails-sdk] ⚠️ Unexpected relayer status "${originalStatus}" for ${opHashToPoll}:`,
|
|
94
|
-
opStatus,
|
|
95
|
-
)
|
|
96
|
-
newStatusEntry = {
|
|
97
|
-
status: "unknown",
|
|
98
|
-
} as RelayerOperationUnknownStatus
|
|
99
|
-
}
|
|
100
|
-
return newStatusEntry
|
|
101
|
-
},
|
|
102
|
-
refetchIntervalInBackground: true,
|
|
103
|
-
refetchInterval: (
|
|
104
|
-
query: Query<
|
|
105
|
-
RelayerOperationStatus,
|
|
106
|
-
Error,
|
|
107
|
-
RelayerOperationStatus,
|
|
108
|
-
ReadonlyArray<unknown>
|
|
109
|
-
>,
|
|
110
|
-
) => {
|
|
111
|
-
const data = query.state.data
|
|
112
|
-
if (!data) return POLL_INTERVAL
|
|
113
|
-
if (data.status === "confirmed") return false
|
|
114
|
-
return POLL_INTERVAL
|
|
115
|
-
},
|
|
116
|
-
enabled: !!metaTxn && !!metaTxn.id && !!metaTxn.chainId,
|
|
117
|
-
retry: (failureCount: number, error: Error) => {
|
|
118
|
-
if (failureCount >= 30) {
|
|
119
|
-
logger.console.error(
|
|
120
|
-
`[trails-sdk] ❌ Giving up on transaction ${opHashToPoll} after 3 failed API attempts:`,
|
|
121
|
-
error,
|
|
122
|
-
)
|
|
123
|
-
return false
|
|
124
|
-
}
|
|
125
|
-
return true
|
|
126
|
-
},
|
|
127
|
-
}
|
|
128
|
-
}),
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
const statuses: MetaTxnStatus = useMemo(() => {
|
|
132
|
-
const newStatuses: MetaTxnStatus = {}
|
|
133
|
-
;(metaTxns || []).forEach((metaTxn, index) => {
|
|
134
|
-
const operationKey = `${metaTxn.chainId}-${metaTxn.id}`
|
|
135
|
-
const queryResult = results[index]
|
|
136
|
-
|
|
137
|
-
if (queryResult) {
|
|
138
|
-
if (
|
|
139
|
-
queryResult.isLoading &&
|
|
140
|
-
queryResult.fetchStatus !== "idle" &&
|
|
141
|
-
!queryResult.data
|
|
142
|
-
) {
|
|
143
|
-
newStatuses[operationKey] = {
|
|
144
|
-
status: "pending",
|
|
145
|
-
} as RelayerOperationPendingStatus
|
|
146
|
-
} else if (queryResult.isError) {
|
|
147
|
-
newStatuses[operationKey] = {
|
|
148
|
-
status: "failed",
|
|
149
|
-
reason:
|
|
150
|
-
(queryResult.error as Error)?.message ||
|
|
151
|
-
"An unknown error occurred",
|
|
152
|
-
} as RelayerOperationFailedStatus
|
|
153
|
-
} else if (queryResult.data) {
|
|
154
|
-
newStatuses[operationKey] = queryResult.data as RelayerOperationStatus
|
|
155
|
-
} else {
|
|
156
|
-
newStatuses[operationKey] = {
|
|
157
|
-
status: "unknown",
|
|
158
|
-
} as RelayerOperationUnknownStatus
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
newStatuses[operationKey] = {
|
|
162
|
-
status: "failed",
|
|
163
|
-
reason: "Query result unexpectedly missing",
|
|
164
|
-
} as RelayerOperationFailedStatus
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
return newStatuses
|
|
168
|
-
}, [metaTxns, results])
|
|
169
|
-
|
|
170
|
-
return statuses
|
|
171
|
-
}
|
package/src/metaTxns.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { Relayer } from "@0xsequence/relayer"
|
|
2
|
-
import type { IntentPrecondition } from "@0xsequence/trails-api"
|
|
3
|
-
import type { Hex } from "viem"
|
|
4
|
-
import type { MetaTxn } from "./metaTxnMonitor.js"
|
|
5
|
-
import { logger } from "./logger.js"
|
|
6
|
-
|
|
7
|
-
export async function relayerSendMetaTx(
|
|
8
|
-
relayer: Relayer.RpcRelayer,
|
|
9
|
-
metaTx: MetaTxn,
|
|
10
|
-
preconditions: IntentPrecondition[],
|
|
11
|
-
feeQuote?: Relayer.FeeQuote,
|
|
12
|
-
): Promise<Hex> {
|
|
13
|
-
const { opHash } = await relayer.sendMetaTxn(
|
|
14
|
-
metaTx.walletAddress as `0x${string}`,
|
|
15
|
-
metaTx.contract as `0x${string}`,
|
|
16
|
-
metaTx.input as Hex,
|
|
17
|
-
Number(metaTx.chainId),
|
|
18
|
-
feeQuote,
|
|
19
|
-
preconditions,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
return opHash
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export async function getMetaTxnReceipt(
|
|
26
|
-
relayer: Relayer.RpcRelayer,
|
|
27
|
-
metaTxId: string,
|
|
28
|
-
chainId: number,
|
|
29
|
-
): Promise<{ receipt: { status: "confirmed" | "failed" | "pending" } }> {
|
|
30
|
-
try {
|
|
31
|
-
const status = await relayer.status(metaTxId as `0x${string}`, chainId)
|
|
32
|
-
|
|
33
|
-
switch (status.status) {
|
|
34
|
-
case "confirmed":
|
|
35
|
-
return { receipt: { status: "confirmed" } }
|
|
36
|
-
case "failed":
|
|
37
|
-
return { receipt: { status: "failed" } }
|
|
38
|
-
default:
|
|
39
|
-
return { receipt: { status: "pending" } }
|
|
40
|
-
}
|
|
41
|
-
} catch (error) {
|
|
42
|
-
logger.console.error("Error getting meta transaction receipt:", error)
|
|
43
|
-
return { receipt: { status: "pending" } }
|
|
44
|
-
}
|
|
45
|
-
}
|