@ledgerhq/live-common 34.40.0 → 34.41.0-nightly.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 (146) hide show
  1. package/lib/e2e/enum/Provider.d.ts +3 -0
  2. package/lib/e2e/enum/Provider.d.ts.map +1 -1
  3. package/lib/e2e/enum/Provider.js +3 -0
  4. package/lib/e2e/enum/Provider.js.map +1 -1
  5. package/lib/e2e/index.d.ts +0 -2
  6. package/lib/e2e/index.d.ts.map +1 -1
  7. package/lib/exchange/error.d.ts +1 -0
  8. package/lib/exchange/error.d.ts.map +1 -1
  9. package/lib/exchange/error.js +11 -1
  10. package/lib/exchange/error.js.map +1 -1
  11. package/lib/exchange/swap/api/v5/actions.d.ts +3 -0
  12. package/lib/exchange/swap/api/v5/actions.d.ts.map +1 -0
  13. package/lib/exchange/swap/api/v5/actions.js +36 -0
  14. package/lib/exchange/swap/api/v5/actions.js.map +1 -0
  15. package/lib/exchange/swap/getCompleteSwapHistory.js +1 -1
  16. package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
  17. package/lib/exchange/swap/postSwapState.d.ts.map +1 -1
  18. package/lib/exchange/swap/postSwapState.js +19 -9
  19. package/lib/exchange/swap/postSwapState.js.map +1 -1
  20. package/lib/exchange/swap/setBroadcastTransaction.d.ts +3 -2
  21. package/lib/exchange/swap/setBroadcastTransaction.d.ts.map +1 -1
  22. package/lib/exchange/swap/setBroadcastTransaction.js +4 -2
  23. package/lib/exchange/swap/setBroadcastTransaction.js.map +1 -1
  24. package/lib/exchange/swap/transactionStrategies.d.ts +25 -0
  25. package/lib/exchange/swap/transactionStrategies.d.ts.map +1 -0
  26. package/lib/exchange/swap/transactionStrategies.js +152 -0
  27. package/lib/exchange/swap/transactionStrategies.js.map +1 -0
  28. package/lib/exchange/swap/types.d.ts +59 -0
  29. package/lib/exchange/swap/types.d.ts.map +1 -1
  30. package/lib/families/cardano/signerSerializer.js +4 -2
  31. package/lib/families/cardano/signerSerializer.js.map +1 -1
  32. package/lib/families/evm/bridge/mock.js +2 -2
  33. package/lib/families/evm/platformAdapter.js +2 -2
  34. package/lib/families/evm/platformAdapter.js.map +1 -1
  35. package/lib/families/evm/platformAdapter.test.js +4 -4
  36. package/lib/families/evm/platformAdapter.test.js.map +1 -1
  37. package/lib/families/evm/react.js +1 -1
  38. package/lib/families/evm/react.js.map +1 -1
  39. package/lib/families/evm/react.test.js +2 -2
  40. package/lib/families/evm/react.test.js.map +1 -1
  41. package/lib/families/evm/walletApiAdapter.js +1 -1
  42. package/lib/families/evm/walletApiAdapter.js.map +1 -1
  43. package/lib/featureFlags/defaultFeatures.js +1 -1
  44. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  45. package/lib/featureFlags/useFeature.d.ts +1 -1
  46. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  47. package/lib/hw/extractOnboardingState.d.ts.map +1 -1
  48. package/lib/hw/extractOnboardingState.js +8 -6
  49. package/lib/hw/extractOnboardingState.js.map +1 -1
  50. package/lib/hw/extractOnboardingState.test.js +7 -0
  51. package/lib/hw/extractOnboardingState.test.js.map +1 -1
  52. package/lib/mock/account.d.ts.map +1 -1
  53. package/lib/mock/account.js +1 -0
  54. package/lib/mock/account.js.map +1 -1
  55. package/lib/wallet-api/Exchange/server.d.ts +29 -10
  56. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  57. package/lib/wallet-api/Exchange/server.js +204 -7
  58. package/lib/wallet-api/Exchange/server.js.map +1 -1
  59. package/lib/wallet-api/Exchange/server.test.js +3 -1
  60. package/lib/wallet-api/Exchange/server.test.js.map +1 -1
  61. package/lib/wallet-api/useDappLogic.js +2 -2
  62. package/lib-es/e2e/enum/Provider.d.ts +3 -0
  63. package/lib-es/e2e/enum/Provider.d.ts.map +1 -1
  64. package/lib-es/e2e/enum/Provider.js +3 -0
  65. package/lib-es/e2e/enum/Provider.js.map +1 -1
  66. package/lib-es/e2e/index.d.ts +0 -2
  67. package/lib-es/e2e/index.d.ts.map +1 -1
  68. package/lib-es/exchange/error.d.ts +1 -0
  69. package/lib-es/exchange/error.d.ts.map +1 -1
  70. package/lib-es/exchange/error.js +9 -0
  71. package/lib-es/exchange/error.js.map +1 -1
  72. package/lib-es/exchange/swap/api/v5/actions.d.ts +3 -0
  73. package/lib-es/exchange/swap/api/v5/actions.d.ts.map +1 -0
  74. package/lib-es/exchange/swap/api/v5/actions.js +29 -0
  75. package/lib-es/exchange/swap/api/v5/actions.js.map +1 -0
  76. package/lib-es/exchange/swap/getCompleteSwapHistory.js +1 -1
  77. package/lib-es/exchange/swap/getCompleteSwapHistory.js.map +1 -1
  78. package/lib-es/exchange/swap/postSwapState.d.ts.map +1 -1
  79. package/lib-es/exchange/swap/postSwapState.js +17 -7
  80. package/lib-es/exchange/swap/postSwapState.js.map +1 -1
  81. package/lib-es/exchange/swap/setBroadcastTransaction.d.ts +3 -2
  82. package/lib-es/exchange/swap/setBroadcastTransaction.d.ts.map +1 -1
  83. package/lib-es/exchange/swap/setBroadcastTransaction.js +4 -2
  84. package/lib-es/exchange/swap/setBroadcastTransaction.js.map +1 -1
  85. package/lib-es/exchange/swap/transactionStrategies.d.ts +25 -0
  86. package/lib-es/exchange/swap/transactionStrategies.d.ts.map +1 -0
  87. package/lib-es/exchange/swap/transactionStrategies.js +140 -0
  88. package/lib-es/exchange/swap/transactionStrategies.js.map +1 -0
  89. package/lib-es/exchange/swap/types.d.ts +59 -0
  90. package/lib-es/exchange/swap/types.d.ts.map +1 -1
  91. package/lib-es/families/cardano/signerSerializer.js +4 -2
  92. package/lib-es/families/cardano/signerSerializer.js.map +1 -1
  93. package/lib-es/families/evm/bridge/mock.js +1 -1
  94. package/lib-es/families/evm/platformAdapter.js +1 -1
  95. package/lib-es/families/evm/platformAdapter.js.map +1 -1
  96. package/lib-es/families/evm/platformAdapter.test.js +1 -1
  97. package/lib-es/families/evm/platformAdapter.test.js.map +1 -1
  98. package/lib-es/families/evm/react.js +1 -1
  99. package/lib-es/families/evm/react.js.map +1 -1
  100. package/lib-es/families/evm/react.test.js +2 -2
  101. package/lib-es/families/evm/react.test.js.map +1 -1
  102. package/lib-es/families/evm/walletApiAdapter.js +1 -1
  103. package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
  104. package/lib-es/featureFlags/defaultFeatures.js +1 -1
  105. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  106. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  107. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  108. package/lib-es/hw/extractOnboardingState.d.ts.map +1 -1
  109. package/lib-es/hw/extractOnboardingState.js +8 -6
  110. package/lib-es/hw/extractOnboardingState.js.map +1 -1
  111. package/lib-es/hw/extractOnboardingState.test.js +7 -0
  112. package/lib-es/hw/extractOnboardingState.test.js.map +1 -1
  113. package/lib-es/mock/account.d.ts.map +1 -1
  114. package/lib-es/mock/account.js +1 -0
  115. package/lib-es/mock/account.js.map +1 -1
  116. package/lib-es/wallet-api/Exchange/server.d.ts +29 -10
  117. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  118. package/lib-es/wallet-api/Exchange/server.js +206 -9
  119. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  120. package/lib-es/wallet-api/Exchange/server.test.js +3 -1
  121. package/lib-es/wallet-api/Exchange/server.test.js.map +1 -1
  122. package/lib-es/wallet-api/useDappLogic.js +1 -1
  123. package/package.json +40 -40
  124. package/src/e2e/enum/Provider.ts +3 -0
  125. package/src/exchange/error.ts +10 -0
  126. package/src/exchange/swap/api/v5/actions.ts +36 -0
  127. package/src/exchange/swap/getCompleteSwapHistory.ts +1 -1
  128. package/src/exchange/swap/postSwapState.ts +24 -6
  129. package/src/exchange/swap/setBroadcastTransaction.ts +6 -2
  130. package/src/exchange/swap/transactionStrategies.ts +234 -0
  131. package/src/exchange/swap/types.ts +64 -0
  132. package/src/families/cardano/__snapshots__/bridge.integration.test.ts.snap +1 -0
  133. package/src/families/cardano/signerSerializer.ts +4 -2
  134. package/src/families/evm/bridge/mock.ts +1 -1
  135. package/src/families/evm/platformAdapter.test.ts +1 -1
  136. package/src/families/evm/platformAdapter.ts +1 -1
  137. package/src/families/evm/react.test.ts +3 -3
  138. package/src/families/evm/react.ts +1 -1
  139. package/src/families/evm/walletApiAdapter.ts +1 -1
  140. package/src/featureFlags/defaultFeatures.ts +1 -1
  141. package/src/hw/extractOnboardingState.test.ts +9 -0
  142. package/src/hw/extractOnboardingState.ts +12 -8
  143. package/src/mock/account.ts +1 -0
  144. package/src/wallet-api/Exchange/server.test.ts +7 -5
  145. package/src/wallet-api/Exchange/server.ts +344 -32
  146. package/src/wallet-api/useDappLogic.ts +1 -1
