@ledgerhq/coin-hedera 1.15.0-nightly.20251205111238 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +26 -10
  3. package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -1
  4. package/lib/bridge/buildOptimisticOperation.js +0 -33
  5. package/lib/bridge/buildOptimisticOperation.js.map +1 -1
  6. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  7. package/lib/bridge/getTransactionStatus.js +0 -54
  8. package/lib/bridge/getTransactionStatus.js.map +1 -1
  9. package/lib/bridge/index.d.ts.map +1 -1
  10. package/lib/bridge/index.js +2 -4
  11. package/lib/bridge/index.js.map +1 -1
  12. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  13. package/lib/bridge/prepareTransaction.js +0 -16
  14. package/lib/bridge/prepareTransaction.js.map +1 -1
  15. package/lib/bridge/serialization.d.ts.map +1 -1
  16. package/lib/bridge/serialization.js +0 -20
  17. package/lib/bridge/serialization.js.map +1 -1
  18. package/lib/bridge/signOperation.d.ts +4 -4
  19. package/lib/bridge/signOperation.d.ts.map +1 -1
  20. package/lib/bridge/signOperation.js +0 -10
  21. package/lib/bridge/signOperation.js.map +1 -1
  22. package/lib/bridge/synchronisation.d.ts.map +1 -1
  23. package/lib/bridge/synchronisation.js +0 -8
  24. package/lib/bridge/synchronisation.js.map +1 -1
  25. package/lib/constants.d.ts +1 -21
  26. package/lib/constants.d.ts.map +1 -1
  27. package/lib/constants.js +1 -22
  28. package/lib/constants.js.map +1 -1
  29. package/lib/deviceTransactionConfig.d.ts.map +1 -1
  30. package/lib/deviceTransactionConfig.js +0 -30
  31. package/lib/deviceTransactionConfig.js.map +1 -1
  32. package/lib/errors.d.ts +0 -9
  33. package/lib/errors.d.ts.map +1 -1
  34. package/lib/errors.js +1 -4
  35. package/lib/errors.js.map +1 -1
  36. package/lib/logic/craftTransaction.d.ts +2 -2
  37. package/lib/logic/craftTransaction.d.ts.map +1 -1
  38. package/lib/logic/craftTransaction.js +8 -42
  39. package/lib/logic/craftTransaction.js.map +1 -1
  40. package/lib/logic/getBlock.d.ts.map +1 -1
  41. package/lib/logic/getBlock.js +0 -1
  42. package/lib/logic/getBlock.js.map +1 -1
  43. package/lib/logic/listOperations.d.ts.map +1 -1
  44. package/lib/logic/listOperations.js +7 -39
  45. package/lib/logic/listOperations.js.map +1 -1
  46. package/lib/logic/utils.d.ts +3 -61
  47. package/lib/logic/utils.d.ts.map +1 -1
  48. package/lib/logic/utils.js +3 -116
  49. package/lib/logic/utils.js.map +1 -1
  50. package/lib/network/api.d.ts +1 -3
  51. package/lib/network/api.d.ts.map +1 -1
  52. package/lib/network/api.js +0 -19
  53. package/lib/network/api.js.map +1 -1
  54. package/lib/test/fixtures/account.fixture.d.ts +1 -1
  55. package/lib/test/fixtures/account.fixture.d.ts.map +1 -1
  56. package/lib/test/fixtures/account.fixture.js +0 -2
  57. package/lib/test/fixtures/account.fixture.js.map +1 -1
  58. package/lib/transaction.d.ts.map +1 -1
  59. package/lib/transaction.js +0 -34
  60. package/lib/transaction.js.map +1 -1
  61. package/lib/types/alpaca.d.ts +0 -3
  62. package/lib/types/alpaca.d.ts.map +1 -1
  63. package/lib/types/bridge.d.ts +3 -87
  64. package/lib/types/bridge.d.ts.map +1 -1
  65. package/lib/types/logic.d.ts +1 -5
  66. package/lib/types/logic.d.ts.map +1 -1
  67. package/lib/types/mirror.d.ts +0 -19
  68. package/lib/types/mirror.d.ts.map +1 -1
  69. package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -1
  70. package/lib-es/bridge/buildOptimisticOperation.js +1 -34
  71. package/lib-es/bridge/buildOptimisticOperation.js.map +1 -1
  72. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  73. package/lib-es/bridge/getTransactionStatus.js +3 -57
  74. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  75. package/lib-es/bridge/index.d.ts.map +1 -1
  76. package/lib-es/bridge/index.js +2 -4
  77. package/lib-es/bridge/index.js.map +1 -1
  78. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  79. package/lib-es/bridge/prepareTransaction.js +2 -15
  80. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  81. package/lib-es/bridge/serialization.d.ts.map +1 -1
  82. package/lib-es/bridge/serialization.js +0 -17
  83. package/lib-es/bridge/serialization.js.map +1 -1
  84. package/lib-es/bridge/signOperation.d.ts +4 -4
  85. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  86. package/lib-es/bridge/signOperation.js +1 -11
  87. package/lib-es/bridge/signOperation.js.map +1 -1
  88. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  89. package/lib-es/bridge/synchronisation.js +0 -8
  90. package/lib-es/bridge/synchronisation.js.map +1 -1
  91. package/lib-es/constants.d.ts +1 -21
  92. package/lib-es/constants.d.ts.map +1 -1
  93. package/lib-es/constants.js +0 -21
  94. package/lib-es/constants.js.map +1 -1
  95. package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
  96. package/lib-es/deviceTransactionConfig.js +1 -31
  97. package/lib-es/deviceTransactionConfig.js.map +1 -1
  98. package/lib-es/errors.d.ts +0 -9
  99. package/lib-es/errors.d.ts.map +1 -1
  100. package/lib-es/errors.js +0 -3
  101. package/lib-es/errors.js.map +1 -1
  102. package/lib-es/logic/craftTransaction.d.ts +2 -2
  103. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  104. package/lib-es/logic/craftTransaction.js +10 -44
  105. package/lib-es/logic/craftTransaction.js.map +1 -1
  106. package/lib-es/logic/getBlock.d.ts.map +1 -1
  107. package/lib-es/logic/getBlock.js +1 -2
  108. package/lib-es/logic/getBlock.js.map +1 -1
  109. package/lib-es/logic/listOperations.d.ts.map +1 -1
  110. package/lib-es/logic/listOperations.js +7 -39
  111. package/lib-es/logic/listOperations.js.map +1 -1
  112. package/lib-es/logic/utils.d.ts +3 -61
  113. package/lib-es/logic/utils.d.ts.map +1 -1
  114. package/lib-es/logic/utils.js +3 -106
  115. package/lib-es/logic/utils.js.map +1 -1
  116. package/lib-es/network/api.d.ts +1 -3
  117. package/lib-es/network/api.d.ts.map +1 -1
  118. package/lib-es/network/api.js +0 -19
  119. package/lib-es/network/api.js.map +1 -1
  120. package/lib-es/test/fixtures/account.fixture.d.ts +1 -1
  121. package/lib-es/test/fixtures/account.fixture.d.ts.map +1 -1
  122. package/lib-es/test/fixtures/account.fixture.js +0 -2
  123. package/lib-es/test/fixtures/account.fixture.js.map +1 -1
  124. package/lib-es/transaction.d.ts.map +1 -1
  125. package/lib-es/transaction.js +0 -34
  126. package/lib-es/transaction.js.map +1 -1
  127. package/lib-es/types/alpaca.d.ts +0 -3
  128. package/lib-es/types/alpaca.d.ts.map +1 -1
  129. package/lib-es/types/bridge.d.ts +3 -87
  130. package/lib-es/types/bridge.d.ts.map +1 -1
  131. package/lib-es/types/logic.d.ts +1 -5
  132. package/lib-es/types/logic.d.ts.map +1 -1
  133. package/lib-es/types/mirror.d.ts +0 -19
  134. package/lib-es/types/mirror.d.ts.map +1 -1
  135. package/package.json +9 -10
  136. package/src/api/index.integ.test.ts +1 -11
  137. package/src/bridge/buildOptimisticOperation.integration.test.ts +4 -159
  138. package/src/bridge/buildOptimisticOperation.ts +2 -50
  139. package/src/bridge/getTransactionStatus.test.ts +21 -191
  140. package/src/bridge/getTransactionStatus.ts +1 -75
  141. package/src/bridge/index.ts +2 -4
  142. package/src/bridge/prepareTransaction.test.ts +8 -112
  143. package/src/bridge/prepareTransaction.ts +2 -20
  144. package/src/bridge/serialization.ts +0 -17
  145. package/src/bridge/signOperation.ts +5 -15
  146. package/src/bridge/synchronisation.ts +0 -9
  147. package/src/bridge/utils.integration.test.ts +10 -3
  148. package/src/constants.ts +0 -22
  149. package/src/deviceTransactionConfig.ts +1 -37
  150. package/src/errors.ts +0 -7
  151. package/src/logic/craftTransaction.ts +13 -70
  152. package/src/logic/getBalance.test.ts +16 -15
  153. package/src/logic/getBlock.ts +1 -2
  154. package/src/logic/listOperations.test.ts +29 -86
  155. package/src/logic/listOperations.ts +6 -46
  156. package/src/logic/utils.test.ts +8 -362
  157. package/src/logic/utils.ts +3 -157
  158. package/src/network/api.test.ts +6 -58
  159. package/src/network/api.ts +0 -25
  160. package/src/network/thirdweb.test.ts +2 -2
  161. package/src/network/utils.test.ts +6 -4
  162. package/src/test/fixtures/account.fixture.ts +1 -3
  163. package/src/transaction.ts +0 -42
  164. package/src/types/alpaca.ts +0 -4
  165. package/src/types/bridge.ts +3 -108
  166. package/src/types/logic.ts +1 -6
  167. package/src/types/mirror.ts +0 -21
  168. package/lib/preload-data.d.ts +0 -7
  169. package/lib/preload-data.d.ts.map +0 -1
  170. package/lib/preload-data.js +0 -37
  171. package/lib/preload-data.js.map +0 -1
  172. package/lib/preload.d.ts +0 -8
  173. package/lib/preload.d.ts.map +0 -1
  174. package/lib/preload.js +0 -76
  175. package/lib/preload.js.map +0 -1
  176. package/lib-es/preload-data.d.ts +0 -7
  177. package/lib-es/preload-data.d.ts.map +0 -1
  178. package/lib-es/preload-data.js +0 -31
  179. package/lib-es/preload-data.js.map +0 -1
  180. package/lib-es/preload.d.ts +0 -8
  181. package/lib-es/preload.d.ts.map +0 -1
  182. package/lib-es/preload.js +0 -67
  183. package/lib-es/preload.js.map +0 -1
  184. package/src/deviceTransactionConfig.test.ts +0 -315
  185. package/src/preload-data.ts +0 -38
  186. package/src/preload.test.ts +0 -64
  187. package/src/preload.ts +0 -80
