@ledgerhq/coin-sui 0.7.1-nightly.1 → 0.8.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 (100) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +2 -1
  3. package/CHANGELOG.md +24 -0
  4. package/lib/api/index.d.ts +2 -3
  5. package/lib/api/index.d.ts.map +1 -1
  6. package/lib/api/index.integration.test.d.ts +1 -0
  7. package/lib/api/index.integration.test.js +98 -105
  8. package/lib/api/index.integration.test.js.map +1 -1
  9. package/lib/api/index.js.map +1 -1
  10. package/lib/bridge/buildTransaction.d.ts.map +1 -1
  11. package/lib/bridge/buildTransaction.js +11 -2
  12. package/lib/bridge/buildTransaction.js.map +1 -1
  13. package/lib/bridge/buildTransaction.test.js +0 -2
  14. package/lib/bridge/buildTransaction.test.js.map +1 -1
  15. package/lib/logic/craftTransaction.d.ts +1 -4
  16. package/lib/logic/craftTransaction.d.ts.map +1 -1
  17. package/lib/logic/craftTransaction.js +6 -2
  18. package/lib/logic/craftTransaction.js.map +1 -1
  19. package/lib/logic/estimateFees.d.ts +1 -2
  20. package/lib/logic/estimateFees.d.ts.map +1 -1
  21. package/lib/logic/estimateFees.js.map +1 -1
  22. package/lib/logic/getBalance.d.ts +1 -2
  23. package/lib/logic/getBalance.d.ts.map +1 -1
  24. package/lib/logic/getBalance.js.map +1 -1
  25. package/lib/logic/getBlock.d.ts +1 -2
  26. package/lib/logic/getBlock.d.ts.map +1 -1
  27. package/lib/logic/getBlock.js.map +1 -1
  28. package/lib/logic/listOperations.d.ts +1 -2
  29. package/lib/logic/listOperations.d.ts.map +1 -1
  30. package/lib/logic/listOperations.js.map +1 -1
  31. package/lib/logic/listOperations.test.js.map +1 -1
  32. package/lib/network/sdk.d.ts +7 -8
  33. package/lib/network/sdk.d.ts.map +1 -1
  34. package/lib/network/sdk.integration.test.d.ts +1 -0
  35. package/lib/network/sdk.integration.test.js +212 -224
  36. package/lib/network/sdk.integration.test.js.map +1 -1
  37. package/lib/network/sdk.js +1 -1
  38. package/lib/network/sdk.js.map +1 -1
  39. package/lib/network/sdk.test.js +4 -4
  40. package/lib/network/sdk.test.js.map +1 -1
  41. package/lib-es/api/index.d.ts +2 -3
  42. package/lib-es/api/index.d.ts.map +1 -1
  43. package/lib-es/api/index.integration.test.d.ts +1 -0
  44. package/lib-es/api/index.integration.test.js +97 -106
  45. package/lib-es/api/index.integration.test.js.map +1 -1
  46. package/lib-es/api/index.js.map +1 -1
  47. package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
  48. package/lib-es/bridge/buildTransaction.js +11 -2
  49. package/lib-es/bridge/buildTransaction.js.map +1 -1
  50. package/lib-es/bridge/buildTransaction.test.js +0 -2
  51. package/lib-es/bridge/buildTransaction.test.js.map +1 -1
  52. package/lib-es/logic/craftTransaction.d.ts +1 -4
  53. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  54. package/lib-es/logic/craftTransaction.js +6 -2
  55. package/lib-es/logic/craftTransaction.js.map +1 -1
  56. package/lib-es/logic/estimateFees.d.ts +1 -2
  57. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  58. package/lib-es/logic/estimateFees.js.map +1 -1
  59. package/lib-es/logic/getBalance.d.ts +1 -2
  60. package/lib-es/logic/getBalance.d.ts.map +1 -1
  61. package/lib-es/logic/getBalance.js.map +1 -1
  62. package/lib-es/logic/getBlock.d.ts +1 -2
  63. package/lib-es/logic/getBlock.d.ts.map +1 -1
  64. package/lib-es/logic/getBlock.js.map +1 -1
  65. package/lib-es/logic/listOperations.d.ts +1 -2
  66. package/lib-es/logic/listOperations.d.ts.map +1 -1
  67. package/lib-es/logic/listOperations.js.map +1 -1
  68. package/lib-es/logic/listOperations.test.js.map +1 -1
  69. package/lib-es/network/sdk.d.ts +7 -8
  70. package/lib-es/network/sdk.d.ts.map +1 -1
  71. package/lib-es/network/sdk.integration.test.d.ts +1 -0
  72. package/lib-es/network/sdk.integration.test.js +208 -225
  73. package/lib-es/network/sdk.integration.test.js.map +1 -1
  74. package/lib-es/network/sdk.js +1 -1
  75. package/lib-es/network/sdk.js.map +1 -1
  76. package/lib-es/network/sdk.test.js +4 -4
  77. package/lib-es/network/sdk.test.js.map +1 -1
  78. package/package.json +6 -8
  79. package/src/api/index.integration.test.ts +115 -123
  80. package/src/api/index.ts +5 -9
  81. package/src/bridge/buildTransaction.test.ts +0 -2
  82. package/src/bridge/buildTransaction.ts +12 -2
  83. package/src/logic/craftTransaction.ts +7 -4
  84. package/src/logic/estimateFees.ts +1 -2
  85. package/src/logic/getBalance.ts +1 -2
  86. package/src/logic/getBlock.ts +1 -2
  87. package/src/logic/listOperations.test.ts +1 -2
  88. package/src/logic/listOperations.ts +1 -2
  89. package/src/network/sdk.integration.test.ts +238 -244
  90. package/src/network/sdk.test.ts +4 -4
  91. package/src/network/sdk.ts +8 -13
  92. package/lib/api/types.d.ts +0 -6
  93. package/lib/api/types.d.ts.map +0 -1
  94. package/lib/api/types.js +0 -3
  95. package/lib/api/types.js.map +0 -1
  96. package/lib-es/api/types.d.ts +0 -6
  97. package/lib-es/api/types.d.ts.map +0 -1
  98. package/lib-es/api/types.js +0 -2
  99. package/lib-es/api/types.js.map +0 -1
  100. package/src/api/types.ts +0 -7
