@ledgerhq/coin-tron 3.1.0-nightly.1 → 4.0.0-next.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -8
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -6
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.js +2 -7
- package/lib/api/index.test.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -7
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.integ.test.js +4 -56
- package/lib/logic/listOperations.integ.test.js.map +1 -1
- package/lib/logic/listOperations.js +7 -20
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/listOperations.unit.test.js +3 -5
- package/lib/logic/listOperations.unit.test.js.map +1 -1
- package/lib/network/index.d.ts +1 -5
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +5 -8
- package/lib/network/index.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +1 -6
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.js +2 -7
- package/lib-es/api/index.test.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -7
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.integ.test.js +5 -57
- package/lib-es/logic/listOperations.integ.test.js.map +1 -1
- package/lib-es/logic/listOperations.js +7 -19
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/listOperations.unit.test.js +4 -6
- package/lib-es/logic/listOperations.unit.test.js.map +1 -1
- package/lib-es/network/index.d.ts +1 -5
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +5 -8
- package/lib-es/network/index.js.map +1 -1
- package/package.json +5 -5
- package/src/api/index.test.ts +2 -7
- package/src/api/index.ts +1 -7
- package/src/logic/listOperations.integ.test.ts +5 -74
- package/src/logic/listOperations.ts +7 -31
- package/src/logic/listOperations.unit.test.ts +4 -8
- package/src/network/index.ts +6 -13
|
@@ -2,7 +2,7 @@ import BigNumber from "bignumber.js";
|
|
|
2
2
|
import { defaultFetchParams, fetchTronAccountTxs, getBlock } from "../network";
|
|
3
3
|
import { fromTrongridTxInfoToOperation } from "../network/trongrid/trongrid-adapters";
|
|
4
4
|
import { TrongridTxInfo, TronAsset } from "../types";
|
|
5
|
-
import {
|
|
5
|
+
import { listOperations } from "./listOperations";
|
|
6
6
|
import type { Operation } from "@ledgerhq/coin-framework/api/index";
|
|
7
7
|
|
|
8
8
|
// Mock the fetchTronAccountTxs and fromTrongridTxInfoToOperation functions
|
|
@@ -30,8 +30,6 @@ describe("listOperations", () => {
|
|
|
30
30
|
const expectedFetchParams = {
|
|
31
31
|
...defaultFetchParams,
|
|
32
32
|
minTimestamp: mockBlockTimestamp,
|
|
33
|
-
hintGlobalLimit: 1000,
|
|
34
|
-
order: "desc",
|
|
35
33
|
};
|
|
36
34
|
|
|
37
35
|
it("should fetch transactions and return operations", async () => {
|
|
@@ -53,7 +51,7 @@ describe("listOperations", () => {
|
|
|
53
51
|
};
|
|
54
52
|
});
|
|
55
53
|
|
|
56
|
-
const [operations, token] = await listOperations(mockAddress,
|
|
54
|
+
const [operations, token] = await listOperations(mockAddress, 0);
|
|
57
55
|
|
|
58
56
|
expect(fetchTronAccountTxs).toHaveBeenCalledWith(
|
|
59
57
|
mockAddress,
|
|
@@ -73,7 +71,7 @@ describe("listOperations", () => {
|
|
|
73
71
|
(fetchTronAccountTxs as jest.Mock).mockResolvedValue(mockTxs);
|
|
74
72
|
(fromTrongridTxInfoToOperation as jest.Mock).mockImplementation(() => null);
|
|
75
73
|
|
|
76
|
-
const [operations, token] = await listOperations(mockAddress,
|
|
74
|
+
const [operations, token] = await listOperations(mockAddress, 0);
|
|
77
75
|
|
|
78
76
|
expect(fetchTronAccountTxs).toHaveBeenCalledWith(
|
|
79
77
|
mockAddress,
|
|
@@ -89,8 +87,6 @@ describe("listOperations", () => {
|
|
|
89
87
|
const exampleError = new Error("Network error!");
|
|
90
88
|
(fetchTronAccountTxs as jest.Mock).mockRejectedValue(exampleError);
|
|
91
89
|
|
|
92
|
-
await expect(listOperations(mockAddress,
|
|
93
|
-
new Error(exampleError.message),
|
|
94
|
-
);
|
|
90
|
+
await expect(listOperations(mockAddress, 0)).rejects.toThrow(new Error(exampleError.message));
|
|
95
91
|
});
|
|
96
92
|
});
|
package/src/network/index.ts
CHANGED
|
@@ -483,18 +483,13 @@ export type FetchTxsStopPredicate = (
|
|
|
483
483
|
) => boolean;
|
|
484
484
|
|
|
485
485
|
export type FetchParams = {
|
|
486
|
-
|
|
487
|
-
limitPerCall: number;
|
|
488
|
-
/** Hint about the number of transactions to be fetched in total (hint to optimize `limitPerCall`) */
|
|
489
|
-
hintGlobalLimit?: number;
|
|
486
|
+
limit: number;
|
|
490
487
|
minTimestamp: number;
|
|
491
|
-
order: "asc" | "desc";
|
|
492
488
|
};
|
|
493
489
|
|
|
494
490
|
export const defaultFetchParams: FetchParams = {
|
|
495
|
-
|
|
491
|
+
limit: 100,
|
|
496
492
|
minTimestamp: 0,
|
|
497
|
-
order: "desc",
|
|
498
493
|
} as const;
|
|
499
494
|
|
|
500
495
|
export async function fetchTronAccountTxs(
|
|
@@ -503,15 +498,12 @@ export async function fetchTronAccountTxs(
|
|
|
503
498
|
cacheTransactionInfoById: Record<string, TronTransactionInfo>,
|
|
504
499
|
params: FetchParams,
|
|
505
500
|
): Promise<TrongridTxInfo[]> {
|
|
506
|
-
const
|
|
507
|
-
? Math.min(params.limitPerCall, params.hintGlobalLimit)
|
|
508
|
-
: params.limitPerCall;
|
|
509
|
-
const queryParams = `limit=${adjustedLimitPerCall}&min_timestamp=${params.minTimestamp}&order_by=block_timestamp,${params.order}`;
|
|
501
|
+
const queryParamsNativeTxs = `limit=${params.limit}&min_timestamp=${params.minTimestamp}`;
|
|
510
502
|
const nativeTxs = (
|
|
511
503
|
await getAllTransactions<
|
|
512
504
|
(TransactionTronAPI & { detail?: TronTransactionInfo }) | MalformedTransactionTronAPI
|
|
513
505
|
>(
|
|
514
|
-
`${getBaseApiUrl()}/v1/accounts/${addr}/transactions?${
|
|
506
|
+
`${getBaseApiUrl()}/v1/accounts/${addr}/transactions?${queryParamsNativeTxs}`,
|
|
515
507
|
shouldFetchMoreTxs,
|
|
516
508
|
getTransactions(cacheTransactionInfoById),
|
|
517
509
|
)
|
|
@@ -536,9 +528,10 @@ export async function fetchTronAccountTxs(
|
|
|
536
528
|
|
|
537
529
|
// we need to fetch and filter trc20 transactions from another endpoint
|
|
538
530
|
// doc https://developers.tron.network/reference/get-trc20-transaction-info-by-account-address
|
|
531
|
+
const queryParamsTrc20Txs = `limit=${params.limit}&min_timestamp=${params.minTimestamp}`;
|
|
539
532
|
const trc20Txs = (
|
|
540
533
|
await getAllTransactions<Trc20API>(
|
|
541
|
-
`${getBaseApiUrl()}/v1/accounts/${addr}/transactions/trc20?${
|
|
534
|
+
`${getBaseApiUrl()}/v1/accounts/${addr}/transactions/trc20?${queryParamsTrc20Txs}&get_detail=true`,
|
|
542
535
|
shouldFetchMoreTxs,
|
|
543
536
|
getTrc20,
|
|
544
537
|
)
|