@@ -1,4 +1,3 @@
1
- import BigNumber from "bignumber.js";
2
1
  import type { AccountRaw, Account } from "@ledgerhq/types-live";
3
2
  import type {
4
3
  HederaAccount,
@@ -9,35 +8,19 @@ import type {
9
8
 
10
9
  export function toHederaResourcesRaw(resources: HederaResources): HederaResourcesRaw {
11
10
  const { maxAutomaticTokenAssociations, isAutoTokenAssociationEnabled } = resources;
12
- const delegation = resources.delegation
13
- ? {
14
- nodeId: resources.delegation.nodeId,
15
- delegated: resources.delegation.delegated.toString(),
16
- pendingReward: resources.delegation.pendingReward.toString(),
17
- }
18
- : null;
19
11
 
20
12
  return {
21
13
  maxAutomaticTokenAssociations,
22
14
  isAutoTokenAssociationEnabled,
23
- delegation,
24
15
  };
25
16
  }
26
17
 
27
18
  export function fromHederaResourcesRaw(rawResources: HederaResourcesRaw): HederaResources {
28
19
  const { maxAutomaticTokenAssociations, isAutoTokenAssociationEnabled } = rawResources;
29
- const delegation = rawResources.delegation
30
- ? {
31
- nodeId: rawResources.delegation.nodeId,
32
- delegated: new BigNumber(rawResources.delegation.delegated),
33
- pendingReward: new BigNumber(rawResources.delegation.pendingReward),
34
- }
35
- : null;
36
20
 
37
21
  return {
38
22
  maxAutomaticTokenAssociations,
39
23
  isAutoTokenAssociationEnabled,
40
- delegation,
41
24
  };
42
25
  }
43
26
 
@@ -1,7 +1,7 @@
1
1
  import { Observable } from "rxjs";
2
- import type { AccountBridge } from "@ledgerhq/types-live";
3
- import type { AssetInfo, FeeEstimation } from "@ledgerhq/coin-framework/api/types";
4
- import type { SignerContext } from "@ledgerhq/coin-framework/signer";
2
+ import { Account, AccountBridge } from "@ledgerhq/types-live";
3
+ import { AssetInfo, FeeEstimation } from "@ledgerhq/coin-framework/api/types";
4
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
5
5
  import { findSubAccountById } from "@ledgerhq/coin-framework/account/helpers";
6
6
  import { buildOptimisticOperation } from "./buildOptimisticOperation";
7
7
  import { DEFAULT_GAS_LIMIT, HEDERA_TRANSACTION_MODES } from "../constants";
@@ -12,14 +12,13 @@ import {
12
12
  serializeTransaction,
13
13
  getHederaTransactionBodyBytes,
14
14
  isTokenAssociateTransaction,
15
- isStakingTransaction,
16
15
  } from "../logic/utils";
17
- import type { Transaction, HederaSigner, HederaTxData, HederaAccount } from "../types";
16
+ import type { Transaction, HederaSigner, HederaTxData } from "../types";
18
17
 
19
18
  export const buildSignOperation =
20
19
  (
21
20
  signerContext: SignerContext<HederaSigner>,
22
- ): AccountBridge<Transaction, HederaAccount>["signOperation"] =>
21
+ ): AccountBridge<Transaction, Account>["signOperation"] =>
23
22
  ({ account, transaction, deviceId }) =>
24
23
  new Observable(o => {
25
24
  void (async function () {
@@ -65,15 +64,6 @@ export const buildSignOperation =
65
64
  type: "erc20",
66
65
  gasLimit: BigInt((transaction.gasLimit ?? DEFAULT_GAS_LIMIT).toString()),
67
66
  };
68
- } else if (isStakingTransaction(transaction)) {
69
- type = transaction.mode;
70
- asset = {
71
- type: "native",
72
- };
73
- data = {
74
- type: "staking",
75
- stakingNodeId: transaction.properties?.stakingNodeId,
76
- };
77
67
  } else {
78
68
  type = HEDERA_TRANSACTION_MODES.Send;
79
69
  asset = {
@@ -107,14 +107,6 @@ export const getAccountShape: GetAccountShape<HederaAccount> = async (
107
107
  const operations = shouldSyncFromScratch
108
108
  ? enrichedNewOperations
109
109
  : mergeOps(oldOperations, enrichedNewOperations);
110
- const delegation =
111
- typeof mirrorAccount.staked_node_id === "number"
112
- ? {
113
- nodeId: mirrorAccount.staked_node_id,
114
- delegated: accountBalance,
115
- pendingReward: new BigNumber(mirrorAccount.pending_reward),
116
- }
117
- : null;
118
110
 
119
111
  // how ERC20 operations are handled:
120
112
  // - mirror node doesn't include "IN" erc20 token transactions
@@ -167,7 +159,6 @@ export const getAccountShape: GetAccountShape<HederaAccount> = async (
167
159
  hederaResources: {
168
160
  maxAutomaticTokenAssociations: mirrorAccount.max_automatic_token_associations,
169
161
  isAutoTokenAssociationEnabled: mirrorAccount.max_automatic_token_associations === -1,
170
- delegation,
171
162
  },
172
163
  };
173
164
  };
@@ -218,7 +218,7 @@ describe("utils", () => {
218
218
  erc20Tokens: [],
219
219
  });
220
220
 
221
- expect(result).toEqual([]);
221
+ expect(result).toHaveLength(0);
222
222
  });
223
223
 
224
224
  it("returns sub account for mirror token with no operations yet (e.g. right after association)", async () => {
@@ -237,6 +237,7 @@ describe("utils", () => {
237
237
  erc20Tokens: [],
238
238
  });
239
239
 
240
+ expect(result).toHaveLength(1);
240
241
  expect(result).toMatchObject([
241
242
  {
242
243
  token: tokenCurrencyFromCAL,
@@ -258,6 +259,7 @@ describe("utils", () => {
258
259
  erc20Tokens: [{ balance: new BigNumber(42), token: tokenCurrencyFromCAL }],
259
260
  });
260
261
 
262
+ expect(result).toHaveLength(1);
261
263
  expect(result).toMatchObject([
262
264
  {
263
265
  token: tokenCurrencyFromCAL,
@@ -339,6 +341,7 @@ describe("utils", () => {
339
341
  hash: incomingTxHash,
340
342
  blockHash: incomingERC20Transaction.blockHash,
341
343
  });
344
+ expect(incomingOp?.subOperations).toHaveLength(1);
342
345
  expect(incomingOp?.subOperations).toMatchObject([
343
346
  {
344
347
  type: "IN",
@@ -350,6 +353,7 @@ describe("utils", () => {
350
353
  recipients: [address],
351
354
  },
352
355
  ]);
356
+ expect(newERC20TokenOperations).toHaveLength(1);
353
357
  expect(newERC20TokenOperations).toMatchObject([incomingOp?.subOperations?.[0]]);
354
358
  expect(updatedOperations).toHaveLength(oldMirrorOperations.length + 1);
355
359
  });
@@ -418,6 +422,7 @@ describe("utils", () => {
418
422
  blockHash: allowanceERC20Transaction.blockHash,
419
423
  standard: "erc20",
420
424
  });
425
+ expect(allowanceOp?.subOperations).toHaveLength(1);
421
426
  expect(allowanceOp?.subOperations).toMatchObject([
422
427
  {
423
428
  type: "OUT",
@@ -429,6 +434,7 @@ describe("utils", () => {
429
434
  recipients: [allowanceTxTo],
430
435
  },
431
436
  ]);
437
+ expect(newERC20TokenOperations).toHaveLength(1);
432
438
  expect(newERC20TokenOperations).toMatchObject([allowanceOp?.subOperations?.[0]]);
433
439
  expect(updatedOperations).toHaveLength(oldMirrorOperations.length + 1);
434
440
  });
@@ -513,7 +519,7 @@ describe("utils", () => {
513
519
  );
514
520
 
515
521
  expect(updatedOperations).toHaveLength(2);
516
- expect(duplicatedContractCalls).toEqual([]);
522
+ expect(duplicatedContractCalls).toHaveLength(0);
517
523
  expect(feesOps).toHaveLength(1);
518
524
  expect(feesOps).toMatchObject([{ blockHash: "0xBLOCK" }]);
519
525
  });
@@ -547,7 +553,7 @@ describe("utils", () => {
547
553
 
548
554
  expect(pendingOp).toBeUndefined();
549
555
  expect(updatedOperations).toHaveLength(1);
550
- expect(updatedOperations).toMatchObject([{ hash: "confirmed_tx" }]);
556
+ expect(updatedOperations[0].hash).toBe("confirmed_tx");
551
557
  });
552
558
 
553
559
  /**
@@ -666,6 +672,7 @@ describe("utils", () => {
666
672
  },
667
673
  ],
668
674
  });
675
+ expect(newERC20TokenOperations).toHaveLength(1);
669
676
  expect(newERC20TokenOperations).toMatchObject([
670
677
  {
671
678
  type: "OUT",
package/src/constants.ts CHANGED
@@ -7,17 +7,12 @@ import BigNumber from "bignumber.js";
7
7
  export enum HEDERA_TRANSACTION_MODES {
8
8
  Send = "send",
9
9
  TokenAssociate = "token-associate",
10
- Delegate = "delegate",
11
- Undelegate = "undelegate",
12
- Redelegate = "redelegate",
13
- ClaimRewards = "claim-rewards",
14
10
  }
15
11
 
16
12
  /**
17
13
  * Enum representing the supported Hedera operation types for fee estimation
18
14
  */
19
15
  export enum HEDERA_OPERATION_TYPES {
20
- CryptoUpdate = "CryptoUpdate",
21
16
  CryptoTransfer = "CryptoTransfer",
22
17
  TokenTransfer = "TokenTransfer",
23
18
  TokenAssociate = "TokenAssociate",
@@ -44,15 +39,6 @@ export const DEFAULT_GAS_PRICE_TINYBARS = new BigNumber(100);
44
39
 
45
40
  export const HEDERA_MAINNET_CHAIN_ID = 295;
46
41
 
47
- /**
48
- * Enum representing the delegation status of a Hedera account
49
- */
50
- export enum HEDERA_DELEGATION_STATUS {
51
- Inactive = "inactive",
52
- Overstaked = "overstaked",
53
- Active = "active",
54
- }
55
-
56
42
  /**
57
43
  * https://docs.hedera.com/hedera/networks/mainnet/fees
58
44
  *
@@ -63,7 +49,6 @@ export enum HEDERA_DELEGATION_STATUS {
63
49
  * has sufficient balance to cover the cost of a transaction (e.g. token association).
64
50
  */
65
51
  export const BASE_USD_FEE_BY_OPERATION_TYPE = {
66
- [HEDERA_OPERATION_TYPES.CryptoUpdate]: 0.00022 * 10 ** TINYBAR_SCALE,
67
52
  [HEDERA_OPERATION_TYPES.CryptoTransfer]: 0.0001 * 10 ** TINYBAR_SCALE,
68
53
  [HEDERA_OPERATION_TYPES.TokenTransfer]: 0.001 * 10 ** TINYBAR_SCALE,
69
54
  [HEDERA_OPERATION_TYPES.TokenAssociate]: 0.05 * 10 ** TINYBAR_SCALE,
@@ -99,10 +84,3 @@ export const SUPPORTED_ERC20_TOKENS = [
99
84
  tokenId: "0.0.10047837",
100
85
  },
101
86
  ];
102
-
103
- export const MAP_STAKING_MODE_TO_MEMO = {
104
- [HEDERA_TRANSACTION_MODES.ClaimRewards]: "Collect Staking Rewards",
105
- [HEDERA_TRANSACTION_MODES.Delegate]: "Stake",
106
- [HEDERA_TRANSACTION_MODES.Undelegate]: "Unstake",
107
- [HEDERA_TRANSACTION_MODES.Redelegate]: "Restake",
108
- } as const;
@@ -1,7 +1,7 @@
1
1
  import type { CommonDeviceTransactionField as DeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
2
2
  import type { AccountLike, Account } from "@ledgerhq/types-live";
3
3
  import { HEDERA_TRANSACTION_MODES } from "./constants";
4
- import { isTokenAssociateTransaction, isStakingTransaction } from "./logic/utils";
4
+ import { isTokenAssociateTransaction } from "./logic/utils";
5
5
  import type { Transaction, TransactionStatus } from "./types";
6
6
 
7
7
  async function getDeviceTransactionConfig({
@@ -15,42 +15,6 @@ async function getDeviceTransactionConfig({
15
15
  }): Promise<Array<DeviceTransactionField>> {
16
16
  const fields: Array<DeviceTransactionField> = [];
17
17
 
18
- if (isStakingTransaction(transaction)) {
19
- fields.push({
20
- type: "text",
21
- label: "Method",
22
- value:
23
- transaction.mode === HEDERA_TRANSACTION_MODES.ClaimRewards
24
- ? "Claim Rewards"
25
- : "Update Account",
26
- });
27
-
28
- if (!estimatedFees.isZero()) {
29
- fields.push({
30
- type: "fees",
31
- label: "Fees",
32
- });
33
- }
34
-
35
- if (typeof transaction.properties?.stakingNodeId === "number") {
36
- fields.push({
37
- type: "text",
38
- label: "Staked Node ID",
39
- value: transaction.properties.stakingNodeId.toString(),
40
- });
41
- }
42
-
43
- if (transaction.memo) {
44
- fields.push({
45
- type: "text",
46
- label: "Memo",
47
- value: transaction.memo,
48
- });
49
- }
50
-
51
- return fields;
52
- }
53
-
54
18
  const method = (() => {
55
19
  if (isTokenAssociateTransaction(transaction)) return "Associate Token";
56
20
  else if (transaction.useAllAmount) return "Transfer All";
package/src/errors.ts CHANGED
@@ -16,10 +16,3 @@ export const HederaRecipientTokenAssociationUnverified = createCustomErrorClass(
16
16
  export const HederaRecipientEvmAddressVerificationRequired = createCustomErrorClass(
17
17
  "HederaRecipientEvmAddressVerificationRequired",
18
18
  );
19
- export const HederaRedundantStakingNodeIdError = createCustomErrorClass(
20
- "HederaRedundantStakingNodeIdError",
21
- );
22
- export const HederaInvalidStakingNodeIdError = createCustomErrorClass(
23
- "HederaInvalidStakingNodeIdError",
24
- );
25
- export const HederaNoStakingRewardsError = createCustomErrorClass("HederaNoStakingRewardsError");
@@ -2,7 +2,6 @@ import BigNumber from "bignumber.js";
2
2
  import invariant from "invariant";
3
3
  import {
4
4
  AccountId,
5
- AccountUpdateTransaction,
6
5
  ContractExecuteTransaction,
7
6
  ContractFunctionParameters,
8
7
  ContractId,
@@ -14,7 +13,7 @@ import {
14
13
  import type { FeeEstimation, TransactionIntent } from "@ledgerhq/coin-framework/api/index";
15
14
  import { DEFAULT_GAS_LIMIT, HEDERA_TRANSACTION_MODES } from "../constants";
16
15
  import type { HederaMemo, HederaTxData } from "../types";
17
- import { hasSpecificIntentData, serializeTransaction } from "./utils";
16
+ import { serializeTransaction } from "./utils";
18
17
 
19
18
  // avoid "sign" prompt loop by having only one node (one transaction)
20
19
  // https://github.com/LedgerHQ/ledger-live/pull/72/commits/1e942687d4301660e43e0c4b5419fcfa2733b290
@@ -56,14 +55,6 @@ interface BuilderTokenAssociateTransaction extends BuilderCommonTransactionField
56
55
  tokenId: string;
57
56
  }
58
57
 
59
- interface BuilderUpdateAccountTransaction extends BuilderCommonTransactionFields {
60
- type:
61
- | HEDERA_TRANSACTION_MODES.Delegate
62
- | HEDERA_TRANSACTION_MODES.Undelegate
63
- | HEDERA_TRANSACTION_MODES.Redelegate;
64
- stakingNodeId: number | null | undefined;
65
- }
66
-
67
58
  async function buildUnsignedCoinTransaction({
68
59
  account,
69
60
  transaction,
@@ -168,42 +159,13 @@ async function buildTokenAssociateTransaction({
168
159
  return tx.freeze();
169
160
  }
170
161
 
171
- async function buildUnsignedUpdateAccountTransaction({
172
- account,
173
- transaction,
174
- }: {
175
- account: BuilderOperator;
176
- transaction: BuilderUpdateAccountTransaction;
177
- }): Promise<AccountUpdateTransaction> {
178
- const accountId = account.accountId;
179
-
180
- const tx = new AccountUpdateTransaction()
181
- .setNodeAccountIds([new AccountId(3)])
182
- .setTransactionId(TransactionId.generate(accountId))
183
- .setTransactionMemo(transaction.memo ?? "")
184
- .setAccountId(accountId);
185
-
186
- if (transaction.maxFee) {
187
- tx.setMaxTransactionFee(Hbar.fromTinybars(transaction.maxFee.toNumber()));
188
- }
189
-
190
- if (typeof transaction.stakingNodeId === "number") {
191
- tx.setStakedNodeId(transaction.stakingNodeId);
192
- }
193
-
194
- if (transaction.stakingNodeId === null) {
195
- tx.clearStakedNodeId();
196
- }
197
-
198
- return tx.freeze();
199
- }
200
-
201
162
  export async function craftTransaction(
202
163
  txIntent: TransactionIntent<HederaMemo, HederaTxData>,
203
164
  customFees?: FeeEstimation,
204
165
  ) {
205
- const account = { accountId: txIntent.sender };
206
- const maxFee = customFees ? new BigNumber(customFees.value.toString()) : undefined;
166
+ const account = {
167
+ accountId: txIntent.sender,
168
+ };
207
169
 
208
170
  let tx;
209
171
 
@@ -217,7 +179,7 @@ export async function craftTransaction(
217
179
  type: txIntent.type,
218
180
  tokenId: txIntent.asset.assetReference,
219
181
  memo: txIntent.memo.value,
220
- maxFee,
182
+ maxFee: customFees ? new BigNumber(customFees.value.toString()) : undefined,
221
183
  },
222
184
  });
223
185
  } else if (txIntent.type === HEDERA_TRANSACTION_MODES.Send && txIntent.asset.type === "hts") {
@@ -233,16 +195,17 @@ export async function craftTransaction(
233
195
  amount,
234
196
  recipient: txIntent.recipient,
235
197
  memo: txIntent.memo.value,
236
- maxFee,
198
+ maxFee: customFees ? new BigNumber(customFees.value.toString()) : undefined,
237
199
  },
238
200
  });
239
201
  } else if (txIntent.type === HEDERA_TRANSACTION_MODES.Send && txIntent.asset.type === "erc20") {
240
202
  invariant("assetReference" in txIntent.asset, "hedera: no assetReference in token transfer");
241
203
 
242
204
  const amount = new BigNumber(txIntent.amount.toString());
243
- const gasLimit = hasSpecificIntentData(txIntent, "erc20")
244
- ? new BigNumber(txIntent.data.gasLimit.toString())
245
- : DEFAULT_GAS_LIMIT;
205
+ const gasLimit =
206
+ "data" in txIntent && txIntent.data.gasLimit
207
+ ? new BigNumber(txIntent.data.gasLimit.toString())
208
+ : DEFAULT_GAS_LIMIT;
246
209
 
247
210
  tx = await buildUnsignedERC20TokenTransaction({
248
211
  account,
@@ -252,31 +215,11 @@ export async function craftTransaction(
252
215
  amount,
253
216
  recipient: txIntent.recipient,
254
217
  memo: txIntent.memo.value,
255
- maxFee,
218
+ maxFee: customFees ? new BigNumber(customFees.value.toString()) : undefined,
256
219
  gasLimit,
257
220
  },
258
221
  });
259
- } else if (
260
- txIntent.type === HEDERA_TRANSACTION_MODES.Redelegate ||
261
- txIntent.type === HEDERA_TRANSACTION_MODES.Undelegate ||
262
- txIntent.type === HEDERA_TRANSACTION_MODES.Delegate
263
- ) {
264
- const stakingNodeId = hasSpecificIntentData(txIntent, "staking")
265
- ? txIntent.data.stakingNodeId
266
- : undefined;
267
-
268
- tx = await buildUnsignedUpdateAccountTransaction({
269
- account,
270
- transaction: {
271
- type: txIntent.type,
272
- memo: txIntent.memo.value,
273
- maxFee,
274
- stakingNodeId,
275
- },
276
- });
277
- }
278
- // HEDERA_TRANSACTION_MODES.ClaimRewards is just a coin transfer that triggers staking rewards claim
279
- else {
222
+ } else {
280
223
  const amount = new BigNumber(txIntent.amount.toString());
281
224
 
282
225
  tx = await buildUnsignedCoinTransaction({
@@ -286,7 +229,7 @@ export async function craftTransaction(
286
229
  amount,
287
230
  recipient: txIntent.recipient,
288
231
  memo: txIntent.memo.value,
289
- maxFee,
232
+ maxFee: customFees ? new BigNumber(customFees.value.toString()) : undefined,
290
233
  },
291
234
  });
292
235
  }
@@ -29,6 +29,7 @@ describe("getBalance", () => {
29
29
  expect(apiClient.getAccount).toHaveBeenCalledWith(address);
30
30
  expect(apiClient.getAccountTokens).toHaveBeenCalledTimes(1);
31
31
  expect(apiClient.getAccountTokens).toHaveBeenCalledWith(address);
32
+ expect(result).toHaveLength(1);
32
33
  expect(result).toEqual([
33
34
  {
34
35
  asset: { type: "native" },
@@ -79,6 +80,7 @@ describe("getBalance", () => {
79
80
  expect(apiClient.getAccountTokens).toHaveBeenCalledWith(address);
80
81
  expect(findTokenByAddressInCurrencyMock).toHaveBeenCalledTimes(1);
81
82
  expect(findTokenByAddressInCurrencyMock).toHaveBeenCalledWith("0.0.7890", "hedera");
83
+ expect(result).toHaveLength(2);
82
84
  expect(result).toEqual(
83
85
  expect.arrayContaining([
84
86
  {
@@ -148,22 +150,21 @@ describe("getBalance", () => {
148
150
 
149
151
  const result = await getBalance(mockCurrency, address);
150
152
 
151
- expect(result).toEqual([
152
- {
153
- asset: { type: "native" },
154
- value: BigInt("1000000000"),
155
- },
156
- {
157
- value: BigInt("5000"),
158
- asset: {
159
- type: mockTokenHTS.tokenType,
160
- assetReference: mockTokenHTS.contractAddress,
161
- assetOwner: address,
162
- name: mockTokenHTS.name,
163
- unit: mockTokenHTS.units[0],
164
- },
153
+ expect(result).toHaveLength(2);
154
+ expect(result[0]).toEqual({
155
+ asset: { type: "native" },
156
+ value: BigInt("1000000000"),
157
+ });
158
+ expect(result[1]).toEqual({
159
+ value: BigInt("5000"),
160
+ asset: {
161
+ type: mockTokenHTS.tokenType,
162
+ assetReference: mockTokenHTS.contractAddress,
163
+ assetOwner: address,
164
+ name: mockTokenHTS.name,
165
+ unit: mockTokenHTS.units[0],
165
166
  },
166
- ]);
167
+ });
167
168
  });
168
169
 
169
170
  it("should throw when failing to getAccount data", async () => {
@@ -7,7 +7,7 @@ import type {
7
7
  import { getBlockInfo } from "./getBlockInfo";
8
8
  import { apiClient } from "../network/api";
9
9
  import type { HederaMirrorCoinTransfer, HederaMirrorTokenTransfer } from "../types";
10
- import { getMemoFromBase64, getTimestampRangeFromBlockHeight } from "./utils";
10
+ import { getTimestampRangeFromBlockHeight } from "./utils";
11
11
 
12
12
  function toHederaAsset(
13
13
  mirrorTransfer: HederaMirrorCoinTransfer | HederaMirrorTokenTransfer,
@@ -64,7 +64,6 @@ export async function getBlock(height: number): Promise<Block> {
64
64
  operations,
65
65
  fees: BigInt(tx.charged_tx_fee),
66
66
  feesPayer: payerAccount,
67
- details: { memo: getMemoFromBase64(tx.memo_base64) },
68
67
  };
69
68
  });
70
69