0xtrails 0.2.5 → 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/abortController.d.ts +8 -0
- package/dist/abortController.d.ts.map +1 -0
- package/dist/{ccip-CXlshvBY.js → ccip-Xjh9d1gb.js} +7 -7
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/fees.d.ts +19 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/{index-_QuyGrjU.js → index-BnhdZ8Ho.js} +34769 -34247
- package/dist/index.js +726 -520
- package/dist/prepareSend.d.ts +11 -77
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -2
- package/dist/transactions.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts +4 -0
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts.map +1 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +2 -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/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/FundSwap.d.ts +2 -2
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Identicon.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -3
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +2 -2
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +3 -2
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +3 -2
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- 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/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +2 -2
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts +11 -0
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts.map +1 -0
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Tooltip.d.ts +9 -0
- package/dist/widget/components/Tooltip.d.ts.map +1 -0
- package/dist/widget/components/WaasFeeOptions.d.ts +1 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +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/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 +5 -0
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/abortController.ts +35 -0
- package/src/constants.ts +3 -0
- package/src/fees.ts +199 -0
- package/src/prepareSend.ts +225 -398
- package/src/trails.ts +3 -3
- package/src/transactions.ts +62 -18
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
- package/src/widget/components/AccountSettings.tsx +48 -36
- package/src/widget/components/ChainFilterDropdown.tsx +24 -3
- package/src/widget/components/ClassicSwap.tsx +24 -62
- package/src/widget/components/ConnectWallet.tsx +4 -1
- package/src/widget/components/ConnectedWallets.tsx +21 -21
- package/src/widget/components/DynamicInputStyles.tsx +76 -0
- package/src/widget/components/Earn.tsx +34 -29
- package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
- package/src/widget/components/FeeBreakdown.tsx +155 -0
- package/src/widget/components/Fund.tsx +10 -26
- package/src/widget/components/FundSwap.tsx +2 -2
- package/src/widget/components/FundingMethodSelectorButton.tsx +24 -14
- package/src/widget/components/Identicon.tsx +164 -95
- package/src/widget/components/MeshConnectExchanges.tsx +2 -15
- package/src/widget/components/Modal.tsx +0 -12
- package/src/widget/components/Pay.tsx +65 -63
- package/src/widget/components/PoolDeposit.tsx +206 -230
- package/src/widget/components/PoolWithdraw.tsx +219 -238
- package/src/widget/components/PriceImpactWarning.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +25 -8
- package/src/widget/components/Receipt.tsx +16 -2
- package/src/widget/components/RecipientSelectorButton.tsx +7 -5
- package/src/widget/components/Recipients.tsx +1 -1
- package/src/widget/components/ScreenHeader.tsx +60 -36
- package/src/widget/components/Swap.tsx +2 -2
- package/src/widget/components/ThemeProvider.tsx +2 -1
- package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
- package/src/widget/components/TokenImage.tsx +1 -1
- package/src/widget/components/TokenSelector.tsx +62 -53
- package/src/widget/components/TokenSelectorButton.tsx +38 -15
- package/src/widget/components/Tooltip.tsx +51 -0
- package/src/widget/components/TransferPendingVertical.tsx +1 -1
- package/src/widget/components/WaasFeeOptions.tsx +124 -5
- package/src/widget/components/WalletConfirmation.tsx +23 -13
- package/src/widget/components/WalletConnect.tsx +93 -29
- package/src/widget/hooks/useQuote.ts +413 -0
- package/src/widget/hooks/useSendForm.ts +8 -4
- package/src/widget/widget.tsx +175 -190
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),
|