@ledgerhq/live-common 34.54.0-nightly.20251204023901 → 34.54.0-nightly.20251205023918

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 (193) hide show
  1. package/lib/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
  2. package/lib/bridge/generic-alpaca/broadcast.js +3 -3
  3. package/lib/bridge/generic-alpaca/broadcast.js.map +1 -1
  4. package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
  5. package/lib/bridge/generic-alpaca/currencyBridge.js +1 -3
  6. package/lib/bridge/generic-alpaca/currencyBridge.js.map +1 -1
  7. package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  8. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
  9. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  10. package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  11. package/lib/bridge/generic-alpaca/getAccountShape.js +16 -7
  12. package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  13. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  14. package/lib/bridge/generic-alpaca/getTransactionStatus.js +16 -1
  15. package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  16. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  17. package/lib/bridge/generic-alpaca/prepareTransaction.js +38 -4
  18. package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  19. package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  20. package/lib/bridge/generic-alpaca/signOperation.js +18 -2
  21. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  22. package/lib/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
  23. package/lib/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
  24. package/lib/bridge/generic-alpaca/signer/Eth.js +8 -1
  25. package/lib/bridge/generic-alpaca/signer/Eth.js.map +1 -1
  26. package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
  27. package/lib/bridge/generic-alpaca/signer/index.js +7 -0
  28. package/lib/bridge/generic-alpaca/signer/index.js.map +1 -1
  29. package/lib/bridge/generic-alpaca/types.d.ts +4 -0
  30. package/lib/bridge/generic-alpaca/types.d.ts.map +1 -1
  31. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  32. package/lib/bridge/generic-alpaca/utils.js +11 -3
  33. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  34. package/lib/bridge/impl.d.ts.map +1 -1
  35. package/lib/bridge/impl.js +14 -3
  36. package/lib/bridge/impl.js.map +1 -1
  37. package/lib/e2e/index.d.ts +7 -0
  38. package/lib/e2e/index.d.ts.map +1 -1
  39. package/lib/env.react.d.ts +1 -1
  40. package/lib/env.react.d.ts.map +1 -1
  41. package/lib/families/canton/config.d.ts.map +1 -1
  42. package/lib/families/canton/config.js +4 -4
  43. package/lib/families/canton/config.js.map +1 -1
  44. package/lib/families/celo/setup.d.ts.map +1 -1
  45. package/lib/families/celo/setup.js +11 -0
  46. package/lib/families/celo/setup.js.map +1 -1
  47. package/lib/families/evm/bridge/mock.d.ts +1 -0
  48. package/lib/families/evm/bridge/mock.d.ts.map +1 -1
  49. package/lib/families/evm/bridge/mock.js +12 -0
  50. package/lib/families/evm/bridge/mock.js.map +1 -1
  51. package/lib/families/evm/setup.d.ts +1 -4
  52. package/lib/families/evm/setup.d.ts.map +1 -1
  53. package/lib/families/evm/setup.js +1 -8
  54. package/lib/families/evm/setup.js.map +1 -1
  55. package/lib/families/evm/walletApiAdapter.d.ts +7 -0
  56. package/lib/families/evm/walletApiAdapter.d.ts.map +1 -1
  57. package/lib/families/evm/walletApiAdapter.js +36 -2
  58. package/lib/families/evm/walletApiAdapter.js.map +1 -1
  59. package/lib/families/hedera/react.d.ts +6 -0
  60. package/lib/families/hedera/react.d.ts.map +1 -0
  61. package/lib/families/hedera/react.js +50 -0
  62. package/lib/families/hedera/react.js.map +1 -0
  63. package/lib/families/stacks/constants.d.ts +1 -1
  64. package/lib/families/stacks/constants.d.ts.map +1 -1
  65. package/lib/families/stacks/constants.js +1 -1
  66. package/lib/families/stacks/constants.js.map +1 -1
  67. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  68. package/lib/featureFlags/defaultFeatures.js +1 -0
  69. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  70. package/lib/featureFlags/useFeature.d.ts +1 -1
  71. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  72. package/lib/generated/bridge/js.d.ts +0 -1
  73. package/lib/generated/bridge/js.d.ts.map +1 -1
  74. package/lib/generated/bridge/js.js +30 -32
  75. package/lib/generated/bridge/js.js.map +1 -1
  76. package/lib/generated/bridge/mock.d.ts +1 -0
  77. package/lib/generated/bridge/mock.d.ts.map +1 -1
  78. package/lib/operation.d.ts.map +1 -1
  79. package/lib/operation.js +7 -2
  80. package/lib/operation.js.map +1 -1
  81. package/lib/wallet-api/constants.d.ts +1 -1
  82. package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
  83. package/lib-es/bridge/generic-alpaca/broadcast.js +3 -3
  84. package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -1
  85. package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
  86. package/lib-es/bridge/generic-alpaca/currencyBridge.js +1 -3
  87. package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -1
  88. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  89. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
  90. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  91. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  92. package/lib-es/bridge/generic-alpaca/getAccountShape.js +16 -7
  93. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  94. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  95. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +16 -1
  96. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  97. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  98. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +38 -4
  99. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  100. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  101. package/lib-es/bridge/generic-alpaca/signOperation.js +18 -2
  102. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  103. package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
  104. package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
  105. package/lib-es/bridge/generic-alpaca/signer/Eth.js +4 -0
  106. package/lib-es/bridge/generic-alpaca/signer/Eth.js.map +1 -1
  107. package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
  108. package/lib-es/bridge/generic-alpaca/signer/index.js +7 -0
  109. package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
  110. package/lib-es/bridge/generic-alpaca/types.d.ts +4 -0
  111. package/lib-es/bridge/generic-alpaca/types.d.ts.map +1 -1
  112. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  113. package/lib-es/bridge/generic-alpaca/utils.js +11 -3
  114. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  115. package/lib-es/bridge/impl.d.ts.map +1 -1
  116. package/lib-es/bridge/impl.js +14 -3
  117. package/lib-es/bridge/impl.js.map +1 -1
  118. package/lib-es/e2e/index.d.ts +7 -0
  119. package/lib-es/e2e/index.d.ts.map +1 -1
  120. package/lib-es/env.react.d.ts +1 -1
  121. package/lib-es/env.react.d.ts.map +1 -1
  122. package/lib-es/families/canton/config.d.ts.map +1 -1
  123. package/lib-es/families/canton/config.js +4 -4
  124. package/lib-es/families/canton/config.js.map +1 -1
  125. package/lib-es/families/celo/setup.d.ts.map +1 -1
  126. package/lib-es/families/celo/setup.js +11 -0
  127. package/lib-es/families/celo/setup.js.map +1 -1
  128. package/lib-es/families/evm/bridge/mock.d.ts +1 -0
  129. package/lib-es/families/evm/bridge/mock.d.ts.map +1 -1
  130. package/lib-es/families/evm/bridge/mock.js +12 -0
  131. package/lib-es/families/evm/bridge/mock.js.map +1 -1
  132. package/lib-es/families/evm/setup.d.ts +1 -4
  133. package/lib-es/families/evm/setup.d.ts.map +1 -1
  134. package/lib-es/families/evm/setup.js +2 -8
  135. package/lib-es/families/evm/setup.js.map +1 -1
  136. package/lib-es/families/evm/walletApiAdapter.d.ts +7 -0
  137. package/lib-es/families/evm/walletApiAdapter.d.ts.map +1 -1
  138. package/lib-es/families/evm/walletApiAdapter.js +30 -1
  139. package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
  140. package/lib-es/families/hedera/react.d.ts +6 -0
  141. package/lib-es/families/hedera/react.d.ts.map +1 -0
  142. package/lib-es/families/hedera/react.js +41 -0
  143. package/lib-es/families/hedera/react.js.map +1 -0
  144. package/lib-es/families/stacks/constants.d.ts +1 -1
  145. package/lib-es/families/stacks/constants.d.ts.map +1 -1
  146. package/lib-es/families/stacks/constants.js +1 -1
  147. package/lib-es/families/stacks/constants.js.map +1 -1
  148. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  149. package/lib-es/featureFlags/defaultFeatures.js +1 -0
  150. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  151. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  152. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  153. package/lib-es/generated/bridge/js.d.ts +0 -1
  154. package/lib-es/generated/bridge/js.d.ts.map +1 -1
  155. package/lib-es/generated/bridge/js.js +0 -2
  156. package/lib-es/generated/bridge/js.js.map +1 -1
  157. package/lib-es/generated/bridge/mock.d.ts +1 -0
  158. package/lib-es/generated/bridge/mock.d.ts.map +1 -1
  159. package/lib-es/operation.d.ts.map +1 -1
  160. package/lib-es/operation.js +7 -2
  161. package/lib-es/operation.js.map +1 -1
  162. package/lib-es/wallet-api/constants.d.ts +1 -1
  163. package/package.json +55 -55
  164. package/src/bridge/generic-alpaca/broadcast.ts +6 -3
  165. package/src/bridge/generic-alpaca/currencyBridge.ts +1 -3
  166. package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +2 -1
  167. package/src/bridge/generic-alpaca/getAccountShape.ts +24 -12
  168. package/src/bridge/generic-alpaca/getTransactionStatus.ts +16 -1
  169. package/src/bridge/generic-alpaca/prepareTransaction.ts +44 -10
  170. package/src/bridge/generic-alpaca/signOperation.ts +18 -2
  171. package/src/bridge/generic-alpaca/signer/Eth.ts +5 -1
  172. package/src/bridge/generic-alpaca/signer/index.ts +7 -0
  173. package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +2 -2
  174. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +32 -0
  175. package/src/bridge/generic-alpaca/types.ts +4 -0
  176. package/src/bridge/generic-alpaca/utils.test.ts +1 -0
  177. package/src/bridge/generic-alpaca/utils.ts +14 -3
  178. package/src/bridge/impl.ts +16 -3
  179. package/src/families/canton/config.ts +5 -4
  180. package/src/families/celo/setup.ts +12 -0
  181. package/src/families/evm/bridge/mock.ts +14 -0
  182. package/src/families/evm/setup.ts +3 -22
  183. package/src/families/evm/walletApiAdapter.ts +33 -1
  184. package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +229 -14
  185. package/src/families/hedera/react.test.ts +272 -0
  186. package/src/families/hedera/react.ts +63 -0
  187. package/src/families/stacks/__snapshots__/bridge.integration.test.ts.snap +1537 -18
  188. package/src/families/stacks/__tests__/sync.integration.test.ts +2 -2
  189. package/src/families/stacks/constants.ts +1 -1
  190. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +9 -9
  191. package/src/featureFlags/defaultFeatures.ts +1 -0
  192. package/src/generated/bridge/js.ts +0 -2
  193. package/src/operation.ts +10 -2
