@ledgerhq/coin-tron 4.5.0-nightly.2 → 4.5.1-nightly.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 +51 -13
- package/lib/api/index.d.ts +2 -2
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.integ.test.js.map +1 -1
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.js +2 -3
- package/lib/api/index.test.js.map +1 -1
- package/lib/bridge/getEstimateFees.d.ts.map +1 -1
- package/lib/bridge/getEstimateFees.js +3 -4
- package/lib/bridge/getEstimateFees.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +3 -3
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.integ.test.js +11 -16
- package/lib/logic/craftTransaction.integ.test.js.map +1 -1
- package/lib/logic/craftTransaction.js +6 -5
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/craftTransaction.test.js +10 -14
- package/lib/logic/craftTransaction.test.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +2 -2
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +1 -1
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/estimateFees.test.js +4 -6
- package/lib/logic/estimateFees.test.js.map +1 -1
- package/lib/logic/getBalance.d.ts +3 -4
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.integ.test.js +4 -1
- package/lib/logic/getBalance.integ.test.js.map +1 -1
- package/lib/logic/getBalance.js +4 -6
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBalance.test.js +60 -20
- package/lib/logic/getBalance.test.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -2
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.integ.test.js +8 -12
- package/lib/logic/listOperations.integ.test.js.map +1 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/listOperations.unit.test.js.map +1 -1
- package/lib/network/trongrid/trongrid-adapters.d.ts +2 -2
- package/lib/network/trongrid/trongrid-adapters.d.ts.map +1 -1
- package/lib/network/trongrid/trongrid-adapters.js +4 -6
- package/lib/network/trongrid/trongrid-adapters.js.map +1 -1
- package/lib/network/trongrid/trongrid-adapters.test.js +1 -1
- package/lib/network/trongrid/trongrid-adapters.test.js.map +1 -1
- package/lib/types/assets.d.ts +1 -11
- package/lib/types/assets.d.ts.map +1 -1
- package/lib-es/api/index.d.ts +2 -2
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.integ.test.js.map +1 -1
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.js +2 -3
- package/lib-es/api/index.test.js.map +1 -1
- package/lib-es/bridge/getEstimateFees.d.ts.map +1 -1
- package/lib-es/bridge/getEstimateFees.js +3 -4
- package/lib-es/bridge/getEstimateFees.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +3 -3
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.integ.test.js +11 -16
- package/lib-es/logic/craftTransaction.integ.test.js.map +1 -1
- package/lib-es/logic/craftTransaction.js +6 -5
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/craftTransaction.test.js +10 -14
- package/lib-es/logic/craftTransaction.test.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +2 -2
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +1 -1
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/estimateFees.test.js +4 -6
- package/lib-es/logic/estimateFees.test.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +3 -4
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.integ.test.js +4 -1
- package/lib-es/logic/getBalance.integ.test.js.map +1 -1
- package/lib-es/logic/getBalance.js +4 -6
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBalance.test.js +60 -20
- package/lib-es/logic/getBalance.test.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -2
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.integ.test.js +8 -12
- package/lib-es/logic/listOperations.integ.test.js.map +1 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/listOperations.unit.test.js.map +1 -1
- package/lib-es/network/trongrid/trongrid-adapters.d.ts +2 -2
- package/lib-es/network/trongrid/trongrid-adapters.d.ts.map +1 -1
- package/lib-es/network/trongrid/trongrid-adapters.js +4 -6
- package/lib-es/network/trongrid/trongrid-adapters.js.map +1 -1
- package/lib-es/network/trongrid/trongrid-adapters.test.js +1 -1
- package/lib-es/network/trongrid/trongrid-adapters.test.js.map +1 -1
- package/lib-es/types/assets.d.ts +1 -11
- package/lib-es/types/assets.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/api/index.integ.test.ts +1 -2
- package/src/api/index.test.ts +4 -6
- package/src/api/index.ts +5 -7
- package/src/bridge/getEstimateFees.ts +5 -6
- package/src/logic/craftTransaction.integ.test.ts +11 -16
- package/src/logic/craftTransaction.test.ts +15 -20
- package/src/logic/craftTransaction.ts +11 -11
- package/src/logic/estimateFees.test.ts +7 -10
- package/src/logic/estimateFees.ts +3 -3
- package/src/logic/getBalance.integ.test.ts +4 -1
- package/src/logic/getBalance.test.ts +60 -20
- package/src/logic/getBalance.ts +12 -15
- package/src/logic/listOperations.integ.test.ts +12 -17
- package/src/logic/listOperations.ts +1 -2
- package/src/logic/listOperations.unit.test.ts +5 -5
- package/src/network/trongrid/trongrid-adapters.test.ts +1 -1
- package/src/network/trongrid/trongrid-adapters.ts +8 -10
- package/src/types/assets.ts +1 -13
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { defaultOptions, listOperations, Options } from "./listOperations";
|
|
2
2
|
import coinConfig from "../config";
|
|
3
3
|
import { Operation } from "@ledgerhq/coin-framework/api/types";
|
|
4
|
-
import { TronAsset } from "../types";
|
|
5
4
|
|
|
6
5
|
describe("listOperations", () => {
|
|
7
6
|
beforeAll(() => {
|
|
@@ -18,7 +17,7 @@ describe("listOperations", () => {
|
|
|
18
17
|
describe("Account TRqkRnAj6ceJFYAn2p1eE7aWrgBBwtdhS9 with minHeight", () => {
|
|
19
18
|
// https://tronscan.org/#/address/TRqkRnAj6ceJFYAn2p1eE7aWrgBBwtdhS9
|
|
20
19
|
|
|
21
|
-
let operations: Operation
|
|
20
|
+
let operations: Operation[];
|
|
22
21
|
|
|
23
22
|
const testingAccount = "TRqkRnAj6ceJFYAn2p1eE7aWrgBBwtdhS9";
|
|
24
23
|
|
|
@@ -44,7 +43,7 @@ describe("listOperations", () => {
|
|
|
44
43
|
describe("Account TRRYfGVrzuUvJYRe9UaA8KqxjgVSwU9m6L withe more than 15k+ txs, with minHeight 0 / order asc / softLimit 2", () => {
|
|
45
44
|
// https://tronscan.org/#/address/TRRYfGVrzuUvJYRe9UaA8KqxjgVSwU9m6L
|
|
46
45
|
|
|
47
|
-
let operations: Operation
|
|
46
|
+
let operations: Operation[];
|
|
48
47
|
|
|
49
48
|
const testingAccount = "TRRYfGVrzuUvJYRe9UaA8KqxjgVSwU9m6L";
|
|
50
49
|
|
|
@@ -77,7 +76,7 @@ describe("listOperations", () => {
|
|
|
77
76
|
describe("Account TRRYfGVrzuUvJYRe9UaA8KqxjgVSwU9m6L withe more than 15k+ txs, with minHeight / order asc / softLimit 2", () => {
|
|
78
77
|
// https://tronscan.org/#/address/TRRYfGVrzuUvJYRe9UaA8KqxjgVSwU9m6L
|
|
79
78
|
|
|
80
|
-
let operations: Operation
|
|
79
|
+
let operations: Operation[];
|
|
81
80
|
|
|
82
81
|
const testingAccount = "TRRYfGVrzuUvJYRe9UaA8KqxjgVSwU9m6L";
|
|
83
82
|
|
|
@@ -117,7 +116,7 @@ describe("listOperations", () => {
|
|
|
117
116
|
// 255 as of 17/02/2025
|
|
118
117
|
const historySize = 255;
|
|
119
118
|
|
|
120
|
-
let operations: Operation
|
|
119
|
+
let operations: Operation[];
|
|
121
120
|
|
|
122
121
|
const testingAccount = "TRqkRnAj6ceJFYAn2p1eE7aWrgBBwtdhS9";
|
|
123
122
|
|
|
@@ -223,9 +222,8 @@ describe("listOperations", () => {
|
|
|
223
222
|
recipients: [testingAccount],
|
|
224
223
|
senders: ["TWBEcQ57vbFSEhrQCvsHLDuSb39wprpsEX"],
|
|
225
224
|
asset: {
|
|
226
|
-
type: "
|
|
227
|
-
|
|
228
|
-
tokenId: "1004031",
|
|
225
|
+
type: "trc10",
|
|
226
|
+
assetReference: "1004031",
|
|
229
227
|
},
|
|
230
228
|
});
|
|
231
229
|
});
|
|
@@ -240,9 +238,8 @@ describe("listOperations", () => {
|
|
|
240
238
|
senders: [testingAccount],
|
|
241
239
|
recipients: ["TVKG4gUar24bpAVrDv4GSzyDRtPkjPkogL"],
|
|
242
240
|
asset: {
|
|
243
|
-
type: "
|
|
244
|
-
|
|
245
|
-
tokenId: "1002000",
|
|
241
|
+
type: "trc10",
|
|
242
|
+
assetReference: "1002000",
|
|
246
243
|
},
|
|
247
244
|
});
|
|
248
245
|
});
|
|
@@ -260,9 +257,8 @@ describe("listOperations", () => {
|
|
|
260
257
|
senders: ["TUgU8FRUFSUfxTAoSPsaUBzJgSwpUuJs9N"],
|
|
261
258
|
recipients: [testingAccount],
|
|
262
259
|
asset: {
|
|
263
|
-
type: "
|
|
264
|
-
|
|
265
|
-
contractAddress: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
|
260
|
+
type: "trc20",
|
|
261
|
+
assetReference: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
|
266
262
|
},
|
|
267
263
|
});
|
|
268
264
|
});
|
|
@@ -278,9 +274,8 @@ describe("listOperations", () => {
|
|
|
278
274
|
senders: [testingAccount],
|
|
279
275
|
recipients: ["TLAhq1ds7UR339t48TpzYcJWtfGnXk1KzX"],
|
|
280
276
|
asset: {
|
|
281
|
-
type: "
|
|
282
|
-
|
|
283
|
-
contractAddress: "TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7",
|
|
277
|
+
type: "trc20",
|
|
278
|
+
assetReference: "TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7",
|
|
284
279
|
},
|
|
285
280
|
});
|
|
286
281
|
});
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
getBlock,
|
|
7
7
|
} from "../network";
|
|
8
8
|
import { fromTrongridTxInfoToOperation } from "../network/trongrid/trongrid-adapters";
|
|
9
|
-
import { TronAsset } from "../types";
|
|
10
9
|
|
|
11
10
|
export type Options = {
|
|
12
11
|
// the soft limit is an indicative number of transactions to fetch
|
|
@@ -27,7 +26,7 @@ export const defaultOptions: Options = {
|
|
|
27
26
|
export async function listOperations(
|
|
28
27
|
address: string,
|
|
29
28
|
options: Options,
|
|
30
|
-
): Promise<[Operation
|
|
29
|
+
): Promise<[Operation[], string]> {
|
|
31
30
|
// there is a possible optimisation here: when height is 0, set the minTimestamp to 0
|
|
32
31
|
const block = await getBlock(options.minHeight);
|
|
33
32
|
const minTimestamp = block.time?.getTime() ?? defaultFetchParams.minTimestamp;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import { defaultFetchParams, fetchTronAccountTxs, getBlock } from "../network";
|
|
3
3
|
import { fromTrongridTxInfoToOperation } from "../network/trongrid/trongrid-adapters";
|
|
4
|
-
import { TrongridTxInfo
|
|
4
|
+
import { TrongridTxInfo } from "../types";
|
|
5
5
|
import { defaultOptions, listOperations } from "./listOperations";
|
|
6
6
|
import type { Operation } from "@ledgerhq/coin-framework/api/index";
|
|
7
7
|
|
|
@@ -40,9 +40,9 @@ describe("listOperations", () => {
|
|
|
40
40
|
{ txID: "tx2", value: new BigNumber(42) },
|
|
41
41
|
];
|
|
42
42
|
|
|
43
|
-
const expectedOperations: Partial<Operation
|
|
44
|
-
{ tx: { hash: "tx1" } as Partial<Operation
|
|
45
|
-
{ tx: { hash: "tx2" } as Partial<Operation
|
|
43
|
+
const expectedOperations: Partial<Operation>[] = [
|
|
44
|
+
{ tx: { hash: "tx1" } as Partial<Operation>["tx"], value: BigInt(0) },
|
|
45
|
+
{ tx: { hash: "tx2" } as Partial<Operation>["tx"], value: BigInt(42) },
|
|
46
46
|
];
|
|
47
47
|
|
|
48
48
|
(fetchTronAccountTxs as jest.Mock).mockResolvedValue(mockTxs);
|
|
@@ -68,7 +68,7 @@ describe("listOperations", () => {
|
|
|
68
68
|
|
|
69
69
|
it("should handle empty transactions", async () => {
|
|
70
70
|
const mockTxs: Partial<TrongridTxInfo>[] = [];
|
|
71
|
-
const expectedOperations: Partial<Operation
|
|
71
|
+
const expectedOperations: Partial<Operation>[] = [];
|
|
72
72
|
|
|
73
73
|
(fetchTronAccountTxs as jest.Mock).mockResolvedValue(mockTxs);
|
|
74
74
|
(fromTrongridTxInfoToOperation as jest.Mock).mockImplementation(() => null);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Operation } from "@ledgerhq/coin-framework/api/types";
|
|
1
|
+
import { AssetInfo, Operation } from "@ledgerhq/coin-framework/api/types";
|
|
2
2
|
import { fromBigNumberToBigInt } from "@ledgerhq/coin-framework/utils";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TrongridTxInfo } from "../../types";
|
|
4
4
|
|
|
5
5
|
export function fromTrongridTxInfoToOperation(
|
|
6
6
|
trongridTxInfo: TrongridTxInfo,
|
|
7
7
|
userAddress: string,
|
|
8
|
-
): Operation
|
|
8
|
+
): Operation {
|
|
9
9
|
return {
|
|
10
10
|
id: trongridTxInfo.txID,
|
|
11
11
|
tx: {
|
|
@@ -35,21 +35,19 @@ function inferOperationType(trongridTxInfo: TrongridTxInfo, userAddress: string)
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function inferAssetInfo(trongridTxInfo: TrongridTxInfo):
|
|
38
|
+
function inferAssetInfo(trongridTxInfo: TrongridTxInfo): AssetInfo {
|
|
39
39
|
switch (true) {
|
|
40
40
|
case trongridTxInfo.tokenType === "trc10":
|
|
41
41
|
return {
|
|
42
|
-
type: "
|
|
43
|
-
standard: "trc10",
|
|
42
|
+
type: "trc10",
|
|
44
43
|
// if tokenType is trc10, tokenId is always defined
|
|
45
|
-
|
|
44
|
+
assetReference: trongridTxInfo.tokenId as string,
|
|
46
45
|
};
|
|
47
46
|
case trongridTxInfo.tokenType === "trc20":
|
|
48
47
|
return {
|
|
49
|
-
type: "
|
|
50
|
-
standard: "trc20",
|
|
48
|
+
type: "trc20",
|
|
51
49
|
// if tokenType is trc20, contractAddress is always defined
|
|
52
|
-
|
|
50
|
+
assetReference: trongridTxInfo.tokenAddress as string,
|
|
53
51
|
};
|
|
54
52
|
default:
|
|
55
53
|
return { type: "native" };
|
package/src/types/assets.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StringMemo } from "@ledgerhq/coin-framework/api/types";
|
|
2
2
|
import { MemoNotSupported } from "@ledgerhq/coin-framework/lib-es/api/types";
|
|
3
3
|
|
|
4
|
-
export type TronToken = Trc10Token | Trc20Token;
|
|
5
|
-
export type TronAsset = Asset<TronToken>;
|
|
6
|
-
|
|
7
4
|
/*
|
|
8
5
|
TRC10 tokens use a standard implementation on the protocol level.
|
|
9
6
|
They are identified by a tokenId and do not require a smart contract.
|
|
@@ -16,11 +13,6 @@ export type TronAsset = Asset<TronToken>;
|
|
|
16
13
|
tokenId: "1002000",
|
|
17
14
|
}
|
|
18
15
|
*/
|
|
19
|
-
export type Trc10Token = {
|
|
20
|
-
standard: "trc10";
|
|
21
|
-
tokenId: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
16
|
/*
|
|
25
17
|
TRC20 tokens are smart contracts that implement the TRC20 interface.
|
|
26
18
|
|
|
@@ -30,10 +22,6 @@ export type Trc10Token = {
|
|
|
30
22
|
contractAddress: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
|
31
23
|
}
|
|
32
24
|
*/
|
|
33
|
-
export type Trc20Token = {
|
|
34
|
-
standard: "trc20";
|
|
35
|
-
contractAddress: string;
|
|
36
|
-
};
|
|
37
25
|
|
|
38
26
|
// Since memo is not always present and depends on transaction type (e.g. not allowed for TRC20):
|
|
39
27
|
export type TronMemo = MemoNotSupported | StringMemo<"memo">;
|