@@ -11,13 +11,15 @@ export const setBroadcastTransaction = ({
11
11
  targetCurrencyId,
12
12
  hardwareWalletType,
13
13
  swapType,
14
+ swapAppVersion,
14
15
  }: {
15
- result: { operation: Operation; swapId: string };
16
+ result: { operation: Operation | string; swapId: string };
16
17
  provider: string;
17
18
  sourceCurrencyId?: string;
18
19
  targetCurrencyId?: string;
19
20
  hardwareWalletType?: DeviceModelId;
20
21
  swapType?: TradeMethod;
22
+ swapAppVersion?: string;
21
23
  }) => {
22
24
  const { operation, swapId } = result;
23
25
 
@@ -36,16 +38,18 @@ export const setBroadcastTransaction = ({
36
38
  targetCurrencyId,
37
39
  hardwareWalletType,
38
40
  swapType: swapType,
41
+ swapAppVersion,
39
42
  });
40
43
  } else {
41
44
  postSwapAccepted({
42
45
  provider,
43
46
  swapId,
44
- transactionId: operation.hash,
47
+ transactionId: typeof operation === "string" ? operation : operation.hash,
45
48
  sourceCurrencyId,
46
49
  targetCurrencyId,
47
50
  hardwareWalletType,
48
51
  swapType,
52
+ swapAppVersion,
49
53
  });
50
54
  }
