@ledgerhq/coin-tron 4.5.0 → 5.0.0-nightly.3

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.
Files changed (111) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +27 -20
  3. package/lib/api/index.d.ts +2 -2
  4. package/lib/api/index.d.ts.map +1 -1
  5. package/lib/api/index.integ.test.js.map +1 -1
  6. package/lib/api/index.js.map +1 -1
  7. package/lib/api/index.test.js +2 -3
  8. package/lib/api/index.test.js.map +1 -1
  9. package/lib/bridge/getEstimateFees.d.ts.map +1 -1
  10. package/lib/bridge/getEstimateFees.js +3 -4
  11. package/lib/bridge/getEstimateFees.js.map +1 -1
  12. package/lib/logic/craftTransaction.d.ts +3 -3
  13. package/lib/logic/craftTransaction.d.ts.map +1 -1
  14. package/lib/logic/craftTransaction.integ.test.js +11 -16
  15. package/lib/logic/craftTransaction.integ.test.js.map +1 -1
  16. package/lib/logic/craftTransaction.js +6 -5
  17. package/lib/logic/craftTransaction.js.map +1 -1
  18. package/lib/logic/craftTransaction.test.js +10 -14
  19. package/lib/logic/craftTransaction.test.js.map +1 -1
  20. package/lib/logic/estimateFees.d.ts +2 -2
  21. package/lib/logic/estimateFees.d.ts.map +1 -1
  22. package/lib/logic/estimateFees.js +1 -1
  23. package/lib/logic/estimateFees.js.map +1 -1
  24. package/lib/logic/estimateFees.test.js +4 -6
  25. package/lib/logic/estimateFees.test.js.map +1 -1
  26. package/lib/logic/getBalance.d.ts +3 -4
  27. package/lib/logic/getBalance.d.ts.map +1 -1
  28. package/lib/logic/getBalance.integ.test.js +4 -1
  29. package/lib/logic/getBalance.integ.test.js.map +1 -1
  30. package/lib/logic/getBalance.js +4 -6
  31. package/lib/logic/getBalance.js.map +1 -1
  32. package/lib/logic/getBalance.test.js +60 -20
  33. package/lib/logic/getBalance.test.js.map +1 -1
  34. package/lib/logic/listOperations.d.ts +1 -2
  35. package/lib/logic/listOperations.d.ts.map +1 -1
  36. package/lib/logic/listOperations.integ.test.js +8 -12
  37. package/lib/logic/listOperations.integ.test.js.map +1 -1
  38. package/lib/logic/listOperations.js.map +1 -1
  39. package/lib/logic/listOperations.unit.test.js.map +1 -1
  40. package/lib/network/trongrid/trongrid-adapters.d.ts +2 -2
  41. package/lib/network/trongrid/trongrid-adapters.d.ts.map +1 -1
  42. package/lib/network/trongrid/trongrid-adapters.js +4 -6
  43. package/lib/network/trongrid/trongrid-adapters.js.map +1 -1
  44. package/lib/network/trongrid/trongrid-adapters.test.js +1 -1
  45. package/lib/network/trongrid/trongrid-adapters.test.js.map +1 -1
  46. package/lib/types/assets.d.ts +1 -11
  47. package/lib/types/assets.d.ts.map +1 -1
  48. package/lib-es/api/index.d.ts +2 -2
  49. package/lib-es/api/index.d.ts.map +1 -1
  50. package/lib-es/api/index.integ.test.js.map +1 -1
  51. package/lib-es/api/index.js.map +1 -1
  52. package/lib-es/api/index.test.js +2 -3
  53. package/lib-es/api/index.test.js.map +1 -1
  54. package/lib-es/bridge/getEstimateFees.d.ts.map +1 -1
  55. package/lib-es/bridge/getEstimateFees.js +3 -4
  56. package/lib-es/bridge/getEstimateFees.js.map +1 -1
  57. package/lib-es/logic/craftTransaction.d.ts +3 -3
  58. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  59. package/lib-es/logic/craftTransaction.integ.test.js +11 -16
  60. package/lib-es/logic/craftTransaction.integ.test.js.map +1 -1
  61. package/lib-es/logic/craftTransaction.js +6 -5
  62. package/lib-es/logic/craftTransaction.js.map +1 -1
  63. package/lib-es/logic/craftTransaction.test.js +10 -14
  64. package/lib-es/logic/craftTransaction.test.js.map +1 -1
  65. package/lib-es/logic/estimateFees.d.ts +2 -2
  66. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  67. package/lib-es/logic/estimateFees.js +1 -1
  68. package/lib-es/logic/estimateFees.js.map +1 -1
  69. package/lib-es/logic/estimateFees.test.js +4 -6
  70. package/lib-es/logic/estimateFees.test.js.map +1 -1
  71. package/lib-es/logic/getBalance.d.ts +3 -4
  72. package/lib-es/logic/getBalance.d.ts.map +1 -1
  73. package/lib-es/logic/getBalance.integ.test.js +4 -1
  74. package/lib-es/logic/getBalance.integ.test.js.map +1 -1
  75. package/lib-es/logic/getBalance.js +4 -6
  76. package/lib-es/logic/getBalance.js.map +1 -1
  77. package/lib-es/logic/getBalance.test.js +60 -20
  78. package/lib-es/logic/getBalance.test.js.map +1 -1
  79. package/lib-es/logic/listOperations.d.ts +1 -2
  80. package/lib-es/logic/listOperations.d.ts.map +1 -1
  81. package/lib-es/logic/listOperations.integ.test.js +8 -12
  82. package/lib-es/logic/listOperations.integ.test.js.map +1 -1
  83. package/lib-es/logic/listOperations.js.map +1 -1
  84. package/lib-es/logic/listOperations.unit.test.js.map +1 -1
  85. package/lib-es/network/trongrid/trongrid-adapters.d.ts +2 -2
  86. package/lib-es/network/trongrid/trongrid-adapters.d.ts.map +1 -1
  87. package/lib-es/network/trongrid/trongrid-adapters.js +4 -6
  88. package/lib-es/network/trongrid/trongrid-adapters.js.map +1 -1
  89. package/lib-es/network/trongrid/trongrid-adapters.test.js +1 -1
  90. package/lib-es/network/trongrid/trongrid-adapters.test.js.map +1 -1
  91. package/lib-es/types/assets.d.ts +1 -11
  92. package/lib-es/types/assets.d.ts.map +1 -1
  93. package/package.json +8 -8
  94. package/src/api/index.integ.test.ts +1 -2
  95. package/src/api/index.test.ts +4 -6
  96. package/src/api/index.ts +5 -7
  97. package/src/bridge/getEstimateFees.ts +5 -6
  98. package/src/logic/craftTransaction.integ.test.ts +11 -16
  99. package/src/logic/craftTransaction.test.ts +15 -20
  100. package/src/logic/craftTransaction.ts +11 -11
  101. package/src/logic/estimateFees.test.ts +7 -10
  102. package/src/logic/estimateFees.ts +3 -3
  103. package/src/logic/getBalance.integ.test.ts +4 -1
  104. package/src/logic/getBalance.test.ts +60 -20
  105. package/src/logic/getBalance.ts +12 -15
  106. package/src/logic/listOperations.integ.test.ts +12 -17
  107. package/src/logic/listOperations.ts +1 -2
  108. package/src/logic/listOperations.unit.test.ts +5 -5
  109. package/src/network/trongrid/trongrid-adapters.test.ts +1 -1
  110. package/src/network/trongrid/trongrid-adapters.ts +8 -10
  111. 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<TronAsset>[];
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<TronAsset>[];
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<TronAsset>[];
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<TronAsset>[];
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: "token",
227
- standard: "trc10",
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: "token",
244
- standard: "trc10",
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: "token",
264
- standard: "trc20",
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: "token",
282
- standard: "trc20",
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<TronAsset>[], string]> {
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, TronAsset } from "../types";
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<TronAsset>>[] = [
44
- { tx: { hash: "tx1" } as Partial<Operation<TronAsset>>["tx"], value: BigInt(0) },
45
- { tx: { hash: "tx2" } as Partial<Operation<TronAsset>>["tx"], value: BigInt(42) },
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<TronAsset>>[] = [];
71
+ const expectedOperations: Partial<Operation>[] = [];
72
72
 
73
73
  (fetchTronAccountTxs as jest.Mock).mockResolvedValue(mockTxs);
74
74
  (fromTrongridTxInfoToOperation as jest.Mock).mockImplementation(() => null);
@@ -44,7 +44,7 @@ describe("fromTrongridTxInfoToOperation", () => {
44
44
  value: BigInt(5000),
45
45
  senders: ["from"],
46
46
  recipients: ["to"],
47
- asset: { standard: "trc20", contractAddress: "boo", type: "token" },
47
+ asset: { type: "trc20", assetReference: "boo" },
48
48
  });
49
49
  });
