0xtrails 0.2.2 → 0.2.4
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/{ccip-ConT1gDe.js → ccip-BlV1Mry3.js} +1 -1
- package/dist/chains.d.ts +5 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/{index-CMh8uEbV.js → index-BNWCIGfQ.js} +48821 -45983
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/intentEntrypoint.d.ts +0 -8
- package/dist/intentEntrypoint.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts +5 -4
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/metaTxns.d.ts +3 -3
- package/dist/metaTxns.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +3 -3
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/relayer.d.ts +10 -7
- package/dist/relayer.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +7 -0
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +2 -2
- package/dist/trails.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +1 -0
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +1 -0
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RefundWarning.d.ts +1 -0
- package/dist/widget/components/RefundWarning.d.ts.map +1 -1
- package/dist/widget/hooks/useBack.d.ts +5 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useInitialRedirect.d.ts +7 -0
- package/dist/widget/hooks/useInitialRedirect.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/chains.ts +23 -3
- package/src/constants.ts +10 -17
- package/src/error.ts +1 -1
- package/src/index.ts +8 -3
- package/src/intentEntrypoint.ts +0 -15
- package/src/metaTxnMonitor.ts +28 -22
- package/src/metaTxns.ts +5 -3
- package/src/prepareSend.ts +216 -301
- package/src/relayer.ts +15 -16
- package/src/sequenceWallet.ts +7 -3
- package/src/tokenBalances.ts +47 -0
- package/src/tokens.ts +10 -0
- package/src/trails.ts +2 -2
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountActionsDropdown.tsx +6 -2
- package/src/widget/components/AccountIntentTransactionHistory.tsx +1 -1
- package/src/widget/components/AccountSettings.tsx +5 -4
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +1 -1
- package/src/widget/components/ConnectWallet.tsx +6 -2
- package/src/widget/components/EarnPools.tsx +2 -1
- package/src/widget/components/Fund.tsx +50 -27
- package/src/widget/components/Pay.tsx +24 -1
- package/src/widget/components/Receive.tsx +1 -1
- package/src/widget/components/Recipients.tsx +4 -2
- package/src/widget/components/RefundWarning.tsx +5 -1
- package/src/widget/components/SwapSettings.tsx +9 -9
- package/src/widget/components/TokenSelector.tsx +1 -1
- package/src/widget/components/WalletList.tsx +3 -3
- package/src/widget/hooks/useBack.tsx +111 -9
- package/src/widget/hooks/useInitialRedirect.tsx +70 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +10 -16
- package/src/widget/hooks/useSendForm.ts +10 -10
- package/src/widget/hooks/useTokenList.ts +1 -1
- package/src/widget/widget.tsx +85 -106
- /package/dist/{style.css → 0xtrails.css} +0 -0
package/src/relayer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Relayer } from "@0xsequence/
|
|
1
|
+
import { type Relayer, RpcRelayer } from "@0xsequence/relayer"
|
|
2
2
|
import { useMemo } from "react"
|
|
3
3
|
import { getChainInfo, getRpcUrl } from "./chains.js"
|
|
4
4
|
import { Hex } from "ox"
|
|
@@ -45,7 +45,10 @@ export interface MetaTxnReceipt {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export type RelayerOperationStatus = Relayer.OperationStatus
|
|
48
|
-
export type
|
|
48
|
+
export type RelayerOperationFailedStatus = Relayer.OperationFailedStatus
|
|
49
|
+
export type RelayerOperationPendingStatus = Relayer.OperationPendingStatus
|
|
50
|
+
export type RelayerOperationConfirmedStatus = Relayer.OperationConfirmedStatus
|
|
51
|
+
export type RelayerOperationUnknownStatus = Relayer.OperationUnknownStatus
|
|
49
52
|
|
|
50
53
|
export type RelayerConfig = {
|
|
51
54
|
hostname: string
|
|
@@ -120,15 +123,15 @@ function wrappedFetch(
|
|
|
120
123
|
|
|
121
124
|
export function getBackupRelayer(
|
|
122
125
|
chainId: number,
|
|
123
|
-
):
|
|
126
|
+
): RpcRelayer.RpcRelayer | undefined {
|
|
124
127
|
if (chainId === 42161) {
|
|
125
|
-
return new
|
|
128
|
+
return new RpcRelayer.RpcRelayer(
|
|
126
129
|
"https://a1b4a8c5d856.ngrok.app/",
|
|
127
130
|
chainId,
|
|
128
131
|
getRpcUrl(chainId)!,
|
|
129
132
|
)
|
|
130
133
|
} else if (chainId === 8453) {
|
|
131
|
-
return new
|
|
134
|
+
return new RpcRelayer.RpcRelayer(
|
|
132
135
|
"https://644a6aeb891e.ngrok.app/",
|
|
133
136
|
chainId,
|
|
134
137
|
getRpcUrl(chainId)!,
|
|
@@ -187,7 +190,7 @@ export function getRelayer(
|
|
|
187
190
|
env: getSequenceEnv() as RelayerEnv,
|
|
188
191
|
},
|
|
189
192
|
chainId: number,
|
|
190
|
-
):
|
|
193
|
+
): RpcRelayer.RpcRelayer {
|
|
191
194
|
const chain = getChainInfo(chainId)
|
|
192
195
|
|
|
193
196
|
if (!chain) {
|
|
@@ -201,7 +204,7 @@ export function getRelayer(
|
|
|
201
204
|
|
|
202
205
|
const relayerUrl = getRelayerUrl(config, chainId)
|
|
203
206
|
|
|
204
|
-
const relayer = new
|
|
207
|
+
const relayer = new RpcRelayer.RpcRelayer(
|
|
205
208
|
relayerUrl,
|
|
206
209
|
chainId,
|
|
207
210
|
rpcUrl,
|
|
@@ -258,20 +261,16 @@ export function useRelayers(
|
|
|
258
261
|
env: getSequenceEnv() as RelayerEnv,
|
|
259
262
|
},
|
|
260
263
|
): {
|
|
261
|
-
relayers: Map<number,
|
|
262
|
-
getRelayer: (chainId: number) =>
|
|
263
|
-
getBackupRelayer: (
|
|
264
|
-
chainId: number,
|
|
265
|
-
) => Relayer.Standard.Rpc.RpcRelayer | undefined
|
|
264
|
+
relayers: Map<number, RpcRelayer.RpcRelayer>
|
|
265
|
+
getRelayer: (chainId: number) => RpcRelayer.RpcRelayer
|
|
266
|
+
getBackupRelayer: (chainId: number) => RpcRelayer.RpcRelayer | undefined
|
|
266
267
|
} {
|
|
267
268
|
const relayers = useMemo(() => {
|
|
268
|
-
const relayerMap = new Map<number,
|
|
269
|
+
const relayerMap = new Map<number, RpcRelayer.RpcRelayer>()
|
|
269
270
|
return relayerMap
|
|
270
271
|
}, [])
|
|
271
272
|
|
|
272
|
-
const getCachedRelayer = (
|
|
273
|
-
chainId: number,
|
|
274
|
-
): Relayer.Standard.Rpc.RpcRelayer => {
|
|
273
|
+
const getCachedRelayer = (chainId: number): RpcRelayer.RpcRelayer => {
|
|
275
274
|
let relayer = relayers.get(chainId)
|
|
276
275
|
|
|
277
276
|
if (!relayer) {
|
package/src/sequenceWallet.ts
CHANGED
|
@@ -14,10 +14,11 @@ import {
|
|
|
14
14
|
toHex,
|
|
15
15
|
type WalletClient,
|
|
16
16
|
} from "viem"
|
|
17
|
-
import type {
|
|
17
|
+
import type { RelayerEnvConfig, RelayerEnv } from "./relayer.js"
|
|
18
18
|
import { getRelayerUrl } from "./relayer.js"
|
|
19
19
|
import { getSequenceProjectAccessKey, getSequenceEnv } from "./config.js"
|
|
20
20
|
import { logger } from "./logger.js"
|
|
21
|
+
import type { RpcRelayer, Relayer } from "@0xsequence/relayer"
|
|
21
22
|
|
|
22
23
|
export type FlatTransaction = {
|
|
23
24
|
to: string
|
|
@@ -527,11 +528,14 @@ export class StaticSigner implements signers.SapientSigner {
|
|
|
527
528
|
}
|
|
528
529
|
|
|
529
530
|
export async function getFeeOptions(
|
|
530
|
-
relayer:
|
|
531
|
+
relayer: RpcRelayer.RpcRelayer,
|
|
531
532
|
wallet: string,
|
|
532
533
|
chainId: number,
|
|
533
534
|
calls: Payload.Call[],
|
|
534
|
-
) {
|
|
535
|
+
): Promise<{
|
|
536
|
+
options: Relayer.FeeOption[]
|
|
537
|
+
quote?: Relayer.FeeQuote
|
|
538
|
+
}> {
|
|
535
539
|
const feeOptions = await relayer.feeOptions(
|
|
536
540
|
wallet as `0x${string}`,
|
|
537
541
|
chainId,
|
package/src/tokenBalances.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { useIndexerGatewayClient } from "./indexerClient.js"
|
|
|
17
17
|
import { getTokenPrices, useTokenPrices } from "./prices.js"
|
|
18
18
|
import { logger } from "./logger.js"
|
|
19
19
|
import { getChainInfo } from "./chains.js"
|
|
20
|
+
import { getTokenImageUrl } from "./tokens.js"
|
|
20
21
|
|
|
21
22
|
export type { NativeTokenBalance, TokenBalance }
|
|
22
23
|
|
|
@@ -58,6 +59,10 @@ export interface TokenBalanceWithPrice extends TokenBalance {
|
|
|
58
59
|
balanceUsd?: number
|
|
59
60
|
balanceUsdFormatted?: string
|
|
60
61
|
chainName?: string
|
|
62
|
+
imageUrl?: string
|
|
63
|
+
symbol?: string
|
|
64
|
+
name?: string
|
|
65
|
+
decimals?: number
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
export interface NativeTokenBalanceWithPrice extends NativeTokenBalance {
|
|
@@ -66,6 +71,9 @@ export interface NativeTokenBalanceWithPrice extends NativeTokenBalance {
|
|
|
66
71
|
balanceUsdFormatted?: string
|
|
67
72
|
symbol?: string
|
|
68
73
|
chainName?: string
|
|
74
|
+
imageUrl?: string
|
|
75
|
+
name?: string
|
|
76
|
+
decimals?: number
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
export type TokenBalanceExtended =
|
|
@@ -268,11 +276,32 @@ export function useTokenBalances(
|
|
|
268
276
|
...token,
|
|
269
277
|
contractAddress: zeroAddress, // Native tokens always use zero address
|
|
270
278
|
chainName: getChainInfo(token.chainId)?.name || "",
|
|
279
|
+
symbol: token.symbol ?? (token as any).contractInfo?.symbol,
|
|
280
|
+
name: (token as any).name ?? (token as any).contractInfo?.name,
|
|
281
|
+
decimals:
|
|
282
|
+
(token as any).decimals ??
|
|
283
|
+
(token as any).contractInfo?.decimals ??
|
|
284
|
+
18, // Use token decimals or default to 18
|
|
285
|
+
imageUrl: getTokenImageUrl({
|
|
286
|
+
chainId: token.chainId,
|
|
287
|
+
contractAddress: zeroAddress,
|
|
288
|
+
symbol: token.symbol ?? (token as any).contractInfo?.symbol,
|
|
289
|
+
fallbackImageUrl: (token as any).contractInfo?.logoURI,
|
|
290
|
+
}),
|
|
271
291
|
})),
|
|
272
292
|
...tokenBalancesData.balances.map((token) => ({
|
|
273
293
|
...token,
|
|
274
294
|
contractAddress: token.contractAddress,
|
|
275
295
|
chainName: getChainInfo(token.contractInfo?.chainId)?.name || "",
|
|
296
|
+
symbol: token.contractInfo?.symbol,
|
|
297
|
+
name: token.contractInfo?.name,
|
|
298
|
+
decimals: token.contractInfo?.decimals,
|
|
299
|
+
imageUrl: getTokenImageUrl({
|
|
300
|
+
chainId: token.contractInfo?.chainId || 0,
|
|
301
|
+
contractAddress: token.contractAddress,
|
|
302
|
+
symbol: token.contractInfo?.symbol,
|
|
303
|
+
fallbackImageUrl: token.contractInfo?.logoURI,
|
|
304
|
+
}),
|
|
276
305
|
})),
|
|
277
306
|
].filter((token) => {
|
|
278
307
|
try {
|
|
@@ -614,6 +643,15 @@ export async function getTokenBalancesFlatArray({
|
|
|
614
643
|
...b,
|
|
615
644
|
contractAddress: b.contractAddress ?? zeroAddress,
|
|
616
645
|
tokenId: b.contractInfo?.symbol,
|
|
646
|
+
symbol: b.contractInfo?.symbol,
|
|
647
|
+
name: b.contractInfo?.name,
|
|
648
|
+
decimals: b.contractInfo?.decimals,
|
|
649
|
+
imageUrl: getTokenImageUrl({
|
|
650
|
+
chainId: b.contractInfo?.chainId || 0,
|
|
651
|
+
contractAddress: b.contractAddress ?? zeroAddress,
|
|
652
|
+
symbol: b.contractInfo?.symbol,
|
|
653
|
+
fallbackImageUrl: b.contractInfo?.logoURI,
|
|
654
|
+
}),
|
|
617
655
|
},
|
|
618
656
|
)
|
|
619
657
|
})
|
|
@@ -625,6 +663,15 @@ export async function getTokenBalancesFlatArray({
|
|
|
625
663
|
...b,
|
|
626
664
|
contractAddress: b.contractAddress ?? zeroAddress,
|
|
627
665
|
tokenId: b.symbol,
|
|
666
|
+
symbol: b.symbol,
|
|
667
|
+
name: b.name,
|
|
668
|
+
decimals: b.decimals ?? b.contractInfo?.decimals ?? 18, // Use token decimals or default to 18
|
|
669
|
+
imageUrl: getTokenImageUrl({
|
|
670
|
+
chainId: b.chainId,
|
|
671
|
+
contractAddress: zeroAddress,
|
|
672
|
+
symbol: b.symbol,
|
|
673
|
+
fallbackImageUrl: b.contractInfo?.logoURI,
|
|
674
|
+
}),
|
|
628
675
|
})
|
|
629
676
|
})
|
|
630
677
|
}
|
package/src/tokens.ts
CHANGED
|
@@ -44,6 +44,10 @@ export const commonTokenImages: Record<string, string> = {
|
|
|
44
44
|
XTZ: "https://assets.sequence.info/images/tokens/large/42793/0x0000000000000000000000000000000000000000.webp",
|
|
45
45
|
WXTZ: "https://assets.coingecko.com/coins/images/976/standard/Tezos-logo.png?1696502091",
|
|
46
46
|
SOMI: "https://assets.sequence.info/images/tokens/large/5031/0x0000000000000000000000000000000000000000.webp",
|
|
47
|
+
XAI: "https://assets.coingecko.com/coins/images/34258/large/round_icon_2048_px.png?1719523838",
|
|
48
|
+
APE: "https://assets.sequence.info/images/tokens/large/33139/0x0000000000000000000000000000000000000000.webp",
|
|
49
|
+
ANIME:
|
|
50
|
+
"https://assets.coingecko.com/coins/images/53575/large/anime.jpg?1736748703",
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
const cacheVersion = "01"
|
|
@@ -728,10 +732,12 @@ export function getTokenImageUrl({
|
|
|
728
732
|
chainId,
|
|
729
733
|
contractAddress,
|
|
730
734
|
symbol,
|
|
735
|
+
fallbackImageUrl,
|
|
731
736
|
}: {
|
|
732
737
|
chainId?: number
|
|
733
738
|
contractAddress?: string
|
|
734
739
|
symbol?: string
|
|
740
|
+
fallbackImageUrl?: string
|
|
735
741
|
}) {
|
|
736
742
|
if (!chainId || !contractAddress || !symbol) {
|
|
737
743
|
return ""
|
|
@@ -757,6 +763,10 @@ export function getTokenImageUrl({
|
|
|
757
763
|
}
|
|
758
764
|
}
|
|
759
765
|
|
|
766
|
+
if (fallbackImageUrl) {
|
|
767
|
+
return fallbackImageUrl
|
|
768
|
+
}
|
|
769
|
+
|
|
760
770
|
const imageUrl = `https://assets.sequence.info/images/tokens/large/${chainId}/${contractAddress.toLowerCase()}.webp`
|
|
761
771
|
return imageUrl
|
|
762
772
|
}
|
package/src/trails.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
IntentPrecondition,
|
|
7
7
|
} from "@0xsequence/trails-api"
|
|
8
8
|
import type { TrailsClient } from "./trailsClient.js"
|
|
9
|
-
import type {
|
|
9
|
+
import type { RelayerOperationStatus } from "./relayer.js"
|
|
10
10
|
import { useMutation, useQuery } from "@tanstack/react-query"
|
|
11
11
|
import { Address } from "ox"
|
|
12
12
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
@@ -154,7 +154,7 @@ export type UseTrailsReturn = {
|
|
|
154
154
|
sendMetaTxnError: Error | null
|
|
155
155
|
sendMetaTxnArgs: { selectedId: string | null } | undefined
|
|
156
156
|
clearIntent: () => void
|
|
157
|
-
metaTxnMonitorStatuses: { [key: string]:
|
|
157
|
+
metaTxnMonitorStatuses: { [key: string]: RelayerOperationStatus }
|
|
158
158
|
createIntent: (args: GetIntentCallsPayloadsArgs) => void
|
|
159
159
|
createIntentPending: boolean
|
|
160
160
|
createIntentSuccess: boolean
|