51
55
  };
@@ -0,0 +1,234 @@
1
+ import { BigNumber } from "bignumber.js";
2
+
3
+ import {
4
+ CosmosTransaction,
5
+ ElrondTransaction,
6
+ RippleTransaction,
7
+ SolanaTransaction,
8
+ StellarTransaction,
9
+ TonTransaction,
10
+ Transaction,
11
+ TransactionCommon,
12
+ } from "@ledgerhq/wallet-api-client";
13
+
14
+ export type { SwapLiveError } from "@ledgerhq/wallet-api-exchange-module";
15
+
16
+ export function defaultTransaction({
17
+ family,
18
+ amount,
19
+ recipient,
20
+ customFeeConfig,
21
+ }: TransactionWithCustomFee): Transaction {
22
+ return <Transaction>{
23
+ family,
24
+ amount,
25
+ recipient,
26
+ ...customFeeConfig,
27
+ };
28
+ }
29
+
30
+ export function modeSendTransaction({
31
+ family,
32
+ amount,
33
+ recipient,
34
+ customFeeConfig,
35
+ }: TransactionWithCustomFee): Transaction {
36
+ return {
37
+ ...defaultTransaction({ family, amount, recipient, customFeeConfig }),
38
+ mode: "send",
39
+ };
40
+ }
41
+
42
+ export function stellarTransaction({
43
+ family,
44
+ amount,
45
+ recipient,
46
+ customFeeConfig,
47
+ payinExtraId,
48
+ customErrorType,
49
+ }: TransactionWithCustomFee): StellarTransaction {
50
+ if (!payinExtraId)
51
+ throw {
52
+ error: new Error("Missing payinExtraId"),
53
+ step: "PayinExtraIdStepError",
54
+ customErrorType,
55
+ };
56
+
57
+ return {
58
+ ...defaultTransaction({ family, amount, recipient, customFeeConfig }),
59
+ family: "stellar",
60
+ memoValue: payinExtraId,
61
+ memoType: "MEMO_TEXT",
62
+ };
63
+ }
64
+
65
+ export function rippleTransaction({
66
+ amount,
67
+ recipient,
68
+ customFeeConfig,
69
+ payinExtraId,
70
+ customErrorType,
71
+ }: TransactionWithCustomFee): RippleTransaction {
72
+ if (!payinExtraId)
73
+ throw {
74
+ error: new Error("Missing payinExtraId"),
75
+ step: "PayinExtraIdStepError",
76
+ customErrorType,
77
+ };
78
+
79
+ const transaction: RippleTransaction = {
80
+ family: "ripple",
81
+ amount,
82
+ recipient,
83
+ ...customFeeConfig,
84
+ tag: new BigNumber(payinExtraId).toNumber(),
85
+ };
86
+ return transaction;
87
+ }
88
+
89
+ // Function to remove gasLimit from customFeeConfig for Ethereum or Bitcoin
90
+ export function withoutGasLimitTransaction({
91
+ family,
92
+ amount,
93
+ recipient,
94
+ customFeeConfig,
95
+ extraTransactionParameters,
96
+ }: TransactionWithCustomFee): Transaction {
97
+ if (customFeeConfig?.gasLimit) {
98
+ delete customFeeConfig.gasLimit;
99
+ }
100
+
101
+ if (extraTransactionParameters) {
102
+ return <Transaction>{
103
+ family,
104
+ amount,
105
+ recipient,
106
+ ...customFeeConfig,
107
+ data: Buffer.from(extraTransactionParameters, "hex"),
108
+ };
109
+ }
110
+ return defaultTransaction({ family, amount, recipient, customFeeConfig });
111
+ }
112
+
113
+ export function bitcoinTransaction({
114
+ amount,
115
+ recipient,
116
+ customFeeConfig,
117
+ extraTransactionParameters,
118
+ }: TransactionWithCustomFee): Transaction {
119
+ if (extraTransactionParameters) {
120
+ return {
121
+ family: "bitcoin",
122
+ amount,
123
+ recipient,
124
+ ...customFeeConfig,
125
+ opReturnData: Buffer.from(extraTransactionParameters, "utf-8"),
126
+ };
127
+ }
128
+ return {
129
+ family: "bitcoin",
130
+ amount,
131
+ recipient,
132
+ ...customFeeConfig,
133
+ };
134
+ }
135
+
136
+ export function solanaTransaction({
137
+ family,
138
+ amount,
139
+ recipient,
140
+ customFeeConfig,
141
+ }: TransactionWithCustomFee): SolanaTransaction {
142
+ return {
143
+ ...defaultTransaction({ family, amount, recipient, customFeeConfig }),
144
+ family: "solana",
145
+ model: { kind: "transfer", uiState: {} },
146
+ };
147
+ }
148
+
149
+ export function elrondTransaction({
150
+ amount,
151
+ recipient,
152
+ customFeeConfig,
153
+ }: TransactionWithCustomFee): ElrondTransaction {
154
+ const transaction: ElrondTransaction = {
155
+ family: "elrond",
156
+ amount,
157
+ recipient,
158
+ mode: "send",
159
+ ...customFeeConfig,
160
+ gasLimit: 0, // FIXME: Placeholder, adjust as needed
161
+ };
162
+ return transaction;
163
+ }
164
+
165
+ function tonTransaction({
166
+ family,
167
+ amount,
168
+ recipient,
169
+ customFeeConfig,
170
+ }: TransactionWithCustomFee): TonTransaction {
171
+ return {
172
+ ...defaultTransaction({ family, amount, recipient, customFeeConfig }),
173
+ family: "ton",
174
+ comment: { isEncrypted: false, text: "" },
175
+ fees: new BigNumber(0), // Set default value as completeExchange call prepareTransaction, which set again fees.
176
+ };
177
+ }
178
+
179
+ export function cosmosTransaction({
180
+ family,
181
+ amount,
182
+ recipient,
183
+ customFeeConfig,
184
+ payinExtraId,
185
+ }: TransactionWithCustomFee): CosmosTransaction {
186
+ return <CosmosTransaction>{
187
+ ...defaultTransaction({ family, amount, recipient, customFeeConfig }),
188
+ family: "cosmos",
189
+ mode: "send",
190
+ memo: payinExtraId ?? undefined,
191
+ };
192
+ }
193
+
194
+ export type TransactionWithCustomFee = TransactionCommon & {
195
+ customFeeConfig: {
196
+ [key: string]: BigNumber;
197
+ };
198
+ payinExtraId?: string;
199
+ customErrorType?: "swap";
200
+ extraTransactionParameters?: string;
201
+ };
202
+
203
+ // Define a specific type for the strategy functions, assuming they might need parameters
204
+ export type TransactionStrategyFunction = (params: TransactionWithCustomFee) => Transaction;
205
+
206
+ export const transactionStrategy: {
207
+ [K in Transaction["family"]]: TransactionStrategyFunction;
208
+ } = {
209
+ algorand: defaultTransaction,
210
+ aptos: defaultTransaction,
211
+ bitcoin: bitcoinTransaction,
212
+ cardano: modeSendTransaction,
213
+ celo: defaultTransaction,
214
+ cosmos: cosmosTransaction,
215
+ crypto_org: defaultTransaction,
216
+ elrond: elrondTransaction,
217
+ ethereum: withoutGasLimitTransaction,
218
+ filecoin: defaultTransaction,
219
+ hedera: defaultTransaction,
220
+ near: modeSendTransaction,
221
+ neo: defaultTransaction,
222
+ polkadot: defaultTransaction,
223
+ ripple: rippleTransaction,
224
+ solana: solanaTransaction,
225
+ stacks: defaultTransaction,
226
+ stellar: stellarTransaction,
227
+ tezos: modeSendTransaction,
228
+ ton: tonTransaction,
229
+ tron: modeSendTransaction,
230
+ vechain: defaultTransaction,
231
+ casper: defaultTransaction,
232
+ sui: defaultTransaction,
233
+ internet_computer: defaultTransaction,
234
+ };
@@ -4,6 +4,7 @@ import { Account, AccountLike, AccountRaw, AccountRawLike, Operation } from "@le
4
4
  import { BigNumber } from "bignumber.js";