50
50
 
@@ -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 { TronAsset, TrongridTxInfo } from "../../types";
3
+ import type { TrongridTxInfo } from "../../types";
4
4
 
5
5
  export function fromTrongridTxInfoToOperation(
6
6
  trongridTxInfo: TrongridTxInfo,
7
7
  userAddress: string,
8
- ): Operation<TronAsset> {
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): TronAsset {
38
+ function inferAssetInfo(trongridTxInfo: TrongridTxInfo): AssetInfo {
39
39
  switch (true) {
40
40
  case trongridTxInfo.tokenType === "trc10":
41
41
  return {
42
- type: "token",
43
- standard: "trc10",
42
+ type: "trc10",
44
43
  // if tokenType is trc10, tokenId is always defined
45
- tokenId: trongridTxInfo.tokenId as string,
44
+ assetReference: trongridTxInfo.tokenId as string,
46
45
  };
47
46
  case trongridTxInfo.tokenType === "trc20":
48
47
  return {
49
- type: "token",
50
- standard: "trc20",
48
+ type: "trc20",
51
49
  // if tokenType is trc20, contractAddress is always defined
52
- contractAddress: trongridTxInfo.tokenAddress as string,
50
+ assetReference: trongridTxInfo.tokenAddress as string,
53
51
  };
54
52
  default:
55
53
  return { type: "native" };
@@ -1,9 +1,6 @@
1
- import { Asset, StringMemo } from "@ledgerhq/coin-framework/api/types";
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">;