@ledgerhq/coin-sui 0.8.0-nightly.2 → 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.
@@ -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
+ });