5
5
  import { Result as UseBridgeTransactionResult } from "../../bridge/useBridgeTransaction";
6
6
  import { Transaction, TransactionRaw } from "../../generated/types";
7
+
7
8
  export type { SwapLiveError } from "@ledgerhq/wallet-api-exchange-module";
8
9
 
9
10
  export type ExchangeSwap = {
@@ -198,6 +199,7 @@ type SwapStateRequest = {
198
199
  targetCurrencyId: string;
199
200
  hardwareWalletType: DeviceModelId;
200
201
  swapType: TradeMethod;
202
+ swapAppVersion?: string;
201
203
  }>;
202
204
 
203
205
  export type SwapStateAcceptedRequest = SwapStateRequest & {
@@ -336,3 +338,65 @@ export type SwapTransactionType = UseBridgeTransactionResult & {
336
338
  fromAmountError?: Error;
337
339
  fromAmountWarning?: Error;
338
340
  };
341
+
342
+ export type SwapPayloadRequestData = {
343
+ provider: string;
344
+ deviceTransactionId: string;
345
+ fromAccountAddress: string;
346
+ toAccountAddress: string;
347
+ fromAccountCurrency: string;
348
+ toAccountCurrency: string;
349
+ amount: string;
350
+ amountInAtomicUnit: number;
351
+ quoteId?: string;
352
+ toNewTokenId?: string;
353
+ };
354
+ export type SwapPayloadResponse = {
355
+ binaryPayload: string;
356
+ signature: string;
357
+ payinAddress: string;
358
+ swapId: string;
359
+ payinExtraId?: string;
360
+ extraTransactionParameters?: string;
361
+ };
362
+
363
+ export type ConfirmSwapRequest = {
364
+ provider: string;
365
+ swapId: string;
366
+ transactionId: string;
367
+ sourceCurrencyId?: string;
368
+ targetCurrencyId?: string;
369
+ hardwareWalletType?: string;
370
+ };
371
+
372
+ export type CancelSwapRequest = {
373
+ provider: string;
374
+ swapId: string;
375
+ statusCode?: string;
376
+ errorMessage?: string;
377
+ sourceCurrencyId?: string;
378
+ targetCurrencyId?: string;
379
+ hardwareWalletType?: string;
380
+ swapType?: string;
381
+ swapStep?: string;
382
+ };
383
+
384
+ export type SwapBackendResponse = {
385
+ provider: string;
386
+ swapId: string;
387
+ apiExtraFee: number;
388
+ apiFee: number;
389
+ refundAddress: string;
390
+ amountExpectedFrom: number;
391
+ amountExpectedTo: number;
392
+ status: string;
393
+ from: string;
394
+ to: string;
395
+ payinAddress: string;
396
+ payoutAddress: string;
397
+ createdAt: string; // ISO-8601
398
+ binaryPayload: string;
399
+ signature: string;
400
+ payinExtraId?: string;
401
+ extraTransactionParameters?: string;
402
+ };
@@ -7,6 +7,7 @@ exports[`cardano_testnet currency bridge scanAccounts cardano_testnet seed 1 1`]
7
7
  "cardanoResources": {
8
8
  "delegation": {
9
9
  "dRepHex": undefined,
10
+ "deposit": "2000000",
10
11
  "name": "Apex Cardano Pool",
11
12
  "poolId": "7facad662e180ce45e5c504957cd1341940c72a708728f7ecfc6e349",
12
13
  "rewards": "0",
@@ -121,9 +121,10 @@ function prepareCertificate(cert: SignerTxCertificate): Certificate {
121
121
  switch (cert.type) {
122
122
  case "REGISTRATION":
123
123
  return {
124
- type: CertificateType.STAKE_REGISTRATION,
124
+ type: CertificateType.STAKE_REGISTRATION_CONWAY,
125
125
  params: {
126
126
  stakeCredential,
127
+ deposit: cert.params.deposit,
127
128
  },
128
129
  };
129
130
  case "DELEGATION":
@@ -136,9 +137,10 @@ function prepareCertificate(cert: SignerTxCertificate): Certificate {
136
137
  };
137
138
  case "DEREGISTRATION":
138
139
  return {
139
- type: CertificateType.STAKE_DEREGISTRATION,
140
+ type: CertificateType.STAKE_DEREGISTRATION_CONWAY,
140
141
  params: {
141
142
  stakeCredential,
143
+ deposit: cert.params.deposit,
142
144
  },
143
145
  };
144
146
  case "VOTE_DELEGATION_ABSTAIN":
@@ -14,7 +14,7 @@ import {
14
14
  getSerializedAddressParameters,
15
15
  updateTransaction,
16
16
  } from "@ledgerhq/coin-framework/bridge/jsHelpers";
17
- import { getGasLimit } from "@ledgerhq/coin-evm/logic";
17
+ import { getGasLimit } from "@ledgerhq/coin-evm/utils";
18
18
  import { getTypedTransaction } from "@ledgerhq/coin-evm/transaction";
19
19
  const receive = makeAccountBridgeReceive();
20
20
  const defaultGetFees = (_a, t: any) => (t.gasPrice || new BigNumber(0)).times(getGasLimit(t));
@@ -1,8 +1,8 @@
1
- import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/createTransaction";
2
1
  import { Transaction } from "@ledgerhq/coin-evm/types/index";
3
2
  import { FAMILIES, EthereumTransaction as PlatformTransaction } from "@ledgerhq/live-app-sdk";
4
3
  import BigNumber from "bignumber.js";
5
4
  import evm from "./platformAdapter";
5
+ import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/utils";
6
6
 
7
7
  describe("getPlatformTransactionSignFlowInfos", () => {
8
8
  describe("should properly get infos for ETH platform tx", () => {
@@ -1,6 +1,6 @@
1
1
  // TODO: to remove once live-app-sdk is depreciated and removed from LL
2
2
 
3
- import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/createTransaction";
3
+ import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/utils";
4
4
  import { Transaction } from "@ledgerhq/coin-evm/types/index";
5
5
  import { EthereumTransaction as PlatformTransaction } from "@ledgerhq/live-app-sdk";
6
6
 
@@ -4,15 +4,15 @@
4
4
  import BigNumber from "bignumber.js";
5
5
  import { renderHook, waitFor } from "@testing-library/react";
6
6
  import { Transaction } from "@ledgerhq/coin-evm/types/index";
7
- import { getGasTracker } from "@ledgerhq/coin-evm/api/gasTracker/index";
8
- import type { GasTrackerApi } from "@ledgerhq/coin-evm/api/gasTracker/types";
7
+ import { getGasTracker } from "@ledgerhq/coin-evm/network/gasTracker/index";
8
+ import type { GasTrackerApi } from "@ledgerhq/coin-evm/network/gasTracker/types";
9
9
  import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
10
10
  import { useGasOptions } from "./react";
11
11
 
12
12
  jest.useFakeTimers();
13
13
  jest.spyOn(global, "setInterval");
14
14
 
15
- jest.mock("@ledgerhq/coin-evm/api/gasTracker/index");
15
+ jest.mock("@ledgerhq/coin-evm/network/gasTracker/index");
16
16
  const mockedGetGasTracker = jest.mocked(getGasTracker);
17
17
 
18
18
  const mockedGetGasOptions = jest.fn();
@@ -1,4 +1,4 @@
1
- import { getGasTracker } from "@ledgerhq/coin-evm/api/gasTracker/index";
1
+ import { getGasTracker } from "@ledgerhq/coin-evm/network/gasTracker/index";
2
2
  import type { GasOptions, Transaction } from "@ledgerhq/coin-evm/types/index";
3
3
  import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
4
4
  import { useEffect, useMemo, useState } from "react";
@@ -1,4 +1,4 @@
1
- import { createTransaction } from "@ledgerhq/coin-evm/createTransaction";
1
+ import { createTransaction } from "@ledgerhq/coin-evm/bridge/createTransaction";
2
2
  import { Transaction } from "@ledgerhq/coin-evm/types/index";
3
3
  import { EthereumTransaction as WalletAPIEthereumTransaction } from "@ledgerhq/wallet-api-core";
4
4
  import {
@@ -153,6 +153,7 @@ export const DEFAULT_FEATURES: Features = {
153
153
  protectServicesDesktop: {
154
154
  enabled: false,
155
155
  params: {
156
+ openWithDevTools: false,
156
157
  availableOnDesktop: false,
157
158
  isNew: false,
158
159
  ledgerliveStorageState: false,
@@ -530,7 +531,6 @@ export const DEFAULT_FEATURES: Features = {
530
531
  ...DEFAULT_FEATURE,
531
532
  params: { link: null },
532
533
  },
533
- llmNetworkBasedAddAccountFlow: DEFAULT_FEATURE,
534
534
  llCounterValueGranularitiesRates: {
535
535
  ...DEFAULT_FEATURE,
536
536
  params: {
@@ -35,6 +35,15 @@ describe("@hw/extractOnboardingState", () => {
35
35
  expect(onboardingState?.currentOnboardingStep).toBe(OnboardingStep.Ready);
36
36
  expect(onboardingState?.charonStatus).toBeNull();
37
37
  });
38
+
39
+ it("should ignore charon update status", () => {
40
+ const charonState = Buffer.from([0x20]);
41
+ const onboardingState = extractOnboardingState(flagsBytes, charonState);
42
+
43
+ expect(onboardingState).not.toBeNull();
44
+ expect(onboardingState?.currentOnboardingStep).toBe(OnboardingStep.Ready);
45
+ expect(onboardingState?.charonStatus).toBeNull();
46
+ });
38
47
  });
39
48
 
40
49
  describe("and the user refuse to backup the charon", () => {
@@ -137,6 +137,14 @@ export const extractOnboardingState = (
137
137
 
138
138
  const currentSeedWordIndex = flagsBytes[2] & currentSeedWordIndexMask;
139
139
 
140
+ const charonSupported = charonState !== undefined && charonState.length > 0;
141
+ const charonOnboardingBits = charonSupported ? charonState[0] & 0xf : 0;
142
+ //const charonUpdateBits = charonSupported ? (charonState[0] & 0x30) >> 4 : 0;
143
+ const charonStatus =
144
+ charonSupported && fromBitsToCharonStatusMap.has(charonOnboardingBits)
145
+ ? fromBitsToCharonStatusMap.get(charonOnboardingBits)!
146
+ : null;
147
+
140
148
  /*
141
149
  * Once the device is seeded, there are some additional states for backing up with Charon (for devices that support it)
142
150
  * There are 2 scenarios:
@@ -148,9 +156,11 @@ export const extractOnboardingState = (
148
156
  if (
149
157
  isOnboarded &&
150
158
  [OnboardingStep.Ready, OnboardingStep.WelcomeScreen1].includes(currentOnboardingStep) &&
151
- charonState !== undefined
159
+ charonSupported
152
160
  ) {
153
- currentOnboardingStep = fromBitsToOnboardingStep.get(charonState[0] + CHARON_STEP_BIT_MASK);
161
+ currentOnboardingStep = fromBitsToOnboardingStep.get(
162
+ charonOnboardingBits + CHARON_STEP_BIT_MASK,
163
+ );
154
164
 
155
165
  if (!currentOnboardingStep) {
156
166
  throw new DeviceExtractOnboardingStateError(
@@ -159,12 +169,6 @@ export const extractOnboardingState = (
159
169
  }
160
170
  }
161
171
 
162
- const charonSupported = charonState !== undefined && charonState.length > 0;
163
- const charonStatus =
164
- charonSupported && fromBitsToCharonStatusMap.has(charonState[0])
165
- ? fromBitsToCharonStatusMap.get(charonState[0])!
166
- : null;
167
-
168
172
  return {
169
173
  isOnboarded,
170
174
  isInRecoveryMode,
@@ -130,6 +130,7 @@ export function genAccount(id: number | string, opts: GenAccountOptions = {}): A
130
130
  (account as CardanoAccount).cardanoResources = {
131
131
  delegation: {
132
132
  status: true,
133
+ deposit: "2000000",
133
134
  poolId: "45",
134
135
  ticker: "ADA",
135
136
  name: "Cardano",
@@ -1,14 +1,14 @@
1
- import { handlers } from "./server";
2
- import { AppBranch, AppPlatform, Visibility } from "../types";
3
- import { of } from "rxjs";
1
+ import { RpcRequest } from "@ledgerhq/wallet-api-core";
4
2
  import {
5
3
  ExchangeStartParams,
6
4
  ExchangeStartSellParams,
7
5
  ExchangeStartSwapParams,
8
6
  } from "@ledgerhq/wallet-api-exchange-module";
9
- import { RpcRequest } from "@ledgerhq/wallet-api-core";
10
- import { genAccount } from "../../mock/account";
11
7
  import { WalletContext, WalletHandlers } from "@ledgerhq/wallet-api-server";
8
+ import { of } from "rxjs";
9
+ import { genAccount } from "../../mock/account";
10
+ import { AppBranch, AppPlatform, Visibility } from "../types";
11
+ import { handlers } from "./server";
12
12
 
13
13
  const mockTracking = {
14
14
  startExchangeRequested: jest.fn(),
@@ -46,6 +46,7 @@ const testAppManifest = {
46
46
 
47
47
  const mockUiStartExchange = jest.fn();
48
48
  const mockUiCompleteExchange = jest.fn();
49
+ const mockUiSwap = jest.fn();
49
50
  const mockUiError = jest.fn();
50
51
  const mockIsReady = jest.fn();
51
52
 
@@ -54,6 +55,7 @@ const mockUiHooks = {
54
55
  "custom.exchange.complete": mockUiCompleteExchange,
55
56
  "custom.exchange.error": mockUiError,
56
57
  "custom.isReady": mockIsReady,
58
+ "custom.exchange.swap": mockUiSwap,
57
59
  };
58
60
 
59
61
  // Mock converter id to send back the id received in params.