@@ -1,6 +1,5 @@
1
1
  import { Block, BlockInfo } from "@ledgerhq/coin-framework/lib/api/types";
2
2
  import { getBlock as sdkGetBlock, getBlockInfo as sdkGetBlockInfo } from "../network/sdk";
3
- import { SuiAsset } from "../api/types";
4
3
 
5
4
  /**
6
5
  * Get a checkpoint (a.k.a, a block) metadata only.
@@ -18,6 +17,6 @@ export async function getBlockInfo(height: number): Promise<BlockInfo> {
18
17
  * @param height the checkpoint sequence number
19
18
  * @see {@link getBlockInfo}
20
19
  */
21
- export async function getBlock(height: number): Promise<Block<SuiAsset>> {
20
+ export async function getBlock(height: number): Promise<Block> {
22
21
  return sdkGetBlock(height.toString());
23
22
  }
@@ -1,11 +1,10 @@
1
1
  import { listOperations } from "./listOperations";
2
2
  import { getListOperations } from "../network/sdk";
3
3
  import { Operation, Pagination } from "@ledgerhq/coin-framework/lib/api/types";
4
- import { SuiAsset } from "../api/types";
5
4
 
6
5
  jest.mock("../network/sdk");
7
6
 
8
- const mockOperations: Operation<SuiAsset>[] = [
7
+ const mockOperations: Operation[] = [
9
8
  {
10
9
  tx: {
11
10
  date: new Date("2024-03-20T10:00:00.000Z"),
@@ -1,11 +1,10 @@
1
1
  import { Operation, Pagination } from "@ledgerhq/coin-framework/lib/api/types";
2
2
  import { getListOperations } from "../network/sdk";
3
- import { SuiAsset } from "../api/types";
4
3
 
5
4
  export const listOperations = async (
6
5
  address: string,
7
6
  { cursor }: Pagination & { cursor?: string },
8
- ): Promise<[Operation<SuiAsset>[], string]> => {
7
+ ): Promise<[Operation[], string]> => {
9
8
  const ops = await getListOperations(address, cursor);
10
9
  return [ops, ops.length ? ops[0].tx.hash : ""];
11
10
  };
@@ -1,246 +1,240 @@
1
- // TODO: re-enable tests once the reverse proxy for SUI is back online
2
- describe("sdk integration test", () => {
3
- it("is disabled", () => {
4
- expect(true).toBeTruthy();
1
+ import BigNumber from "bignumber.js";
2
+ import type { Operation } from "@ledgerhq/types-live";
3
+ import coinConfig from "../config";
4
+ import {
5
+ createTransaction,
6
+ DEFAULT_COIN_TYPE,
7
+ getAccountBalances,
8
+ getOperations,
9
+ getCheckpoint,
10
+ paymentInfo,
11
+ getBlock,
12
+ getBlockInfo,
13
+ } from "./sdk";
14
+ import { getFullnodeUrl } from "@mysten/sui/client";
15
+
16
+ describe("SUI SDK Integration tests", () => {
17
+ beforeAll(() => {
18
+ coinConfig.setCoinConfig(() => ({
19
+ status: {
20
+ type: "active",
21
+ },
22
+ node: {
23
+ url: getFullnodeUrl("mainnet"),
24
+ },
25
+ }));
26
+ });
27
+
28
+ describe("getOperations", () => {
29
+ describe("Account 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164", () => {
30
+ // https://suiscan.xyz/mainnet/account/0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164/activity
31
+
32
+ // 5 as of 14/05/2025
33
+ const IN_OPERATIONS_COUNT = 2;
34
+ const OUT_OPERATIONS_COUNT = 3;
35
+ const TOTAL_OPERATIONS_COUNT = IN_OPERATIONS_COUNT + OUT_OPERATIONS_COUNT;
36
+
37
+ let operations: Operation[];
38
+
39
+ const testingAccount = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
40
+
41
+ beforeAll(async () => {
42
+ operations = await getOperations("mockAccoundId", testingAccount);
43
+ });
44
+
45
+ describe("List", () => {
46
+ it("should fetch operations successfully", async () => {
47
+ expect(Array.isArray(operations)).toBeDefined();
48
+ });
49
+
50
+ it("should fetch all operations", async () => {
51
+ expect(operations.length).toBeGreaterThanOrEqual(TOTAL_OPERATIONS_COUNT);
52
+ });
53
+
54
+ it("should return the first operation at index 0 and the last at the end", async () => {
55
+ const oldestTxHash = "rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg";
56
+ const newestTxHash = "2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7";
57
+ expect(operations[operations.length - TOTAL_OPERATIONS_COUNT].hash).toEqual(newestTxHash);
58
+ expect(operations[operations.length - 1].hash).toEqual(oldestTxHash);
59
+ });
60
+ });
61
+
62
+ describe("Transaction types", () => {
63
+ it("should return correct IN/OUT operations numbers", async () => {
64
+ const inOps = operations.filter(op => op.type === "IN");
65
+ const outOps = operations.filter(op => op.type === "OUT");
66
+ expect(inOps.length).toBeGreaterThanOrEqual(IN_OPERATIONS_COUNT);
67
+ expect(outOps.length).toBeGreaterThanOrEqual(OUT_OPERATIONS_COUNT);
68
+ });
69
+
70
+ describe("SUI operations", () => {
71
+ it("should return SUI IN operations correctly", () => {
72
+ // https://suiscan.xyz/mainnet/tx/rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg
73
+ // Send 0.15 SUI to 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
74
+ const txHash = "rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg";
75
+ const operation = operations.find(op => op.hash === txHash);
76
+ expect(operation).toMatchObject({
77
+ type: "IN",
78
+ value: BigNumber("150000000"),
79
+ senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
80
+ recipients: [testingAccount],
81
+ extra: { coinType: "0x2::sui::SUI" },
82
+ });
83
+ });
84
+ it("should return SUI OUT operations correctly", () => {
85
+ // https://suiscan.xyz/mainnet/tx/CnVCqFLDv9iJc3DPU2WGpJdZUjqFPhyEVJ5BAigEj9VW
86
+ // Get 0.052 SUI from 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
87
+ const txHash = "CnVCqFLDv9iJc3DPU2WGpJdZUjqFPhyEVJ5BAigEj9VW";
88
+ const operation = operations.find(op => op.hash === txHash);
89
+ expect(operation).toMatchObject({
90
+ type: "OUT",
91
+ value: BigNumber("51747880"),
92
+ recipients: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
93
+ senders: [testingAccount],
94
+ extra: { coinType: "0x2::sui::SUI" },
95
+ });
96
+ });
97
+ });
98
+
99
+ describe("SUI tokens operations", () => {
100
+ it("should return SUI tokens IN operations correctly", () => {
101
+ // https://suiscan.xyz/mainnet/tx/B7x8pACzpoFSQ5rmA5T3Q91Q48CroFuerXf62KLaY5TY
102
+ // Send 0.59 USDT to 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
103
+ const txHash = "B7x8pACzpoFSQ5rmA5T3Q91Q48CroFuerXf62KLaY5TY";
104
+ const operation = operations.find(op => op.hash === txHash);
105
+ expect(operation).toMatchObject({
106
+ type: "IN",
107
+ value: BigNumber("592557"),
108
+ senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
109
+ recipients: [testingAccount],
110
+ extra: {
111
+ coinType:
112
+ "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
113
+ },
114
+ });
115
+ });
116
+ it("should return SUI tokens OUT operations correctly", () => {
117
+ // https://suiscan.xyz/mainnet/tx/2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7
118
+ // Get 0.59 USDT from 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
119
+ const txHash = "2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7";
120
+ const operation = operations.find(op => op.hash === txHash);
121
+ expect(operation).toMatchObject({
122
+ type: "OUT",
123
+ value: BigNumber("592557"),
124
+ recipients: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
125
+ senders: [testingAccount],
126
+ extra: {
127
+ coinType:
128
+ "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
129
+ },
130
+ });
131
+ });
132
+ });
133
+ });
134
+ });
135
+ });
136
+
137
+ describe("getBalance", () => {
138
+ test("getAccountBalances should return account balance", async () => {
139
+ const address = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
140
+ const balance = await getAccountBalances(address);
141
+ expect(balance[0]).toHaveProperty("blockHeight");
142
+ expect(balance[0]).toHaveProperty("balance");
143
+ });
144
+ });
145
+
146
+ describe("createTransaction", () => {
147
+ test("createTransaction should build a transaction", async () => {
148
+ const address = "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0";
149
+ const transaction = {
150
+ mode: "send" as const,
151
+ family: "sui" as const,
152
+ coinType: DEFAULT_COIN_TYPE,
153
+ amount: new BigNumber(100),
154
+ recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
155
+ errors: {},
156
+ };
157
+ const tx = await createTransaction(address, transaction);
158
+ expect(tx).toBeInstanceOf(Uint8Array);
159
+ });
5
160
  });
6
- });
7
161
 
8
- // import BigNumber from "bignumber.js";
9
- // import type { Operation } from "@ledgerhq/types-live";
10
- // import { getEnv } from "@ledgerhq/live-env";
11
- // import coinConfig from "../config";
12
- // import {
13
- // createTransaction,
14
- // DEFAULT_COIN_TYPE,
15
- // getAccountBalances,
16
- // getOperations,
17
- // getCheckpoint,
18
- // getCheckpointWithTransactions,
19
- // paymentInfo,
20
- // } from "./sdk";
21
-
22
- // describe("SUI SDK Integration tests", () => {
23
- // beforeAll(() => {
24
- // coinConfig.setCoinConfig(() => ({
25
- // status: {
26
- // type: "active",
27
- // },
28
- // node: {
29
- // url: getEnv("API_SUI_NODE_PROXY"),
30
- // },
31
- // }));
32
- // });
33
-
34
- // describe("getOperations", () => {
35
- // describe("Account 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164", () => {
36
- // // https://suiscan.xyz/mainnet/account/0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164/activity
37
-
38
- // // 5 as of 14/05/2025
39
- // const IN_OPERATIONS_COUNT = 2;
40
- // const OUT_OPERATIONS_COUNT = 3;
41
- // const TOTAL_OPERATIONS_COUNT = IN_OPERATIONS_COUNT + OUT_OPERATIONS_COUNT;
42
-
43
- // let operations: Operation[];
44
-
45
- // const testingAccount = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
46
-
47
- // beforeAll(async () => {
48
- // operations = await getOperations("mockAccoundId", testingAccount);
49
- // });
50
-
51
- // describe("List", () => {
52
- // it("should fetch operations successfully", async () => {
53
- // expect(Array.isArray(operations)).toBeDefined();
54
- // });
55
-
56
- // it("should fetch all operations", async () => {
57
- // expect(operations.length).toBeGreaterThanOrEqual(TOTAL_OPERATIONS_COUNT);
58
- // });
59
-
60
- // it("should return the first operation at index 0 and the last at the end", async () => {
61
- // const oldestTxHash = "rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg";
62
- // const newestTxHash = "2jXqsRSZNHZm4uEfpFxJE7A7RoZxWPZeANfBP4qGWkPR";
63
- // expect(operations[operations.length - TOTAL_OPERATIONS_COUNT].hash).toEqual(newestTxHash);
64
- // expect(operations[operations.length - 1].hash).toEqual(oldestTxHash);
65
- // });
66
- // });
67
-
68
- // describe("Transaction types", () => {
69
- // it("should return correct IN/OUT operations numbers", async () => {
70
- // const inOps = operations.filter(op => op.type === "IN");
71
- // const outOps = operations.filter(op => op.type === "OUT");
72
- // expect(inOps.length).toBeGreaterThanOrEqual(IN_OPERATIONS_COUNT);
73
- // expect(outOps.length).toBeGreaterThanOrEqual(OUT_OPERATIONS_COUNT);
74
- // });
75
-
76
- // describe("SUI operations", () => {
77
- // it("should return SUI IN operations correctly", () => {
78
- // // https://suiscan.xyz/mainnet/tx/rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg
79
- // // Send 0.15 SUI to 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
80
- // const txHash = "rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg";
81
- // const operation = operations.find(op => op.hash === txHash);
82
- // expect(operation).toMatchObject({
83
- // type: "IN",
84
- // value: BigNumber("150000000"),
85
- // senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
86
- // recipients: [testingAccount],
87
- // extra: { coinType: "0x2::sui::SUI" },
88
- // });
89
- // });
90
- // it("should return SUI OUT operations correctly", () => {
91
- // // https://suiscan.xyz/mainnet/tx/CnVCqFLDv9iJc3DPU2WGpJdZUjqFPhyEVJ5BAigEj9VW
92
- // // Get 0.052 SUI from 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
93
- // const txHash = "CnVCqFLDv9iJc3DPU2WGpJdZUjqFPhyEVJ5BAigEj9VW";
94
- // const operation = operations.find(op => op.hash === txHash);
95
- // expect(operation).toMatchObject({
96
- // type: "OUT",
97
- // value: BigNumber("51747880"),
98
- // recipients: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
99
- // senders: [testingAccount],
100
- // extra: { coinType: "0x2::sui::SUI" },
101
- // });
102
- // });
103
- // });
104
-
105
- // describe("SUI tokens operations", () => {
106
- // it("should return SUI tokens IN operations correctly", () => {
107
- // // https://suiscan.xyz/mainnet/tx/B7x8pACzpoFSQ5rmA5T3Q91Q48CroFuerXf62KLaY5TY
108
- // // Send 0.59 USDT to 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
109
- // const txHash = "B7x8pACzpoFSQ5rmA5T3Q91Q48CroFuerXf62KLaY5TY";
110
- // const operation = operations.find(op => op.hash === txHash);
111
- // expect(operation).toMatchObject({
112
- // type: "IN",
113
- // value: BigNumber("592557"),
114
- // senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
115
- // recipients: [testingAccount],
116
- // extra: {
117
- // coinType:
118
- // "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
119
- // },
120
- // });
121
- // });
122
- // it("should return SUI tokens OUT operations correctly", () => {
123
- // // https://suiscan.xyz/mainnet/tx/2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7
124
- // // Get 0.59 USDT from 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
125
- // const txHash = "2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7";
126
- // const operation = operations.find(op => op.hash === txHash);
127
- // expect(operation).toMatchObject({
128
- // type: "OUT",
129
- // value: BigNumber("592557"),
130
- // recipients: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
131
- // senders: [testingAccount],
132
- // extra: {
133
- // coinType:
134
- // "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
135
- // },
136
- // });
137
- // });
138
- // });
139
- // });
140
- // });
141
- // });
142
-
143
- // describe("getBalance", () => {
144
- // test("getAccountBalances should return account balance", async () => {
145
- // const address = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
146
- // const balance = await getAccountBalances(address);
147
- // expect(balance[0]).toHaveProperty("blockHeight");
148
- // expect(balance[0]).toHaveProperty("balance");
149
- // });
150
- // });
151
-
152
- // describe("createTransaction", () => {
153
- // test("createTransaction should build a transaction", async () => {
154
- // const address = "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0";
155
- // const transaction = {
156
- // mode: "send" as const,
157
- // family: "sui" as const,
158
- // coinType: DEFAULT_COIN_TYPE,
159
- // amount: new BigNumber(100),
160
- // recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
161
- // errors: {},
162
- // };
163
- // const tx = await createTransaction(address, transaction);
164
- // expect(tx).toBeInstanceOf(Uint8Array);
165
- // });
166
- // });
167
-
168
- // describe("paymentInfo", () => {
169
- // test("paymentInfo should return gas budget and fees", async () => {
170
- // const sender = "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0";
171
- // const fakeTransaction = {
172
- // mode: "send" as const,
173
- // family: "sui" as const,
174
- // coinType: DEFAULT_COIN_TYPE,
175
- // amount: new BigNumber(100),
176
- // recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
177
- // errors: {},
178
- // };
179
- // const info = await paymentInfo(sender, fakeTransaction);
180
- // expect(info).toHaveProperty("gasBudget");
181
- // expect(info).toHaveProperty("totalGasUsed");
182
- // expect(info).toHaveProperty("fees");
183
- // });
184
- // });
185
- // });
186
-
187
- // describe("getCheckpoint", () => {
188
- // test("getCheckpoint", async () => {
189
- // const checkpointById = await getCheckpoint("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
190
- // const checkpointBySequenceNumber = await getCheckpoint("164167623");
191
- // expect(checkpointById.epoch).toEqual("814");
192
- // expect(checkpointById.sequenceNumber).toEqual("164167623");
193
- // expect(checkpointById.timestampMs).toEqual("1751696298663");
194
- // expect(checkpointById.digest).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
195
- // expect(checkpointById.previousDigest).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
196
- // expect(checkpointById.transactions.length).toEqual(19);
197
- // expect(checkpointById).toEqual(checkpointBySequenceNumber);
198
- // });
199
-
200
- // test("getCheckpointWithTransactions", async () => {
201
- // const { checkpoint: checkpointById, transactions: checkpointByIdTransactions } =
202
- // await getCheckpointWithTransactions("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
203
- // const {
204
- // checkpoint: checkpointBySequenceNumber,
205
- // transactions: checkpointBySequenceNumberTransactions,
206
- // } = await getCheckpointWithTransactions("164167623");
207
- // expect(checkpointById.epoch).toEqual("814");
208
- // expect(checkpointById.sequenceNumber).toEqual("164167623");
209
- // expect(checkpointById.timestampMs).toEqual("1751696298663");
210
- // expect(checkpointById.digest).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
211
- // expect(checkpointById.previousDigest).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
212
- // expect(checkpointById.transactions.length).toEqual(19);
213
- // expect(checkpointById).toEqual(checkpointBySequenceNumber);
214
- // expect(checkpointByIdTransactions.length).toEqual(19);
215
- // expect(checkpointBySequenceNumberTransactions.length).toEqual(19);
216
- // expect(checkpointByIdTransactions).toEqual(checkpointBySequenceNumberTransactions);
217
- // });
218
- // });
219
-
220
- // describe("getBlockInfo", () => {
221
- // test("getBlockInfo should get block info by id or sequence number", async () => {
222
- // const blockById = await getBlockInfo("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
223
- // const blockBySequenceNumber = await getBlockInfo("164167623");
224
- // expect(blockById.height).toEqual(164167623);
225
- // expect(blockById.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
226
- // expect(blockById.time).toEqual(new Date(1751696298663));
227
- // expect(blockById.parent?.height).toEqual(164167622);
228
- // expect(blockById.parent?.hash).toEqual("TODO");
229
- // expect(blockById).toEqual(blockBySequenceNumber);
230
- // });
231
- // });
232
-
233
- // describe("getBlock", () => {
234
- // test("getBlock should get block by id or sequence number", async () => {
235
- // const blockById = await getBlock("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
236
- // const blockBySequenceNumber = await getBlock("164167623");
237
- // expect(blockById.info.height).toEqual(164167623);
238
- // expect(blockById.info.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
239
- // expect(blockById.info.time).toEqual(new Date(1751696298663));
240
- // expect(blockById.info.parent?.height).toEqual(164167622);
241
- // expect(blockById.info.parent?.hash).toEqual("TODO");
242
- // expect(blockById.transactions.length).toEqual(19);
243
- // expect(blockById).toEqual(blockBySequenceNumber);
244
- // });
245
- // });
246
- // });
162
+ describe("paymentInfo", () => {
163
+ test("paymentInfo should return gas budget and fees", async () => {
164
+ const sender = "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0";
165
+ const fakeTransaction = {
166
+ mode: "send" as const,
167
+ family: "sui" as const,
168
+ coinType: DEFAULT_COIN_TYPE,
169
+ amount: new BigNumber(100),
170
+ recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
171
+ errors: {},
172
+ };
173
+ const info = await paymentInfo(sender, fakeTransaction);
174
+ expect(info).toHaveProperty("gasBudget");
175
+ expect(info).toHaveProperty("totalGasUsed");
176
+ expect(info).toHaveProperty("fees");
177
+ });
178
+ });
179
+
180
+ describe("getCheckpoint", () => {
181
+ test("getCheckpoint", async () => {
182
+ const checkpointById = await getCheckpoint("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
183
+ const checkpointBySequenceNumber = await getCheckpoint("164167623");
184
+ expect(checkpointById.epoch).toEqual("814");
185
+ expect(checkpointById.sequenceNumber).toEqual("164167623");
186
+ expect(checkpointById.timestampMs).toEqual("1751696298663");
187
+ expect(checkpointById.digest).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
188
+ expect(checkpointById.previousDigest).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
189
+ expect(checkpointById.transactions.length).toEqual(19);
190
+ expect(checkpointById.digest).toEqual(checkpointBySequenceNumber.digest);
191
+ });
192
+ /*
193
+ test("getCheckpointWithTransactions", async () => {
194
+ const { checkpoint: checkpointById, transactions: checkpointByIdTransactions } =
195
+ await getCheckpointWithTransactions("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
196
+ const {
197
+ checkpoint: checkpointBySequenceNumber,
198
+ transactions: checkpointBySequenceNumberTransactions,
199
+ } = await getCheckpointWithTransactions("164167623");
200
+ expect(checkpointById.epoch).toEqual("814");
201
+ expect(checkpointById.sequenceNumber).toEqual("164167623");
202
+ expect(checkpointById.timestampMs).toEqual("1751696298663");
203
+ expect(checkpointById.digest).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
204
+ expect(checkpointById.previousDigest).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
205
+ expect(checkpointById.transactions.length).toEqual(19);
206
+ expect(checkpointById).toEqual(checkpointBySequenceNumber);
207
+ expect(checkpointByIdTransactions.length).toEqual(19);
208
+ expect(checkpointBySequenceNumberTransactions.length).toEqual(19);
209
+ expect(checkpointByIdTransactions).toEqual(checkpointBySequenceNumberTransactions);
210
+ });
211
+ */
212
+ });
213
+
214
+ describe("getBlockInfo", () => {
215
+ test("getBlockInfo should get block info by id or sequence number", async () => {
216
+ const blockById = await getBlockInfo("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
217
+ const blockBySequenceNumber = await getBlockInfo("164167623");
218
+ expect(blockById.height).toEqual(164167623);
219
+ expect(blockById.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
220
+ expect(blockById.time).toEqual(new Date(1751696298663));
221
+ expect(blockById.parent?.height).toEqual(164167622);
222
+ // expect(blockById.parent?.hash).toEqual("TODO");
223
+ expect(blockById).toEqual(blockBySequenceNumber);
224
+ });
225
+ });
226
+
227
+ describe("getBlock", () => {
228
+ test("getBlock should get block by id or sequence number", async () => {
229
+ const blockById = await getBlock("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
230
+ const blockBySequenceNumber = await getBlock("164167623");
231
+ expect(blockById.info.height).toEqual(164167623);
232
+ expect(blockById.info.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
233
+ expect(blockById.info.time).toEqual(new Date(1751696298663));
234
+ expect(blockById.info.parent?.height).toEqual(164167622);
235
+ // expect(blockById.info.parent?.hash).toEqual("TODO");
236
+ expect(blockById.transactions.length).toEqual(19);
237
+ expect(blockById).toEqual(blockBySequenceNumber);
238
+ });
239
+ });
240
+ });
@@ -500,7 +500,7 @@ describe("SDK Functions", () => {
500
500
  "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
501
501
  ]);
502
502
  expect(operation.value).toEqual(500000n);
503
- expect(operation.asset).toEqual({ type: "token", coinType: "0x123::test::TOKEN" });
503
+ expect(operation.asset).toEqual({ type: "token", assetReference: "0x123::test::TOKEN" });
504
504
  expect(operation.memo).toBeUndefined();
505
505
  expect(operation.details).toBeUndefined();
506
506
  expect(operation.tx).toMatchObject({
@@ -1449,7 +1449,7 @@ describe("filterOperations", () => {
1449
1449
  amount: 8824n,
1450
1450
  asset: {
1451
1451
  type: "token",
1452
- coinType: "0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC",
1452
+ assetReference: "0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC",
1453
1453
  },
1454
1454
  },
1455
1455
  ]);
@@ -1512,7 +1512,7 @@ describe("filterOperations", () => {
1512
1512
  {
1513
1513
  address: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
1514
1514
  amount: 500000n,
1515
- asset: { type: "token", coinType: "0x123::test::TOKEN" },
1515
+ asset: { type: "token", assetReference: "0x123::test::TOKEN" },
1516
1516
  type: "transfer",
1517
1517
  },
1518
1518
  ],
@@ -1526,7 +1526,7 @@ describe("filterOperations", () => {
1526
1526
  test("suiCoinTypeToAsset should map tokens correctly", () => {
1527
1527
  expect(sdk.toSuiAsset("0x123::test::TOKEN")).toEqual({
1528
1528
  type: "token",
1529
- coinType: "0x123::test::TOKEN",
1529
+ assetReference: "0x123::test::TOKEN",
1530
1530
  });
1531
1531
  });
1532
1532
  });
@@ -20,6 +20,7 @@ import type {
20
20
  BlockTransaction,
21
21
  BlockOperation,
22
22
  Operation as Op,
23
+ AssetInfo,
23
24
  } from "@ledgerhq/coin-framework/api/index";
24
25
  import type { Operation, OperationType } from "@ledgerhq/types-live";
25
26
  import uniqBy from "lodash/unionBy";
@@ -30,7 +31,6 @@ import type { Transaction as TransactionType } from "../types";
30
31
  import type { CreateExtrinsicArg } from "../logic/craftTransaction";
31
32
  import { ensureAddressFormat } from "../utils";
32
33
  import coinConfig from "../config";
33
- import { SuiAsset } from "../api/types";
34
34
  import { getEnv } from "@ledgerhq/live-env";
35
35
 
36
36
  type AsyncApiFunction<T> = (api: SuiClient) => Promise<T>;
@@ -253,10 +253,7 @@ export function transactionToOperation(
253
253
  };
254
254
  }
255
255
 
256
- export function transactionToOp(
257
- address: string,
258
- transaction: SuiTransactionBlockResponse,
259
- ): Op<SuiAsset> {
256
+ export function transactionToOp(address: string, transaction: SuiTransactionBlockResponse): Op {
260
257
  const type = getOperationType(address, transaction.transaction?.data);
261
258
  const coinType = getOperationCoinType(transaction);
262
259
  const hash = transaction.digest;
@@ -315,9 +312,7 @@ export function toBlockInfo(checkpoint: Checkpoint): BlockInfo {
315
312
  *
316
313
  * @param transaction SUI RPC transaction block response
317
314
  */
318
- export function toBlockTransaction(
319
- transaction: SuiTransactionBlockResponse,
320
- ): BlockTransaction<SuiAsset> {
315
+ export function toBlockTransaction(transaction: SuiTransactionBlockResponse): BlockTransaction {
321
316
  return {
322
317
  hash: transaction.digest,
323
318
  failed: transaction.effects?.status.status != "success",
@@ -332,7 +327,7 @@ export function toBlockTransaction(
332
327
  *
333
328
  * @param change balance change
334
329
  */
335
- export function toBlockOperation(change: BalanceChange): BlockOperation<SuiAsset>[] {
330
+ export function toBlockOperation(change: BalanceChange): BlockOperation[] {
336
331
  if (typeof change.owner == "string" || !("AddressOwner" in change.owner)) return [];
337
332
  return [
338
333
  {
@@ -349,12 +344,12 @@ export function toBlockOperation(change: BalanceChange): BlockOperation<SuiAsset
349
344
  *
350
345
  * @param coinType coin type, as returned from SUI RPC
351
346
  */
352
- export function toSuiAsset(coinType: string): SuiAsset {
347
+ export function toSuiAsset(coinType: string): AssetInfo {
353
348
  switch (coinType) {
354
349
  case DEFAULT_COIN_TYPE:
355
350
  return { type: "native" };
356
351
  default:
357
- return { type: "token", coinType };
352
+ return { type: "token", assetReference: coinType };
358
353
  }
359
354
  }
360
355
 
@@ -429,7 +424,7 @@ export const getListOperations = async (
429
424
  addr: string,
430
425
  cursor: QueryTransactionBlocksParams["cursor"] = null,
431
426
  withApiImpl: typeof withApi = withApi,
432
- ): Promise<Op<SuiAsset>[]> =>
427
+ ): Promise<Op[]> =>
433
428
  withApiImpl(async api => {
434
429
  const opsOut = await loadOperations({
435
430
  api,
@@ -478,7 +473,7 @@ export const getBlockInfo = async (id: string): Promise<BlockInfo> =>
478
473
  * @param id the checkpoint digest or sequence number (as a string)
479
474
  * @see {@link getBlockInfo}
480
475
  */
481
- export const getBlock = async (id: string): Promise<Block<SuiAsset>> =>
476
+ export const getBlock = async (id: string): Promise<Block> =>
482
477
  withApi(async api => {
483
478
  const checkpoint = await api.getCheckpoint({ id });
484
479
  const rawTxs = await queryTransactionsByDigest({ api, digests: checkpoint.transactions });
@@ -1,6 +0,0 @@
1
- import { type Asset } from "@ledgerhq/coin-framework/api/types";
2
- export type SuiAsset = Asset<SuiTokenInformation>;
3
- export type SuiTokenInformation = {
4
- coinType: string;
5
- };
6
- //# sourceMappingURL=types.d.ts.map