@ledgerhq/coin-tron 4.5.0 → 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.
Files changed (110) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/api/index.d.ts +2 -2
  3. package/lib/api/index.d.ts.map +1 -1
  4. package/lib/api/index.integ.test.js.map +1 -1
  5. package/lib/api/index.js.map +1 -1
  6. package/lib/api/index.test.js +2 -3
  7. package/lib/api/index.test.js.map +1 -1
  8. package/lib/bridge/getEstimateFees.d.ts.map +1 -1
  9. package/lib/bridge/getEstimateFees.js +3 -4
  10. package/lib/bridge/getEstimateFees.js.map +1 -1
  11. package/lib/logic/craftTransaction.d.ts +3 -3
  12. package/lib/logic/craftTransaction.d.ts.map +1 -1
  13. package/lib/logic/craftTransaction.integ.test.js +11 -16
  14. package/lib/logic/craftTransaction.integ.test.js.map +1 -1
  15. package/lib/logic/craftTransaction.js +6 -5
  16. package/lib/logic/craftTransaction.js.map +1 -1
  17. package/lib/logic/craftTransaction.test.js +10 -14
  18. package/lib/logic/craftTransaction.test.js.map +1 -1
  19. package/lib/logic/estimateFees.d.ts +2 -2
  20. package/lib/logic/estimateFees.d.ts.map +1 -1
  21. package/lib/logic/estimateFees.js +1 -1
  22. package/lib/logic/estimateFees.js.map +1 -1
  23. package/lib/logic/estimateFees.test.js +4 -6
  24. package/lib/logic/estimateFees.test.js.map +1 -1
  25. package/lib/logic/getBalance.d.ts +3 -4
  26. package/lib/logic/getBalance.d.ts.map +1 -1
  27. package/lib/logic/getBalance.integ.test.js +4 -1
  28. package/lib/logic/getBalance.integ.test.js.map +1 -1
  29. package/lib/logic/getBalance.js +4 -6
  30. package/lib/logic/getBalance.js.map +1 -1
  31. package/lib/logic/getBalance.test.js +60 -20
  32. package/lib/logic/getBalance.test.js.map +1 -1
  33. package/lib/logic/listOperations.d.ts +1 -2
  34. package/lib/logic/listOperations.d.ts.map +1 -1
  35. package/lib/logic/listOperations.integ.test.js +8 -12
  36. package/lib/logic/listOperations.integ.test.js.map +1 -1
  37. package/lib/logic/listOperations.js.map +1 -1
  38. package/lib/logic/listOperations.unit.test.js.map +1 -1
  39. package/lib/network/trongrid/trongrid-adapters.d.ts +2 -2
  40. package/lib/network/trongrid/trongrid-adapters.d.ts.map +1 -1
  41. package/lib/network/trongrid/trongrid-adapters.js +4 -6
  42. package/lib/network/trongrid/trongrid-adapters.js.map +1 -1
  43. package/lib/network/trongrid/trongrid-adapters.test.js +1 -1
  44. package/lib/network/trongrid/trongrid-adapters.test.js.map +1 -1
  45. package/lib/types/assets.d.ts +1 -11
  46. package/lib/types/assets.d.ts.map +1 -1
  47. package/lib-es/api/index.d.ts +2 -2
  48. package/lib-es/api/index.d.ts.map +1 -1
  49. package/lib-es/api/index.integ.test.js.map +1 -1
  50. package/lib-es/api/index.js.map +1 -1
  51. package/lib-es/api/index.test.js +2 -3
  52. package/lib-es/api/index.test.js.map +1 -1
  53. package/lib-es/bridge/getEstimateFees.d.ts.map +1 -1
  54. package/lib-es/bridge/getEstimateFees.js +3 -4
  55. package/lib-es/bridge/getEstimateFees.js.map +1 -1
  56. package/lib-es/logic/craftTransaction.d.ts +3 -3
  57. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  58. package/lib-es/logic/craftTransaction.integ.test.js +11 -16
  59. package/lib-es/logic/craftTransaction.integ.test.js.map +1 -1
  60. package/lib-es/logic/craftTransaction.js +6 -5
  61. package/lib-es/logic/craftTransaction.js.map +1 -1
  62. package/lib-es/logic/craftTransaction.test.js +10 -14
  63. package/lib-es/logic/craftTransaction.test.js.map +1 -1
  64. package/lib-es/logic/estimateFees.d.ts +2 -2
  65. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  66. package/lib-es/logic/estimateFees.js +1 -1
  67. package/lib-es/logic/estimateFees.js.map +1 -1
  68. package/lib-es/logic/estimateFees.test.js +4 -6
  69. package/lib-es/logic/estimateFees.test.js.map +1 -1
  70. package/lib-es/logic/getBalance.d.ts +3 -4
  71. package/lib-es/logic/getBalance.d.ts.map +1 -1
  72. package/lib-es/logic/getBalance.integ.test.js +4 -1
  73. package/lib-es/logic/getBalance.integ.test.js.map +1 -1
  74. package/lib-es/logic/getBalance.js +4 -6
  75. package/lib-es/logic/getBalance.js.map +1 -1
  76. package/lib-es/logic/getBalance.test.js +60 -20
  77. package/lib-es/logic/getBalance.test.js.map +1 -1
  78. package/lib-es/logic/listOperations.d.ts +1 -2
  79. package/lib-es/logic/listOperations.d.ts.map +1 -1
  80. package/lib-es/logic/listOperations.integ.test.js +8 -12
  81. package/lib-es/logic/listOperations.integ.test.js.map +1 -1
  82. package/lib-es/logic/listOperations.js.map +1 -1
  83. package/lib-es/logic/listOperations.unit.test.js.map +1 -1
  84. package/lib-es/network/trongrid/trongrid-adapters.d.ts +2 -2
  85. package/lib-es/network/trongrid/trongrid-adapters.d.ts.map +1 -1
  86. package/lib-es/network/trongrid/trongrid-adapters.js +4 -6
  87. package/lib-es/network/trongrid/trongrid-adapters.js.map +1 -1
  88. package/lib-es/network/trongrid/trongrid-adapters.test.js +1 -1
  89. package/lib-es/network/trongrid/trongrid-adapters.test.js.map +1 -1
  90. package/lib-es/types/assets.d.ts +1 -11
  91. package/lib-es/types/assets.d.ts.map +1 -1
  92. package/package.json +7 -7
  93. package/src/api/index.integ.test.ts +1 -2
  94. package/src/api/index.test.ts +4 -6
  95. package/src/api/index.ts +5 -7
  96. package/src/bridge/getEstimateFees.ts +5 -6
  97. package/src/logic/craftTransaction.integ.test.ts +11 -16
  98. package/src/logic/craftTransaction.test.ts +15 -20
  99. package/src/logic/craftTransaction.ts +11 -11
  100. package/src/logic/estimateFees.test.ts +7 -10
  101. package/src/logic/estimateFees.ts +3 -3
  102. package/src/logic/getBalance.integ.test.ts +4 -1
  103. package/src/logic/getBalance.test.ts +60 -20
  104. package/src/logic/getBalance.ts +12 -15
  105. package/src/logic/listOperations.integ.test.ts +12 -17
  106. package/src/logic/listOperations.ts +1 -2
  107. package/src/logic/listOperations.unit.test.ts +5 -5
  108. package/src/network/trongrid/trongrid-adapters.test.ts +1 -1
  109. package/src/network/trongrid/trongrid-adapters.ts +8 -10
  110. package/src/types/assets.ts +1 -13
@@ -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">;