0xtrails 0.5.0 → 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-DhEkQ6QC.js → ccip-Dw5AN7oU.js} +1 -1
- package/dist/cctp.d.ts +0 -149
- package/dist/cctp.d.ts.map +1 -1
- package/dist/chains.d.ts +28 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- 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-MhD2DA7_.js → index-BtVUTbEZ.js} +30984 -38945
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -107
- package/dist/indexerClient.d.ts +2 -2
- package/dist/intents.d.ts +0 -17
- 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/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +10 -8
- package/dist/tokens.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 +4 -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 +6 -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 +2 -20
- 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/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/Toast.d.ts.map +1 -1
- package/dist/widget/components/TokenImage.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 +5 -8
- 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.js +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts +23 -12
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/widget.d.ts +11 -0
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/analytics.ts +53 -21
- package/src/cctp.ts +0 -1016
- package/src/chains.ts +93 -39
- package/src/config.ts +24 -6
- package/src/constants.ts +1 -4
- 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 +7 -6
- package/src/indexerClient.ts +2 -2
- package/src/intents.ts +52 -206
- package/src/mutations.ts +3 -2
- package/src/paymasterSend.ts +2 -5
- package/src/prepareSend.ts +9 -12
- package/src/sendUserOp.ts +3 -64
- package/src/tokenBalances.ts +2 -1
- package/src/tokens.ts +62 -133
- package/src/trailsClient.ts +1 -1
- 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 +165 -385
- 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 +6 -27
- package/src/transactionIntent/utils/index.ts +0 -1
- package/src/transactions.ts +6 -203
- package/src/umd.tsx +1 -3
- package/src/utils.ts +28 -8
- package/src/walletUtils.ts +42 -0
- package/src/wallets.ts +361 -203
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +73 -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 +1 -1
- 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/Toast.tsx +10 -0
- package/src/widget/components/TokenImage.tsx +56 -13
- 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 +788 -418
- package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +43 -0
- package/src/widget/hooks/useIsSequenceWallet.ts +17 -0
- package/src/widget/hooks/useQuote.ts +16 -17
- package/src/widget/hooks/useRecentTokens.ts +2 -1
- package/src/widget/hooks/useSelectedFeeOption.tsx +257 -0
- package/src/widget/hooks/useSendForm.ts +172 -47
- package/src/widget/hooks/useTokenList.ts +15 -2
- package/src/widget/providers/TrailsProvider.tsx +53 -25
- package/src/widget/widget.tsx +119 -48
- 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/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 -69
- package/src/preconditions.ts +0 -47
- 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/transactions.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query"
|
|
2
2
|
import { getChainInfo } from "./chains.js"
|
|
3
|
-
import { getTrailsClient } from "./trailsClient.js"
|
|
4
3
|
import type { GuestModuleEvent, TrailsTokenSweeperEvent } from "./decoders.js"
|
|
5
4
|
import { logger } from "./logger.js"
|
|
6
|
-
import { bigintReplacer } from "./utils.js"
|
|
7
5
|
import { getExplorerUrl } from "./explorer.js"
|
|
8
|
-
import {
|
|
6
|
+
import { JsonEncode } from "@0xsequence/trails-api"
|
|
9
7
|
import { getChainIndexerUrl } from "./indexerClient.js"
|
|
10
8
|
import { abortControllerRegistry } from "./abortController.js"
|
|
11
9
|
import { useTrails } from "./widget/providers/TrailsProvider.js"
|
|
@@ -222,7 +220,7 @@ export async function getAccountTransactionHistory({
|
|
|
222
220
|
"Content-Type": "application/json",
|
|
223
221
|
"X-Access-Key": apiKey,
|
|
224
222
|
},
|
|
225
|
-
body:
|
|
223
|
+
body: JsonEncode(requestBody),
|
|
226
224
|
signal: abortSignal || operationAbortController.signal,
|
|
227
225
|
})
|
|
228
226
|
|
|
@@ -278,6 +276,9 @@ export type IntentTransaction = {
|
|
|
278
276
|
destinationTokenAmount?: string
|
|
279
277
|
destinationToAddress?: string
|
|
280
278
|
createdAt?: string
|
|
279
|
+
// Transaction hashes from API response
|
|
280
|
+
originTransactionHash?: string // Transaction hash from API
|
|
281
|
+
destinationTransactionHash?: string // Transaction hash from API
|
|
281
282
|
// Enriched token information
|
|
282
283
|
originToken?: {
|
|
283
284
|
symbol: string
|
|
@@ -313,155 +314,6 @@ export type IntentTransactionHistoryResponse = {
|
|
|
313
314
|
transactions: IntentTransaction[]
|
|
314
315
|
}
|
|
315
316
|
|
|
316
|
-
export type GetIntentTransactionHistoryParams = {
|
|
317
|
-
accountAddress: string
|
|
318
|
-
pageSize?: number
|
|
319
|
-
page?: number
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export async function getIntentTransactionHistory({
|
|
323
|
-
accountAddress,
|
|
324
|
-
pageSize = 10,
|
|
325
|
-
page = 1,
|
|
326
|
-
apiKey,
|
|
327
|
-
apiUrl,
|
|
328
|
-
}: GetIntentTransactionHistoryParams & {
|
|
329
|
-
apiKey: string
|
|
330
|
-
apiUrl: string
|
|
331
|
-
}): Promise<IntentTransactionHistoryResponse> {
|
|
332
|
-
if (!apiKey) {
|
|
333
|
-
throw new Error("Trails api key is required")
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
try {
|
|
337
|
-
const trailsClient = getTrailsClient({ apiKey, hostname: apiUrl })
|
|
338
|
-
|
|
339
|
-
const requestParams = {
|
|
340
|
-
byOwnerAddress: accountAddress,
|
|
341
|
-
page: {
|
|
342
|
-
pageSize,
|
|
343
|
-
sort: [
|
|
344
|
-
{
|
|
345
|
-
column: "created_at",
|
|
346
|
-
order: SortOrder.DESC,
|
|
347
|
-
},
|
|
348
|
-
],
|
|
349
|
-
},
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
logger.console.log(
|
|
353
|
-
"[trails-sdk] getIntentTransactionHistory request:",
|
|
354
|
-
requestParams,
|
|
355
|
-
)
|
|
356
|
-
|
|
357
|
-
// Use the hybrid client's getIntentTransactionHistory method which tries Trails API first, then Sequence API
|
|
358
|
-
const result = await trailsClient.getIntentTransactionHistory(requestParams)
|
|
359
|
-
|
|
360
|
-
logger.console.log("[trails-sdk] getIntentTransactionHistory response:", {
|
|
361
|
-
intentCount: result.intents?.length || 0,
|
|
362
|
-
hasNextPage: !!result.nextPage,
|
|
363
|
-
firstIntent: result.intents?.[0],
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
// Map the API response to our local type structure
|
|
367
|
-
const mappedTransactions: IntentTransaction[] = (result.intents || []).map(
|
|
368
|
-
(intent: IntentSummary) => {
|
|
369
|
-
// Map API status to UI status format
|
|
370
|
-
const mapStatus = (apiStatus: string): string => {
|
|
371
|
-
const status = apiStatus?.toUpperCase() || "UNKNOWN"
|
|
372
|
-
switch (status) {
|
|
373
|
-
case "SUCCEEDED":
|
|
374
|
-
return "completed"
|
|
375
|
-
case "EXECUTING":
|
|
376
|
-
return "processing"
|
|
377
|
-
case "PENDING":
|
|
378
|
-
return "pending"
|
|
379
|
-
case "FAILED":
|
|
380
|
-
return "failed"
|
|
381
|
-
case "CREATED":
|
|
382
|
-
return "created"
|
|
383
|
-
default:
|
|
384
|
-
return apiStatus?.toLowerCase() || "unknown"
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return {
|
|
389
|
-
originIntentAddress: intent.originIntentAddress,
|
|
390
|
-
destinationIntentAddress: intent.destinationIntentAddress,
|
|
391
|
-
mainSigner: intent.ownerAddress,
|
|
392
|
-
metaTxnId: intent.intentId,
|
|
393
|
-
txnHash:
|
|
394
|
-
intent.originTransactionHash ||
|
|
395
|
-
intent.destinationTransactionHash ||
|
|
396
|
-
undefined,
|
|
397
|
-
executionStatus: mapStatus(intent.status),
|
|
398
|
-
originChainId: intent.originChainId,
|
|
399
|
-
destinationChainId: intent.destinationChainId,
|
|
400
|
-
originTokenAddress: intent.originTokenAddress,
|
|
401
|
-
originTokenAmount: intent.originTokenAmount.toString(),
|
|
402
|
-
destinationTokenAddress: intent.destinationTokenAddress,
|
|
403
|
-
destinationTokenAmount: intent.destinationTokenAmount.toString(),
|
|
404
|
-
destinationToAddress: intent.ownerAddress,
|
|
405
|
-
createdAt: intent.createdAt,
|
|
406
|
-
// Map origin token metadata if available
|
|
407
|
-
originToken: intent.originTokenMetadata
|
|
408
|
-
? ({
|
|
409
|
-
symbol: intent.originTokenMetadata.symbol || "",
|
|
410
|
-
name: intent.originTokenMetadata.name || "",
|
|
411
|
-
decimals: intent.originTokenMetadata.decimals ?? 18,
|
|
412
|
-
imageUrl: intent.originTokenMetadata.logoUri ?? "",
|
|
413
|
-
chainId: intent.originTokenMetadata.chainId,
|
|
414
|
-
} as {
|
|
415
|
-
symbol: string
|
|
416
|
-
name: string
|
|
417
|
-
decimals: number
|
|
418
|
-
imageUrl: string
|
|
419
|
-
chainId: number
|
|
420
|
-
})
|
|
421
|
-
: undefined,
|
|
422
|
-
// Map destination token metadata if available
|
|
423
|
-
destinationToken: intent.destinationTokenMetadata
|
|
424
|
-
? ({
|
|
425
|
-
symbol: intent.destinationTokenMetadata.symbol || "",
|
|
426
|
-
name: intent.destinationTokenMetadata.name || "",
|
|
427
|
-
decimals: intent.destinationTokenMetadata.decimals ?? 18,
|
|
428
|
-
imageUrl: intent.destinationTokenMetadata.logoUri ?? "",
|
|
429
|
-
chainId: intent.destinationTokenMetadata.chainId,
|
|
430
|
-
} as {
|
|
431
|
-
symbol: string
|
|
432
|
-
name: string
|
|
433
|
-
decimals: number
|
|
434
|
-
imageUrl: string
|
|
435
|
-
chainId: number
|
|
436
|
-
})
|
|
437
|
-
: undefined,
|
|
438
|
-
}
|
|
439
|
-
},
|
|
440
|
-
)
|
|
441
|
-
|
|
442
|
-
return {
|
|
443
|
-
page: result.nextPage
|
|
444
|
-
? {
|
|
445
|
-
page,
|
|
446
|
-
pageSize,
|
|
447
|
-
more: result.nextPage.more || false,
|
|
448
|
-
}
|
|
449
|
-
: {
|
|
450
|
-
page,
|
|
451
|
-
pageSize,
|
|
452
|
-
more: false,
|
|
453
|
-
},
|
|
454
|
-
transactions: mappedTransactions,
|
|
455
|
-
}
|
|
456
|
-
} catch (error) {
|
|
457
|
-
logger.console.error(
|
|
458
|
-
"[trails-sdk] Error fetching intent transaction history:",
|
|
459
|
-
error,
|
|
460
|
-
)
|
|
461
|
-
throw error
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
317
|
export type UseAccountTransactionHistoryParams = {
|
|
466
318
|
chainId?: number | null
|
|
467
319
|
accountAddress?: string | null
|
|
@@ -510,7 +362,7 @@ export function useAccountTransactionHistory({
|
|
|
510
362
|
page,
|
|
511
363
|
includeMetadata,
|
|
512
364
|
abortSignal: effectiveSignal,
|
|
513
|
-
apiKey: trailsApiKey,
|
|
365
|
+
apiKey: trailsApiKey || "",
|
|
514
366
|
indexerUrl: sequenceIndexerUrl!,
|
|
515
367
|
})
|
|
516
368
|
},
|
|
@@ -529,52 +381,3 @@ export function useAccountTransactionHistory({
|
|
|
529
381
|
error: error as Error | null,
|
|
530
382
|
}
|
|
531
383
|
}
|
|
532
|
-
|
|
533
|
-
export type UseIntentTransactionHistoryParams = {
|
|
534
|
-
accountAddress?: string | null
|
|
535
|
-
pageSize?: number
|
|
536
|
-
page?: number
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
export type UseIntentTransactionHistoryReturn = {
|
|
540
|
-
data: IntentTransactionHistoryResponse | undefined
|
|
541
|
-
isLoading: boolean
|
|
542
|
-
error: Error | null
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
export function useIntentTransactionHistory({
|
|
546
|
-
accountAddress,
|
|
547
|
-
pageSize = 10,
|
|
548
|
-
page = 1,
|
|
549
|
-
}: UseIntentTransactionHistoryParams): UseIntentTransactionHistoryReturn {
|
|
550
|
-
const { trailsApiKey, trailsApiUrl } = useTrails()
|
|
551
|
-
const { data, isLoading, error } = useQuery({
|
|
552
|
-
queryKey: ["intentTransactionHistory", accountAddress, pageSize, page],
|
|
553
|
-
queryFn: async () => {
|
|
554
|
-
if (!accountAddress) {
|
|
555
|
-
return undefined
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
return await getIntentTransactionHistory({
|
|
559
|
-
accountAddress,
|
|
560
|
-
pageSize,
|
|
561
|
-
page,
|
|
562
|
-
apiKey: trailsApiKey,
|
|
563
|
-
apiUrl: trailsApiUrl!,
|
|
564
|
-
})
|
|
565
|
-
},
|
|
566
|
-
enabled: Boolean(accountAddress),
|
|
567
|
-
staleTime: 30 * 1000, // Consider data fresh for 30 seconds
|
|
568
|
-
refetchOnWindowFocus: false,
|
|
569
|
-
refetchOnMount: false,
|
|
570
|
-
refetchInterval: false,
|
|
571
|
-
retry: 2,
|
|
572
|
-
refetchOnReconnect: true,
|
|
573
|
-
})
|
|
574
|
-
|
|
575
|
-
return {
|
|
576
|
-
data,
|
|
577
|
-
isLoading,
|
|
578
|
-
error: error as Error | null,
|
|
579
|
-
}
|
|
580
|
-
}
|
package/src/umd.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { createRoot } from "react-dom/client"
|
|
3
|
-
import type { RelayerEnv } from "./relayer.js"
|
|
4
3
|
import type { Theme } from "./theme.js"
|
|
5
4
|
import { TrailsWidget } from "./widget/widget.js"
|
|
6
5
|
|
|
@@ -8,10 +7,9 @@ interface TrailsGlobal {
|
|
|
8
7
|
render: (
|
|
9
8
|
element: HTMLElement,
|
|
10
9
|
options: {
|
|
11
|
-
|
|
10
|
+
apiKey: string
|
|
12
11
|
sequenceIndexerUrl?: string
|
|
13
12
|
trailsApiUrl?: string
|
|
14
|
-
sequenceEnv?: RelayerEnv
|
|
15
13
|
toAddress?: string | null
|
|
16
14
|
toAmount?: string | null
|
|
17
15
|
toChainId?: number | string | null
|
package/src/utils.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ethAddress, zeroAddress } from "viem"
|
|
2
|
+
|
|
1
3
|
export async function requestWithTimeout<T>(
|
|
2
4
|
client: { request: (...args: any[]) => Promise<T> },
|
|
3
5
|
args: Parameters<typeof client.request>,
|
|
@@ -11,10 +13,6 @@ export async function requestWithTimeout<T>(
|
|
|
11
13
|
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
export function bigintToString(n: bigint): string {
|
|
15
|
-
return n.toString()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
16
|
/**
|
|
19
17
|
* Formats completion time in seconds to human-readable format
|
|
20
18
|
* @param seconds - Time in seconds
|
|
@@ -69,10 +67,6 @@ export function getTimeAgo(timestamp?: number): string {
|
|
|
69
67
|
return `Sent ${diffInDays} days ago`
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
export function bigintReplacer(_key: string, value: any) {
|
|
73
|
-
return typeof value === "bigint" ? value.toString() : value
|
|
74
|
-
}
|
|
75
|
-
|
|
76
70
|
/**
|
|
77
71
|
* Truncates an Ethereum address to show first 6 and last 4 characters
|
|
78
72
|
* @param address - The full Ethereum address
|
|
@@ -86,3 +80,29 @@ export function truncateAddress(
|
|
|
86
80
|
if (!address) return ""
|
|
87
81
|
return `${address.slice(0, start)}…${address.slice(-end)}`
|
|
88
82
|
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Checks if an address represents a native token (ETH or zero address)
|
|
86
|
+
* @param address - The token address to check
|
|
87
|
+
* @param caseInsensitive - Whether to perform case-insensitive comparison (default: true)
|
|
88
|
+
* @returns True if the address is a native token address
|
|
89
|
+
*/
|
|
90
|
+
export function isNativeToken(
|
|
91
|
+
address?: string | null,
|
|
92
|
+
caseInsensitive = true,
|
|
93
|
+
): boolean {
|
|
94
|
+
if (!address) {
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const addresses = caseInsensitive
|
|
99
|
+
? [zeroAddress.toLowerCase(), ethAddress.toLowerCase()]
|
|
100
|
+
: [zeroAddress, ethAddress]
|
|
101
|
+
|
|
102
|
+
const normalizedAddress = caseInsensitive ? address.toLowerCase() : address
|
|
103
|
+
|
|
104
|
+
return addresses.includes(normalizedAddress)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const normalizeAddress = (address?: string | null): string =>
|
|
108
|
+
(address ?? "").toLowerCase()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Connector } from "wagmi"
|
|
2
|
+
import { getIsContract } from "./contractUtils.js"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a wallet connector is a Sequence wallet.
|
|
6
|
+
* @param connector - The wagmi connector to check
|
|
7
|
+
* @returns true if the connector is a Sequence wallet, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export function isSequenceWallet(connector: Connector | undefined): boolean {
|
|
10
|
+
if (!connector) return false
|
|
11
|
+
const connectorName = connector.name?.toLowerCase() || ""
|
|
12
|
+
const connectorId = connector.id?.toLowerCase() || ""
|
|
13
|
+
return connectorName.includes("sequence") || connectorId.includes("sequence")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Checks if a wallet ID indicates a Sequence wallet.
|
|
18
|
+
* @param walletId - The wallet ID to check
|
|
19
|
+
* @returns true if the wallet ID indicates a Sequence wallet, false otherwise
|
|
20
|
+
*/
|
|
21
|
+
export function isSequenceWalletById(walletId: string | undefined): boolean {
|
|
22
|
+
if (!walletId) return false
|
|
23
|
+
return walletId.toLowerCase().includes("sequence")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Checks if an address is a smart contract wallet.
|
|
28
|
+
* @param address - The wallet address to check
|
|
29
|
+
* @param chainId - The chain ID to check the wallet on
|
|
30
|
+
* @returns Promise that resolves to true if the address is a smart contract, false otherwise
|
|
31
|
+
*/
|
|
32
|
+
export async function isSmartContractWallet(
|
|
33
|
+
address: string,
|
|
34
|
+
chainId: number,
|
|
35
|
+
): Promise<boolean> {
|
|
36
|
+
try {
|
|
37
|
+
return await getIsContract(address as `0x${string}`, chainId)
|
|
38
|
+
} catch {
|
|
39
|
+
// Return false on error to be safe
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
}
|