@@ -23,6 +23,7 @@ import { AddressesSanctionedError } from "@ledgerhq/coin-framework/sanction/erro
23
23
  // Removed: stores are now managed globally by @ledgerhq/cryptoassets/cal-client/store
24
24
 
25
25
  const alpacaized = {
26
+ evm: true,
26
27
  xrp: true,
27
28
  stellar: true,
28
29
  tezos: true,
@@ -35,7 +36,13 @@ const currencyBridgeCache: Record<string, CurrencyBridge> = {};
35
36
  export const getCurrencyBridge = (currency: CryptoCurrency): CurrencyBridge => {
36
37
  if (getEnv("MOCK")) {
37
38
  const mockBridge = mockBridges[currency.family];
38
- if (mockBridge) return mockBridge.currencyBridge;
39
+ // TODO Remove once we delete mock bridges tests
40
+ if (mockBridge) {
41
+ if (typeof mockBridge.loadCoinConfig === "function") {
42
+ mockBridge.loadCoinConfig();
43
+ }
44
+ return mockBridge.currencyBridge;
45
+ }
39
46
  throw new CurrencyNotSupported("no mock implementation available for currency " + currency.id, {
40
47
  currencyName: currency.id,
41
48
  });
@@ -85,13 +92,19 @@ export function getAccountBridgeByFamily(family: string, accountId?: string): Ac
85
92
 
86
93
  if (type === "mock") {
87
94
  const mockBridge = mockBridges[family];
88
- if (mockBridge) return wrapAccountBridge(mockBridge.accountBridge);
95
+ // TODO Remove once we delete mock bridges tests
96
+ if (mockBridge) {
97
+ if (typeof mockBridge.loadCoinConfig === "function") {
98
+ mockBridge.loadCoinConfig();
99
+ }
100
+ return wrapAccountBridge(mockBridge.accountBridge);
101
+ }
89
102
  }
90
103
  }
91
104
 
92
105
  if (alpacaized[family]) {
93
106
  if (!bridgeCache[family]) {
94
- bridgeCache[family] = getAlpacaAccountBridge(family, "local");
107
+ bridgeCache[family] = wrapAccountBridge(getAlpacaAccountBridge(family, "local"));
95
108
  }
96
109
  return bridgeCache[family];
97
110
  }
@@ -23,9 +23,9 @@ export const cantonConfig: Record<string, ConfigInfo> = {
23
23
  status: {
24
24
  type: "active",
25
25
  },
26
- nodeUrl: "https://canton-gateway.api.live.ledger.com/v1/node/ledger-live-devnet",
26
+ nodeUrl: "https://canton-gateway-devnet.api.live.ledger-test.com/v1/node/ledger-live-devnet",
27
27
  nodeId: "ledger-live-devnet",
28
- gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
28
+ gatewayUrl: "https://canton-gateway-devnet.api.live.ledger-test.com",
29
29
  minReserve: 0,
30
30
  useGateway: true,
31
31
  networkType: "devnet",
@@ -39,9 +39,10 @@ export const cantonConfig: Record<string, ConfigInfo> = {
39
39
  status: {
40
40
  type: "active",
41
41
  },
42
- nodeUrl: "https://canton-gateway.api.live.ledger.com/v1/node/ledger-live-testnet",
42
+ nodeUrl:
43
+ "https://canton-gateway-testnet.api.live.ledger-test.com/v1/node/ledger-live-testnet",
43
44
  nodeId: "ledger-live-testnet",
44
- gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
45
+ gatewayUrl: "https://canton-gateway-testnet.api.live.ledger-test.com",
45
46
  minReserve: 0,
46
47
  nativeInstrumentId: "Amulet",
47
48
  useGateway: true,
@@ -10,9 +10,21 @@ import { CreateSigner, createResolver, executeWithSigner } from "../../bridge/se
10
10
  import type { Resolver } from "../../hw/getAddress/types";
11
11
  import { Transaction, CeloAccount } from "./types";
12
12
  import { CeloSigner } from "@ledgerhq/coin-celo/signer";
13
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
14
+ import { createApi as createEvmApi } from "@ledgerhq/coin-evm/api/index";
15
+ import { getCurrencyConfiguration } from "../../config";
16
+ import type { EvmConfigInfo } from "@ledgerhq/coin-evm/config";
13
17
 
14
18
  const createSigner: CreateSigner<CeloSigner> = (transport: Transport) => new Celo(transport);
15
19
 
20
+ // NOTE Create an unused instance of EVM API with Celo configuration.
21
+ // It has the side effect of initializing the EVM coin config as well as injecting
22
+ // the input Celo config.
23
+ // TODO Remove this hack while deleting the Celo bridge
24
+ const getCurrencyConfig = () => {
25
+ return { info: getCurrencyConfiguration<EvmConfigInfo>(getCryptoCurrencyById("celo")) };
26
+ };
27
+ createEvmApi(getCurrencyConfig, "celo");
16
28
  const bridge: Bridge<Transaction, CeloAccount> = createBridges(executeWithSigner(createSigner));
17
29
 
18
30
  const resolver: Resolver = createResolver(createSigner, CeloResolver);
@@ -17,6 +17,9 @@ import {
17
17
  } from "@ledgerhq/coin-framework/bridge/jsHelpers";
18
18
  import { getGasLimit } from "@ledgerhq/coin-evm/utils";
19
19
  import { getTypedTransaction } from "@ledgerhq/coin-evm/transaction";
20
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
21
+ import { getCurrencyConfiguration } from "../../../config";
22
+ import { EvmConfigInfo, setCoinConfig } from "@ledgerhq/coin-evm/config";
20
23
  const receive = makeAccountBridgeReceive();
21
24
  const defaultGetFees = (_a, t: any) => (t.gasPrice || new BigNumber(0)).times(getGasLimit(t));
22
25
 
@@ -110,6 +113,16 @@ const prepareTransaction = async (_a, t) => {
110
113
  return typedTransaction;
111
114
  };
112
115
 
116
+ let isConfigLoaded = false;
117
+ const loadCoinConfig = () => {
118
+ if (!isConfigLoaded) {
119
+ setCoinConfig((currency: CryptoCurrency) => {
120
+ isConfigLoaded = true;
121
+ return { info: getCurrencyConfiguration<EvmConfigInfo>(currency) };
122
+ });
123
+ }
124
+ };
125
+
113
126
  const accountBridge: AccountBridge<Transaction> = {
114
127
  createTransaction,
115
128
  updateTransaction,
@@ -131,4 +144,5 @@ const currencyBridge: CurrencyBridge = {
131
144
  export default {
132
145
  currencyBridge,
133
146
  accountBridge,
147
+ loadCoinConfig,
134
148
  };
@@ -1,25 +1,15 @@
1
1
  // Goal of this file is to inject all necessary device/signer dependency to coin-modules
2
2
 
3
- import { createBridges } from "@ledgerhq/coin-evm/bridge/js";
4
3
  import makeCliTools from "@ledgerhq/coin-evm/cli-transaction";
5
4
  import evmResolver from "@ledgerhq/coin-evm/hw-getAddress";
6
5
  import { prepareMessageToSign, signMessage } from "@ledgerhq/coin-evm/hw-signMessage";
7
- import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/index";
8
- import {
9
- CreateSigner,
10
- createMessageSigner,
11
- createResolver,
12
- executeWithSigner,
13
- } from "../../bridge/setup";
6
+ import { CreateSigner, createMessageSigner, createResolver } from "../../bridge/setup";
14
7
  import { Resolver } from "../../hw/getAddress/types";
15
8
  import Transport from "@ledgerhq/hw-transport";
16
- import type { Bridge } from "@ledgerhq/types-live";
17
- import { getCurrencyConfiguration } from "../../config";
18
- import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
19
- import { EvmConfigInfo } from "@ledgerhq/coin-evm/config";
20
9
  import { type DeviceManagementKit } from "@ledgerhq/device-management-kit";
21
10
  import { DmkSignerEth, LegacySignerEth } from "@ledgerhq/live-signer-evm";
22
11
  import { EvmSigner } from "@ledgerhq/coin-evm/types/signer";
12
+
23
13
  const createSigner: CreateSigner<EvmSigner> = (transport: Transport) => {
24
14
  if (isDmkTransport(transport)) {
25
15
  return new DmkSignerEth(transport.dmk, transport.sessionId);
@@ -39,15 +29,6 @@ const isDmkTransport = (
39
29
  );
40
30
  };
41
31
 
42
- const getCurrencyConfig = (currency: CryptoCurrency) => {
43
- return { info: getCurrencyConfiguration<EvmConfigInfo>(currency) };
44
- };
45
-
46
- const bridge: Bridge<EvmTransaction> = createBridges(
47
- executeWithSigner(createSigner),
48
- getCurrencyConfig,
49
- );
50
-
51
32
  const messageSigner = {
52
33
  prepareMessageToSign,
53
34
  signMessage: createMessageSigner(createSigner, signMessage),
@@ -57,4 +38,4 @@ const resolver: Resolver = createResolver(createSigner, evmResolver);
57
38
 
58
39
  const cliTools = makeCliTools();
59
40
 
60
- export { bridge, cliTools, resolver, messageSigner };
41
+ export { cliTools, resolver, messageSigner };
@@ -1,4 +1,3 @@
1
- import { createTransaction } from "@ledgerhq/coin-evm/bridge/createTransaction";
2
1
  import { Transaction } from "@ledgerhq/coin-evm/types/index";
3
2
  import { EthereumTransaction as WalletAPIEthereumTransaction } from "@ledgerhq/wallet-api-core";
4
3
  import {
@@ -6,9 +5,42 @@ import {
6
5
  ConvertToLiveTransaction,
7
6
  GetWalletAPITransactionSignFlowInfos,
8
7
  } from "../../wallet-api/types";
8
+ import BigNumber from "bignumber.js";
9
+ import { AccountLike } from "@ledgerhq/types-live";
10
+ import { DEFAULT_GAS_LIMIT, DEFAULT_NONCE } from "@ledgerhq/coin-evm/utils";
9
11
 
10
12
  const CAN_EDIT_FEES = true;
11
13
 
14
+ const getChainId = (account: AccountLike): number => {
15
+ if (account.type === "Account") {
16
+ return account.currency.ethereumLikeInfo?.chainId || 0;
17
+ }
18
+ if (account.type === "TokenAccount") {
19
+ return account.token.parentCurrency.ethereumLikeInfo?.chainId || 0;
20
+ }
21
+ return 0;
22
+ };
23
+
24
+ /**
25
+ * EVM Transaction factory.
26
+ * By default the transaction is an EIP-1559 transaction.
27
+ * @see prepareTransaction that will make sure it's compatible or not
28
+ */
29
+ export const createTransaction: (account: AccountLike) => Transaction = account => ({
30
+ family: "evm",
31
+ mode: "send",
32
+ amount: new BigNumber(0),
33
+ useAllAmount: false,
34
+ recipient: "",
35
+ maxFeePerGas: new BigNumber(0),
36
+ maxPriorityFeePerGas: new BigNumber(0),
37
+ gasLimit: DEFAULT_GAS_LIMIT,
38
+ nonce: DEFAULT_NONCE,
39
+ chainId: getChainId(account),
40
+ feesStrategy: "medium",
41
+ type: 2,
42
+ });
43
+
12
44
  const areFeesProvided: AreFeesProvided<WalletAPIEthereumTransaction> = tx =>
13
45
  !!((tx.gasLimit && tx.gasPrice) || (tx.gasLimit && tx.maxFeePerGas && tx.maxPriorityFeePerGas));
14
46
 
@@ -3,24 +3,29 @@
3
3
  exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
4
4
  [
5
5
  {
6
- "balance": "31516347222",
6
+ "balance": "31515040999",
7
7
  "currencyId": "hedera",
8
8
  "derivationMode": "hederaBip44",
9
9
  "freshAddress": "0.0.1040977",
10
10
  "freshAddressPath": "44/3030",
11
11
  "hederaResources": {
12
+ "delegation": {
13
+ "delegated": "31515040999",
14
+ "nodeId": 0,
15
+ "pendingReward": "0",
16
+ },
12
17
  "isAutoTokenAssociationEnabled": false,
13
18
  "maxAutomaticTokenAssociations": 0,
14
19
  },
15
20
  "id": "js:2:hedera:0.0.1040977:hederaBip44",
16
21
  "index": 0,
17
- "operationsCount": 46,
22
+ "operationsCount": 54,
18
23
  "pendingOperations": [],
19
24
  "seedIdentifier": "9e92a312233d5fd6b5a723875aeea2cea81a8e48ffc00341cff6dffcfd3ab7f2",
20
- "spendableBalance": "31516347222",
25
+ "spendableBalance": "31515040999",
21
26
  "subAccounts": [],
22
27
  "swapHistory": [],
23
- "syncHash": "0x5cb60fa7",
28
+ "syncHash": "0x43decf71",
24
29
  "used": true,
25
30
  },
26
31
  {
@@ -63,6 +68,11 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
63
68
  "freshAddress": "0.0.7305122",
64
69
  "freshAddressPath": "44/3030",
65
70
  "hederaResources": {
71
+ "delegation": {
72
+ "delegated": "226095",
73
+ "nodeId": 0,
74
+ "pendingReward": "0",
75
+ },
66
76
  "isAutoTokenAssociationEnabled": false,
67
77
  "maxAutomaticTokenAssociations": 0,
68
78
  },
@@ -74,7 +84,7 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
74
84
  "spendableBalance": "226095",
75
85
  "subAccounts": [],
76
86
  "swapHistory": [],
77
- "syncHash": "0x5cb60fa7",
87
+ "syncHash": "0x43decf71",
78
88
  "used": true,
79
89
  },
80
90
  {
@@ -84,6 +94,11 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
84
94
  "freshAddress": "0.0.7560245",
85
95
  "freshAddressPath": "44/3030",
86
96
  "hederaResources": {
97
+ "delegation": {
98
+ "delegated": "80189",
99
+ "nodeId": 1,
100
+ "pendingReward": "0",
101
+ },
87
102
  "isAutoTokenAssociationEnabled": false,
88
103
  "maxAutomaticTokenAssociations": 0,
89
104
  },
@@ -95,7 +110,7 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
95
110
  "spendableBalance": "80189",
96
111
  "subAccounts": [],
97
112
  "swapHistory": [],
98
- "syncHash": "0x5cb60fa7",
113
+ "syncHash": "0x43decf71",
99
114
  "used": true,
100
115
  },
101
116
  {
@@ -105,6 +120,11 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
105
120
  "freshAddress": "0.0.7578015",
106
121
  "freshAddressPath": "44/3030",
107
122
  "hederaResources": {
123
+ "delegation": {
124
+ "delegated": "99836954",
125
+ "nodeId": 5,
126
+ "pendingReward": "0",
127
+ },
108
128
  "isAutoTokenAssociationEnabled": false,
109
129
  "maxAutomaticTokenAssociations": 0,
110
130
  },
@@ -116,7 +136,7 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
116
136
  "spendableBalance": "99836954",
117
137
  "subAccounts": [],
118
138
  "swapHistory": [],
119
- "syncHash": "0x5cb60fa7",
139
+ "syncHash": "0x43decf71",
120
140
  "used": true,
121
141
  },
122
142
  {
@@ -126,6 +146,7 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
126
146
  "freshAddress": "0.0.8313485",
127
147
  "freshAddressPath": "44/3030",
128
148
  "hederaResources": {
149
+ "delegation": null,
129
150
  "isAutoTokenAssociationEnabled": false,
130
151
  "maxAutomaticTokenAssociations": 0,
131
152
  },
@@ -137,7 +158,7 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
137
158
  "spendableBalance": "671187583",
138
159
  "subAccounts": [],
139
160
  "swapHistory": [],
140
- "syncHash": "0x5cb60fa7",
161
+ "syncHash": "0x43decf71",
141
162
  "used": true,
142
163
  },
143
164
  {
@@ -158,6 +179,11 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
158
179
  "freshAddress": "0.0.10096785",
159
180
  "freshAddressPath": "44/3030",
160
181
  "hederaResources": {
182
+ "delegation": {
183
+ "delegated": "100000000",
184
+ "nodeId": 7,
185
+ "pendingReward": "130131",
186
+ },
161
187
  "isAutoTokenAssociationEnabled": false,
162
188
  "maxAutomaticTokenAssociations": 0,
163
189
  },
@@ -169,7 +195,7 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
169
195
  "spendableBalance": "100000000",
170
196
  "subAccounts": [],
171
197
  "swapHistory": [],
172
- "syncHash": "0x5cb60fa7",
198
+ "syncHash": "0x43decf71",
173
199
  "used": true,
174
200
  },
175
201
  {
@@ -179,6 +205,11 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
179
205
  "freshAddress": "0.0.10096815",
180
206
  "freshAddressPath": "44/3030",
181
207
  "hederaResources": {
208
+ "delegation": {
209
+ "delegated": "0",
210
+ "nodeId": 9,
211
+ "pendingReward": "0",
212
+ },
182
213
  "isAutoTokenAssociationEnabled": false,
183
214
  "maxAutomaticTokenAssociations": 0,
184
215
  },
@@ -190,7 +221,7 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
190
221
  "spendableBalance": "0",
191
222
  "subAccounts": [],
192
223
  "swapHistory": [],
193
- "syncHash": "0x5cb60fa7",
224
+ "syncHash": "0x43decf71",
194
225
  "used": false,
195
226
  },
196
227
  ]
@@ -245,6 +276,29 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
245
276
  "type": "IN",
246
277
  "value": "9755232",
247
278
  },
279
+ {
280
+ "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
281
+ "blockHash": null,
282
+ "blockHeight": 10,
283
+ "extra": {
284
+ "consensusTimestamp": "1764676581.905435000",
285
+ "memo": "Stake",
286
+ "pagingToken": "1764676581.905435000",
287
+ "transactionId": "0.0.1040977-1764676567-725968138",
288
+ },
289
+ "fee": "163226",
290
+ "hasFailed": false,
291
+ "hash": "3NpFiiRWJ79s2ggmEnHm1jTkNbK9zVKKUuxP7DI9h0iis5_r9_59USttxDINMkav",
292
+ "id": "js:2:hedera:0.0.1040977:hederaBip44-3NpFiiRWJ79s2ggmEnHm1jTkNbK9zVKKUuxP7DI9h0iis5_r9_59USttxDINMkav-UPDATE_ACCOUNT",
293
+ "recipients": [
294
+ "0.0.3",
295
+ ],
296
+ "senders": [
297
+ "0.0.1040977",
298
+ ],
299
+ "type": "UPDATE_ACCOUNT",
300
+ "value": "163226",
301
+ },
248
302
  {
249
303
  "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
250
304
  "blockHash": null,
@@ -339,6 +393,29 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
339
393
  "type": "IN",
340
394
  "value": "12300000",
341
395
  },
396
+ {
397
+ "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
398
+ "blockHash": null,
399
+ "blockHeight": 10,
400
+ "extra": {
401
+ "consensusTimestamp": "1764676088.728437000",
402
+ "memo": "Stake",
403
+ "pagingToken": "1764676088.728437000",
404
+ "transactionId": "0.0.1040977-1764676070-835083192",
405
+ },
406
+ "fee": "163226",
407
+ "hasFailed": false,
408
+ "hash": "BMngqkCurhw4aCSs6_fCjsZwYD-J2qZSWYQWBK9zQlSoS77O_DEi5xSo1y_sqgcX",
409
+ "id": "js:2:hedera:0.0.1040977:hederaBip44-BMngqkCurhw4aCSs6_fCjsZwYD-J2qZSWYQWBK9zQlSoS77O_DEi5xSo1y_sqgcX-UPDATE_ACCOUNT",
410
+ "recipients": [
411
+ "0.0.3",
412
+ ],
413
+ "senders": [
414
+ "0.0.1040977",
415
+ ],
416
+ "type": "UPDATE_ACCOUNT",
417
+ "value": "163226",
418
+ },
342
419
  {
343
420
  "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
344
421
  "blockHash": null,
@@ -654,6 +731,29 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
654
731
  "type": "IN",
655
732
  "value": "98000000",
656
733
  },
734
+ {
735
+ "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
736
+ "blockHash": null,
737
+ "blockHeight": 10,
738
+ "extra": {
739
+ "consensusTimestamp": "1764676556.594347000",
740
+ "memo": "Unstake",
741
+ "pagingToken": "1764676556.594347000",
742
+ "transactionId": "0.0.1040977-1764676542-962449536",
743
+ },
744
+ "fee": "163309",
745
+ "hasFailed": false,
746
+ "hash": "Hjp3OhUDHHFXeOHCLzm2C13IT7qATHLSUvuLj0I5BOIEdRmxqFdc9A-eiC9mdYTg",
747
+ "id": "js:2:hedera:0.0.1040977:hederaBip44-Hjp3OhUDHHFXeOHCLzm2C13IT7qATHLSUvuLj0I5BOIEdRmxqFdc9A-eiC9mdYTg-UPDATE_ACCOUNT",
748
+ "recipients": [
749
+ "0.0.3",
750
+ ],
751
+ "senders": [
752
+ "0.0.1040977",
753
+ ],
754
+ "type": "UPDATE_ACCOUNT",
755
+ "value": "163309",
756
+ },
657
757
  {
658
758
  "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
659
759
  "blockHash": null,
@@ -724,6 +824,52 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
724
824
  "type": "IN",
725
825
  "value": "99870000",
726
826
  },
827
+ {
828
+ "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
829
+ "blockHash": null,
830
+ "blockHeight": 10,
831
+ "extra": {
832
+ "consensusTimestamp": "1764676452.498442000",
833
+ "memo": "Stake",
834
+ "pagingToken": "1764676452.498442000",
835
+ "transactionId": "0.0.1040977-1764676435-598710986",
836
+ },
837
+ "fee": "163226",
838
+ "hasFailed": false,
839
+ "hash": "isU2vxS30gIzkizC9qpjv7A7QKuLy_OjXCRCEdVegehf6oavk3770Agu7R0cDnJE",
840
+ "id": "js:2:hedera:0.0.1040977:hederaBip44-isU2vxS30gIzkizC9qpjv7A7QKuLy_OjXCRCEdVegehf6oavk3770Agu7R0cDnJE-UPDATE_ACCOUNT",
841
+ "recipients": [
842
+ "0.0.3",
843
+ ],
844
+ "senders": [
845
+ "0.0.1040977",
846
+ ],
847
+ "type": "UPDATE_ACCOUNT",
848
+ "value": "163226",
849
+ },
850
+ {
851
+ "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
852
+ "blockHash": null,
853
+ "blockHeight": 10,
854
+ "extra": {
855
+ "consensusTimestamp": "1764676635.614168000",
856
+ "memo": "Restake",
857
+ "pagingToken": "1764676635.614168000",
858
+ "transactionId": "0.0.1040977-1764676618-505767166",
859
+ },
860
+ "fee": "163309",
861
+ "hasFailed": false,
862
+ "hash": "JhrnOAxqfXnZrMe0U7YFB1M_Odko2DvtA113S92D1DHDX4mpTybW9TldrZG6VBeY",
863
+ "id": "js:2:hedera:0.0.1040977:hederaBip44-JhrnOAxqfXnZrMe0U7YFB1M_Odko2DvtA113S92D1DHDX4mpTybW9TldrZG6VBeY-UPDATE_ACCOUNT",
864
+ "recipients": [
865
+ "0.0.3",
866
+ ],
867
+ "senders": [
868
+ "0.0.1040977",
869
+ ],
870
+ "type": "UPDATE_ACCOUNT",
871
+ "value": "163309",
872
+ },
727
873
  {
728
874
  "accountId": "",
729
875
  "blockHash": null,
@@ -915,6 +1061,52 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
915
1061
  "type": "OUT",
916
1062
  "value": "1000054816",
917
1063
  },
1064
+ {
1065
+ "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
1066
+ "blockHash": null,
1067
+ "blockHeight": 10,
1068
+ "extra": {
1069
+ "consensusTimestamp": "1764676405.364046000",
1070
+ "memo": "Unstake",
1071
+ "pagingToken": "1764676405.364046000",
1072
+ "transactionId": "0.0.1040977-1764676388-012116929",
1073
+ },
1074
+ "fee": "163309",
1075
+ "hasFailed": false,
1076
+ "hash": "o_lyqFg3vhdJa7uyo6xyVQzx-mGWHAsIa_XQ09gLUmUKvamUv5ROiMMTcmrnyLyD",
1077
+ "id": "js:2:hedera:0.0.1040977:hederaBip44-o_lyqFg3vhdJa7uyo6xyVQzx-mGWHAsIa_XQ09gLUmUKvamUv5ROiMMTcmrnyLyD-UPDATE_ACCOUNT",
1078
+ "recipients": [
1079
+ "0.0.3",
1080
+ ],
1081
+ "senders": [
1082
+ "0.0.1040977",
1083
+ ],
1084
+ "type": "UPDATE_ACCOUNT",
1085
+ "value": "163309",
1086
+ },
1087
+ {
1088
+ "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
1089
+ "blockHash": null,
1090
+ "blockHeight": 10,
1091
+ "extra": {
1092
+ "consensusTimestamp": "1764676526.955756000",
1093
+ "memo": "Restake",
1094
+ "pagingToken": "1764676526.955756000",
1095
+ "transactionId": "0.0.1040977-1764676513-182900536",
1096
+ },
1097
+ "fee": "163309",
1098
+ "hasFailed": false,
1099
+ "hash": "qc2j0ge0X1-KuJ5A8PaqCgvtgGZONWE0AcQ-2ypl80ylTHJnVAqHlfbK6EaEBsXJ",
1100
+ "id": "js:2:hedera:0.0.1040977:hederaBip44-qc2j0ge0X1-KuJ5A8PaqCgvtgGZONWE0AcQ-2ypl80ylTHJnVAqHlfbK6EaEBsXJ-UPDATE_ACCOUNT",
1101
+ "recipients": [
1102
+ "0.0.3",
1103
+ ],
1104
+ "senders": [
1105
+ "0.0.1040977",
1106
+ ],
1107
+ "type": "UPDATE_ACCOUNT",
1108
+ "value": "163309",
1109
+ },
918
1110
  {
919
1111
  "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
920
1112
  "blockHash": null,
@@ -962,6 +1154,29 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
962
1154
  "type": "OUT",
963
1155
  "value": "187669298",
964
1156
  },
1157
+ {
1158
+ "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
1159
+ "blockHash": null,
1160
+ "blockHeight": 10,
1161
+ "extra": {
1162
+ "consensusTimestamp": "1764676500.998306000",
1163
+ "memo": "Restake",
1164
+ "pagingToken": "1764676500.998306000",
1165
+ "transactionId": "0.0.1040977-1764676479-824016135",
1166
+ },
1167
+ "fee": "163309",
1168
+ "hasFailed": false,
1169
+ "hash": "RErEuVaA6cqxWE-mnc7KK0X_pbNQH4DfYZQtSlTkVjeOKcLtOCOxHhlsbSUX_ytM",
1170
+ "id": "js:2:hedera:0.0.1040977:hederaBip44-RErEuVaA6cqxWE-mnc7KK0X_pbNQH4DfYZQtSlTkVjeOKcLtOCOxHhlsbSUX_ytM-UPDATE_ACCOUNT",
1171
+ "recipients": [
1172
+ "0.0.3",
1173
+ ],
1174
+ "senders": [
1175
+ "0.0.1040977",
1176
+ ],
1177
+ "type": "UPDATE_ACCOUNT",
1178
+ "value": "163309",
1179
+ },
965
1180
  {
966
1181
  "accountId": "js:2:hedera:0.0.1040977:hederaBip44",
967
1182
  "blockHash": null,
@@ -1734,14 +1949,14 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
1734
1949
  "fee": "414180",
1735
1950
  "hasFailed": false,
1736
1951
  "hash": "SX6QjkXKRGbFG1tWq31I0rv1Aof4r9iRXxLlxd_tO6YNuER_6CCmvW_s47FtPVhl",
1737
- "id": "js:2:hedera:0.0.7305122:hederaBip44-SX6QjkXKRGbFG1tWq31I0rv1Aof4r9iRXxLlxd_tO6YNuER_6CCmvW_s47FtPVhl-OUT",
1952
+ "id": "js:2:hedera:0.0.7305122:hederaBip44-SX6QjkXKRGbFG1tWq31I0rv1Aof4r9iRXxLlxd_tO6YNuER_6CCmvW_s47FtPVhl-UPDATE_ACCOUNT",
1738
1953
  "recipients": [
1739
1954
  "0.0.25",
1740
1955
  ],
1741
1956
  "senders": [
1742
1957
  "0.0.7305122",
1743
1958
  ],
1744
- "type": "OUT",
1959
+ "type": "UPDATE_ACCOUNT",
1745
1960
  "value": "414180",
1746
1961
  },
1747
1962
  {
@@ -1803,14 +2018,14 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
1803
2018
  "fee": "415339",
1804
2019
  "hasFailed": false,
1805
2020
  "hash": "ZPCrj02WZwh_depYNheXuCLRpq6gDHfxeskEvIr-PCZzoM9WdUUSswRqRf-bZZfS",
1806
- "id": "js:2:hedera:0.0.7305122:hederaBip44-ZPCrj02WZwh_depYNheXuCLRpq6gDHfxeskEvIr-PCZzoM9WdUUSswRqRf-bZZfS-OUT",
2021
+ "id": "js:2:hedera:0.0.7305122:hederaBip44-ZPCrj02WZwh_depYNheXuCLRpq6gDHfxeskEvIr-PCZzoM9WdUUSswRqRf-bZZfS-UPDATE_ACCOUNT",
1807
2022
  "recipients": [
1808
2023
  "0.0.23",
1809
2024
  ],
1810
2025
  "senders": [
1811
2026
  "0.0.7305122",
1812
2027
  ],
1813
- "type": "OUT",
2028
+ "type": "UPDATE_ACCOUNT",
1814
2029
  "value": "415339",
1815
2030
  },
1816
2031
  {