0xtrails 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics.d.ts +8 -3
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-C9CA3tIi.js → ccip-Dw5AN7oU.js} +27 -27
- package/dist/cctp.d.ts +0 -149
- package/dist/cctp.d.ts.map +1 -1
- package/dist/chains.d.ts +31 -4
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +28 -52
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -7
- package/dist/constants.d.ts.map +1 -1
- package/dist/contractUtils.d.ts.map +1 -1
- package/dist/estimate.d.ts.map +1 -1
- package/dist/fees.d.ts.map +1 -1
- package/dist/gasless.d.ts +12 -0
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-CNB57v0n.js → index-BtVUTbEZ.js} +32255 -40547
- package/dist/index.d.ts +13 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +320 -944
- package/dist/indexerClient.d.ts +9 -6
- package/dist/indexerClient.d.ts.map +1 -1
- package/dist/intents.d.ts +0 -18
- package/dist/intents.d.ts.map +1 -1
- package/dist/mutations.d.ts.map +1 -1
- package/dist/paymasterSend.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +1 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/sendUserOp.d.ts +0 -18
- package/dist/sendUserOp.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +1 -1
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +10 -8
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +3 -3
- package/dist/trailsClient.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +4 -5
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +4 -5
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +2 -2
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts +2 -2
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/crossChain.d.ts +6 -4
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/index.d.ts +0 -1
- package/dist/transactionIntent/handlers/index.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +4 -34
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +2 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +7 -19
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactionIntent/utils/index.d.ts +0 -1
- package/dist/transactionIntent/utils/index.d.ts.map +1 -1
- package/dist/transactions.d.ts +6 -18
- package/dist/transactions.d.ts.map +1 -1
- package/dist/utils.d.ts +8 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/walletUtils.d.ts +21 -0
- package/dist/walletUtils.d.ts.map +1 -0
- package/dist/wallets.d.ts +33 -240
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +8 -13
- package/dist/widget/components/FeeOption.d.ts.map +1 -1
- package/dist/widget/components/FeeOptions.d.ts +11 -5
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/NativeGasOption.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/QRCodeDeposit.d.ts +5 -0
- package/dist/widget/components/QRCodeDeposit.d.ts.map +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts +13 -0
- package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -0
- package/dist/widget/components/QrCode.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/ScreenHeader.d.ts +1 -1
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/SlippageToleranceSettings.d.ts +1 -0
- package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
- package/dist/widget/components/Toast.d.ts.map +1 -1
- package/dist/widget/components/TokenImage.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +15 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts +7 -0
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts.map +1 -0
- package/dist/widget/hooks/useIsSequenceWallet.d.ts +6 -0
- package/dist/widget/hooks/useIsSequenceWallet.d.ts.map +1 -0
- package/dist/widget/hooks/useQuote.d.ts +6 -11
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeOption.d.ts +30 -0
- package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +6 -15
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.d.ts +1 -0
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +4 -2
- package/dist/widget/providers/TrailsProvider.d.ts +29 -0
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -0
- package/dist/widget/widget.d.ts +14 -3
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/analytics.ts +53 -21
- package/src/cctp.ts +0 -1016
- package/src/chains.ts +155 -68
- package/src/config.ts +51 -207
- package/src/constants.ts +1 -13
- package/src/contractUtils.ts +6 -6
- package/src/estimate.ts +3 -6
- package/src/fees.ts +5 -10
- package/src/gasless.ts +45 -0
- package/src/index.ts +18 -40
- package/src/indexerClient.ts +39 -48
- package/src/intents.ts +51 -226
- package/src/mutations.ts +3 -2
- package/src/paymasterSend.ts +2 -5
- package/src/prepareSend.ts +21 -14
- package/src/sendUserOp.ts +3 -64
- package/src/sequenceWallet.ts +1 -2
- package/src/tokenBalances.ts +2 -1
- package/src/tokens.ts +62 -133
- package/src/trailsClient.ts +17 -12
- package/src/transactionIntent/deposits/depositOrchestrator.ts +14 -15
- package/src/transactionIntent/deposits/gaslessDeposit.ts +70 -100
- package/src/transactionIntent/deposits/standardDeposit.ts +22 -28
- package/src/transactionIntent/execution/transactionState.ts +2 -2
- package/src/transactionIntent/handlers/crossChain.ts +179 -381
- package/src/transactionIntent/handlers/index.ts +0 -1
- package/src/transactionIntent/handlers/sameChainSameToken.ts +228 -94
- package/src/transactionIntent/quote/normalizeQuote.ts +4 -6
- package/src/transactionIntent/quote/quoteHelpers.ts +35 -3
- package/src/transactionIntent/types.ts +7 -27
- package/src/transactionIntent/utils/index.ts +0 -1
- package/src/transactions.ts +19 -118
- package/src/umd.tsx +1 -3
- package/src/utils.ts +28 -8
- package/src/walletUtils.ts +42 -0
- package/src/wallets.ts +365 -208
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +78 -4
- package/src/widget/components/AccountSettings.tsx +17 -17
- package/src/widget/components/ChainList.tsx +3 -3
- package/src/widget/components/ClassicSwap.tsx +19 -10
- package/src/widget/components/ConfigDisplay.tsx +19 -59
- package/src/widget/components/FeeOption.tsx +63 -20
- package/src/widget/components/FeeOptions.tsx +54 -123
- package/src/widget/components/NativeGasOption.tsx +3 -1
- package/src/widget/components/Pay.tsx +18 -11
- package/src/widget/components/PoolDeposit.tsx +23 -10
- package/src/widget/components/QRCodeDeposit.tsx +50 -30
- package/src/widget/components/QRCodeWalletSelect.tsx +77 -0
- package/src/widget/components/QrCode.tsx +188 -233
- package/src/widget/components/QuoteDetails.tsx +48 -2
- package/src/widget/components/Receipt.tsx +5 -2
- package/src/widget/components/ScreenHeader.tsx +10 -8
- package/src/widget/components/SlippageToleranceSettings.tsx +63 -14
- package/src/widget/components/Toast.tsx +10 -0
- package/src/widget/components/TokenImage.tsx +56 -13
- package/src/widget/components/WalletConnect.tsx +37 -99
- package/src/widget/hooks/useCheckout.ts +71 -0
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDebugScreens.ts +5 -0
- package/src/widget/hooks/useIntentTransactionHistory.ts +790 -412
- package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +43 -0
- package/src/widget/hooks/useIsSequenceWallet.ts +17 -0
- package/src/widget/hooks/useQuote.ts +27 -34
- package/src/widget/hooks/useRecentTokens.ts +2 -1
- package/src/widget/hooks/useSelectedFeeOption.tsx +257 -0
- package/src/widget/hooks/useSendForm.ts +175 -46
- package/src/widget/hooks/useTokenList.ts +15 -2
- package/src/widget/index.tsx +8 -0
- package/src/widget/providers/TrailsProvider.tsx +123 -0
- package/src/widget/widget.tsx +165 -143
- package/dist/cctpqueue.d.ts +0 -18
- package/dist/cctpqueue.d.ts.map +0 -1
- package/dist/preconditions.d.ts +0 -12
- package/dist/preconditions.d.ts.map +0 -1
- package/dist/trails.d.ts +0 -110
- package/dist/trails.d.ts.map +0 -1
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +0 -62
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +0 -1
- package/dist/transactionIntent/utils/lifiHelpers.d.ts +0 -10
- package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +0 -33
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +0 -1
- package/src/cctpqueue.ts +0 -66
- package/src/preconditions.ts +0 -47
- package/src/trails.ts +0 -1303
- package/src/transactionIntent/handlers/sameChainDifferentToken.ts +0 -323
- package/src/transactionIntent/utils/lifiHelpers.ts +0 -68
- package/src/widget/hooks/useSelectedFeeToken.tsx +0 -288
package/src/chains.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query"
|
|
2
|
-
import type { Chain as ViemChain } from "viem"
|
|
2
|
+
import type { Chain as ViemChain, PublicClient } from "viem"
|
|
3
|
+
import { createPublicClient, http } from "viem"
|
|
4
|
+
import { getConfig } from "./config.js"
|
|
3
5
|
|
|
4
6
|
import {
|
|
5
7
|
arbitrum,
|
|
@@ -35,10 +37,6 @@ import {
|
|
|
35
37
|
} from "viem/chains"
|
|
36
38
|
import { getRelaySupportedChains } from "./relaySdk.js"
|
|
37
39
|
import { getLifiSupportedChains } from "./lifi.js"
|
|
38
|
-
import {
|
|
39
|
-
getSequenceProjectAccessKey,
|
|
40
|
-
getSequenceNodeGatewayUrl,
|
|
41
|
-
} from "./config.js"
|
|
42
40
|
import type { QuoteProvider } from "./intents.js"
|
|
43
41
|
import { somnia } from "./customChains.js"
|
|
44
42
|
|
|
@@ -89,44 +87,103 @@ export function getAllChains(): Chain[] {
|
|
|
89
87
|
]
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
function getSequenceRpcUrlFromSlug(
|
|
93
|
-
|
|
90
|
+
function getSequenceRpcUrlFromSlug(
|
|
91
|
+
chainSlug: string,
|
|
92
|
+
sequenceNodeGatewayUrl: string,
|
|
93
|
+
): string {
|
|
94
|
+
return `${sequenceNodeGatewayUrl}/${chainSlug}`
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
// Dynamic function to get sequence RPC URLs (computed at runtime to respect environment changes)
|
|
97
|
-
function getSequenceRpcUrls(
|
|
98
|
+
function getSequenceRpcUrls(
|
|
99
|
+
sequenceNodeGatewayUrl: string,
|
|
100
|
+
): Record<number, string> {
|
|
98
101
|
return {
|
|
99
|
-
[arbitrum.id]: getSequenceRpcUrlFromSlug(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
[
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
[
|
|
110
|
-
[
|
|
111
|
-
[
|
|
112
|
-
[
|
|
113
|
-
[
|
|
114
|
-
[
|
|
115
|
-
|
|
102
|
+
[arbitrum.id]: getSequenceRpcUrlFromSlug(
|
|
103
|
+
"arbitrum",
|
|
104
|
+
sequenceNodeGatewayUrl,
|
|
105
|
+
),
|
|
106
|
+
[base.id]: getSequenceRpcUrlFromSlug("base", sequenceNodeGatewayUrl),
|
|
107
|
+
[mainnet.id]: getSequenceRpcUrlFromSlug("mainnet", sequenceNodeGatewayUrl),
|
|
108
|
+
[optimism.id]: getSequenceRpcUrlFromSlug(
|
|
109
|
+
"optimism",
|
|
110
|
+
sequenceNodeGatewayUrl,
|
|
111
|
+
),
|
|
112
|
+
[gnosis.id]: getSequenceRpcUrlFromSlug("gnosis", sequenceNodeGatewayUrl),
|
|
113
|
+
[polygon.id]: getSequenceRpcUrlFromSlug("polygon", sequenceNodeGatewayUrl),
|
|
114
|
+
[soneium.id]: getSequenceRpcUrlFromSlug("soneium", sequenceNodeGatewayUrl),
|
|
115
|
+
[somnia.id]: getSequenceRpcUrlFromSlug("somnia", sequenceNodeGatewayUrl),
|
|
116
|
+
[xai.id]: getSequenceRpcUrlFromSlug("xai", sequenceNodeGatewayUrl),
|
|
117
|
+
[apeChain.id]: getSequenceRpcUrlFromSlug(
|
|
118
|
+
"apechain",
|
|
119
|
+
sequenceNodeGatewayUrl,
|
|
120
|
+
),
|
|
121
|
+
[arbitrumNova.id]: getSequenceRpcUrlFromSlug(
|
|
122
|
+
"arbitrum-nova",
|
|
123
|
+
sequenceNodeGatewayUrl,
|
|
124
|
+
),
|
|
125
|
+
[avalanche.id]: getSequenceRpcUrlFromSlug(
|
|
126
|
+
"avalanche",
|
|
127
|
+
sequenceNodeGatewayUrl,
|
|
128
|
+
),
|
|
129
|
+
[b3.id]: getSequenceRpcUrlFromSlug("b3", sequenceNodeGatewayUrl),
|
|
130
|
+
[blast.id]: getSequenceRpcUrlFromSlug("blast", sequenceNodeGatewayUrl),
|
|
131
|
+
[bsc.id]: getSequenceRpcUrlFromSlug("bsc", sequenceNodeGatewayUrl),
|
|
132
|
+
[katana.id]: getSequenceRpcUrlFromSlug("katana", sequenceNodeGatewayUrl),
|
|
133
|
+
[etherlink.id]: getSequenceRpcUrlFromSlug(
|
|
134
|
+
"etherlink",
|
|
135
|
+
sequenceNodeGatewayUrl,
|
|
136
|
+
),
|
|
116
137
|
}
|
|
117
138
|
}
|
|
118
139
|
|
|
119
140
|
export const getRpcUrl = (
|
|
120
141
|
chainId: number,
|
|
121
|
-
sequenceProjectAccessKey: string
|
|
142
|
+
sequenceProjectAccessKey: string,
|
|
143
|
+
sequenceNodeGatewayUrl: string,
|
|
122
144
|
): string | null => {
|
|
123
|
-
const sequenceRpcUrls = getSequenceRpcUrls()
|
|
145
|
+
const sequenceRpcUrls = getSequenceRpcUrls(sequenceNodeGatewayUrl)
|
|
124
146
|
if (!sequenceRpcUrls[chainId]) {
|
|
125
147
|
return null
|
|
126
148
|
}
|
|
127
149
|
return `${sequenceRpcUrls[chainId]}/${sequenceProjectAccessKey}`
|
|
128
150
|
}
|
|
129
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Get HTTP transport for a chain using Sequence RPC URLs
|
|
154
|
+
* This is a temporary solution to use global config for RPC URLs
|
|
155
|
+
* @param chainId - The chain ID to get the transport for
|
|
156
|
+
* @returns Viem HTTP transport configured with Sequence RPC URL if available
|
|
157
|
+
*/
|
|
158
|
+
export function getHttpTransport(chainId: number) {
|
|
159
|
+
const config = getConfig()
|
|
160
|
+
const trailsApiKey = config.trailsApiKey
|
|
161
|
+
const sequenceNodeGatewayUrl = config.sequenceNodeGatewayUrl
|
|
162
|
+
|
|
163
|
+
if (trailsApiKey && sequenceNodeGatewayUrl) {
|
|
164
|
+
const rpcUrl = getRpcUrl(chainId, trailsApiKey, sequenceNodeGatewayUrl)
|
|
165
|
+
if (rpcUrl) {
|
|
166
|
+
return http(rpcUrl)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Fallback to default http() if Sequence RPC URL is not available
|
|
171
|
+
return http()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Create a public RPC client for a chain using Sequence RPC URLs
|
|
176
|
+
* This is a temporary solution to use global config for RPC URLs
|
|
177
|
+
* @param chain - The chain to create the public client for
|
|
178
|
+
* @returns Viem PublicClient configured with Sequence RPC URL if available
|
|
179
|
+
*/
|
|
180
|
+
export function getPublicRpcClient(chain: Chain): PublicClient {
|
|
181
|
+
return createPublicClient({
|
|
182
|
+
chain,
|
|
183
|
+
transport: getHttpTransport(chain.id),
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
130
187
|
export const supportedSequenceChains: Record<number, Chain> = {
|
|
131
188
|
[apeChain.id]: getChainInfo(apeChain.id)!,
|
|
132
189
|
[arbitrum.id]: getChainInfo(arbitrum.id)!,
|
|
@@ -186,15 +243,28 @@ export const mainnetChainsToTestnetChains: Record<number, Chain> = {
|
|
|
186
243
|
// Helper to get chain info
|
|
187
244
|
export function getChainInfo(
|
|
188
245
|
chainId?: number,
|
|
189
|
-
options?: {
|
|
246
|
+
options?: {
|
|
247
|
+
usePublicRpc?: boolean
|
|
248
|
+
sequenceProjectAccessKey?: string
|
|
249
|
+
sequenceNodeGatewayUrl?: string
|
|
250
|
+
},
|
|
190
251
|
): Chain | null {
|
|
191
252
|
if (!chainId) return null
|
|
192
253
|
const chainInfo =
|
|
193
254
|
getAllChains().find((chain: Chain) => chain.id === chainId) || null
|
|
194
255
|
|
|
195
256
|
// Use Sequence RPC by default. We'll want to use public RPC when adding chains to user's metamask wallet.
|
|
196
|
-
if (
|
|
197
|
-
|
|
257
|
+
if (
|
|
258
|
+
chainInfo &&
|
|
259
|
+
!options?.usePublicRpc &&
|
|
260
|
+
options?.sequenceProjectAccessKey &&
|
|
261
|
+
options?.sequenceNodeGatewayUrl
|
|
262
|
+
) {
|
|
263
|
+
const rpcUrl = getRpcUrl(
|
|
264
|
+
chainId,
|
|
265
|
+
options.sequenceProjectAccessKey,
|
|
266
|
+
options.sequenceNodeGatewayUrl,
|
|
267
|
+
)
|
|
198
268
|
if (rpcUrl) {
|
|
199
269
|
chainInfo.rpcUrls = {
|
|
200
270
|
default: {
|
|
@@ -247,30 +317,67 @@ export async function getSupportedSequenceChains(): Promise<Chain[]> {
|
|
|
247
317
|
return Object.values(supportedSequenceChains)
|
|
248
318
|
}
|
|
249
319
|
|
|
250
|
-
|
|
251
|
-
|
|
320
|
+
// Chain order for sorting (in the desired display order)
|
|
321
|
+
const CHAIN_ORDER = [
|
|
322
|
+
1, // Ethereum
|
|
323
|
+
8453, // Base
|
|
324
|
+
42161, // Arbitrum
|
|
325
|
+
137, // Polygon
|
|
326
|
+
747474, // Katana
|
|
327
|
+
56, // BNB Smart Chain
|
|
328
|
+
10, // Optimism
|
|
329
|
+
43114, // Avalanche
|
|
330
|
+
42170, // Arbitrum Nova
|
|
331
|
+
42793, // Etherlink
|
|
332
|
+
100, // Gnosis
|
|
333
|
+
8333, // B3
|
|
334
|
+
33139, // Ape Chain
|
|
335
|
+
1868, // Soneium
|
|
336
|
+
5031, // Somnia
|
|
337
|
+
660279, // Xai
|
|
338
|
+
]
|
|
339
|
+
|
|
340
|
+
// Mapping of chain ID to normalized display name
|
|
341
|
+
const CHAIN_NAME_MAP: Record<number, string> = {
|
|
342
|
+
[arbitrum.id]: "Arbitrum", // Rename from "Arbitrum One"
|
|
343
|
+
[optimism.id]: "Optimism", // Rename from "OP Mainnet"
|
|
344
|
+
[soneium.id]: "Soneium", // Rename from "Soneium Mainnet"
|
|
345
|
+
[xai.id]: "Xai", // Rename from "Xai Mainnet"
|
|
252
346
|
}
|
|
253
347
|
|
|
254
|
-
|
|
255
|
-
|
|
348
|
+
/**
|
|
349
|
+
* Gets the normalized display name for a chain.
|
|
350
|
+
* @param chainId - The chain ID
|
|
351
|
+
* @param originalName - The original chain name from viem
|
|
352
|
+
* @returns The normalized chain name
|
|
353
|
+
*/
|
|
354
|
+
export function getNormalizedChainName(
|
|
355
|
+
chainId: number,
|
|
356
|
+
originalName: string,
|
|
357
|
+
): string {
|
|
358
|
+
return CHAIN_NAME_MAP[chainId] || originalName
|
|
359
|
+
}
|
|
256
360
|
|
|
257
|
-
|
|
258
|
-
|
|
361
|
+
/**
|
|
362
|
+
* Sorts chains by the predefined order, then alphabetically for chains not in the order.
|
|
363
|
+
* @param chainList - The list of chains to sort
|
|
364
|
+
* @returns The sorted list of chains
|
|
365
|
+
*/
|
|
366
|
+
export function sortChainsByOrder(chainList: Chain[]): Chain[] {
|
|
259
367
|
return chainList.sort((a, b) => {
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
const bPriority = PRIORITY_CHAIN_IDS.indexOf(b.id)
|
|
368
|
+
const aIndex = CHAIN_ORDER.indexOf(a.id)
|
|
369
|
+
const bIndex = CHAIN_ORDER.indexOf(b.id)
|
|
263
370
|
|
|
264
|
-
// If both are
|
|
265
|
-
if (
|
|
266
|
-
return
|
|
371
|
+
// If both chains are in the order, sort by their position
|
|
372
|
+
if (aIndex !== -1 && bIndex !== -1) {
|
|
373
|
+
return aIndex - bIndex
|
|
267
374
|
}
|
|
268
375
|
|
|
269
|
-
// If only one is
|
|
270
|
-
if (
|
|
271
|
-
if (
|
|
376
|
+
// If only one chain is in the order, prioritize it
|
|
377
|
+
if (aIndex !== -1) return -1
|
|
378
|
+
if (bIndex !== -1) return 1
|
|
272
379
|
|
|
273
|
-
//
|
|
380
|
+
// If neither chain is in the order, sort alphabetically
|
|
274
381
|
return a.name.localeCompare(b.name)
|
|
275
382
|
})
|
|
276
383
|
}
|
|
@@ -312,10 +419,8 @@ export async function getSupportedChains({
|
|
|
312
419
|
(chain, index, self) => index === self.findIndex((c) => c.id === chain.id),
|
|
313
420
|
)
|
|
314
421
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
// Sort chains by priority and then by name
|
|
318
|
-
return sortedChains
|
|
422
|
+
// Sort chains by predefined order
|
|
423
|
+
return sortChainsByOrder(uniqueChains)
|
|
319
424
|
}
|
|
320
425
|
|
|
321
426
|
export function useSupportedChains({
|
|
@@ -345,21 +450,3 @@ export function getIsTestnetChainId(chainId: number): boolean {
|
|
|
345
450
|
const testnetChainIds = Object.keys(supportedSequenceTestnetChains)
|
|
346
451
|
return testnetChainIds.includes(chainId.toString())
|
|
347
452
|
}
|
|
348
|
-
|
|
349
|
-
// Get chain color for UI styling
|
|
350
|
-
export function getChainColor(chainId: number): string {
|
|
351
|
-
switch (chainId) {
|
|
352
|
-
case 1:
|
|
353
|
-
return "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200" // More gray-blue for Ethereum
|
|
354
|
-
case 8453:
|
|
355
|
-
return "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200" // Blue for Base
|
|
356
|
-
case 42161:
|
|
357
|
-
return "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"
|
|
358
|
-
case 137:
|
|
359
|
-
return "bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200"
|
|
360
|
-
case 10:
|
|
361
|
-
return "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"
|
|
362
|
-
default:
|
|
363
|
-
return "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200"
|
|
364
|
-
}
|
|
365
|
-
}
|
package/src/config.ts
CHANGED
|
@@ -1,130 +1,57 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PROD_SEQUENCE_INDEXER_URL,
|
|
3
|
+
PROD_SEQUENCE_METADATA_URL,
|
|
3
4
|
DEFAULT_WALLETCONNECT_PROJECT_ID,
|
|
4
5
|
DEFAULT_SLIPPAGE_TOLERANCE,
|
|
5
|
-
PROD_SEQUENCE_PROJECT_ACCESS_KEY,
|
|
6
|
-
DEV_SEQUENCE_INDEXER_URL,
|
|
7
|
-
DEV_TRAILS_API_URL,
|
|
8
|
-
DEV_SEQUENCE_PROJECT_ACCESS_KEY,
|
|
9
|
-
DEFAULT_SEQUENCE_ENV,
|
|
10
6
|
PROD_SEQUENCE_NODE_GATEWAY_URL,
|
|
11
|
-
DEV_SEQUENCE_NODE_GATEWAY_URL,
|
|
12
7
|
PROD_TRAILS_API_URL,
|
|
13
|
-
LOCAL_TRAILS_API_URL,
|
|
14
8
|
} from "./constants.js"
|
|
15
9
|
import { getQueryParam } from "./queryParams.js"
|
|
16
10
|
import { logger } from "./logger.js"
|
|
17
11
|
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
trailsApiUrl: declareTrailsApiUrl(),
|
|
12
|
+
export interface TrailsConfig {
|
|
13
|
+
trailsApiKey: string
|
|
14
|
+
trailsApiUrl?: string
|
|
15
|
+
sequenceIndexerUrl?: string
|
|
16
|
+
sequenceNodeGatewayUrl?: string
|
|
17
|
+
sequenceMetadataUrl?: string
|
|
18
|
+
walletConnectProjectId?: string
|
|
19
|
+
slippageTolerance?: string
|
|
20
|
+
debug?: boolean
|
|
21
|
+
commitHash?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const globalConfig: TrailsConfig = {
|
|
25
|
+
trailsApiKey: "",
|
|
26
|
+
sequenceIndexerUrl: PROD_SEQUENCE_INDEXER_URL,
|
|
27
|
+
sequenceNodeGatewayUrl: PROD_SEQUENCE_NODE_GATEWAY_URL,
|
|
28
|
+
sequenceMetadataUrl: PROD_SEQUENCE_METADATA_URL,
|
|
29
|
+
trailsApiUrl: PROD_TRAILS_API_URL,
|
|
37
30
|
walletConnectProjectId: DEFAULT_WALLETCONNECT_PROJECT_ID,
|
|
38
31
|
slippageTolerance: DEFAULT_SLIPPAGE_TOLERANCE,
|
|
39
32
|
debug: false,
|
|
33
|
+
commitHash: declareCommitHash(),
|
|
40
34
|
}
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// Check explicit ENV variable first
|
|
49
|
-
const explicitEnv = getEnvVar("ENV")
|
|
50
|
-
if (explicitEnv === "local") {
|
|
51
|
-
return "local"
|
|
52
|
-
}
|
|
53
|
-
if (explicitEnv === "development" || explicitEnv === "dev") {
|
|
54
|
-
return "dev"
|
|
55
|
-
}
|
|
56
|
-
if (explicitEnv === "production" || explicitEnv === "prod") {
|
|
57
|
-
return "prod"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Special handling for Cloudflare Pages branches
|
|
61
|
-
const cfPagesBranch = getEnvVar("CF_PAGES_BRANCH")
|
|
62
|
-
if (cfPagesBranch) {
|
|
63
|
-
// If running on Cloudflare Pages, all branches except "production" default to dev
|
|
64
|
-
if (cfPagesBranch === "prod" || cfPagesBranch === "production") {
|
|
65
|
-
return "prod"
|
|
66
|
-
}
|
|
67
|
-
// Preview mode and other branches default to dev
|
|
68
|
-
return "dev"
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// If we're in a browser/Cloudflare environment but no explicit env is set,
|
|
72
|
-
// check if we have dev environment variables set (indicating non-prod)
|
|
73
|
-
// This helps with Cloudflare Workers preview mode
|
|
74
|
-
if (typeof window !== "undefined" || typeof process === "undefined") {
|
|
75
|
-
// In browser/Cloudflare Workers context, if no explicit prod indicators,
|
|
76
|
-
// default to dev for safety (unless explicitly set to prod)
|
|
77
|
-
// This prevents accidental prod usage in preview/staging environments
|
|
78
|
-
return "dev"
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return DEFAULT_SEQUENCE_ENV
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function declareSequenceIndexerUrl() {
|
|
85
|
-
if (declareSequenceEnv() === "prod") {
|
|
86
|
-
return PROD_SEQUENCE_INDEXER_URL
|
|
87
|
-
}
|
|
88
|
-
return DEV_SEQUENCE_INDEXER_URL
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function declareTrailsApiUrl() {
|
|
92
|
-
if (declareSequenceEnv() === "prod") {
|
|
93
|
-
return PROD_TRAILS_API_URL
|
|
94
|
-
}
|
|
95
|
-
if (declareSequenceEnv() === "local") {
|
|
96
|
-
return LOCAL_TRAILS_API_URL
|
|
97
|
-
}
|
|
98
|
-
return DEV_TRAILS_API_URL
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function declareSequenceNodeGatewayUrl() {
|
|
102
|
-
if (declareSequenceEnv() === "prod") {
|
|
103
|
-
return PROD_SEQUENCE_NODE_GATEWAY_URL
|
|
104
|
-
}
|
|
105
|
-
return DEV_SEQUENCE_NODE_GATEWAY_URL
|
|
36
|
+
/**
|
|
37
|
+
* Updates the global config with new values
|
|
38
|
+
* This is a temporary solution to sync config from TrailsProvider
|
|
39
|
+
*/
|
|
40
|
+
export function updateGlobalConfig(updates: Partial<TrailsConfig>) {
|
|
41
|
+
Object.assign(globalConfig, updates)
|
|
106
42
|
}
|
|
107
43
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// Use dev/prod keys based on environment
|
|
120
|
-
const sequenceEnv = declareSequenceEnv()
|
|
121
|
-
if (sequenceEnv === "prod") {
|
|
122
|
-
return PROD_SEQUENCE_PROJECT_ACCESS_KEY
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return DEV_SEQUENCE_PROJECT_ACCESS_KEY
|
|
44
|
+
// DEPRECATED: Use TrailsProvider context instead
|
|
45
|
+
// This is kept only for backward compatibility during migration
|
|
46
|
+
export function getConfig<T extends keyof TrailsConfig | undefined = undefined>(
|
|
47
|
+
propName?: T,
|
|
48
|
+
): T extends undefined ? Readonly<TrailsConfig> : TrailsConfig[NonNullable<T>] {
|
|
49
|
+
// console.warn(
|
|
50
|
+
// "[trails-sdk] getConfig is deprecated. Use TrailsProvider context with useTrails() hook instead.",
|
|
51
|
+
// propName,
|
|
52
|
+
// )
|
|
53
|
+
return (propName ? globalConfig[propName] : globalConfig) as any
|
|
126
54
|
}
|
|
127
|
-
|
|
128
55
|
export function declareCommitHash() {
|
|
129
56
|
const cfPagesCommitHash = getEnvVar("CF_PAGES_COMMIT_SHA")
|
|
130
57
|
const viteCommitHash = getEnvVar("VITE_COMMIT_SHA")
|
|
@@ -141,121 +68,38 @@ export function declareCommitHash() {
|
|
|
141
68
|
return cfPagesCommitHash || viteCommitHash
|
|
142
69
|
}
|
|
143
70
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function getSequenceProjectAccessKey() {
|
|
149
|
-
return globalConfig.sequenceProjectAccessKey
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function setSequenceProjectAccessKey(sequenceProjectAccessKey: string) {
|
|
153
|
-
globalConfig.sequenceProjectAccessKey = sequenceProjectAccessKey
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function setSequenceIndexerUrl(sequenceIndexerUrl: string) {
|
|
157
|
-
globalConfig.sequenceIndexerUrl = sequenceIndexerUrl
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function getSequenceIndexerUrl() {
|
|
161
|
-
return globalConfig.sequenceIndexerUrl
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function setSequenceNodeGatewayUrl(sequenceNodeGatewayUrl: string) {
|
|
165
|
-
globalConfig.sequenceNodeGatewayUrl = sequenceNodeGatewayUrl
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export function getSequenceNodeGatewayUrl() {
|
|
169
|
-
return globalConfig.sequenceNodeGatewayUrl
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export function setTrailsApiUrl(trailsApiUrl: string) {
|
|
173
|
-
globalConfig.trailsApiUrl = trailsApiUrl
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function getTrailsApiUrl() {
|
|
177
|
-
return globalConfig.trailsApiUrl
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export function setSequenceEnv(sequenceEnv: SequenceEnv) {
|
|
181
|
-
globalConfig.sequenceEnv = sequenceEnv
|
|
182
|
-
|
|
183
|
-
if (sequenceEnv === "prod") {
|
|
184
|
-
setSequenceIndexerUrl(PROD_SEQUENCE_INDEXER_URL)
|
|
185
|
-
setTrailsApiUrl(PROD_TRAILS_API_URL)
|
|
186
|
-
setSequenceNodeGatewayUrl(PROD_SEQUENCE_NODE_GATEWAY_URL)
|
|
187
|
-
setSequenceProjectAccessKey(PROD_SEQUENCE_PROJECT_ACCESS_KEY)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (sequenceEnv === "local") {
|
|
191
|
-
if (getEnvVar("TRAILS_API_URL")) {
|
|
192
|
-
setTrailsApiUrl(getEnvVar("TRAILS_API_URL"))
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (sequenceEnv === "dev") {
|
|
197
|
-
setSequenceIndexerUrl(DEV_SEQUENCE_INDEXER_URL)
|
|
198
|
-
setTrailsApiUrl(DEV_TRAILS_API_URL)
|
|
199
|
-
setSequenceNodeGatewayUrl(DEV_SEQUENCE_NODE_GATEWAY_URL)
|
|
200
|
-
setSequenceProjectAccessKey(DEV_SEQUENCE_PROJECT_ACCESS_KEY)
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export function getSequenceEnv() {
|
|
205
|
-
return globalConfig.sequenceEnv
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export function setWalletConnectProjectId(walletConnectProjectId: string) {
|
|
209
|
-
globalConfig.walletConnectProjectId = walletConnectProjectId
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export function getWalletConnectProjectId() {
|
|
213
|
-
return globalConfig.walletConnectProjectId
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Set slippage tolerance for swaps
|
|
218
|
-
* @param slippageTolerance - Slippage tolerance as decimal string (e.g., "0.05" for 5%, "0.001" for 0.1%)
|
|
219
|
-
*/
|
|
220
|
-
export function setSlippageTolerance(slippageTolerance: string) {
|
|
221
|
-
globalConfig.slippageTolerance = slippageTolerance
|
|
222
|
-
}
|
|
71
|
+
// DEPRECATED: These getter functions are kept for backward compatibility
|
|
72
|
+
// New code should use TrailsProvider context with useTrails() hook
|
|
223
73
|
|
|
224
74
|
/**
|
|
225
|
-
*
|
|
226
|
-
* @returns Slippage tolerance as decimal string (e.g., "0.05" for 5%, "0.001" for 0.1%)
|
|
75
|
+
* @deprecated Use TrailsProvider context instead
|
|
227
76
|
*/
|
|
228
77
|
export function getSlippageTolerance() {
|
|
229
78
|
return globalConfig.slippageTolerance
|
|
230
79
|
}
|
|
231
80
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use TrailsProvider context instead
|
|
83
|
+
*/
|
|
236
84
|
export function getDebug() {
|
|
237
85
|
return globalConfig.debug || getQueryParam("debug") === "true"
|
|
238
86
|
}
|
|
239
87
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Sets the global debug mode for backward compatibility with getDebug()
|
|
90
|
+
* This is called by TrailsProvider to sync the debug state
|
|
91
|
+
*/
|
|
92
|
+
export function setGlobalDebug(debug: boolean) {
|
|
93
|
+
globalConfig.debug = debug
|
|
245
94
|
}
|
|
246
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated Use TrailsProvider context instead
|
|
98
|
+
*/
|
|
247
99
|
export function getCommitHash() {
|
|
248
100
|
return globalConfig.commitHash
|
|
249
101
|
}
|
|
250
102
|
|
|
251
|
-
export function getAccountIntentTransactionHistory() {
|
|
252
|
-
return FeatureFlags.accountIntentTransactionHistory
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export const FeatureFlags = {
|
|
256
|
-
accountIntentTransactionHistory: false,
|
|
257
|
-
}
|
|
258
|
-
|
|
259
103
|
export function getEnvVar(name: string) {
|
|
260
104
|
// In Vite/browser environments, check import.meta.env first
|
|
261
105
|
// This is where Vite injects environment variables at build time
|
package/src/constants.ts
CHANGED
|
@@ -27,22 +27,10 @@ export const TRAILS_INTENT_ENTRYPOINT_ADDRESS: Address.Address =
|
|
|
27
27
|
export const ATTESATION_SIGNER_ADDRESS: Address.Address =
|
|
28
28
|
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
|
|
29
29
|
|
|
30
|
-
export const DEFAULT_SEQUENCE_ENV = "prod"
|
|
31
|
-
|
|
32
30
|
export const PROD_SEQUENCE_NODE_GATEWAY_URL = "https://nodes.sequence.app"
|
|
33
31
|
export const PROD_SEQUENCE_INDEXER_URL = "https://indexer.sequence.app"
|
|
32
|
+
export const PROD_SEQUENCE_METADATA_URL = "https://metadata.sequence.app"
|
|
34
33
|
export const PROD_TRAILS_API_URL = "https://trails-api.sequence.app"
|
|
35
|
-
export const DEV_SEQUENCE_NODE_GATEWAY_URL = "https://dev-nodes.sequence.app"
|
|
36
|
-
export const DEV_SEQUENCE_INDEXER_URL = "https://dev-indexer.sequence.app"
|
|
37
|
-
export const DEV_TRAILS_API_URL = "https://dev-trails-api.sequence-dev.app"
|
|
38
|
-
|
|
39
|
-
export const LOCAL_TRAILS_API_URL = "http://localhost:4422"
|
|
40
|
-
|
|
41
|
-
// This is used for Sequence Indexer and API
|
|
42
|
-
export const PROD_SEQUENCE_PROJECT_ACCESS_KEY =
|
|
43
|
-
"AQAAAAAAAKhGHJc3N5V2AWqfJ1v9xZ2u0nA"
|
|
44
|
-
export const DEV_SEQUENCE_PROJECT_ACCESS_KEY =
|
|
45
|
-
"AQAAAAAAAAaq1E41OU0QxifQgrVBMgfqg7k"
|
|
46
34
|
|
|
47
35
|
export const DATABEAT_SERVER = "https://databeat.sequence.app"
|
|
48
36
|
export const DATABEAT_KEY =
|
package/src/contractUtils.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getChainInfo } from "./chains.js"
|
|
1
|
+
import { getChainInfo, getPublicRpcClient } from "./chains.js"
|
|
3
2
|
import { logger } from "./logger.js"
|
|
4
3
|
|
|
5
4
|
export async function getIsContract(address: `0x${string}`, chainId: number) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
5
|
+
const chainInfo = getChainInfo(chainId)
|
|
6
|
+
if (!chainInfo) {
|
|
7
|
+
throw new Error(`Chain ${chainId} not found`)
|
|
8
|
+
}
|
|
9
|
+
const client = getPublicRpcClient(chainInfo)
|
|
10
10
|
|
|
11
11
|
const code = await client.getCode({ address })
|
|
12
12
|
const isNonZero = isNonZeroHexString(code)
|
package/src/estimate.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type PublicClient, formatUnits
|
|
2
|
-
import { getChainInfo } from "./chains.js"
|
|
1
|
+
import { type PublicClient, formatUnits } from "viem"
|
|
2
|
+
import { getChainInfo, getPublicRpcClient } from "./chains.js"
|
|
3
3
|
import { logger } from "./logger.js"
|
|
4
4
|
|
|
5
5
|
// Default minimum gas limit for deposit transactions
|
|
@@ -360,10 +360,7 @@ export async function getDefaultGasCostEstimate(
|
|
|
360
360
|
try {
|
|
361
361
|
const chain = getChainInfo(chainId)
|
|
362
362
|
if (chain) {
|
|
363
|
-
const publicClient =
|
|
364
|
-
chain,
|
|
365
|
-
transport: http(),
|
|
366
|
-
})
|
|
363
|
+
const publicClient = getPublicRpcClient(chain)
|
|
367
364
|
|
|
368
365
|
// Try to estimate gas if we have transaction details
|
|
369
366
|
let gasLimit = DEFAULT_MIN_GASLIMIT
|