@ledgerhq/coin-hedera 1.15.0-nightly.20251209144712 → 1.15.1
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 +48 -14
- package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -1
- package/lib/bridge/buildOptimisticOperation.js +0 -33
- package/lib/bridge/buildOptimisticOperation.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +0 -54
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +2 -4
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +0 -16
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/serialization.d.ts.map +1 -1
- package/lib/bridge/serialization.js +0 -20
- package/lib/bridge/serialization.js.map +1 -1
- package/lib/bridge/signOperation.d.ts +4 -4
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +0 -10
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +0 -8
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/constants.d.ts +1 -21
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +1 -22
- package/lib/constants.js.map +1 -1
- package/lib/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/deviceTransactionConfig.js +0 -30
- package/lib/deviceTransactionConfig.js.map +1 -1
- package/lib/errors.d.ts +0 -9
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -4
- package/lib/errors.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +2 -2
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +8 -42
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +0 -1
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +7 -39
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/utils.d.ts +3 -61
- package/lib/logic/utils.d.ts.map +1 -1
- package/lib/logic/utils.js +4 -117
- package/lib/logic/utils.js.map +1 -1
- package/lib/network/api.d.ts +1 -3
- package/lib/network/api.d.ts.map +1 -1
- package/lib/network/api.js +0 -19
- package/lib/network/api.js.map +1 -1
- package/lib/test/fixtures/account.fixture.d.ts +1 -1
- package/lib/test/fixtures/account.fixture.d.ts.map +1 -1
- package/lib/test/fixtures/account.fixture.js +0 -2
- package/lib/test/fixtures/account.fixture.js.map +1 -1
- package/lib/transaction.d.ts.map +1 -1
- package/lib/transaction.js +0 -34
- package/lib/transaction.js.map +1 -1
- package/lib/types/alpaca.d.ts +0 -3
- package/lib/types/alpaca.d.ts.map +1 -1
- package/lib/types/bridge.d.ts +3 -87
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib/types/logic.d.ts +1 -5
- package/lib/types/logic.d.ts.map +1 -1
- package/lib/types/mirror.d.ts +0 -19
- package/lib/types/mirror.d.ts.map +1 -1
- package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -1
- package/lib-es/bridge/buildOptimisticOperation.js +1 -34
- package/lib-es/bridge/buildOptimisticOperation.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +3 -57
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +2 -4
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +2 -15
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/serialization.d.ts.map +1 -1
- package/lib-es/bridge/serialization.js +0 -17
- package/lib-es/bridge/serialization.js.map +1 -1
- package/lib-es/bridge/signOperation.d.ts +4 -4
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +1 -11
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +0 -8
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/constants.d.ts +1 -21
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +0 -21
- package/lib-es/constants.js.map +1 -1
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/deviceTransactionConfig.js +1 -31
- package/lib-es/deviceTransactionConfig.js.map +1 -1
- package/lib-es/errors.d.ts +0 -9
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +0 -3
- package/lib-es/errors.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +2 -2
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +10 -44
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +1 -2
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +7 -39
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/utils.d.ts +3 -61
- package/lib-es/logic/utils.d.ts.map +1 -1
- package/lib-es/logic/utils.js +4 -107
- package/lib-es/logic/utils.js.map +1 -1
- package/lib-es/network/api.d.ts +1 -3
- package/lib-es/network/api.d.ts.map +1 -1
- package/lib-es/network/api.js +0 -19
- package/lib-es/network/api.js.map +1 -1
- package/lib-es/test/fixtures/account.fixture.d.ts +1 -1
- package/lib-es/test/fixtures/account.fixture.d.ts.map +1 -1
- package/lib-es/test/fixtures/account.fixture.js +0 -2
- package/lib-es/test/fixtures/account.fixture.js.map +1 -1
- package/lib-es/transaction.d.ts.map +1 -1
- package/lib-es/transaction.js +0 -34
- package/lib-es/transaction.js.map +1 -1
- package/lib-es/types/alpaca.d.ts +0 -3
- package/lib-es/types/alpaca.d.ts.map +1 -1
- package/lib-es/types/bridge.d.ts +3 -87
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/lib-es/types/logic.d.ts +1 -5
- package/lib-es/types/logic.d.ts.map +1 -1
- package/lib-es/types/mirror.d.ts +0 -19
- package/lib-es/types/mirror.d.ts.map +1 -1
- package/package.json +11 -12
- package/src/api/index.integ.test.ts +1 -11
- package/src/bridge/buildOptimisticOperation.integration.test.ts +4 -159
- package/src/bridge/buildOptimisticOperation.ts +2 -50
- package/src/bridge/getTransactionStatus.test.ts +21 -191
- package/src/bridge/getTransactionStatus.ts +1 -75
- package/src/bridge/index.ts +2 -4
- package/src/bridge/prepareTransaction.test.ts +8 -112
- package/src/bridge/prepareTransaction.ts +2 -20
- package/src/bridge/serialization.ts +0 -17
- package/src/bridge/signOperation.ts +5 -15
- package/src/bridge/synchronisation.ts +0 -9
- package/src/bridge/utils.integration.test.ts +10 -3
- package/src/constants.ts +0 -22
- package/src/deviceTransactionConfig.ts +1 -37
- package/src/errors.ts +0 -7
- package/src/logic/craftTransaction.ts +13 -70
- package/src/logic/getBalance.test.ts +16 -15
- package/src/logic/getBlock.ts +1 -2
- package/src/logic/listOperations.test.ts +29 -86
- package/src/logic/listOperations.ts +6 -46
- package/src/logic/utils.test.ts +8 -362
- package/src/logic/utils.ts +4 -158
- package/src/network/api.test.ts +6 -58
- package/src/network/api.ts +0 -25
- package/src/network/thirdweb.test.ts +2 -2
- package/src/network/utils.test.ts +6 -4
- package/src/test/fixtures/account.fixture.ts +1 -3
- package/src/transaction.ts +0 -42
- package/src/types/alpaca.ts +0 -4
- package/src/types/bridge.ts +3 -108
- package/src/types/logic.ts +1 -6
- package/src/types/mirror.ts +0 -21
- package/lib/preload-data.d.ts +0 -7
- package/lib/preload-data.d.ts.map +0 -1
- package/lib/preload-data.js +0 -37
- package/lib/preload-data.js.map +0 -1
- package/lib/preload.d.ts +0 -8
- package/lib/preload.d.ts.map +0 -1
- package/lib/preload.js +0 -76
- package/lib/preload.js.map +0 -1
- package/lib-es/preload-data.d.ts +0 -7
- package/lib-es/preload-data.d.ts.map +0 -1
- package/lib-es/preload-data.js +0 -31
- package/lib-es/preload-data.js.map +0 -1
- package/lib-es/preload.d.ts +0 -8
- package/lib-es/preload.d.ts.map +0 -1
- package/lib-es/preload.js +0 -67
- package/lib-es/preload.js.map +0 -1
- package/src/deviceTransactionConfig.test.ts +0 -315
- package/src/preload-data.ts +0 -38
- package/src/preload.test.ts +0 -64
- package/src/preload.ts +0 -80
package/src/network/api.test.ts
CHANGED
|
@@ -72,6 +72,7 @@ describe("getAccountTransactions", () => {
|
|
|
72
72
|
fetchAllPages: true,
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
expect(result.transactions).toHaveLength(3);
|
|
75
76
|
expect(result.transactions.map(tx => tx.consensus_timestamp)).toEqual(["1", "3", "4"]);
|
|
76
77
|
expect(result.nextCursor).toBeNull();
|
|
77
78
|
expect(mockedNetwork).toHaveBeenCalledTimes(5);
|
|
@@ -117,6 +118,7 @@ describe("getAccountTransactions", () => {
|
|
|
117
118
|
fetchAllPages: false,
|
|
118
119
|
});
|
|
119
120
|
|
|
121
|
+
expect(result.transactions).toHaveLength(2);
|
|
120
122
|
expect(result.transactions.map(tx => tx.consensus_timestamp)).toEqual(["1", "3"]);
|
|
121
123
|
expect(result.nextCursor).toBe("3");
|
|
122
124
|
expect(mockedNetwork).toHaveBeenCalledTimes(3);
|
|
@@ -265,7 +267,6 @@ describe("findTransactionByContractCall", () => {
|
|
|
265
267
|
const mockedResults: HederaMirrorTransaction = {
|
|
266
268
|
transfers: [],
|
|
267
269
|
token_transfers: [],
|
|
268
|
-
staking_reward_transfers: [],
|
|
269
270
|
charged_tx_fee: 100,
|
|
270
271
|
transaction_id: "xxxxxxxxxxxxxx",
|
|
271
272
|
transaction_hash: "xxxxxxxxxxxxx",
|
|
@@ -299,7 +300,6 @@ describe("findTransactionByContractCall", () => {
|
|
|
299
300
|
{
|
|
300
301
|
transfers: [],
|
|
301
302
|
token_transfers: [],
|
|
302
|
-
staking_reward_transfers: [],
|
|
303
303
|
charged_tx_fee: 100,
|
|
304
304
|
transaction_hash: "xxxxxxxxxxxxx",
|
|
305
305
|
consensus_timestamp: "xxxxxxxxxxxxx",
|
|
@@ -310,7 +310,6 @@ describe("findTransactionByContractCall", () => {
|
|
|
310
310
|
{
|
|
311
311
|
transfers: [],
|
|
312
312
|
token_transfers: [],
|
|
313
|
-
staking_reward_transfers: [],
|
|
314
313
|
charged_tx_fee: 100,
|
|
315
314
|
transaction_hash: "xxxxxxxxxxxxx",
|
|
316
315
|
consensus_timestamp: "xxxxxxxxxxxxx",
|
|
@@ -318,7 +317,7 @@ describe("findTransactionByContractCall", () => {
|
|
|
318
317
|
entity_id: "0.0.1111",
|
|
319
318
|
name: "CONTRACTCALL",
|
|
320
319
|
},
|
|
321
|
-
]
|
|
320
|
+
],
|
|
322
321
|
}),
|
|
323
322
|
);
|
|
324
323
|
|
|
@@ -451,6 +450,7 @@ describe("getTransactionsByTimestampRange", () => {
|
|
|
451
450
|
"2000.000000000",
|
|
452
451
|
);
|
|
453
452
|
|
|
453
|
+
expect(result).toHaveLength(2);
|
|
454
454
|
expect(result.map(tx => tx.consensus_timestamp)).toEqual(["1500.123456789", "1750.987654321"]);
|
|
455
455
|
expect(mockedNetwork).toHaveBeenCalledTimes(1);
|
|
456
456
|
});
|
|
@@ -481,6 +481,7 @@ describe("getTransactionsByTimestampRange", () => {
|
|
|
481
481
|
"2000.000000000",
|
|
482
482
|
);
|
|
483
483
|
|
|
484
|
+
expect(result).toHaveLength(3);
|
|
484
485
|
expect(result.map(tx => tx.consensus_timestamp)).toEqual([
|
|
485
486
|
"1100.000000000",
|
|
486
487
|
"1200.000000000",
|
|
@@ -515,61 +516,8 @@ describe("getTransactionsByTimestampRange", () => {
|
|
|
515
516
|
"2000.000000000",
|
|
516
517
|
);
|
|
517
518
|
|
|
519
|
+
expect(result).toHaveLength(2);
|
|
518
520
|
expect(result.map(tx => tx.consensus_timestamp)).toEqual(["1100.000000000", "1300.000000000"]);
|
|
519
521
|
expect(mockedNetwork).toHaveBeenCalledTimes(3);
|
|
520
522
|
});
|
|
521
523
|
});
|
|
522
|
-
|
|
523
|
-
describe("getNodes", () => {
|
|
524
|
-
beforeEach(() => {
|
|
525
|
-
jest.resetAllMocks();
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
it("should return all nodes if only one page is needed", async () => {
|
|
529
|
-
mockedNetwork.mockResolvedValueOnce(
|
|
530
|
-
getMockResponse({
|
|
531
|
-
nodes: [
|
|
532
|
-
{ node_id: 0, node_account_id: "0.0.3" },
|
|
533
|
-
{ node_id: 1, node_account_id: "0.0.4" },
|
|
534
|
-
],
|
|
535
|
-
links: { next: null },
|
|
536
|
-
}),
|
|
537
|
-
);
|
|
538
|
-
|
|
539
|
-
const result = await apiClient.getNodes();
|
|
540
|
-
const requestUrl = mockedNetwork.mock.calls[0][0].url;
|
|
541
|
-
|
|
542
|
-
expect(result.map(n => n.node_id)).toEqual([0, 1]);
|
|
543
|
-
expect(requestUrl).toContain("/api/v1/network/nodes");
|
|
544
|
-
expect(requestUrl).toContain("limit=100");
|
|
545
|
-
expect(requestUrl).toContain("order=desc");
|
|
546
|
-
expect(mockedNetwork).toHaveBeenCalledTimes(1);
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
it("should keep fetching if links.next is present and new nodes are returned", async () => {
|
|
550
|
-
mockedNetwork
|
|
551
|
-
.mockResolvedValueOnce(
|
|
552
|
-
getMockResponse({
|
|
553
|
-
nodes: [{ node_id: 0, node_account_id: "0.0.3" }],
|
|
554
|
-
links: { next: "/next-1" },
|
|
555
|
-
}),
|
|
556
|
-
)
|
|
557
|
-
.mockResolvedValueOnce(
|
|
558
|
-
getMockResponse({
|
|
559
|
-
nodes: [{ node_id: 1, node_account_id: "0.0.4" }],
|
|
560
|
-
links: { next: "/next-2" },
|
|
561
|
-
}),
|
|
562
|
-
)
|
|
563
|
-
.mockResolvedValueOnce(
|
|
564
|
-
getMockResponse({
|
|
565
|
-
nodes: [{ node_id: 2, node_account_id: "0.0.5" }],
|
|
566
|
-
links: { next: null },
|
|
567
|
-
}),
|
|
568
|
-
);
|
|
569
|
-
|
|
570
|
-
const result = await apiClient.getNodes();
|
|
571
|
-
|
|
572
|
-
expect(result.map(n => n.node_id)).toEqual([0, 1, 2]);
|
|
573
|
-
expect(mockedNetwork).toHaveBeenCalledTimes(3);
|
|
574
|
-
});
|
|
575
|
-
});
|
package/src/network/api.ts
CHANGED
|
@@ -16,8 +16,6 @@ import type {
|
|
|
16
16
|
HederaMirrorContractCallResult,
|
|
17
17
|
HederaMirrorContractCallBalance,
|
|
18
18
|
HederaMirrorContractCallEstimate,
|
|
19
|
-
HederaMirrorNode,
|
|
20
|
-
HederaMirrorNodesResponse,
|
|
21
19
|
} from "../types";
|
|
22
20
|
|
|
23
21
|
const API_URL = getEnv("API_HEDERA_MIRROR");
|
|
@@ -269,28 +267,6 @@ async function getTransactionsByTimestampRange(
|
|
|
269
267
|
return transactions;
|
|
270
268
|
}
|
|
271
269
|
|
|
272
|
-
async function getNodes(): Promise<HederaMirrorNode[]> {
|
|
273
|
-
const nodes: HederaMirrorNode[] = [];
|
|
274
|
-
const params = new URLSearchParams({
|
|
275
|
-
order: "desc",
|
|
276
|
-
limit: "100",
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
let nextPath: string | null = `/api/v1/network/nodes?${params.toString()}`;
|
|
280
|
-
|
|
281
|
-
while (nextPath) {
|
|
282
|
-
const res: LiveNetworkResponse<HederaMirrorNodesResponse> = await network({
|
|
283
|
-
method: "GET",
|
|
284
|
-
url: `${API_URL}${nextPath}`,
|
|
285
|
-
});
|
|
286
|
-
const newNodes = res.data.nodes;
|
|
287
|
-
nodes.push(...newNodes);
|
|
288
|
-
nextPath = res.data.links.next;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return nodes;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
270
|
export const apiClient = {
|
|
295
271
|
getAccountsForPublicKey,
|
|
296
272
|
getAccount,
|
|
@@ -303,5 +279,4 @@ export const apiClient = {
|
|
|
303
279
|
getERC20Balance,
|
|
304
280
|
estimateContractCallGas,
|
|
305
281
|
getTransactionsByTimestampRange,
|
|
306
|
-
getNodes,
|
|
307
282
|
};
|
|
@@ -84,7 +84,7 @@ describe("fetchERC20Transactions", () => {
|
|
|
84
84
|
};
|
|
85
85
|
const result = await thirdwebClient.fetchERC20Transactions(mockedERC20TokenAddress1, params);
|
|
86
86
|
|
|
87
|
-
expect(result).
|
|
87
|
+
expect(result).toHaveLength(0);
|
|
88
88
|
expect(mockedNetwork).toHaveBeenCalledTimes(1);
|
|
89
89
|
});
|
|
90
90
|
|
|
@@ -139,7 +139,7 @@ describe("getERC20TransactionsForAccount", () => {
|
|
|
139
139
|
since: null,
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
expect(result).
|
|
142
|
+
expect(result).toHaveLength(0);
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
it("should return exactly 2 transactions (out & in)", async () => {
|
|
@@ -207,7 +207,8 @@ describe("network utils", () => {
|
|
|
207
207
|
erc20Token.contractAddress,
|
|
208
208
|
);
|
|
209
209
|
|
|
210
|
-
expect(res).
|
|
210
|
+
expect(res).toHaveLength(mockedSupportedTokenIds.length);
|
|
211
|
+
expect(res).toMatchObject(mockedResponse);
|
|
211
212
|
});
|
|
212
213
|
|
|
213
214
|
it("returns empty array when there are no supported ERC20 tokens", async () => {
|
|
@@ -264,7 +265,8 @@ describe("network utils", () => {
|
|
|
264
265
|
|
|
265
266
|
const result = await getERC20Operations([mockThirdwebTransaction]);
|
|
266
267
|
|
|
267
|
-
expect(result).
|
|
268
|
+
expect(result).toHaveLength(1);
|
|
269
|
+
expect(result).toMatchObject([
|
|
268
270
|
{
|
|
269
271
|
thirdwebTransaction: mockThirdwebTransaction,
|
|
270
272
|
mirrorTransaction: mockMirrorTransaction,
|
|
@@ -297,7 +299,7 @@ describe("network utils", () => {
|
|
|
297
299
|
|
|
298
300
|
const result = await getERC20Operations(mockThirdwebTransactions);
|
|
299
301
|
|
|
300
|
-
expect(result).
|
|
302
|
+
expect(result).toHaveLength(0);
|
|
301
303
|
expect(apiClient.getContractCallResult).not.toHaveBeenCalled();
|
|
302
304
|
expect(apiClient.findTransactionByContractCall).not.toHaveBeenCalled();
|
|
303
305
|
});
|
|
@@ -326,7 +328,7 @@ describe("network utils", () => {
|
|
|
326
328
|
|
|
327
329
|
const result = await getERC20Operations([mockThirdwebTransactions]);
|
|
328
330
|
|
|
329
|
-
expect(result).
|
|
331
|
+
expect(result).toHaveLength(0);
|
|
330
332
|
});
|
|
331
333
|
});
|
|
332
334
|
|
|
@@ -5,9 +5,9 @@ import type {
|
|
|
5
5
|
HederaResources,
|
|
6
6
|
HederaResourcesRaw,
|
|
7
7
|
} from "../../types";
|
|
8
|
-
import type { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
9
8
|
import type { TokenAccount } from "@ledgerhq/types-live";
|
|
10
9
|
import { getMockedCurrency, getMockedHTSTokenCurrency } from "./currency.fixture";
|
|
10
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
11
11
|
|
|
12
12
|
const defaultMockedCurrency = getMockedCurrency();
|
|
13
13
|
const defaultMockedTokenCurrency = getMockedHTSTokenCurrency();
|
|
@@ -19,13 +19,11 @@ const defaultTokenBalance = new BigNumber(10);
|
|
|
19
19
|
export const mockHederaResources: HederaResources = {
|
|
20
20
|
maxAutomaticTokenAssociations: 0,
|
|
21
21
|
isAutoTokenAssociationEnabled: false,
|
|
22
|
-
delegation: null,
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
export const mockHederaResourcesRaw: HederaResourcesRaw = {
|
|
26
25
|
maxAutomaticTokenAssociations: 0,
|
|
27
26
|
isAutoTokenAssociationEnabled: false,
|
|
28
|
-
delegation: null,
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
/**
|
package/src/transaction.ts
CHANGED
|
@@ -40,27 +40,6 @@ export function fromTransactionRaw(tr: TransactionRaw): Transaction {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
if (
|
|
44
|
-
tr.mode === HEDERA_TRANSACTION_MODES.Delegate ||
|
|
45
|
-
tr.mode === HEDERA_TRANSACTION_MODES.Undelegate ||
|
|
46
|
-
tr.mode === HEDERA_TRANSACTION_MODES.Redelegate
|
|
47
|
-
) {
|
|
48
|
-
return {
|
|
49
|
-
...commonGeneric,
|
|
50
|
-
...commonHedera,
|
|
51
|
-
mode: tr.mode,
|
|
52
|
-
properties: tr.properties,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (tr.mode === HEDERA_TRANSACTION_MODES.ClaimRewards) {
|
|
57
|
-
return {
|
|
58
|
-
...commonGeneric,
|
|
59
|
-
...commonHedera,
|
|
60
|
-
mode: tr.mode,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
43
|
return {
|
|
65
44
|
...commonGeneric,
|
|
66
45
|
...commonHedera,
|
|
@@ -88,27 +67,6 @@ export function toTransactionRaw(t: Transaction): TransactionRaw {
|
|
|
88
67
|
};
|
|
89
68
|
}
|
|
90
69
|
|
|
91
|
-
if (
|
|
92
|
-
t.mode === HEDERA_TRANSACTION_MODES.Delegate ||
|
|
93
|
-
t.mode === HEDERA_TRANSACTION_MODES.Undelegate ||
|
|
94
|
-
t.mode === HEDERA_TRANSACTION_MODES.Redelegate
|
|
95
|
-
) {
|
|
96
|
-
return {
|
|
97
|
-
...commonGeneric,
|
|
98
|
-
...commonHedera,
|
|
99
|
-
mode: t.mode,
|
|
100
|
-
properties: t.properties,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (t.mode === HEDERA_TRANSACTION_MODES.ClaimRewards) {
|
|
105
|
-
return {
|
|
106
|
-
...commonGeneric,
|
|
107
|
-
...commonHedera,
|
|
108
|
-
mode: t.mode,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
70
|
return {
|
|
113
71
|
...commonGeneric,
|
|
114
72
|
...commonHedera,
|
package/src/types/alpaca.ts
CHANGED
package/src/types/bridge.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
TransactionStatusCommon,
|
|
10
10
|
TransactionStatusCommonRaw,
|
|
11
11
|
} from "@ledgerhq/types-live";
|
|
12
|
-
import {
|
|
12
|
+
import { HEDERA_TRANSACTION_MODES } from "../constants";
|
|
13
13
|
|
|
14
14
|
export type NetworkInfo = {
|
|
15
15
|
family: "hedera";
|
|
@@ -37,28 +37,6 @@ export type Transaction = TransactionCommon & {
|
|
|
37
37
|
token: TokenCurrency;
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
| {
|
|
41
|
-
mode: HEDERA_TRANSACTION_MODES.Delegate;
|
|
42
|
-
properties: {
|
|
43
|
-
stakingNodeId: number | null;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
| {
|
|
47
|
-
mode: HEDERA_TRANSACTION_MODES.Undelegate;
|
|
48
|
-
properties: {
|
|
49
|
-
stakingNodeId: number | null;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
| {
|
|
53
|
-
mode: HEDERA_TRANSACTION_MODES.Redelegate;
|
|
54
|
-
properties: {
|
|
55
|
-
stakingNodeId: number | null;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
| {
|
|
59
|
-
mode: HEDERA_TRANSACTION_MODES.ClaimRewards;
|
|
60
|
-
properties?: never;
|
|
61
|
-
}
|
|
62
40
|
);
|
|
63
41
|
|
|
64
42
|
export type TransactionRaw = TransactionCommonRaw & {
|
|
@@ -79,77 +57,25 @@ export type TransactionRaw = TransactionCommonRaw & {
|
|
|
79
57
|
token: TokenCurrency;
|
|
80
58
|
};
|
|
81
59
|
}
|
|
82
|
-
| {
|
|
83
|
-
mode: HEDERA_TRANSACTION_MODES.Delegate;
|
|
84
|
-
properties: {
|
|
85
|
-
stakingNodeId: number | null;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
| {
|
|
89
|
-
mode: HEDERA_TRANSACTION_MODES.Undelegate;
|
|
90
|
-
properties: {
|
|
91
|
-
stakingNodeId: number | null;
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
| {
|
|
95
|
-
mode: HEDERA_TRANSACTION_MODES.Redelegate;
|
|
96
|
-
properties: {
|
|
97
|
-
stakingNodeId: number | null;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
| {
|
|
101
|
-
mode: HEDERA_TRANSACTION_MODES.ClaimRewards;
|
|
102
|
-
properties?: never;
|
|
103
|
-
}
|
|
104
60
|
);
|
|
105
61
|
|
|
106
|
-
export type TransactionStatus = TransactionStatusCommon;
|
|
107
|
-
|
|
108
|
-
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
109
|
-
|
|
110
62
|
export type TransactionTokenAssociate = Extract<
|
|
111
63
|
Transaction,
|
|
112
64
|
{ mode: HEDERA_TRANSACTION_MODES.TokenAssociate }
|
|
113
65
|
>;
|
|
114
66
|
|
|
115
|
-
export type
|
|
116
|
-
Transaction,
|
|
117
|
-
{
|
|
118
|
-
mode:
|
|
119
|
-
| HEDERA_TRANSACTION_MODES.Delegate
|
|
120
|
-
| HEDERA_TRANSACTION_MODES.Undelegate
|
|
121
|
-
| HEDERA_TRANSACTION_MODES.Redelegate
|
|
122
|
-
| HEDERA_TRANSACTION_MODES.ClaimRewards;
|
|
123
|
-
}
|
|
124
|
-
>;
|
|
125
|
-
|
|
126
|
-
export interface HederaDelegation {
|
|
127
|
-
nodeId: number;
|
|
128
|
-
delegated: BigNumber;
|
|
129
|
-
pendingReward: BigNumber;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface HederaEnrichedDelegation extends HederaDelegation {
|
|
133
|
-
status: HEDERA_DELEGATION_STATUS;
|
|
134
|
-
validator: HederaValidator;
|
|
135
|
-
}
|
|
67
|
+
export type TransactionStatus = TransactionStatusCommon;
|
|
136
68
|
|
|
137
|
-
|
|
138
|
-
nodeId: number;
|
|
139
|
-
delegated: string;
|
|
140
|
-
pendingReward: string;
|
|
141
|
-
}
|
|
69
|
+
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
142
70
|
|
|
143
71
|
export interface HederaResources {
|
|
144
72
|
maxAutomaticTokenAssociations: number;
|
|
145
73
|
isAutoTokenAssociationEnabled: boolean;
|
|
146
|
-
delegation: HederaDelegation | null;
|
|
147
74
|
}
|
|
148
75
|
|
|
149
76
|
export interface HederaResourcesRaw {
|
|
150
77
|
maxAutomaticTokenAssociations: number;
|
|
151
78
|
isAutoTokenAssociationEnabled: boolean;
|
|
152
|
-
delegation: HederaDelegationRaw | null;
|
|
153
79
|
}
|
|
154
80
|
|
|
155
81
|
export type HederaAccount = Account & {
|
|
@@ -169,37 +95,6 @@ export type HederaOperationExtra = {
|
|
|
169
95
|
gasLimit?: number;
|
|
170
96
|
gasUsed?: number;
|
|
171
97
|
memo?: string | null;
|
|
172
|
-
targetStakingNodeId?: number | null;
|
|
173
|
-
previousStakingNodeId?: number | null;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export type HederaValidator = {
|
|
177
|
-
nodeId: number;
|
|
178
|
-
minStake: BigNumber;
|
|
179
|
-
maxStake: BigNumber;
|
|
180
|
-
activeStake: BigNumber;
|
|
181
|
-
activeStakePercentage: BigNumber;
|
|
182
|
-
address: string;
|
|
183
|
-
addressChecksum: string | null;
|
|
184
|
-
name: string;
|
|
185
|
-
overstaked: boolean;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export type HederaValidatorRaw = {
|
|
189
|
-
nodeId: number;
|
|
190
|
-
minStake: string;
|
|
191
|
-
maxStake: string;
|
|
192
|
-
activeStake: string;
|
|
193
|
-
activeStakePercentage: string;
|
|
194
|
-
address: string;
|
|
195
|
-
addressChecksum: string | null;
|
|
196
|
-
name: string;
|
|
197
|
-
overstaked: boolean;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export type HederaPreloadData = {
|
|
201
|
-
validators: HederaValidator[];
|
|
202
|
-
associatedTokenId?: string;
|
|
203
98
|
};
|
|
204
99
|
|
|
205
100
|
export type HederaOperation = Operation<HederaOperationExtra>;
|
package/src/types/logic.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type EstimateFeesParams =
|
|
|
13
13
|
operationType: Exclude<HEDERA_OPERATION_TYPES, HEDERA_OPERATION_TYPES.ContractCall>;
|
|
14
14
|
}
|
|
15
15
|
| {
|
|
16
|
-
operationType: HEDERA_OPERATION_TYPES.ContractCall;
|
|
16
|
+
operationType: typeof HEDERA_OPERATION_TYPES.ContractCall;
|
|
17
17
|
txIntent: TransactionIntent;
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -42,8 +42,3 @@ export interface ERC20OperationFields {
|
|
|
42
42
|
standard: "erc20";
|
|
43
43
|
hasFailed: false;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
export interface OperationDetailsExtraField {
|
|
47
|
-
key: string;
|
|
48
|
-
value: string | number;
|
|
49
|
-
}
|
package/src/types/mirror.ts
CHANGED
|
@@ -20,7 +20,6 @@ export interface HederaMirrorTokenTransfer {
|
|
|
20
20
|
export interface HederaMirrorTransaction {
|
|
21
21
|
transfers: HederaMirrorCoinTransfer[];
|
|
22
22
|
token_transfers: HederaMirrorTokenTransfer[];
|
|
23
|
-
staking_reward_transfers: HederaMirrorCoinTransfer[];
|
|
24
23
|
charged_tx_fee: number;
|
|
25
24
|
transaction_hash: string;
|
|
26
25
|
transaction_id: string;
|
|
@@ -44,8 +43,6 @@ export interface HederaMirrorToken {
|
|
|
44
43
|
export interface HederaMirrorAccount {
|
|
45
44
|
account: string;
|
|
46
45
|
max_automatic_token_associations: number;
|
|
47
|
-
staked_node_id: number | null;
|
|
48
|
-
pending_reward: number;
|
|
49
46
|
balance: {
|
|
50
47
|
balance: number;
|
|
51
48
|
timestamp: string;
|
|
@@ -106,21 +103,3 @@ export interface HederaMirrorContractCallEstimate {
|
|
|
106
103
|
export interface HederaMirrorContractCallBalance {
|
|
107
104
|
result: string;
|
|
108
105
|
}
|
|
109
|
-
|
|
110
|
-
export interface HederaMirrorNode {
|
|
111
|
-
node_id: number;
|
|
112
|
-
node_account_id: string;
|
|
113
|
-
description: string;
|
|
114
|
-
max_stake: number;
|
|
115
|
-
min_stake: number;
|
|
116
|
-
stake: number;
|
|
117
|
-
stake_rewarded: number;
|
|
118
|
-
reward_rate_start: number;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface HederaMirrorNodesResponse {
|
|
122
|
-
nodes: HederaMirrorNode[];
|
|
123
|
-
links: {
|
|
124
|
-
next: string | null;
|
|
125
|
-
};
|
|
126
|
-
}
|
package/lib/preload-data.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
import type { HederaPreloadData } from "./types";
|
|
4
|
-
export declare function setHederaPreloadData(data: HederaPreloadData, currency: CryptoCurrency): void;
|
|
5
|
-
export declare function getHederaPreloadData(currency: CryptoCurrency): Observable<HederaPreloadData>;
|
|
6
|
-
export declare function getCurrentHederaPreloadData(currency: CryptoCurrency): HederaPreloadData;
|
|
7
|
-
//# sourceMappingURL=preload-data.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preload-data.d.ts","sourceRoot":"","sources":["../src/preload-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAYjD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAO5F;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAM5F;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,cAAc,GAAG,iBAAiB,CAMvF"}
|
package/lib/preload-data.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCurrentHederaPreloadData = exports.getHederaPreloadData = exports.setHederaPreloadData = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const initialData = {
|
|
6
|
-
validators: [],
|
|
7
|
-
};
|
|
8
|
-
const dataByCurrency = new Map([["hedera", initialData]]);
|
|
9
|
-
const dataUpdatesByCurrency = new Map([
|
|
10
|
-
["hedera", new rxjs_1.BehaviorSubject(initialData)],
|
|
11
|
-
]);
|
|
12
|
-
function setHederaPreloadData(data, currency) {
|
|
13
|
-
dataByCurrency.set(currency.id, data ?? initialData);
|
|
14
|
-
const subject = dataUpdatesByCurrency.get(currency.id);
|
|
15
|
-
if (subject === undefined) {
|
|
16
|
-
throw new Error(`unsupported currency ${currency.id}`);
|
|
17
|
-
}
|
|
18
|
-
subject.next(data);
|
|
19
|
-
}
|
|
20
|
-
exports.setHederaPreloadData = setHederaPreloadData;
|
|
21
|
-
function getHederaPreloadData(currency) {
|
|
22
|
-
const subject = dataUpdatesByCurrency.get(currency.id);
|
|
23
|
-
if (subject === undefined) {
|
|
24
|
-
throw new Error(`unsupported currency ${currency.id}`);
|
|
25
|
-
}
|
|
26
|
-
return subject.asObservable();
|
|
27
|
-
}
|
|
28
|
-
exports.getHederaPreloadData = getHederaPreloadData;
|
|
29
|
-
function getCurrentHederaPreloadData(currency) {
|
|
30
|
-
const data = dataByCurrency.get(currency.id);
|
|
31
|
-
if (data === undefined) {
|
|
32
|
-
throw new Error(`unsupported currency ${currency.id}`);
|
|
33
|
-
}
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
exports.getCurrentHederaPreloadData = getCurrentHederaPreloadData;
|
|
37
|
-
//# sourceMappingURL=preload-data.js.map
|
package/lib/preload-data.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preload-data.js","sourceRoot":"","sources":["../src/preload-data.ts"],"names":[],"mappings":";;;AACA,+BAAmD;AAGnD,MAAM,WAAW,GAAsB;IACrC,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,GAAG,CAA4B,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AAErF,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,CAAC,QAAQ,EAAE,IAAI,sBAAe,CAAoB,WAAW,CAAC,CAAC;CAChE,CAAC,CAAC;AAEH,SAAgB,oBAAoB,CAAC,IAAuB,EAAE,QAAwB;IACpF,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC;AAPD,oDAOC;AAED,SAAgB,oBAAoB,CAAC,QAAwB;IAC3D,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC;AAChC,CAAC;AAND,oDAMC;AAED,SAAgB,2BAA2B,CAAC,QAAwB;IAClE,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,kEAMC"}
|
package/lib/preload.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
-
import type { HederaPreloadData } from "./types";
|
|
3
|
-
export declare const getPreloadStrategy: () => {
|
|
4
|
-
preloadMaxAge: number;
|
|
5
|
-
};
|
|
6
|
-
export declare function preload(currency: CryptoCurrency): Promise<HederaPreloadData>;
|
|
7
|
-
export declare function hydrate(data: unknown, currency: CryptoCurrency): void;
|
|
8
|
-
//# sourceMappingURL=preload.d.ts.map
|
package/lib/preload.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preload.d.ts","sourceRoot":"","sources":["../src/preload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,OAAO,KAAK,EAAE,iBAAiB,EAAuC,MAAM,SAAS,CAAC;AAEtF,eAAO,MAAM,kBAAkB;;CAE7B,CAAC;AAEH,wBAAsB,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiClF;AA8BD,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAIrE"}
|
package/lib/preload.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.hydrate = exports.preload = exports.getPreloadStrategy = void 0;
|
|
7
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
-
const logs_1 = require("@ledgerhq/logs");
|
|
9
|
-
const utils_1 = require("./logic/utils");
|
|
10
|
-
const api_1 = require("./network/api");
|
|
11
|
-
const preload_data_1 = require("./preload-data");
|
|
12
|
-
const getPreloadStrategy = () => ({
|
|
13
|
-
preloadMaxAge: 15 * 60 * 1000, // 15 minutes
|
|
14
|
-
});
|
|
15
|
-
exports.getPreloadStrategy = getPreloadStrategy;
|
|
16
|
-
async function preload(currency) {
|
|
17
|
-
(0, logs_1.log)("hedera/preload", "preloading hedera data...");
|
|
18
|
-
const nodes = await api_1.apiClient.getNodes();
|
|
19
|
-
const validators = nodes.map(mirrorNode => {
|
|
20
|
-
const minStake = new bignumber_js_1.default(mirrorNode.min_stake);
|
|
21
|
-
const maxStake = new bignumber_js_1.default(mirrorNode.max_stake);
|
|
22
|
-
const activeStake = new bignumber_js_1.default(mirrorNode.stake_rewarded);
|
|
23
|
-
const activeStakePercentage = maxStake.gt(0)
|
|
24
|
-
? activeStake.dividedBy(maxStake).multipliedBy(100).dp(0, bignumber_js_1.default.ROUND_CEIL)
|
|
25
|
-
: new bignumber_js_1.default(0);
|
|
26
|
-
return {
|
|
27
|
-
nodeId: mirrorNode.node_id,
|
|
28
|
-
address: mirrorNode.node_account_id,
|
|
29
|
-
addressChecksum: (0, utils_1.getChecksum)(mirrorNode.node_account_id),
|
|
30
|
-
name: (0, utils_1.extractCompanyFromNodeDescription)(mirrorNode.description),
|
|
31
|
-
minStake,
|
|
32
|
-
maxStake,
|
|
33
|
-
activeStake,
|
|
34
|
-
activeStakePercentage,
|
|
35
|
-
overstaked: activeStake.gte(maxStake),
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
const sortedValidators = (0, utils_1.sortValidators)(validators);
|
|
39
|
-
const data = {
|
|
40
|
-
validators: sortedValidators,
|
|
41
|
-
};
|
|
42
|
-
(0, preload_data_1.setHederaPreloadData)(data, currency);
|
|
43
|
-
return data;
|
|
44
|
-
}
|
|
45
|
-
exports.preload = preload;
|
|
46
|
-
function mapRawValidatorToValidator(validatorRaw) {
|
|
47
|
-
return {
|
|
48
|
-
nodeId: validatorRaw.nodeId,
|
|
49
|
-
address: validatorRaw.address,
|
|
50
|
-
addressChecksum: validatorRaw.addressChecksum,
|
|
51
|
-
name: validatorRaw.name,
|
|
52
|
-
minStake: new bignumber_js_1.default(validatorRaw.minStake),
|
|
53
|
-
maxStake: new bignumber_js_1.default(validatorRaw.maxStake),
|
|
54
|
-
activeStake: new bignumber_js_1.default(validatorRaw.activeStake),
|
|
55
|
-
activeStakePercentage: new bignumber_js_1.default(validatorRaw.activeStakePercentage),
|
|
56
|
-
overstaked: validatorRaw.overstaked,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function fromHydratePreloadData(data) {
|
|
60
|
-
let validators = [];
|
|
61
|
-
if (data && typeof data === "object" && "validators" in data) {
|
|
62
|
-
if (Array.isArray(data.validators)) {
|
|
63
|
-
validators = data.validators.map(mapRawValidatorToValidator);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
validators,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function hydrate(data, currency) {
|
|
71
|
-
const hydrated = fromHydratePreloadData(data);
|
|
72
|
-
(0, logs_1.log)("hedera/preload", `hydrated ${hydrated.validators.length} hedera validators`);
|
|
73
|
-
(0, preload_data_1.setHederaPreloadData)(hydrated, currency);
|
|
74
|
-
}
|
|
75
|
-
exports.hydrate = hydrate;
|
|
76
|
-
//# sourceMappingURL=preload.js.map
|
package/lib/preload.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preload.js","sourceRoot":"","sources":["../src/preload.ts"],"names":[],"mappings":"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"}
|