@ledgerhq/live-common 34.54.0-nightly.20251204135727 → 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 (163) 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/families/canton/config.d.ts.map +1 -1
  38. package/lib/families/canton/config.js +4 -4
  39. package/lib/families/canton/config.js.map +1 -1
  40. package/lib/families/celo/setup.d.ts.map +1 -1
  41. package/lib/families/celo/setup.js +11 -0
  42. package/lib/families/celo/setup.js.map +1 -1
  43. package/lib/families/evm/bridge/mock.d.ts +1 -0
  44. package/lib/families/evm/bridge/mock.d.ts.map +1 -1
  45. package/lib/families/evm/bridge/mock.js +12 -0
  46. package/lib/families/evm/bridge/mock.js.map +1 -1
  47. package/lib/families/evm/setup.d.ts +1 -4
  48. package/lib/families/evm/setup.d.ts.map +1 -1
  49. package/lib/families/evm/setup.js +1 -8
  50. package/lib/families/evm/setup.js.map +1 -1
  51. package/lib/families/evm/walletApiAdapter.d.ts +7 -0
  52. package/lib/families/evm/walletApiAdapter.d.ts.map +1 -1
  53. package/lib/families/evm/walletApiAdapter.js +36 -2
  54. package/lib/families/evm/walletApiAdapter.js.map +1 -1
  55. package/lib/families/stacks/constants.d.ts +1 -1
  56. package/lib/families/stacks/constants.d.ts.map +1 -1
  57. package/lib/families/stacks/constants.js +1 -1
  58. package/lib/families/stacks/constants.js.map +1 -1
  59. package/lib/generated/bridge/js.d.ts +0 -1
  60. package/lib/generated/bridge/js.d.ts.map +1 -1
  61. package/lib/generated/bridge/js.js +30 -32
  62. package/lib/generated/bridge/js.js.map +1 -1
  63. package/lib/generated/bridge/mock.d.ts +1 -0
  64. package/lib/generated/bridge/mock.d.ts.map +1 -1
  65. package/lib/operation.d.ts.map +1 -1
  66. package/lib/operation.js +7 -2
  67. package/lib/operation.js.map +1 -1
  68. package/lib/wallet-api/constants.d.ts +1 -1
  69. package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
  70. package/lib-es/bridge/generic-alpaca/broadcast.js +3 -3
  71. package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -1
  72. package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
  73. package/lib-es/bridge/generic-alpaca/currencyBridge.js +1 -3
  74. package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -1
  75. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  76. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
  77. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  78. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  79. package/lib-es/bridge/generic-alpaca/getAccountShape.js +16 -7
  80. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  81. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  82. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +16 -1
  83. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  84. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  85. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +38 -4
  86. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  87. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  88. package/lib-es/bridge/generic-alpaca/signOperation.js +18 -2
  89. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  90. package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
  91. package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
  92. package/lib-es/bridge/generic-alpaca/signer/Eth.js +4 -0
  93. package/lib-es/bridge/generic-alpaca/signer/Eth.js.map +1 -1
  94. package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
  95. package/lib-es/bridge/generic-alpaca/signer/index.js +7 -0
  96. package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
  97. package/lib-es/bridge/generic-alpaca/types.d.ts +4 -0
  98. package/lib-es/bridge/generic-alpaca/types.d.ts.map +1 -1
  99. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  100. package/lib-es/bridge/generic-alpaca/utils.js +11 -3
  101. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  102. package/lib-es/bridge/impl.d.ts.map +1 -1
  103. package/lib-es/bridge/impl.js +14 -3
  104. package/lib-es/bridge/impl.js.map +1 -1
  105. package/lib-es/families/canton/config.d.ts.map +1 -1
  106. package/lib-es/families/canton/config.js +4 -4
  107. package/lib-es/families/canton/config.js.map +1 -1
  108. package/lib-es/families/celo/setup.d.ts.map +1 -1
  109. package/lib-es/families/celo/setup.js +11 -0
  110. package/lib-es/families/celo/setup.js.map +1 -1
  111. package/lib-es/families/evm/bridge/mock.d.ts +1 -0
  112. package/lib-es/families/evm/bridge/mock.d.ts.map +1 -1
  113. package/lib-es/families/evm/bridge/mock.js +12 -0
  114. package/lib-es/families/evm/bridge/mock.js.map +1 -1
  115. package/lib-es/families/evm/setup.d.ts +1 -4
  116. package/lib-es/families/evm/setup.d.ts.map +1 -1
  117. package/lib-es/families/evm/setup.js +2 -8
  118. package/lib-es/families/evm/setup.js.map +1 -1
  119. package/lib-es/families/evm/walletApiAdapter.d.ts +7 -0
  120. package/lib-es/families/evm/walletApiAdapter.d.ts.map +1 -1
  121. package/lib-es/families/evm/walletApiAdapter.js +30 -1
  122. package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
  123. package/lib-es/families/stacks/constants.d.ts +1 -1
  124. package/lib-es/families/stacks/constants.d.ts.map +1 -1
  125. package/lib-es/families/stacks/constants.js +1 -1
  126. package/lib-es/families/stacks/constants.js.map +1 -1
  127. package/lib-es/generated/bridge/js.d.ts +0 -1
  128. package/lib-es/generated/bridge/js.d.ts.map +1 -1
  129. package/lib-es/generated/bridge/js.js +0 -2
  130. package/lib-es/generated/bridge/js.js.map +1 -1
  131. package/lib-es/generated/bridge/mock.d.ts +1 -0
  132. package/lib-es/generated/bridge/mock.d.ts.map +1 -1
  133. package/lib-es/operation.d.ts.map +1 -1
  134. package/lib-es/operation.js +7 -2
  135. package/lib-es/operation.js.map +1 -1
  136. package/lib-es/wallet-api/constants.d.ts +1 -1
  137. package/package.json +56 -56
  138. package/src/bridge/generic-alpaca/broadcast.ts +6 -3
  139. package/src/bridge/generic-alpaca/currencyBridge.ts +1 -3
  140. package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +2 -1
  141. package/src/bridge/generic-alpaca/getAccountShape.ts +24 -12
  142. package/src/bridge/generic-alpaca/getTransactionStatus.ts +16 -1
  143. package/src/bridge/generic-alpaca/prepareTransaction.ts +44 -10
  144. package/src/bridge/generic-alpaca/signOperation.ts +18 -2
  145. package/src/bridge/generic-alpaca/signer/Eth.ts +5 -1
  146. package/src/bridge/generic-alpaca/signer/index.ts +7 -0
  147. package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +2 -2
  148. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +32 -0
  149. package/src/bridge/generic-alpaca/types.ts +4 -0
  150. package/src/bridge/generic-alpaca/utils.test.ts +1 -0
  151. package/src/bridge/generic-alpaca/utils.ts +14 -3
  152. package/src/bridge/impl.ts +16 -3
  153. package/src/families/canton/config.ts +5 -4
  154. package/src/families/celo/setup.ts +12 -0
  155. package/src/families/evm/bridge/mock.ts +14 -0
  156. package/src/families/evm/setup.ts +3 -22
  157. package/src/families/evm/walletApiAdapter.ts +33 -1
  158. package/src/families/stacks/__snapshots__/bridge.integration.test.ts.snap +1537 -18
  159. package/src/families/stacks/__tests__/sync.integration.test.ts +2 -2
  160. package/src/families/stacks/constants.ts +1 -1
  161. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +9 -9
  162. package/src/generated/bridge/js.ts +0 -2
  163. 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