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/prices.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Token, TokenPrice } from "@0xsequence/trails-api"
|
|
2
2
|
import { QueryClient, useQuery } from "@tanstack/react-query"
|
|
3
3
|
import { zeroAddress } from "viem"
|
|
4
4
|
import { logger } from "./logger.js"
|
|
5
|
+
import type { TrailsClient } from "./trailsClient.js"
|
|
5
6
|
|
|
6
7
|
// Global caching configuration
|
|
7
8
|
const CACHE_CONFIG = {
|
|
@@ -53,7 +54,7 @@ const tokenPricesQueryClient = new QueryClient({
|
|
|
53
54
|
|
|
54
55
|
// Cache key generation methods
|
|
55
56
|
const createTokenCacheKey = (token: Token): string => {
|
|
56
|
-
return `${token.
|
|
57
|
+
return `${token.tokenAddress}-${token.chainId}-${token.tokenSymbol || ""}`
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
const createBatchCacheKey = (
|
|
@@ -73,11 +74,11 @@ const createSingleCacheKey = (token?: Token | null): (string | null)[] => {
|
|
|
73
74
|
|
|
74
75
|
// Separate fetch function for token prices
|
|
75
76
|
export const fetchGetTokenPrices = async (
|
|
76
|
-
|
|
77
|
+
trailsClient: TrailsClient,
|
|
77
78
|
tokens: Token[],
|
|
78
79
|
): Promise<TokenPrice[]> => {
|
|
79
|
-
if (!
|
|
80
|
-
throw new Error("
|
|
80
|
+
if (!trailsClient) {
|
|
81
|
+
throw new Error("Trails client is required")
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
if (tokens.length === 0) {
|
|
@@ -85,7 +86,7 @@ export const fetchGetTokenPrices = async (
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
try {
|
|
88
|
-
const res = await
|
|
89
|
+
const res = await trailsClient.getTokenPrices({ tokens })
|
|
89
90
|
return res?.tokenPrices || []
|
|
90
91
|
} catch (error) {
|
|
91
92
|
logger.console.error("[trails-sdk] Failed to fetch token prices:", error)
|
|
@@ -94,52 +95,55 @@ export const fetchGetTokenPrices = async (
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
export function normalizeToken(
|
|
97
|
-
token: Token & {
|
|
98
|
+
token: Token & {
|
|
99
|
+
tokenID?: string
|
|
100
|
+
symbol?: string
|
|
101
|
+
contractAddress?: string
|
|
102
|
+
tokenId?: string
|
|
103
|
+
},
|
|
98
104
|
): Token {
|
|
99
105
|
return {
|
|
100
106
|
chainId: token.chainId,
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
tokenAddress: token.tokenAddress || token.contractAddress || zeroAddress,
|
|
108
|
+
tokenSymbol:
|
|
109
|
+
token.tokenSymbol || token.tokenId || token.tokenID || token.symbol,
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
export const getTokenPrices = async (
|
|
107
|
-
|
|
114
|
+
trailsClient: TrailsClient,
|
|
108
115
|
tokens: Token[],
|
|
109
116
|
): Promise<TokenPrice[]> => {
|
|
110
117
|
tokens = tokens.map(normalizeToken)
|
|
111
118
|
|
|
112
119
|
return tokenPricesQueryClient.fetchQuery({
|
|
113
120
|
queryKey: createBatchCacheKey(tokens),
|
|
114
|
-
queryFn: () => fetchGetTokenPrices(
|
|
121
|
+
queryFn: () => fetchGetTokenPrices(trailsClient, tokens),
|
|
115
122
|
...COMMON_QUERY_OPTIONS,
|
|
116
123
|
})
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
export const getTokenPrice = async (
|
|
120
|
-
|
|
127
|
+
trailsClient: TrailsClient,
|
|
121
128
|
token: Token,
|
|
122
129
|
): Promise<TokenPrice | null> => {
|
|
123
130
|
return tokenPricesQueryClient.fetchQuery({
|
|
124
131
|
queryKey: createSingleCacheKey(token),
|
|
125
132
|
queryFn: async () => {
|
|
126
|
-
const prices = await getTokenPrices(
|
|
133
|
+
const prices = await getTokenPrices(trailsClient, [token])
|
|
127
134
|
return prices?.length ? prices[0] : null
|
|
128
135
|
},
|
|
129
136
|
...COMMON_QUERY_OPTIONS,
|
|
130
137
|
})
|
|
131
138
|
}
|
|
132
139
|
|
|
133
|
-
export const useTokenPrices = (
|
|
134
|
-
tokens: Token[],
|
|
135
|
-
apiClient: SequenceAPIClient,
|
|
136
|
-
) => {
|
|
140
|
+
export const useTokenPrices = (tokens: Token[], trailsClient: TrailsClient) => {
|
|
137
141
|
tokens = tokens.map(normalizeToken)
|
|
138
142
|
|
|
139
143
|
const { data: tokenPrices, isLoading: isLoadingTokenPrices } = useQuery({
|
|
140
144
|
queryKey: createBatchCacheKey(tokens),
|
|
141
|
-
queryFn: () => getTokenPrices(
|
|
142
|
-
enabled: tokens.length > 0 && !!
|
|
145
|
+
queryFn: () => getTokenPrices(trailsClient, tokens),
|
|
146
|
+
enabled: tokens.length > 0 && !!trailsClient,
|
|
143
147
|
...COMMON_QUERY_OPTIONS,
|
|
144
148
|
})
|
|
145
149
|
|
|
@@ -151,13 +155,13 @@ export const useTokenPrices = (
|
|
|
151
155
|
|
|
152
156
|
export const useTokenPrice = (
|
|
153
157
|
token?: Token | null,
|
|
154
|
-
|
|
158
|
+
trailsClient?: TrailsClient,
|
|
155
159
|
) => {
|
|
156
160
|
const { data: tokenPrice, isLoading: isLoadingTokenPrice } = useQuery({
|
|
157
161
|
queryKey: createSingleCacheKey(token),
|
|
158
162
|
queryFn: () =>
|
|
159
|
-
token &&
|
|
160
|
-
enabled: !!token && !!
|
|
163
|
+
token && trailsClient ? getTokenPrice(trailsClient, token) : null,
|
|
164
|
+
enabled: !!token && !!trailsClient,
|
|
161
165
|
...COMMON_QUERY_OPTIONS,
|
|
162
166
|
})
|
|
163
167
|
|
package/src/relaySdk.ts
CHANGED
|
@@ -304,12 +304,12 @@ export async function executeSimpleRelayTransaction(
|
|
|
304
304
|
|
|
305
305
|
export function getTxHashFromRelayResult(result: RelayExecuteResult): string {
|
|
306
306
|
let txHash =
|
|
307
|
-
result?.data?.steps?.[result?.data?.steps
|
|
307
|
+
result?.data?.steps?.[result?.data?.steps?.length - 1]?.items?.[0]
|
|
308
308
|
?.txHashes?.[0]?.txHash
|
|
309
309
|
|
|
310
310
|
if (!txHash) {
|
|
311
311
|
txHash =
|
|
312
|
-
result?.data?.steps?.[result?.data?.steps
|
|
312
|
+
result?.data?.steps?.[result?.data?.steps?.length - 1]?.items?.[0]
|
|
313
313
|
?.internalTxHashes?.[0]?.txHash
|
|
314
314
|
}
|
|
315
315
|
|
package/src/sequenceWallet.ts
CHANGED
|
@@ -3,8 +3,6 @@ import { commons } from "@0xsequence/core"
|
|
|
3
3
|
import { allNetworks } from "@0xsequence/network"
|
|
4
4
|
import { trackers } from "@0xsequence/sessions"
|
|
5
5
|
import { Orchestrator, type signers } from "@0xsequence/signhub"
|
|
6
|
-
import type { Payload } from "@0xsequence/wallet-primitives"
|
|
7
|
-
import { ethers } from "ethers"
|
|
8
6
|
import { Abi, AbiFunction } from "ox"
|
|
9
7
|
import {
|
|
10
8
|
bytesToHex,
|
|
@@ -14,11 +12,8 @@ import {
|
|
|
14
12
|
toHex,
|
|
15
13
|
type WalletClient,
|
|
16
14
|
} from "viem"
|
|
17
|
-
import
|
|
18
|
-
import { getRelayerUrl } from "./relayer.js"
|
|
19
|
-
import { getSequenceProjectAccessKey, getSequenceEnv } from "./config.js"
|
|
15
|
+
import { getSequenceProjectAccessKey } from "./config.js"
|
|
20
16
|
import { logger } from "./logger.js"
|
|
21
|
-
import type { Relayer } from "@0xsequence/relayer"
|
|
22
17
|
|
|
23
18
|
export type FlatTransaction = {
|
|
24
19
|
to: string
|
|
@@ -42,38 +37,9 @@ export const TRACKER = new trackers.remote.RemoteConfigTracker(
|
|
|
42
37
|
"https://sessions.sequence.app",
|
|
43
38
|
)
|
|
44
39
|
|
|
45
|
-
type GetAccountNetworksInput = {
|
|
46
|
-
relayerConfig: RelayerEnvConfig
|
|
47
|
-
sequenceProjectAccessKey: string
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function getAccountNetworks(input: GetAccountNetworksInput): any[] {
|
|
51
|
-
return allNetworks.map((network) => {
|
|
52
|
-
try {
|
|
53
|
-
const relayerUrl = getRelayerUrl(input.relayerConfig, network.chainId)
|
|
54
|
-
if (relayerUrl) {
|
|
55
|
-
const relayer: any = {
|
|
56
|
-
provider: new ethers.JsonRpcProvider(network.rpcUrl),
|
|
57
|
-
url: relayerUrl,
|
|
58
|
-
projectAccessKey: input.sequenceProjectAccessKey,
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
...network,
|
|
62
|
-
relayer,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
} catch (_err: unknown) {
|
|
66
|
-
// noop
|
|
67
|
-
}
|
|
68
|
-
return network
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
40
|
export async function createSequenceWallet(
|
|
73
41
|
threshold: number,
|
|
74
42
|
signers: { address: string; weight: number }[],
|
|
75
|
-
relayerConfig: RelayerEnvConfig,
|
|
76
|
-
sequenceProjectAccessKey: string,
|
|
77
43
|
): Promise<Account> {
|
|
78
44
|
const account = await Account.new({
|
|
79
45
|
config: {
|
|
@@ -85,7 +51,7 @@ export async function createSequenceWallet(
|
|
|
85
51
|
tracker: TRACKER,
|
|
86
52
|
contexts: commons.context.defaultContexts,
|
|
87
53
|
orchestrator: new Orchestrator([]),
|
|
88
|
-
networks:
|
|
54
|
+
networks: allNetworks,
|
|
89
55
|
})
|
|
90
56
|
|
|
91
57
|
// Try to fetch the config from the tracker
|
|
@@ -129,7 +95,6 @@ export function toSequenceTransaction(
|
|
|
129
95
|
export function accountFor(args: {
|
|
130
96
|
address: string
|
|
131
97
|
signatures?: { signer: string; signature: string }[]
|
|
132
|
-
relayerConfig: RelayerEnvConfig
|
|
133
98
|
sequenceProjectAccessKey: string
|
|
134
99
|
}): Account {
|
|
135
100
|
const signers: signers.SapientSigner[] = []
|
|
@@ -158,10 +123,7 @@ export function accountFor(args: {
|
|
|
158
123
|
tracker: TRACKER,
|
|
159
124
|
contexts: commons.context.defaultContexts,
|
|
160
125
|
orchestrator: new Orchestrator(signers),
|
|
161
|
-
networks:
|
|
162
|
-
relayerConfig: args.relayerConfig,
|
|
163
|
-
sequenceProjectAccessKey: args.sequenceProjectAccessKey,
|
|
164
|
-
}),
|
|
126
|
+
networks: allNetworks,
|
|
165
127
|
})
|
|
166
128
|
}
|
|
167
129
|
|
|
@@ -217,20 +179,13 @@ export function recoverSigner(
|
|
|
217
179
|
|
|
218
180
|
export async function simpleCreateSequenceWallet(
|
|
219
181
|
account: Account,
|
|
220
|
-
relayerConfig: RelayerEnvConfig = {
|
|
221
|
-
env: getSequenceEnv() as RelayerEnv,
|
|
222
|
-
},
|
|
223
|
-
sequenceProjectAccessKey: string = getSequenceProjectAccessKey(),
|
|
224
182
|
): Promise<`0x${string}`> {
|
|
225
183
|
const signer = account.address
|
|
226
184
|
const threshold = 1
|
|
227
185
|
const weight = 1
|
|
228
|
-
const wallet = await createSequenceWallet(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
relayerConfig,
|
|
232
|
-
sequenceProjectAccessKey,
|
|
233
|
-
)
|
|
186
|
+
const wallet = await createSequenceWallet(threshold, [
|
|
187
|
+
{ address: signer, weight: weight },
|
|
188
|
+
])
|
|
234
189
|
|
|
235
190
|
return wallet.address as `0x${string}`
|
|
236
191
|
}
|
|
@@ -266,9 +221,6 @@ export async function sequenceSendTransaction(
|
|
|
266
221
|
publicClient: PublicClient,
|
|
267
222
|
calls: any[],
|
|
268
223
|
chain: Chain,
|
|
269
|
-
relayerConfig: RelayerEnvConfig = {
|
|
270
|
-
env: getSequenceEnv() as RelayerEnv,
|
|
271
|
-
},
|
|
272
224
|
sequenceProjectAccessKey: string = getSequenceProjectAccessKey(),
|
|
273
225
|
): Promise<string | null> {
|
|
274
226
|
const chainId = chain.id
|
|
@@ -309,7 +261,6 @@ export async function sequenceSendTransaction(
|
|
|
309
261
|
signature: suffixed,
|
|
310
262
|
},
|
|
311
263
|
],
|
|
312
|
-
relayerConfig,
|
|
313
264
|
sequenceProjectAccessKey,
|
|
314
265
|
})
|
|
315
266
|
const sequenceTxs = toSequenceTransactions(txsToExecute)
|
|
@@ -527,24 +478,6 @@ export class StaticSigner implements signers.SapientSigner {
|
|
|
527
478
|
}
|
|
528
479
|
}
|
|
529
480
|
|
|
530
|
-
export async function getFeeOptions(
|
|
531
|
-
relayer: Relayer.RpcRelayer,
|
|
532
|
-
wallet: string,
|
|
533
|
-
chainId: number,
|
|
534
|
-
calls: Payload.Call[],
|
|
535
|
-
): Promise<{
|
|
536
|
-
options: Relayer.FeeOption[]
|
|
537
|
-
quote?: Relayer.FeeQuote
|
|
538
|
-
}> {
|
|
539
|
-
const feeOptions = await relayer.feeOptions(
|
|
540
|
-
wallet as `0x${string}`,
|
|
541
|
-
chainId,
|
|
542
|
-
calls,
|
|
543
|
-
)
|
|
544
|
-
|
|
545
|
-
return feeOptions
|
|
546
|
-
}
|
|
547
|
-
|
|
548
481
|
// Import the encodeGasRefundTransaction function
|
|
549
482
|
function encodeGasRefundTransaction(option?: any): FlatTransaction[] {
|
|
550
483
|
if (!option) return []
|