0xtrails 0.2.4 → 0.2.6
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 +8 -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-BlV1Mry3.js → ccip-Xjh9d1gb.js} +7 -7
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/estimate.d.ts +52 -0
- package/dist/estimate.d.ts.map +1 -1
- package/dist/fees.d.ts +19 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/{index-BNWCIGfQ.js → index-BnhdZ8Ho.js} +76406 -75798
- package/dist/index.js +726 -520
- package/dist/intents.d.ts +40 -0
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts +3 -3
- 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/morpho.d.ts +8 -0
- package/dist/morpho.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +19 -75
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/queryParams.d.ts.map +1 -1
- package/dist/relayer.d.ts +6 -6
- package/dist/relayer.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +2 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -2
- package/dist/transactions.d.ts.map +1 -1
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.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 +4 -2
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts +4 -0
- 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/Earn.d.ts +2 -2
- 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/Fund.d.ts +2 -2
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/{FundSendForm.d.ts → FundSwap.d.ts} +13 -7
- package/dist/widget/components/FundSwap.d.ts.map +1 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts +4 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -0
- 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 -2
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PercentageMaxButtons.d.ts +12 -0
- package/dist/widget/components/PercentageMaxButtons.d.ts.map +1 -0
- package/dist/widget/components/{PaySendForm.d.ts → PoolDeposit.d.ts} +14 -36
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -0
- package/dist/widget/components/{SimpleSwap.d.ts → PoolWithdraw.d.ts} +19 -10
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -0
- package/dist/widget/components/QuoteDetails.d.ts +1 -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/Receive.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts +4 -0
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RequiredPropsError.d.ts +8 -0
- package/dist/widget/components/RequiredPropsError.d.ts.map +1 -0
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +3 -2
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.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/TokenImage.d.ts +1 -0
- package/dist/widget/components/TokenImage.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts +16 -0
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Tooltip.d.ts +9 -0
- package/dist/widget/components/Tooltip.d.ts.map +1 -0
- package/dist/widget/components/UserPreferences.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +9 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -0
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +2 -0
- package/dist/widget/css/index.css +554 -0
- package/dist/widget/hooks/useBack.d.ts +1 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +1 -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/useDefaultTokenSelection.d.ts +3 -3
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +83 -0
- package/dist/widget/hooks/useQuote.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +12 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +2 -2
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +9 -4
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +18 -12
- package/src/aave.ts +32 -0
- package/src/abortController.ts +35 -0
- package/src/config.ts +12 -4
- package/src/constants.ts +5 -0
- package/src/error.ts +19 -1
- package/src/estimate.ts +416 -5
- package/src/fees.ts +199 -0
- package/src/intents.ts +161 -11
- package/src/metaTxnMonitor.ts +3 -3
- package/src/metaTxns.ts +3 -5
- package/src/morpho.ts +32 -0
- package/src/prepareSend.ts +714 -550
- package/src/queryParams.ts +2 -1
- package/src/relayer.ts +11 -11
- package/src/sequenceWallet.ts +2 -2
- package/src/tokens.ts +7 -1
- package/src/trails.ts +3 -3
- package/src/transactions.ts +62 -18
- package/src/wallets.ts +8 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +3 -13
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
- package/src/widget/components/AccountSettings.tsx +48 -54
- package/src/widget/components/ChainFilterDropdown.tsx +24 -3
- package/src/widget/components/ClassicSwap.tsx +131 -213
- package/src/widget/components/ConnectWallet.tsx +8 -38
- package/src/widget/components/ConnectedWallets.tsx +132 -77
- package/src/widget/components/DynamicInputStyles.tsx +76 -0
- package/src/widget/components/Earn.tsx +82 -593
- package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
- package/src/widget/components/FeeBreakdown.tsx +155 -0
- package/src/widget/components/Fund.tsx +41 -108
- package/src/widget/components/FundMethods.tsx +82 -159
- package/src/widget/components/FundSwap.tsx +52 -0
- package/src/widget/components/FundingMethodSelectorButton.tsx +70 -0
- package/src/widget/components/Identicon.tsx +164 -95
- package/src/widget/components/MeshConnectExchanges.tsx +2 -15
- package/src/widget/components/Modal.tsx +0 -8
- package/src/widget/components/Pay.tsx +214 -237
- package/src/widget/components/PercentageMaxButtons.tsx +77 -0
- package/src/widget/components/PoolDeposit.tsx +569 -0
- package/src/widget/components/PoolWithdraw.tsx +884 -0
- package/src/widget/components/PriceImpactWarning.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +43 -12
- package/src/widget/components/Receipt.tsx +16 -2
- package/src/widget/components/Receive.tsx +0 -2
- package/src/widget/components/RecipientSelectorButton.tsx +44 -0
- package/src/widget/components/Recipients.tsx +63 -157
- package/src/widget/components/RequiredPropsError.tsx +33 -0
- package/src/widget/components/ScreenHeader.tsx +62 -34
- package/src/widget/components/SlippageToleranceSettings.tsx +2 -1
- package/src/widget/components/Swap.tsx +4 -45
- package/src/widget/components/SwapSettings.tsx +2 -14
- package/src/widget/components/ThemeProvider.tsx +2 -1
- package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
- package/src/widget/components/TokenImage.tsx +22 -5
- package/src/widget/components/TokenList.tsx +0 -1
- package/src/widget/components/TokenSelector.tsx +63 -53
- package/src/widget/components/TokenSelectorButton.tsx +98 -0
- package/src/widget/components/Tooltip.tsx +51 -0
- package/src/widget/components/TransferPendingVertical.tsx +1 -1
- package/src/widget/components/UserPreferences.tsx +6 -24
- package/src/widget/components/WaasFeeOptions.tsx +450 -0
- package/src/widget/components/WalletConfirmation.tsx +76 -14
- package/src/widget/components/WalletConnect.tsx +93 -29
- package/src/widget/components/WalletList.tsx +4 -2
- package/src/widget/hooks/useBack.tsx +2 -0
- package/src/widget/hooks/useCheckout.ts +36 -20
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDefaultTokenSelection.tsx +104 -28
- package/src/widget/hooks/usePayMessage.tsx +86 -11
- package/src/widget/hooks/useQuote.ts +413 -0
- package/src/widget/hooks/useSelectedFundMethod.tsx +41 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +10 -0
- package/src/widget/hooks/useSendForm.ts +32 -6
- package/src/widget/index.css +27 -0
- package/src/widget/widget.tsx +326 -283
- package/dist/widget/components/FundSendForm.d.ts.map +0 -1
- package/dist/widget/components/PaySendForm.d.ts.map +0 -1
- package/dist/widget/components/SimpleSwap.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapSettings.d.ts +0 -16
- package/dist/widget/hooks/useSwapSettings.d.ts.map +0 -1
- package/src/widget/components/FundSendForm.tsx +0 -903
- package/src/widget/components/PaySendForm.tsx +0 -869
- package/src/widget/components/SimpleSwap.tsx +0 -983
- package/src/widget/hooks/useSwapSettings.tsx +0 -100
package/src/queryParams.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useEffect, useState } from "react"
|
|
2
|
+
import { logger } from "./logger.js"
|
|
2
3
|
|
|
3
4
|
export function getQueryParam(key: string): string | null {
|
|
4
5
|
try {
|
|
5
6
|
if (typeof window === "undefined") return null
|
|
6
7
|
return new URLSearchParams(window.location.search).get(key)
|
|
7
8
|
} catch (error) {
|
|
8
|
-
console.error("Error getting query param", error)
|
|
9
|
+
logger.console.error("Error getting query param", error)
|
|
9
10
|
return null
|
|
10
11
|
}
|
|
11
12
|
}
|
package/src/relayer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Relayer } from "@0xsequence/relayer"
|
|
2
2
|
import { useMemo } from "react"
|
|
3
3
|
import { getChainInfo, getRpcUrl } from "./chains.js"
|
|
4
4
|
import { Hex } from "ox"
|
|
@@ -123,15 +123,15 @@ function wrappedFetch(
|
|
|
123
123
|
|
|
124
124
|
export function getBackupRelayer(
|
|
125
125
|
chainId: number,
|
|
126
|
-
):
|
|
126
|
+
): Relayer.RpcRelayer | undefined {
|
|
127
127
|
if (chainId === 42161) {
|
|
128
|
-
return new
|
|
128
|
+
return new Relayer.RpcRelayer(
|
|
129
129
|
"https://a1b4a8c5d856.ngrok.app/",
|
|
130
130
|
chainId,
|
|
131
131
|
getRpcUrl(chainId)!,
|
|
132
132
|
)
|
|
133
133
|
} else if (chainId === 8453) {
|
|
134
|
-
return new
|
|
134
|
+
return new Relayer.RpcRelayer(
|
|
135
135
|
"https://644a6aeb891e.ngrok.app/",
|
|
136
136
|
chainId,
|
|
137
137
|
getRpcUrl(chainId)!,
|
|
@@ -190,7 +190,7 @@ export function getRelayer(
|
|
|
190
190
|
env: getSequenceEnv() as RelayerEnv,
|
|
191
191
|
},
|
|
192
192
|
chainId: number,
|
|
193
|
-
):
|
|
193
|
+
): Relayer.RpcRelayer {
|
|
194
194
|
const chain = getChainInfo(chainId)
|
|
195
195
|
|
|
196
196
|
if (!chain) {
|
|
@@ -204,7 +204,7 @@ export function getRelayer(
|
|
|
204
204
|
|
|
205
205
|
const relayerUrl = getRelayerUrl(config, chainId)
|
|
206
206
|
|
|
207
|
-
const relayer = new
|
|
207
|
+
const relayer = new Relayer.RpcRelayer(
|
|
208
208
|
relayerUrl,
|
|
209
209
|
chainId,
|
|
210
210
|
rpcUrl,
|
|
@@ -261,16 +261,16 @@ export function useRelayers(
|
|
|
261
261
|
env: getSequenceEnv() as RelayerEnv,
|
|
262
262
|
},
|
|
263
263
|
): {
|
|
264
|
-
relayers: Map<number,
|
|
265
|
-
getRelayer: (chainId: number) =>
|
|
266
|
-
getBackupRelayer: (chainId: number) =>
|
|
264
|
+
relayers: Map<number, Relayer.RpcRelayer>
|
|
265
|
+
getRelayer: (chainId: number) => Relayer.RpcRelayer
|
|
266
|
+
getBackupRelayer: (chainId: number) => Relayer.RpcRelayer | undefined
|
|
267
267
|
} {
|
|
268
268
|
const relayers = useMemo(() => {
|
|
269
|
-
const relayerMap = new Map<number,
|
|
269
|
+
const relayerMap = new Map<number, Relayer.RpcRelayer>()
|
|
270
270
|
return relayerMap
|
|
271
271
|
}, [])
|
|
272
272
|
|
|
273
|
-
const getCachedRelayer = (chainId: number):
|
|
273
|
+
const getCachedRelayer = (chainId: number): Relayer.RpcRelayer => {
|
|
274
274
|
let relayer = relayers.get(chainId)
|
|
275
275
|
|
|
276
276
|
if (!relayer) {
|
package/src/sequenceWallet.ts
CHANGED
|
@@ -18,7 +18,7 @@ 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 {
|
|
21
|
+
import type { Relayer } from "@0xsequence/relayer"
|
|
22
22
|
|
|
23
23
|
export type FlatTransaction = {
|
|
24
24
|
to: string
|
|
@@ -528,7 +528,7 @@ export class StaticSigner implements signers.SapientSigner {
|
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
export async function getFeeOptions(
|
|
531
|
-
relayer:
|
|
531
|
+
relayer: Relayer.RpcRelayer,
|
|
532
532
|
wallet: string,
|
|
533
533
|
chainId: number,
|
|
534
534
|
calls: Payload.Call[],
|
package/src/tokens.ts
CHANGED
|
@@ -701,10 +701,11 @@ export function getCommonTokenImageUrl({
|
|
|
701
701
|
contractAddress?: string | null
|
|
702
702
|
chainId?: number | null
|
|
703
703
|
}) {
|
|
704
|
-
if (!
|
|
704
|
+
if (!contractAddress || !chainId) {
|
|
705
705
|
return ""
|
|
706
706
|
}
|
|
707
707
|
|
|
708
|
+
// If no symbol provided, try to look it up from contract address
|
|
708
709
|
if (!symbol) {
|
|
709
710
|
const token = commonTokens.find(
|
|
710
711
|
(t) =>
|
|
@@ -721,6 +722,7 @@ export function getCommonTokenImageUrl({
|
|
|
721
722
|
}
|
|
722
723
|
|
|
723
724
|
const symbolKey = tokenImageSymbolMap[symbol] ?? symbol
|
|
725
|
+
|
|
724
726
|
if (commonTokenImages[symbolKey]) {
|
|
725
727
|
return commonTokenImages[symbolKey]
|
|
726
728
|
}
|
|
@@ -970,6 +972,10 @@ export const tokenImageSymbolMap: Record<string, string> = {
|
|
|
970
972
|
BAT: "BAT",
|
|
971
973
|
ARB: "ARB",
|
|
972
974
|
LINK: "LINK",
|
|
975
|
+
|
|
976
|
+
// vault tokens
|
|
977
|
+
aBasUSDC: "USDC",
|
|
978
|
+
steakUSDC: "USDC",
|
|
973
979
|
}
|
|
974
980
|
|
|
975
981
|
export const commonTokens: SupportedToken[] = [
|
package/src/trails.ts
CHANGED
|
@@ -1085,10 +1085,10 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1085
1085
|
logger.console.log("[trails-sdk] Selected transactions to send", {
|
|
1086
1086
|
selectedId,
|
|
1087
1087
|
totalMetaTxns: metaTxns.length,
|
|
1088
|
-
txnsToSendCount: txnsToSend.filter((tx) => tx).length,
|
|
1088
|
+
txnsToSendCount: txnsToSend.filter((tx: MetaTxn) => tx).length,
|
|
1089
1089
|
txnsToSend: txnsToSend
|
|
1090
|
-
.filter((tx) => tx)
|
|
1091
|
-
.map((tx) => ({
|
|
1090
|
+
.filter((tx: MetaTxn) => tx)
|
|
1091
|
+
.map((tx: MetaTxn) => ({
|
|
1092
1092
|
id: tx?.id,
|
|
1093
1093
|
chainId: tx?.chainId,
|
|
1094
1094
|
walletAddress: tx?.walletAddress,
|
package/src/transactions.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { bigintReplacer } from "./utils.js"
|
|
|
9
9
|
import { getExplorerUrl } from "./explorer.js"
|
|
10
10
|
import { SortOrder } from "@0xsequence/trails-api"
|
|
11
11
|
import { getChainIndexerUrl } from "./indexerClient.js"
|
|
12
|
+
import { abortControllerRegistry } from "./abortController.js"
|
|
12
13
|
|
|
13
14
|
export type TransactionStateStatus =
|
|
14
15
|
| "pending"
|
|
@@ -99,6 +100,7 @@ export type GetAccountTransactionHistoryParams = {
|
|
|
99
100
|
pageSize?: number
|
|
100
101
|
includeMetadata?: boolean
|
|
101
102
|
page?: number
|
|
103
|
+
abortSignal?: AbortSignal
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
// Standalone function to calculate time difference between two transactions
|
|
@@ -189,8 +191,8 @@ export async function getAccountTransactionHistory({
|
|
|
189
191
|
accountAddress,
|
|
190
192
|
pageSize = 10,
|
|
191
193
|
page = 1,
|
|
192
|
-
|
|
193
194
|
includeMetadata = true,
|
|
195
|
+
abortSignal,
|
|
194
196
|
}: GetAccountTransactionHistoryParams): Promise<TransactionHistoryResponse> {
|
|
195
197
|
const accessKey = getSequenceProjectAccessKey()
|
|
196
198
|
|
|
@@ -198,26 +200,51 @@ export async function getAccountTransactionHistory({
|
|
|
198
200
|
throw new Error("Sequence project access key is required")
|
|
199
201
|
}
|
|
200
202
|
|
|
201
|
-
//
|
|
202
|
-
const
|
|
203
|
-
if (!chainIndexerUrl) {
|
|
204
|
-
throw new Error(`Unsupported chain ID: ${chainId}`)
|
|
205
|
-
}
|
|
203
|
+
// Create a unique ID for this operation
|
|
204
|
+
const operationId = `account-tx-history-${chainId}-${accountAddress}-${page}-${Date.now()}`
|
|
206
205
|
|
|
207
|
-
|
|
206
|
+
// Create an abort controller for this specific operation
|
|
207
|
+
const operationAbortController = new AbortController()
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
accountAddress: accountAddress.toLowerCase(),
|
|
212
|
-
},
|
|
213
|
-
includeMetadata,
|
|
214
|
-
page: {
|
|
215
|
-
page,
|
|
216
|
-
pageSize,
|
|
217
|
-
},
|
|
218
|
-
}
|
|
209
|
+
// Register this operation with the global registry
|
|
210
|
+
abortControllerRegistry.register(operationId, operationAbortController)
|
|
219
211
|
|
|
220
212
|
try {
|
|
213
|
+
// Check if we should abort before starting
|
|
214
|
+
if (abortSignal?.aborted || operationAbortController.signal.aborted) {
|
|
215
|
+
logger.console.log(
|
|
216
|
+
"[trails-sdk] Aborting account transaction history fetch",
|
|
217
|
+
)
|
|
218
|
+
throw new Error("Operation aborted")
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Get the chain-specific indexer URL
|
|
222
|
+
const chainIndexerUrl = getChainIndexerUrl(chainId)
|
|
223
|
+
if (!chainIndexerUrl) {
|
|
224
|
+
throw new Error(`Unsupported chain ID: ${chainId}`)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const endpoint = `${chainIndexerUrl}/rpc/Indexer/GetTransactionHistory`
|
|
228
|
+
|
|
229
|
+
const requestBody = {
|
|
230
|
+
filter: {
|
|
231
|
+
accountAddress: accountAddress.toLowerCase(),
|
|
232
|
+
},
|
|
233
|
+
includeMetadata,
|
|
234
|
+
page: {
|
|
235
|
+
page,
|
|
236
|
+
pageSize,
|
|
237
|
+
},
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Check abort signal before making the request
|
|
241
|
+
if (abortSignal?.aborted || operationAbortController.signal.aborted) {
|
|
242
|
+
logger.console.log(
|
|
243
|
+
"[trails-sdk] Aborting account transaction history fetch before request",
|
|
244
|
+
)
|
|
245
|
+
throw new Error("Operation aborted")
|
|
246
|
+
}
|
|
247
|
+
|
|
221
248
|
const response = await fetch(endpoint, {
|
|
222
249
|
method: "POST",
|
|
223
250
|
headers: {
|
|
@@ -225,6 +252,7 @@ export async function getAccountTransactionHistory({
|
|
|
225
252
|
"X-Access-Key": accessKey,
|
|
226
253
|
},
|
|
227
254
|
body: JSON.stringify(requestBody, bigintReplacer, 2),
|
|
255
|
+
signal: abortSignal || operationAbortController.signal,
|
|
228
256
|
})
|
|
229
257
|
|
|
230
258
|
if (!response.ok) {
|
|
@@ -246,11 +274,21 @@ export async function getAccountTransactionHistory({
|
|
|
246
274
|
transactions,
|
|
247
275
|
}
|
|
248
276
|
} catch (error) {
|
|
277
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
278
|
+
logger.console.log(
|
|
279
|
+
"[trails-sdk] Account transaction history fetch was aborted",
|
|
280
|
+
)
|
|
281
|
+
throw new Error("Operation aborted")
|
|
282
|
+
}
|
|
283
|
+
|
|
249
284
|
logger.console.error(
|
|
250
285
|
"[trails-sdk] Error fetching transaction history:",
|
|
251
286
|
error,
|
|
252
287
|
)
|
|
253
288
|
throw error
|
|
289
|
+
} finally {
|
|
290
|
+
// Always unregister when operation completes or is aborted
|
|
291
|
+
abortControllerRegistry.unregister(operationId)
|
|
254
292
|
}
|
|
255
293
|
}
|
|
256
294
|
|
|
@@ -355,6 +393,7 @@ export type UseAccountTransactionHistoryParams = {
|
|
|
355
393
|
pageSize?: number
|
|
356
394
|
page?: number
|
|
357
395
|
includeMetadata?: boolean
|
|
396
|
+
abortSignal?: AbortSignal
|
|
358
397
|
}
|
|
359
398
|
|
|
360
399
|
export type UseAccountTransactionHistoryReturn = {
|
|
@@ -369,6 +408,7 @@ export function useAccountTransactionHistory({
|
|
|
369
408
|
pageSize = 10,
|
|
370
409
|
page = 1,
|
|
371
410
|
includeMetadata = true,
|
|
411
|
+
abortSignal,
|
|
372
412
|
}: UseAccountTransactionHistoryParams): UseAccountTransactionHistoryReturn {
|
|
373
413
|
const { data, isLoading, error } = useQuery({
|
|
374
414
|
queryKey: [
|
|
@@ -379,17 +419,21 @@ export function useAccountTransactionHistory({
|
|
|
379
419
|
page,
|
|
380
420
|
includeMetadata,
|
|
381
421
|
],
|
|
382
|
-
queryFn: async () => {
|
|
422
|
+
queryFn: async ({ signal }) => {
|
|
383
423
|
if (!chainId || !accountAddress) {
|
|
384
424
|
return undefined
|
|
385
425
|
}
|
|
386
426
|
|
|
427
|
+
// Use the React Query signal if no external abort signal is provided
|
|
428
|
+
const effectiveSignal = abortSignal || signal
|
|
429
|
+
|
|
387
430
|
return await getAccountTransactionHistory({
|
|
388
431
|
chainId,
|
|
389
432
|
accountAddress,
|
|
390
433
|
pageSize,
|
|
391
434
|
page,
|
|
392
435
|
includeMetadata,
|
|
436
|
+
abortSignal: effectiveSignal,
|
|
393
437
|
})
|
|
394
438
|
},
|
|
395
439
|
enabled: Boolean(chainId && accountAddress),
|
package/src/wallets.ts
CHANGED
|
@@ -172,6 +172,7 @@ export const connectors = [
|
|
|
172
172
|
zerionConnector,
|
|
173
173
|
ambireConnector,
|
|
174
174
|
rabbyConnector,
|
|
175
|
+
sequenceConnector,
|
|
175
176
|
]
|
|
176
177
|
|
|
177
178
|
export const WALLET_CONFIGS: Record<string, WalletConfig> = {
|
|
@@ -282,6 +283,12 @@ export const WALLET_CONFIGS: Record<string, WalletConfig> = {
|
|
|
282
283
|
connector: sequenceConnector,
|
|
283
284
|
icon: SequenceLogo as string,
|
|
284
285
|
},
|
|
286
|
+
"sequence-waas": {
|
|
287
|
+
id: "sequence-waas",
|
|
288
|
+
name: "Sequence WaaS",
|
|
289
|
+
connector: sequenceConnector,
|
|
290
|
+
icon: SequenceLogo as string,
|
|
291
|
+
},
|
|
285
292
|
}
|
|
286
293
|
|
|
287
294
|
export const topShownWallets = [
|
|
@@ -320,6 +327,7 @@ export const wagmiConnectorToWalletId = (wagmiConnector: any): string => {
|
|
|
320
327
|
if (wagmiConnectorName.includes("okx")) return "okxwallet"
|
|
321
328
|
if (wagmiConnectorName.includes("privy")) return "privy"
|
|
322
329
|
if (wagmiConnectorName.includes("gemini")) return "gemini"
|
|
330
|
+
if (wagmiConnectorName.includes("waas")) return "sequence-waas"
|
|
323
331
|
if (wagmiConnectorName.includes("sequence")) return "sequence"
|
|
324
332
|
return wagmiConnector.id || "injected"
|
|
325
333
|
}
|