@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
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
|
-
import { setupMockCryptoAssetsStore } from "@ledgerhq/cryptoassets/cal-client/test-helpers";
|
|
3
1
|
import { encodeTokenAccountId } from "@ledgerhq/coin-framework/account/accountId";
|
|
4
2
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
5
3
|
import type { Pagination } from "@ledgerhq/coin-framework/api/types";
|
|
6
|
-
import { getEnv } from "@ledgerhq/live-env";
|
|
7
4
|
import { listOperations } from "./listOperations";
|
|
8
5
|
import { apiClient } from "../network/api";
|
|
9
6
|
import { getMockedCurrency } from "../test/fixtures/currency.fixture";
|
|
10
|
-
import type { HederaMirrorTransaction } from "../types";
|
|
11
7
|
import * as utils from "./utils";
|
|
8
|
+
import { setupMockCryptoAssetsStore } from "@ledgerhq/cryptoassets/cal-client/test-helpers";
|
|
12
9
|
|
|
13
10
|
setupMockCryptoAssetsStore();
|
|
14
11
|
jest.mock("@ledgerhq/coin-framework/account/accountId");
|
|
@@ -76,7 +73,7 @@ describe("listOperations", () => {
|
|
|
76
73
|
order: "desc",
|
|
77
74
|
};
|
|
78
75
|
|
|
79
|
-
const mockTransactions
|
|
76
|
+
const mockTransactions = [
|
|
80
77
|
{
|
|
81
78
|
consensus_timestamp: "1625097600.000000000",
|
|
82
79
|
transaction_hash: "hash1",
|
|
@@ -84,10 +81,9 @@ describe("listOperations", () => {
|
|
|
84
81
|
result: "SUCCESS",
|
|
85
82
|
memo_base64: "test-memo",
|
|
86
83
|
token_transfers: [],
|
|
87
|
-
staking_reward_transfers: [],
|
|
88
84
|
transfers: [
|
|
89
|
-
{ account: address, amount: -1000000 },
|
|
90
|
-
{ account: "0.0.67890", amount: 1000000 },
|
|
85
|
+
{ account: address, amount: "-1000000" },
|
|
86
|
+
{ account: "0.0.67890", amount: "1000000" },
|
|
91
87
|
],
|
|
92
88
|
name: "CRYPTOTRANSFER",
|
|
93
89
|
},
|
|
@@ -109,8 +105,9 @@ describe("listOperations", () => {
|
|
|
109
105
|
useSyntheticBlocks: false,
|
|
110
106
|
});
|
|
111
107
|
|
|
112
|
-
expect(result.tokenOperations).toEqual([]);
|
|
113
108
|
expect(result.coinOperations).toHaveLength(1);
|
|
109
|
+
expect(result.tokenOperations).toEqual([]);
|
|
110
|
+
|
|
114
111
|
expect(result.coinOperations).toMatchObject([
|
|
115
112
|
{
|
|
116
113
|
type: "OUT",
|
|
@@ -147,17 +144,16 @@ describe("listOperations", () => {
|
|
|
147
144
|
units: [{ name: "TT", code: "tt", magnitude: 6 }],
|
|
148
145
|
};
|
|
149
146
|
|
|
150
|
-
const mockTransactions
|
|
147
|
+
const mockTransactions = [
|
|
151
148
|
{
|
|
152
149
|
consensus_timestamp: "1625097600.000000000",
|
|
153
150
|
transaction_hash: "hash1",
|
|
154
151
|
charged_tx_fee: 500000,
|
|
155
152
|
result: "SUCCESS",
|
|
156
153
|
token_transfers: [
|
|
157
|
-
{ token_id: tokenId, account: address, amount: -1000 },
|
|
158
|
-
{ token_id: tokenId, account: "0.0.67890", amount: 1000 },
|
|
154
|
+
{ token_id: tokenId, account: address, amount: "-1000" },
|
|
155
|
+
{ token_id: tokenId, account: "0.0.67890", amount: "1000" },
|
|
159
156
|
],
|
|
160
|
-
staking_reward_transfers: [],
|
|
161
157
|
transfers: [],
|
|
162
158
|
name: "CRYPTOTRANSFER",
|
|
163
159
|
},
|
|
@@ -184,12 +180,16 @@ describe("listOperations", () => {
|
|
|
184
180
|
useSyntheticBlocks: false,
|
|
185
181
|
});
|
|
186
182
|
|
|
183
|
+
expect(result.coinOperations).toHaveLength(1);
|
|
184
|
+
expect(result.tokenOperations).toHaveLength(1);
|
|
185
|
+
|
|
187
186
|
expect(result.coinOperations).toMatchObject([
|
|
188
187
|
{
|
|
189
188
|
type: "FEES",
|
|
190
189
|
fee: expect.any(Object),
|
|
191
190
|
},
|
|
192
191
|
]);
|
|
192
|
+
|
|
193
193
|
expect(result.tokenOperations).toMatchObject([
|
|
194
194
|
{
|
|
195
195
|
type: "OUT",
|
|
@@ -216,15 +216,14 @@ describe("listOperations", () => {
|
|
|
216
216
|
order: "desc",
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
-
const mockTransactions
|
|
219
|
+
const mockTransactions = [
|
|
220
220
|
{
|
|
221
221
|
consensus_timestamp: "1625097600.000000000",
|
|
222
222
|
transaction_hash: "hash1",
|
|
223
223
|
charged_tx_fee: 500000,
|
|
224
224
|
result: "SUCCESS",
|
|
225
225
|
token_transfers: [],
|
|
226
|
-
|
|
227
|
-
transfers: [{ account: address, amount: -500000 }],
|
|
226
|
+
transfers: [{ account: address, amount: "-500000" }],
|
|
228
227
|
name: "TOKENASSOCIATE",
|
|
229
228
|
},
|
|
230
229
|
];
|
|
@@ -245,7 +244,9 @@ describe("listOperations", () => {
|
|
|
245
244
|
useSyntheticBlocks: false,
|
|
246
245
|
});
|
|
247
246
|
|
|
248
|
-
expect(result.
|
|
247
|
+
expect(result.coinOperations).toHaveLength(1);
|
|
248
|
+
expect(result.tokenOperations).toHaveLength(0);
|
|
249
|
+
|
|
249
250
|
expect(result.coinOperations).toMatchObject([
|
|
250
251
|
{
|
|
251
252
|
type: "ASSOCIATE_TOKEN",
|
|
@@ -272,17 +273,16 @@ describe("listOperations", () => {
|
|
|
272
273
|
order: "desc",
|
|
273
274
|
};
|
|
274
275
|
|
|
275
|
-
const mockTransactions
|
|
276
|
+
const mockTransactions = [
|
|
276
277
|
{
|
|
277
278
|
consensus_timestamp: "1625097600.000000000",
|
|
278
279
|
transaction_hash: "hash1",
|
|
279
280
|
charged_tx_fee: 500000,
|
|
280
281
|
result: "SUCCESS",
|
|
281
282
|
token_transfers: [
|
|
282
|
-
{ token_id: tokenId, account: address, amount: -1000 },
|
|
283
|
-
{ token_id: tokenId, account: "0.0.67890", amount: 1000 },
|
|
283
|
+
{ token_id: tokenId, account: address, amount: "-1000" },
|
|
284
|
+
{ token_id: tokenId, account: "0.0.67890", amount: "1000" },
|
|
284
285
|
],
|
|
285
|
-
staking_reward_transfers: [],
|
|
286
286
|
transfers: [],
|
|
287
287
|
name: "CRYPTOTRANSFER",
|
|
288
288
|
},
|
|
@@ -309,8 +309,8 @@ describe("listOperations", () => {
|
|
|
309
309
|
useSyntheticBlocks: false,
|
|
310
310
|
});
|
|
311
311
|
|
|
312
|
-
expect(result.coinOperations).
|
|
313
|
-
expect(result.tokenOperations).
|
|
312
|
+
expect(result.coinOperations).toHaveLength(0);
|
|
313
|
+
expect(result.tokenOperations).toHaveLength(0);
|
|
314
314
|
});
|
|
315
315
|
|
|
316
316
|
it("should use pagination parameters correctly", async () => {
|
|
@@ -358,18 +358,17 @@ describe("listOperations", () => {
|
|
|
358
358
|
order: "desc",
|
|
359
359
|
};
|
|
360
360
|
|
|
361
|
-
const mockTransactions
|
|
361
|
+
const mockTransactions = [
|
|
362
362
|
{
|
|
363
363
|
consensus_timestamp: "1625097600.000000000",
|
|
364
364
|
transaction_hash: "hash1",
|
|
365
365
|
charged_tx_fee: 500000,
|
|
366
366
|
result: "INVALID_SIGNATURE",
|
|
367
|
-
memo_base64:
|
|
367
|
+
memo_base64: null,
|
|
368
368
|
token_transfers: [],
|
|
369
|
-
staking_reward_transfers: [],
|
|
370
369
|
transfers: [
|
|
371
|
-
{ account: address, amount: -1000000 },
|
|
372
|
-
{ account: "0.0.67890", amount: 1000000 },
|
|
370
|
+
{ account: address, amount: "-1000000" },
|
|
371
|
+
{ account: "0.0.67890", amount: "1000000" },
|
|
373
372
|
],
|
|
374
373
|
name: "CRYPTOTRANSFER",
|
|
375
374
|
},
|
|
@@ -391,63 +390,7 @@ describe("listOperations", () => {
|
|
|
391
390
|
useSyntheticBlocks: false,
|
|
392
391
|
});
|
|
393
392
|
|
|
394
|
-
expect(result.coinOperations).
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
it("should create REWARD operation when staking rewards are present", async () => {
|
|
398
|
-
const address = "0.0.1234567";
|
|
399
|
-
const mockCurrency = getMockedCurrency();
|
|
400
|
-
const pagination: Pagination = {
|
|
401
|
-
minHeight: 0,
|
|
402
|
-
limit: 10,
|
|
403
|
-
order: "desc",
|
|
404
|
-
};
|
|
405
|
-
const mockTransaction: Partial<HederaMirrorTransaction> = {
|
|
406
|
-
consensus_timestamp: "1625097600.000000000",
|
|
407
|
-
transaction_hash: "hash1",
|
|
408
|
-
charged_tx_fee: 500000,
|
|
409
|
-
result: "SUCCESS",
|
|
410
|
-
memo_base64: "",
|
|
411
|
-
token_transfers: [],
|
|
412
|
-
staking_reward_transfers: [{ account: address, amount: 1000000 }],
|
|
413
|
-
transfers: [{ account: address, amount: -500000 }],
|
|
414
|
-
name: "CRYPTOTRANSFER",
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
(apiClient.getAccountTransactions as jest.Mock).mockResolvedValue({
|
|
418
|
-
transactions: [mockTransaction],
|
|
419
|
-
nextCursor: null,
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
const result = await listOperations({
|
|
423
|
-
currency: mockCurrency,
|
|
424
|
-
address,
|
|
425
|
-
pagination,
|
|
426
|
-
mirrorTokens: [],
|
|
427
|
-
fetchAllPages: true,
|
|
428
|
-
skipFeesForTokenOperations: false,
|
|
429
|
-
useEncodedHash: false,
|
|
430
|
-
useSyntheticBlocks: false,
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
const rewardTimestamp = result.coinOperations[0].date.getTime();
|
|
434
|
-
const mainTimestamp = result.coinOperations[1].date.getTime();
|
|
435
|
-
|
|
436
|
-
expect(result.tokenOperations).toEqual([]);
|
|
437
|
-
expect(rewardTimestamp).toBe(mainTimestamp + 1);
|
|
438
|
-
expect(result.coinOperations).toMatchObject([
|
|
439
|
-
{
|
|
440
|
-
type: "REWARD",
|
|
441
|
-
hash: `${mockTransaction.transaction_hash}-staking-reward`,
|
|
442
|
-
value: new BigNumber(1000000),
|
|
443
|
-
fee: new BigNumber(0),
|
|
444
|
-
senders: [getEnv("HEDERA_STAKING_REWARD_ACCOUNT_ID")],
|
|
445
|
-
recipients: [address],
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
type: "OUT",
|
|
449
|
-
hash: mockTransaction.transaction_hash,
|
|
450
|
-
},
|
|
451
|
-
]);
|
|
393
|
+
expect(result.coinOperations).toHaveLength(1);
|
|
394
|
+
expect(result.coinOperations[0].hasFailed).toBe(true);
|
|
452
395
|
});
|
|
453
396
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import { getEnv } from "@ledgerhq/live-env";
|
|
3
2
|
import type { Operation, OperationType } from "@ledgerhq/types-live";
|
|
4
3
|
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
5
4
|
import type { Pagination } from "@ledgerhq/coin-framework/api/types";
|
|
@@ -14,7 +13,6 @@ import { base64ToUrlSafeBase64, getMemoFromBase64, getSyntheticBlock } from "./u
|
|
|
14
13
|
const txNameToCustomOperationType: Record<string, OperationType> = {
|
|
15
14
|
TOKENASSOCIATE: "ASSOCIATE_TOKEN",
|
|
16
15
|
CONTRACTCALL: "CONTRACT_CALL",
|
|
17
|
-
CRYPTOUPDATEACCOUNT: "UPDATE_ACCOUNT",
|
|
18
16
|
};
|
|
19
17
|
|
|
20
18
|
function getCommonOperationData(
|
|
@@ -135,27 +133,14 @@ function processTransfers({
|
|
|
135
133
|
ledgerAccountId: string;
|
|
136
134
|
commonData: ReturnType<typeof getCommonOperationData>;
|
|
137
135
|
mirrorTokens: HederaMirrorToken[];
|
|
138
|
-
}): Operation<HederaOperationExtra>
|
|
139
|
-
const coinOperations: Operation<HederaOperationExtra>[] = [];
|
|
136
|
+
}): Operation<HederaOperationExtra> | null {
|
|
140
137
|
const transfers = rawTx.transfers ?? [];
|
|
141
|
-
|
|
142
|
-
if (transfers.length === 0) {
|
|
143
|
-
return [];
|
|
144
|
-
}
|
|
138
|
+
if (transfers.length === 0) return null;
|
|
145
139
|
|
|
146
140
|
const { type, value, senders, recipients } = parseTransfers(transfers, address);
|
|
147
141
|
const { hash, fee, timestamp, blockHeight, blockHash, hasFailed } = commonData;
|
|
148
142
|
const extra = { ...commonData.extra };
|
|
149
143
|
const operationType = txNameToCustomOperationType[rawTx.name] ?? type;
|
|
150
|
-
const stakingReward = rawTx.staking_reward_transfers.reduce((acc, transfer) => {
|
|
151
|
-
const transferAmount = new BigNumber(transfer.amount);
|
|
152
|
-
|
|
153
|
-
if (transfer.account === address) {
|
|
154
|
-
acc = acc.plus(transferAmount);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return acc;
|
|
158
|
-
}, new BigNumber(0));
|
|
159
144
|
|
|
160
145
|
// try to enrich ASSOCIATE_TOKEN operation with extra.associatedTokenId
|
|
161
146
|
// this value is used by custom OperationDetails components in Hedera family
|
|
@@ -170,30 +155,7 @@ function processTransfers({
|
|
|
170
155
|
}
|
|
171
156
|
}
|
|
172
157
|
|
|
173
|
-
|
|
174
|
-
if (stakingReward.gt(0)) {
|
|
175
|
-
const stakingRewardHash = `${hash}-staking-reward`;
|
|
176
|
-
const stakingRewardType: OperationType = "REWARD";
|
|
177
|
-
// offset timestamp by +1ms to ensure it appears just before the operation that triggered it
|
|
178
|
-
const stakingRewardTimestamp = new Date(timestamp.getTime() + 1);
|
|
179
|
-
|
|
180
|
-
coinOperations.push({
|
|
181
|
-
id: encodeOperationId(ledgerAccountId, stakingRewardHash, stakingRewardType),
|
|
182
|
-
accountId: ledgerAccountId,
|
|
183
|
-
type: stakingRewardType,
|
|
184
|
-
value: stakingReward,
|
|
185
|
-
recipients: [address],
|
|
186
|
-
senders: [getEnv("HEDERA_STAKING_REWARD_ACCOUNT_ID")],
|
|
187
|
-
hash: stakingRewardHash,
|
|
188
|
-
fee: new BigNumber(0),
|
|
189
|
-
date: stakingRewardTimestamp,
|
|
190
|
-
blockHeight,
|
|
191
|
-
blockHash,
|
|
192
|
-
extra,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
coinOperations.push({
|
|
158
|
+
return {
|
|
197
159
|
id: encodeOperationId(ledgerAccountId, hash, operationType),
|
|
198
160
|
accountId: ledgerAccountId,
|
|
199
161
|
type: operationType,
|
|
@@ -207,9 +169,7 @@ function processTransfers({
|
|
|
207
169
|
blockHash,
|
|
208
170
|
hasFailed,
|
|
209
171
|
extra,
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return coinOperations;
|
|
172
|
+
};
|
|
213
173
|
}
|
|
214
174
|
|
|
215
175
|
export async function listOperations({
|
|
@@ -271,7 +231,7 @@ export async function listOperations({
|
|
|
271
231
|
|
|
272
232
|
// process regular transfers only if there were no token transfers
|
|
273
233
|
if (!tokenResult) {
|
|
274
|
-
const
|
|
234
|
+
const coinOperation = processTransfers({
|
|
275
235
|
rawTx,
|
|
276
236
|
address,
|
|
277
237
|
ledgerAccountId,
|
|
@@ -279,7 +239,7 @@ export async function listOperations({
|
|
|
279
239
|
mirrorTokens,
|
|
280
240
|
});
|
|
281
241
|
|
|
282
|
-
coinOperations.push(
|
|
242
|
+
if (coinOperation) coinOperations.push(coinOperation);
|
|
283
243
|
}
|
|
284
244
|
}
|
|
285
245
|
|