@ledgerhq/live-common 21.26.2 → 21.29.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 (236) hide show
  1. package/lib/__tests__/currencies.js +1 -1
  2. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.js +27 -26
  3. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.js.map +1 -1
  4. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js +9 -7
  5. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js.map +1 -1
  6. package/lib/apps/support.d.ts.map +1 -1
  7. package/lib/apps/support.js +2 -1
  8. package/lib/apps/support.js.map +1 -1
  9. package/lib/bridge/jsHelpers.js +1 -1
  10. package/lib/bridge/jsHelpers.js.map +1 -1
  11. package/lib/data/icons/react/index.d.ts +1 -0
  12. package/lib/data/icons/react/index.d.ts.map +1 -1
  13. package/lib/data/icons/react/index.js +4 -2
  14. package/lib/data/icons/react/index.js.map +1 -1
  15. package/lib/data/icons/react/sol.js +3 -3
  16. package/lib/data/icons/react/sol.js.map +1 -1
  17. package/lib/data/icons/react/tyc.d.ts +8 -0
  18. package/lib/data/icons/react/tyc.d.ts.map +1 -0
  19. package/lib/data/icons/react/tyc.js +33 -0
  20. package/lib/data/icons/react/tyc.js.map +1 -0
  21. package/lib/data/icons/reactNative/index.d.ts +1 -0
  22. package/lib/data/icons/reactNative/index.d.ts.map +1 -1
  23. package/lib/data/icons/reactNative/index.js +4 -2
  24. package/lib/data/icons/reactNative/index.js.map +1 -1
  25. package/lib/data/icons/reactNative/sol.js +3 -3
  26. package/lib/data/icons/reactNative/sol.js.map +1 -1
  27. package/lib/data/icons/reactNative/tyc.d.ts +8 -0
  28. package/lib/data/icons/reactNative/tyc.d.ts.map +1 -0
  29. package/lib/data/icons/reactNative/tyc.js +34 -0
  30. package/lib/data/icons/reactNative/tyc.js.map +1 -0
  31. package/lib/env.d.ts +15 -6
  32. package/lib/env.d.ts.map +1 -1
  33. package/lib/env.js +11 -2
  34. package/lib/env.js.map +1 -1
  35. package/lib/env.react.d.ts +1 -1
  36. package/lib/env.react.d.ts.map +1 -1
  37. package/lib/exchange/hw-app-exchange/Exchange.d.ts +12 -15
  38. package/lib/exchange/hw-app-exchange/Exchange.d.ts.map +1 -1
  39. package/lib/exchange/hw-app-exchange/Exchange.js +4 -13
  40. package/lib/exchange/hw-app-exchange/Exchange.js.map +1 -1
  41. package/lib/exchange/index.d.ts.map +1 -1
  42. package/lib/exchange/index.js +9 -2
  43. package/lib/exchange/index.js.map +1 -1
  44. package/lib/exchange/platform/completeExchange.d.ts +6 -0
  45. package/lib/exchange/platform/completeExchange.d.ts.map +1 -0
  46. package/lib/exchange/platform/completeExchange.js +24 -0
  47. package/lib/exchange/platform/completeExchange.js.map +1 -0
  48. package/lib/exchange/platform/serialization.d.ts +4 -0
  49. package/lib/exchange/platform/serialization.d.ts.map +1 -0
  50. package/lib/exchange/platform/serialization.js +57 -0
  51. package/lib/exchange/platform/serialization.js.map +1 -0
  52. package/lib/exchange/{swap → platform}/startExchange.d.ts +0 -0
  53. package/lib/exchange/platform/startExchange.d.ts.map +1 -0
  54. package/lib/exchange/{swap → platform}/startExchange.js +3 -3
  55. package/lib/exchange/platform/startExchange.js.map +1 -0
  56. package/lib/exchange/platform/transfer/completeExchange.d.ts +5 -0
  57. package/lib/exchange/platform/transfer/completeExchange.d.ts.map +1 -0
  58. package/lib/exchange/platform/transfer/completeExchange.js +198 -0
  59. package/lib/exchange/platform/transfer/completeExchange.js.map +1 -0
  60. package/lib/exchange/platform/transfer/index.d.ts +5 -0
  61. package/lib/exchange/platform/transfer/index.d.ts.map +1 -0
  62. package/lib/exchange/platform/transfer/index.js +49 -0
  63. package/lib/exchange/platform/transfer/index.js.map +1 -0
  64. package/lib/exchange/platform/types.d.ts +59 -0
  65. package/lib/exchange/platform/types.d.ts.map +1 -0
  66. package/lib/exchange/platform/types.js +3 -0
  67. package/lib/exchange/platform/types.js.map +1 -0
  68. package/lib/exchange/sell/checkSignatureAndPrepare.js +1 -2
  69. package/lib/exchange/sell/checkSignatureAndPrepare.js.map +1 -1
  70. package/lib/exchange/sell/getTransactionId.js +1 -2
  71. package/lib/exchange/sell/getTransactionId.js.map +1 -1
  72. package/lib/exchange/sell/index.d.ts +6 -0
  73. package/lib/exchange/sell/index.d.ts.map +1 -1
  74. package/lib/exchange/sell/index.js +3 -3
  75. package/lib/exchange/sell/index.js.map +1 -1
  76. package/lib/exchange/swap/completeExchange.d.ts +2 -13
  77. package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
  78. package/lib/exchange/swap/completeExchange.js +2 -4
  79. package/lib/exchange/swap/completeExchange.js.map +1 -1
  80. package/lib/exchange/swap/hooks/usePickDefaultAccount.d.ts.map +1 -1
  81. package/lib/exchange/swap/hooks/usePickDefaultAccount.js +4 -9
  82. package/lib/exchange/swap/hooks/usePickDefaultAccount.js.map +1 -1
  83. package/lib/exchange/swap/initSwap.d.ts.map +1 -1
  84. package/lib/exchange/swap/initSwap.js +3 -4
  85. package/lib/exchange/swap/initSwap.js.map +1 -1
  86. package/lib/exchange/swap/types.d.ts +0 -12
  87. package/lib/exchange/swap/types.d.ts.map +1 -1
  88. package/lib/exchange/swap/utils/index.d.ts +6 -1
  89. package/lib/exchange/swap/utils/index.d.ts.map +1 -1
  90. package/lib/exchange/swap/utils/index.js +8 -1
  91. package/lib/exchange/swap/utils/index.js.map +1 -1
  92. package/lib/exchange/swap/utils/index.test.js +27 -0
  93. package/lib/exchange/swap/utils/index.test.js.map +1 -1
  94. package/lib/exchange/testCurrencyConfig/data/coins.d.ts +8 -0
  95. package/lib/exchange/testCurrencyConfig/data/coins.d.ts.map +1 -0
  96. package/lib/exchange/testCurrencyConfig/data/coins.js +21 -0
  97. package/lib/exchange/testCurrencyConfig/data/coins.js.map +1 -0
  98. package/lib/exchange/testCurrencyConfig/index.d.ts +8 -0
  99. package/lib/exchange/testCurrencyConfig/index.d.ts.map +1 -0
  100. package/lib/exchange/testCurrencyConfig/index.js +68 -0
  101. package/lib/exchange/testCurrencyConfig/index.js.map +1 -0
  102. package/lib/families/algorand/api/algodv2.d.ts +2 -1
  103. package/lib/families/algorand/api/algodv2.d.ts.map +1 -1
  104. package/lib/families/algorand/api/algodv2.js +2 -2
  105. package/lib/families/algorand/api/algodv2.js.map +1 -1
  106. package/lib/families/algorand/js-broadcast.js +1 -1
  107. package/lib/families/algorand/js-broadcast.js.map +1 -1
  108. package/lib/families/algorand/js-signOperation.d.ts.map +1 -1
  109. package/lib/families/algorand/js-signOperation.js +1 -1
  110. package/lib/families/algorand/js-signOperation.js.map +1 -1
  111. package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
  112. package/lib/families/bitcoin/wallet-btc/wallet.js +8 -2
  113. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  114. package/lib/families/bitcoin/wallet-btc/xpub.js +1 -1
  115. package/lib/families/bitcoin/wallet-btc/xpub.js.map +1 -1
  116. package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js +1 -1
  117. package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js.map +1 -1
  118. package/lib/families/ethereum/nft.integration.test.js +1 -36
  119. package/lib/families/ethereum/nft.integration.test.js.map +1 -1
  120. package/lib/families/ethereum/specs.d.ts.map +1 -1
  121. package/lib/families/ethereum/specs.js +2 -0
  122. package/lib/families/ethereum/specs.js.map +1 -1
  123. package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
  124. package/lib/families/ethereum/synchronisation.js +2 -7
  125. package/lib/families/ethereum/synchronisation.js.map +1 -1
  126. package/lib/families/solana/api/chain/index.d.ts.map +1 -1
  127. package/lib/families/solana/api/chain/index.js +3 -1
  128. package/lib/families/solana/api/chain/index.js.map +1 -1
  129. package/lib/families/tezos/datasets/tezos.scanAccounts.1.js +1 -1
  130. package/lib/families/tezos/datasets/tezos.scanAccounts.1.js.map +1 -1
  131. package/lib/hw/actions/app.d.ts +3 -0
  132. package/lib/hw/actions/app.d.ts.map +1 -1
  133. package/lib/hw/actions/app.js +7 -1
  134. package/lib/hw/actions/app.js.map +1 -1
  135. package/lib/hw/actions/completeExchange.d.ts +1 -0
  136. package/lib/hw/actions/completeExchange.d.ts.map +1 -1
  137. package/lib/hw/actions/completeExchange.js +4 -3
  138. package/lib/hw/actions/completeExchange.js.map +1 -1
  139. package/lib/hw/connectApp.d.ts +5 -0
  140. package/lib/hw/connectApp.d.ts.map +1 -1
  141. package/lib/hw/connectApp.js +37 -26
  142. package/lib/hw/connectApp.js.map +1 -1
  143. package/lib/market/MarketDataProvider.d.ts +26 -0
  144. package/lib/market/MarketDataProvider.d.ts.map +1 -0
  145. package/lib/market/MarketDataProvider.js +339 -0
  146. package/lib/market/MarketDataProvider.js.map +1 -0
  147. package/lib/market/api/api.d.ts +15 -0
  148. package/lib/market/api/api.d.ts.map +1 -0
  149. package/lib/market/api/api.js +261 -0
  150. package/lib/market/api/api.js.map +1 -0
  151. package/lib/market/api/api.mock.d.ts +15 -0
  152. package/lib/market/api/api.mock.d.ts.map +1 -0
  153. package/lib/market/api/api.mock.js +454 -0
  154. package/lib/market/api/api.mock.js.map +1 -0
  155. package/lib/market/types.d.ts +83 -0
  156. package/lib/market/types.d.ts.map +1 -0
  157. package/lib/market/types.js +3 -0
  158. package/lib/market/types.js.map +1 -0
  159. package/lib/market/utils/countervalueFormatter.d.ts +8 -0
  160. package/lib/market/utils/countervalueFormatter.d.ts.map +1 -0
  161. package/lib/market/utils/countervalueFormatter.js +18 -0
  162. package/lib/market/utils/countervalueFormatter.js.map +1 -0
  163. package/lib/market/utils/rangeDataTable.d.ts +10 -0
  164. package/lib/market/utils/rangeDataTable.d.ts.map +1 -0
  165. package/lib/market/utils/rangeDataTable.js +36 -0
  166. package/lib/market/utils/rangeDataTable.js.map +1 -0
  167. package/lib/nft/support.d.ts.map +1 -1
  168. package/lib/nft/support.js +1 -1
  169. package/lib/nft/support.js.map +1 -1
  170. package/lib/platform/PlatformAppProvider/api/api.mock.d.ts.map +1 -1
  171. package/lib/platform/PlatformAppProvider/api/api.mock.js +27 -0
  172. package/lib/platform/PlatformAppProvider/api/api.mock.js.map +1 -1
  173. package/package.json +17 -17
  174. package/src/__tests__/__snapshots__/all.libcore.ts.snap +221 -212
  175. package/src/__tests__/currencies.ts +1 -1
  176. package/src/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.ts +26 -25
  177. package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +2 -0
  178. package/src/apps/support.ts +1 -0
  179. package/src/bridge/jsHelpers.ts +1 -1
  180. package/src/data/icons/react/index.tsx +1 -0
  181. package/src/data/icons/react/sol.tsx +1 -1
  182. package/src/data/icons/react/tyc.tsx +12 -0
  183. package/src/data/icons/reactNative/index.tsx +1 -0
  184. package/src/data/icons/reactNative/sol.tsx +1 -1
  185. package/src/data/icons/reactNative/tyc.tsx +13 -0
  186. package/src/data/icons/svg/SOL.svg +8 -1
  187. package/src/data/icons/svg/TYC.svg +6 -0
  188. package/src/env.ts +11 -2
  189. package/src/exchange/hw-app-exchange/Exchange.ts +22 -18
  190. package/src/exchange/index.ts +19 -1
  191. package/src/exchange/platform/completeExchange.ts +42 -0
  192. package/src/exchange/platform/serialization.ts +78 -0
  193. package/src/exchange/{swap → platform}/startExchange.ts +6 -2
  194. package/src/exchange/platform/transfer/completeExchange.ts +187 -0
  195. package/src/exchange/platform/transfer/index.ts +66 -0
  196. package/src/exchange/platform/types.ts +76 -0
  197. package/src/exchange/sell/checkSignatureAndPrepare.ts +2 -2
  198. package/src/exchange/sell/getTransactionId.ts +2 -2
  199. package/src/exchange/sell/index.ts +1 -1
  200. package/src/exchange/swap/completeExchange.ts +41 -50
  201. package/src/exchange/swap/hooks/usePickDefaultAccount.ts +4 -9
  202. package/src/exchange/swap/initSwap.ts +4 -7
  203. package/src/exchange/swap/types.ts +1 -14
  204. package/src/exchange/swap/utils/index.test.ts +44 -1
  205. package/src/exchange/swap/utils/index.ts +12 -1
  206. package/src/exchange/testCurrencyConfig/data/coins.ts +20 -0
  207. package/src/exchange/testCurrencyConfig/index.ts +24 -0
  208. package/src/families/algorand/api/algodv2.ts +2 -2
  209. package/src/families/algorand/js-broadcast.ts +1 -1
  210. package/src/families/algorand/js-signOperation.ts +8 -3
  211. package/src/families/bitcoin/wallet-btc/wallet.ts +6 -2
  212. package/src/families/bitcoin/wallet-btc/xpub.ts +1 -1
  213. package/src/families/ethereum/datasets/ethereum.scanAccounts.1.ts +43 -43
  214. package/src/families/ethereum/nft.integration.test.ts +1 -18
  215. package/src/families/ethereum/specs.ts +2 -0
  216. package/src/families/ethereum/synchronisation.ts +1 -6
  217. package/src/families/solana/api/chain/index.ts +6 -2
  218. package/src/families/tezos/datasets/tezos.scanAccounts.1.ts +39 -39
  219. package/src/hw/actions/app.ts +17 -1
  220. package/src/hw/actions/completeExchange.ts +9 -3
  221. package/src/hw/connectApp.ts +53 -31
  222. package/src/market/MarketDataProvider.tsx +440 -0
  223. package/src/market/api/api.mock.ts +374 -0
  224. package/src/market/api/api.ts +227 -0
  225. package/src/market/types.ts +92 -0
  226. package/src/market/utils/countervalueFormatter.ts +24 -0
  227. package/src/market/utils/rangeDataTable.ts +40 -0
  228. package/src/nft/support.ts +1 -3
  229. package/src/platform/PlatformAppProvider/api/api.mock.ts +27 -0
  230. package/lib/exchange/swap/startExchange.d.ts.map +0 -1
  231. package/lib/exchange/swap/startExchange.js.map +0 -1
  232. package/lib/families/ethereum/versions.d.ts +0 -2
  233. package/lib/families/ethereum/versions.d.ts.map +0 -1
  234. package/lib/families/ethereum/versions.js +0 -5
  235. package/lib/families/ethereum/versions.js.map +0 -1
  236. package/src/families/ethereum/versions.ts +0 -1
@@ -0,0 +1,24 @@
1
+ import coins from "./data/coins";
2
+ const all = [...coins];
3
+ const configs = {};
4
+
5
+ for (const [id, config, signature] of all) {
6
+ configs[id] = {
7
+ config,
8
+ signature,
9
+ };
10
+ }
11
+
12
+ /**
13
+ *
14
+ */
15
+ export const findTestExchangeCurrencyConfig = (
16
+ id: string
17
+ ):
18
+ | {
19
+ config: string;
20
+
21
+ signature: string;
22
+ }
23
+ | null
24
+ | undefined => configs[id];
@@ -37,7 +37,6 @@ export const getAccount = async (address: string): Promise<AlgoAccount> => {
37
37
  };
38
38
  };
39
39
 
40
- // TODO Cache
41
40
  export const getTransactionParams =
42
41
  async (): Promise<AlgoTransactionParams> => {
43
42
  const { data } = await network({
@@ -56,12 +55,13 @@ export const getTransactionParams =
56
55
  };
57
56
 
58
57
  export const broadcastTransaction = async (
59
- payload: string
58
+ payload: Buffer
60
59
  ): Promise<string> => {
61
60
  const { data }: { data: AlgoTransactionBroadcastResponse } = await network({
62
61
  method: "POST",
63
62
  url: fullUrl(`/transactions`),
64
63
  data: payload,
64
+ headers: { "Content-Type": "application/x-binary" },
65
65
  });
66
66
 
67
67
  return data.txId;
@@ -12,6 +12,6 @@ export const broadcast = async ({
12
12
  signedOperation: SignedOperation;
13
13
  }): Promise<Operation> => {
14
14
  const { signature, operation } = signedOperation;
15
- const hash = await apiBroadcast(signature);
15
+ const hash = await apiBroadcast(Buffer.from(signature, "hex"));
16
16
  return patchOperationWithHash(operation, hash);
17
17
  };
@@ -2,7 +2,12 @@ import { BigNumber } from "bignumber.js";
2
2
  import { Observable } from "rxjs";
3
3
  import { FeeNotLoaded } from "@ledgerhq/errors";
4
4
  import Algorand from "@ledgerhq/hw-app-algorand";
5
- import type { Account, Operation, SignOperationEvent } from "../../types";
5
+ import type {
6
+ Account,
7
+ Operation,
8
+ SignedOperation,
9
+ SignOperationEvent,
10
+ } from "../../types";
6
11
  import { withDevice } from "../../hw/deviceAccess";
7
12
  import type { Transaction } from "./types";
8
13
  import {
@@ -56,9 +61,9 @@ export const signOperation = ({
56
61
  type: "signed",
57
62
  signedOperation: {
58
63
  operation,
59
- signature: toBroadcast,
64
+ signature: toBroadcast.toString("hex"),
60
65
  expirationDate: null,
61
- },
66
+ } as SignedOperation,
62
67
  });
63
68
  }
64
69
 
@@ -229,7 +229,6 @@ class BitcoinLikeWallet {
229
229
  btc,
230
230
  fromAccount,
231
231
  txInfo,
232
- hasTimestamp,
233
232
  initialTimestamp,
234
233
  additionals,
235
234
  hasExtraData,
@@ -237,7 +236,7 @@ class BitcoinLikeWallet {
237
236
  onDeviceSignatureGranted,
238
237
  onDeviceStreaming,
239
238
  } = params;
240
-
239
+ let hasTimestamp = params.hasTimestamp;
241
240
  let length = txInfo.outputs.reduce((sum, output) => {
242
241
  return sum + 8 + output.script.length + 1;
243
242
  }, 1);
@@ -270,6 +269,11 @@ class BitcoinLikeWallet {
270
269
  number | null | undefined
271
270
  ][];
272
271
  const inputs: Inputs = txInfo.inputs.map((i) => {
272
+ if (additionals && additionals.includes("peercoin")) {
273
+ // remove timestamp for new version of peercoin input, refer to https://github.com/peercoin/rfcs/issues/5 and https://github.com/LedgerHQ/ledgerjs/issues/701
274
+ const version = i.txHex.substring(0, 8);
275
+ hasTimestamp = version === "01000000" || version === "02000000";
276
+ }
273
277
  log("hw", `splitTransaction`, {
274
278
  transactionHex: i.txHex,
275
279
  isSegwitSupported: true,
@@ -67,7 +67,7 @@ class Xpub extends EventEmitter {
67
67
  );
68
68
 
69
69
  this.storage.addAddress(
70
- `${this.derivationMode}-${this.xpub}-${account}-${index}`,
70
+ `${this.crypto.network.name}-${this.derivationMode}-${this.xpub}-${account}-${index}`,
71
71
  address
72
72
  );
73
73
  await this.whenSynced("address", address);
@@ -1,47 +1,47 @@
1
1
  export default {
2
2
  name: "ethereum seed 1",
3
3
  apdus: `
4
- => e00200000d038000002c8000003c80000000
5
- <= 410434ab5fd7ee8bd794b8a41875aa9a78a296d7c4246531dfd36d47fa6bb42c8eb02720c6d9802b8590c4a461f08c2a7696557a9ec1d4fd0ca340c63b33ad359f4228323031653833363838324636384541456433346338323545423463333036446537303830323663629000
6
- => e002000011048000002c8000003c8000000000000000
7
- <= 4104b7577f404537d1e934a8d2a1fd2552a7f399928b5af0aad714acc17b36865b3f5d1843d6a580c737c051656ac35978283a388a759911d289e9994071247d167528356466304333363936343142384166336337653961653037364535343636654636373833313943649000
8
- => e002000011048000002c8000003c8000000000000001
9
- <= 4104bee21a16156c645d0150e262c40648b9fd938c6462efe3adf9051efe077d30b356c86b8bc8a182e58cdc514e6d0c2670f6626d34f78220187e2d279d661d23f628446336313732383838343733383239324134373236353042624133653936433261344638383739369000
10
- => e002000011048000002c8000003c8000000000000002
11
- <= 410467f77bf213f0de5fd7ae7ac2ca2b6f7ad6cacecbb8688acd0bcf0fcc5b7b58512fe786639619b9f4a513061dd0355590ec5b7d2c4d934c43a37778920bf07e1a28623262344230413836384543326530613162326533314131304142414130393365463032386544389000
12
- => e002000011048000002c8000003c8000000000000003
13
- <= 4104dcce479cd733a7972cea67f0b5bf92d786a1e62a9afe5e50ddd2f7f7c8c1aaff89e28b236f5f1e75c702c3c0116de49dde6b32f06f66937f0b190bdd730bd84e28613563334139333430364465323733666639386244443343653935314232653431423137436443469000
14
- => e002000011048000002c8000003c8000000000000004
15
- <= 4104b60582b8ea13540e5292396949f9d2ed23d9ec4344e2463e9fe7fa36c12372da03a0427c48d653dd59abfcbb7628b323076415f1fd53bc601b8071d82ddd635528393945363561463136626644393139303246623638394163373938343338633042464334373439359000
16
- => e002000011048000002c8000003c8000000000000005
17
- <= 4104126bf90b475158cb8c947dbe47d9ecdff88c34c96c7b7f4fc17a05257dff1024c089fd51f657fa7f5b1041d23bc67d46cd0dd4df86c5318f653486199313e18f28663736394533463933663831313733653836333365354461653646433031426262443163634230389000
18
- => e002000011048000002c8000003c8000000000000006
19
- <= 4104dc7934183510e92e07136e9192da7d5bbd4c3a757b4d9bdf8dcca9baabdf8efddfad24ef74e8a0db52d9e4171516665ff6e4cd152273f460627933df3ced177828463439386638653139323342653437633335343932376445334332313661633341453734666535619000
20
- => e002000011048000002c8000003c8000000000000007
21
- <= 4104b7664a7012f69cee691362377df6d8558b0acfe1541dbf95af90e919d6867ac9d46b3b0b42e98fe8543c15ae501fed3d85869fd0310d9804faed0d07ae3b871628353932393338336336626631624439666533383462423665363162394232413230416637434361429000
22
- => e002000011048000002c8000003c8000000000000008
23
- <= 41045cdb8bc99d890837444698a53d9c18d22c6159e0727e051fee54e7299318282d3fe882b4aa133e7e15529e90b824b4f83ea5242b3ad4651c7d9cca12c796e45428634339303838363541443934303634623733433739663235393861373966393843654544364446619000
24
- => e002000011048000002c8000003c8000000000000009
25
- <= 4104720ec99d2297e627e239764e519be6900d06fc3d9145e306daeace60944c3c6dc14e74f24d27fc98278c0c07de821bae71ed5c95e9a7b95538637e817763609128373731663039424535353143386346393734426141426336373365324232323132643637383236469000
26
- => e002000011048000002c8000003c800000000000000a
27
- <= 41043a98496a4115f61e264bd74ba1ea661729ccfa239e72318ecbd307fb747d2032be5e308e435b24417320a95b719d60b7740b0bf297f926b414b4d3b44d903a9f28384138383238373537353662333831336262613844644631376634304232363064423232466334379000
28
- => e002000011048000002c8000003c800000000000000b
29
- <= 41040f3a6497cdef24c68b895a0d8a9f8b54e16ee84e4905a24236a242a82a900e068cb72ad71f52b57dfa41e00090cd035d1a4205dbe3982ac88189c743edb856a828646431344537456135384533384343316134653737386265663338323831664139413134353232419000
30
- => e002000015058000002c8000003c800000000000000000000001
31
- <= 41040374fb34926a57e184cdd3438109021b3169a9c74ffe726d1abc7a187fa9440a11f071b96f72c8e9e0ea1f82dc2180166bd8c7bae9401cdd3d2466a40e1755ca28304536613732456439323243323338394466303365383666354537394261374336344535343933379000
32
- => e002000015058000002c8000003c800000000000000000000000
33
- <= 410478f6d00bc3be349f69a8b88b3957d569d7ed44d27d0824988107ba1a6117cfcefc22b03b9be870ddadb643eeda4357761d44419cfbdccb19701be086780ff71128304533463062623935313646303166324333346332354530393537353138623861433934313463359000
34
- => e002000015058000002c8000003c800000010000000000000000
35
- <= 4104c20d717f7652a279588b267457c051e387fbeb8648b730cd3daeaa8fa3774f37ab535ab9bd024b87776b77b3409546a0b64e1b14828ea43891b4200318fc90fd28363637463942453934613432343538636235334133413636353131446361313962333937373338649000
36
- => e002000015058000002c8000003c800000020000000000000000
37
- <= 4104e788111a6c0254ec8184453383d2d8b18c8e0b86d1fea93c2691a9bc6240572f24129a634155d1291228a1721fc88737f75e51bb7575ccc69937d649c1422ea028386639353530323931314338316135454332626134623831356564326432433565316338383932359000
38
- => e002000015058000002c8000003c800000030000000000000000
39
- <= 4104ffd79641446518c675ad32e6434a2aba9e7c426200bc336d78222cbec00d2c8aa7a8c685084f450870e2a801049795ba051f8b3a878a586158697d6bd4ce0b6d28386261343131303566464135343531306362394436376362334137323632344434303532634130389000
40
- => e002000015058000002c8000003c800000040000000000000000
41
- <= 4104602f7c0f3f73a914b3dd83e8bb6f11f3dc8ea1d2c7308fa4f8d9d2000a4419eec324393f4cf191e83f3adc64de9388f5979664c6d6dac4c23c0566d7aabbddfa28366233343933464531383145413238336530333335653544384437363865323132326243366331389000
42
- => e002000015058000002c8000003c800000050000000000000000
43
- <= 410484f94dfa2c52fee4f8b37b578b0087de88ee282cb788a56af1eabd7711ddd37e6da1c9eada59926b7828d7e12db21c443ed0a2ca4521561806d3175407a557c128323546456139343435344664334137413138443935383131463565346562353733633163434334329000
44
- => e002000015058000002c8000003c800000060000000000000000
45
- <= 4104e7c7f373d0a568554b5372b68f6e697aee3947c053ee5d882afba2f2c9a44273768b2e61b01de519b0c1f365e23aea5e3d041a40a347a125e202a2d7d7ef596828624636373337664138373538463134443838376531646633323442423431363136334533366436319000
46
- `,
4
+ => e00200000d038000002c8000003c80000000
5
+ <= 410469877df9567b58e6ef8f6cf1fb8a8e1bf28a327dee31b183a6b9cd1f3da063af0924506a9912793ef31e41df19f8653fa31bb1fecc32d2e41abdddb22ccb621028373561453661383832363036353137343345356546433033373937313136413335363539663638359000
6
+ => e002000011048000002c8000003c8000000000000000
7
+ <= 4104b7577f404537d1e934a8d2a1fd2552a7f399928b5af0aad714acc17b36865b3f5d1843d6a580c737c051656ac35978283a388a759911d289e9994071247d167528356466304333363936343142384166336337653961653037364535343636654636373833313943649000
8
+ => e002000011048000002c8000003c8000000000000001
9
+ <= 4104bee21a16156c645d0150e262c40648b9fd938c6462efe3adf9051efe077d30b356c86b8bc8a182e58cdc514e6d0c2670f6626d34f78220187e2d279d661d23f628446336313732383838343733383239324134373236353042624133653936433261344638383739369000
10
+ => e002000011048000002c8000003c8000000000000002
11
+ <= 410467f77bf213f0de5fd7ae7ac2ca2b6f7ad6cacecbb8688acd0bcf0fcc5b7b58512fe786639619b9f4a513061dd0355590ec5b7d2c4d934c43a37778920bf07e1a28623262344230413836384543326530613162326533314131304142414130393365463032386544389000
12
+ => e002000011048000002c8000003c8000000000000003
13
+ <= 4104dcce479cd733a7972cea67f0b5bf92d786a1e62a9afe5e50ddd2f7f7c8c1aaff89e28b236f5f1e75c702c3c0116de49dde6b32f06f66937f0b190bdd730bd84e28613563334139333430364465323733666639386244443343653935314232653431423137436443469000
14
+ => e002000011048000002c8000003c8000000000000004
15
+ <= 4104b60582b8ea13540e5292396949f9d2ed23d9ec4344e2463e9fe7fa36c12372da03a0427c48d653dd59abfcbb7628b323076415f1fd53bc601b8071d82ddd635528393945363561463136626644393139303246623638394163373938343338633042464334373439359000
16
+ => e002000011048000002c8000003c8000000000000005
17
+ <= 4104126bf90b475158cb8c947dbe47d9ecdff88c34c96c7b7f4fc17a05257dff1024c089fd51f657fa7f5b1041d23bc67d46cd0dd4df86c5318f653486199313e18f28663736394533463933663831313733653836333365354461653646433031426262443163634230389000
18
+ => e002000011048000002c8000003c8000000000000006
19
+ <= 4104dc7934183510e92e07136e9192da7d5bbd4c3a757b4d9bdf8dcca9baabdf8efddfad24ef74e8a0db52d9e4171516665ff6e4cd152273f460627933df3ced177828463439386638653139323342653437633335343932376445334332313661633341453734666535619000
20
+ => e002000011048000002c8000003c8000000000000007
21
+ <= 4104b7664a7012f69cee691362377df6d8558b0acfe1541dbf95af90e919d6867ac9d46b3b0b42e98fe8543c15ae501fed3d85869fd0310d9804faed0d07ae3b871628353932393338336336626631624439666533383462423665363162394232413230416637434361429000
22
+ => e002000011048000002c8000003c8000000000000008
23
+ <= 41045cdb8bc99d890837444698a53d9c18d22c6159e0727e051fee54e7299318282d3fe882b4aa133e7e15529e90b824b4f83ea5242b3ad4651c7d9cca12c796e45428634339303838363541443934303634623733433739663235393861373966393843654544364446619000
24
+ => e002000011048000002c8000003c8000000000000009
25
+ <= 4104720ec99d2297e627e239764e519be6900d06fc3d9145e306daeace60944c3c6dc14e74f24d27fc98278c0c07de821bae71ed5c95e9a7b95538637e817763609128373731663039424535353143386346393734426141426336373365324232323132643637383236469000
26
+ => e002000011048000002c8000003c800000000000000a
27
+ <= 41043a98496a4115f61e264bd74ba1ea661729ccfa239e72318ecbd307fb747d2032be5e308e435b24417320a95b719d60b7740b0bf297f926b414b4d3b44d903a9f28384138383238373537353662333831336262613844644631376634304232363064423232466334379000
28
+ => e002000011048000002c8000003c800000000000000b
29
+ <= 41040f3a6497cdef24c68b895a0d8a9f8b54e16ee84e4905a24236a242a82a900e068cb72ad71f52b57dfa41e00090cd035d1a4205dbe3982ac88189c743edb856a828646431344537456135384533384343316134653737386265663338323831664139413134353232419000
30
+ => e002000015058000002c8000003c800000000000000000000001
31
+ <= 41040374fb34926a57e184cdd3438109021b3169a9c74ffe726d1abc7a187fa9440a11f071b96f72c8e9e0ea1f82dc2180166bd8c7bae9401cdd3d2466a40e1755ca28304536613732456439323243323338394466303365383666354537394261374336344535343933379000
32
+ => e002000015058000002c8000003c800000000000000000000000
33
+ <= 410478f6d00bc3be349f69a8b88b3957d569d7ed44d27d0824988107ba1a6117cfcefc22b03b9be870ddadb643eeda4357761d44419cfbdccb19701be086780ff71128304533463062623935313646303166324333346332354530393537353138623861433934313463359000
34
+ => e002000015058000002c8000003c800000010000000000000000
35
+ <= 4104c20d717f7652a279588b267457c051e387fbeb8648b730cd3daeaa8fa3774f37ab535ab9bd024b87776b77b3409546a0b64e1b14828ea43891b4200318fc90fd28363637463942453934613432343538636235334133413636353131446361313962333937373338649000
36
+ => e002000015058000002c8000003c800000020000000000000000
37
+ <= 4104e788111a6c0254ec8184453383d2d8b18c8e0b86d1fea93c2691a9bc6240572f24129a634155d1291228a1721fc88737f75e51bb7575ccc69937d649c1422ea028386639353530323931314338316135454332626134623831356564326432433565316338383932359000
38
+ => e002000015058000002c8000003c800000030000000000000000
39
+ <= 4104ffd79641446518c675ad32e6434a2aba9e7c426200bc336d78222cbec00d2c8aa7a8c685084f450870e2a801049795ba051f8b3a878a586158697d6bd4ce0b6d28386261343131303566464135343531306362394436376362334137323632344434303532634130389000
40
+ => e002000015058000002c8000003c800000040000000000000000
41
+ <= 4104602f7c0f3f73a914b3dd83e8bb6f11f3dc8ea1d2c7308fa4f8d9d2000a4419eec324393f4cf191e83f3adc64de9388f5979664c6d6dac4c23c0566d7aabbddfa28366233343933464531383145413238336530333335653544384437363865323132326243366331389000
42
+ => e002000015058000002c8000003c800000050000000000000000
43
+ <= 410484f94dfa2c52fee4f8b37b578b0087de88ee282cb788a56af1eabd7711ddd37e6da1c9eada59926b7828d7e12db21c443ed0a2ca4521561806d3175407a557c128323546456139343435344664334137413138443935383131463565346562353733633163434334329000
44
+ => e002000015058000002c8000003c800000060000000000000000
45
+ <= 4104e7c7f373d0a568554b5372b68f6e697aee3947c053ee5d882afba2f2c9a44273768b2e61b01de519b0c1f365e23aea5e3d041a40a347a125e202a2d7d7ef596828624636373337664138373538463134443838376531646633323442423431363136334533366436319000
46
+ `,
47
47
  };
@@ -5,7 +5,6 @@ import type { Account, AccountRaw } from "../../types";
5
5
  import { getAccountBridge } from "../../bridge";
6
6
  import { makeBridgeCacheSystem } from "../../bridge/cache";
7
7
  import { patchAccount } from "../../reconciliation";
8
- import { setEnv } from "../../env";
9
8
 
10
9
  jest.setTimeout(200000);
11
10
 
@@ -68,10 +67,9 @@ const gaspardBscAccount: AccountRaw = {
68
67
  xpub: "",
69
68
  };
70
69
 
71
- async function sync(account, withNFT = true) {
70
+ async function sync(account) {
72
71
  const bridge = getAccountBridge(account);
73
72
  const blacklistedTokenIds = [];
74
- setEnv("NFT", withNFT);
75
73
  const r = await bridge
76
74
  .sync(account, {
77
75
  paginationConfig: {},
@@ -79,7 +77,6 @@ async function sync(account, withNFT = true) {
79
77
  })
80
78
  .pipe(reduce((a, f: (arg0: Account) => Account) => f(a), account))
81
79
  .toPromise();
82
- setEnv("NFT", false);
83
80
  return r;
84
81
  }
85
82
 
@@ -128,20 +125,6 @@ ethTestingAccounts.forEach((a) => {
128
125
  const resync = await sync(copy);
129
126
  expect(resync.nfts).toEqual(account.nfts);
130
127
  });
131
-
132
- test("start account with .nfts and disable the NFT flag should make it disappear", async () => {
133
- expect(account.nfts).not.toBeFalsy();
134
- const resync = await sync(account, false);
135
- expect(resync.nfts).toBeFalsy();
136
- });
137
-
138
- test("start account without .nfts and enable the NFT flag should make it appear", async () => {
139
- const first = await sync(account, false);
140
- expect(first.nfts).toBeFalsy();
141
- const second = await sync(first, true);
142
- expect(second.nfts).not.toBeFalsy();
143
- expect(second.nfts).toEqual(account.nfts);
144
- });
145
128
  });
146
129
  });
147
130
 
@@ -406,6 +406,7 @@ const bsc: AppSpec<Transaction> = {
406
406
  model: DeviceModelId.nanoS,
407
407
  appName: "Binance Smart Chain",
408
408
  },
409
+ dependency: "Ethereum",
409
410
  testTimeout: 2 * 60 * 1000,
410
411
  transactionCheck: ({ maxSpendable }) => {
411
412
  invariant(
@@ -452,6 +453,7 @@ const polygon: AppSpec<Transaction> = {
452
453
  model: DeviceModelId.nanoS,
453
454
  appName: "Polygon",
454
455
  },
456
+ dependency: "Ethereum",
455
457
  testTimeout: 2 * 60 * 1000,
456
458
  transactionCheck: ({ maxSpendable }) => {
457
459
  invariant(
@@ -20,7 +20,6 @@ import { API, apiForCurrency, Tx } from "../../api/Ethereum";
20
20
  import { digestTokenAccounts, prepareTokenAccounts } from "./modules";
21
21
  import { findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets";
22
22
  import { encodeNftId, isNFTActive, nftsFromOperations } from "../../nft";
23
- import { NFT_VERSION } from "./versions";
24
23
 
25
24
  export const getAccountShape: GetAccountShape = async (
26
25
  infoInput,
@@ -40,15 +39,12 @@ export const getAccountShape: GetAccountShape = async (
40
39
  const initialStableOperations = initialAccount
41
40
  ? stableOperations(initialAccount)
42
41
  : [];
43
- const shouldNFTBeActive = isNFTActive(currency);
44
42
  // fetch transactions, incrementally if possible
45
43
  const mostRecentStableOperation = initialStableOperations[0];
46
44
  // when new tokens are added / blacklist changes, we need to sync again because we need to go through all operations again
47
45
  const syncHash =
48
46
  JSON.stringify(blacklistedTokenIds || []) +
49
47
  "_" +
50
- shouldNFTBeActive +
51
- "_" +
52
48
  listTokensForCryptoCurrency(currency, {
53
49
  withDelisted: true,
54
50
  }).length;
@@ -57,8 +53,7 @@ export const getAccountShape: GetAccountShape = async (
57
53
  initialAccount &&
58
54
  areAllOperationsLoaded(initialAccount) &&
59
55
  mostRecentStableOperation &&
60
- !outdatedSyncHash &&
61
- NFT_VERSION
56
+ !outdatedSyncHash
62
57
  ? mostRecentStableOperation.blockHash
63
58
  : undefined;
64
59
  const txsP = fetchAllTransactions(api, address, pullFromBlockHash);
@@ -9,6 +9,7 @@ import {
9
9
  Connection,
10
10
  FeeCalculator,
11
11
  PublicKey,
12
+ sendAndConfirmRawTransaction,
12
13
  SignaturesForAddressOptions,
13
14
  } from "@solana/web3.js";
14
15
  import { Awaited } from "../../logic";
@@ -96,8 +97,11 @@ export function getChainAPI(config: Config): ChainAPI {
96
97
  .getParsedAccountInfo(new PublicKey(address))
97
98
  .then((r) => r.value),
98
99
 
99
- sendRawTransaction: (buffer: Buffer) =>
100
- connection().sendRawTransaction(buffer),
100
+ sendRawTransaction: (buffer: Buffer) => {
101
+ return sendAndConfirmRawTransaction(connection(), buffer, {
102
+ commitment: "confirmed",
103
+ });
104
+ },
101
105
 
102
106
  findAssocTokenAccAddress: (owner: string, mint: string) =>
103
107
  Token.getAssociatedTokenAddress(
@@ -3,43 +3,43 @@ export default {
3
3
  unstableAccounts: true,
4
4
  // accounts are staking so receive over time. we disable for now snapshot comparison
5
5
  apdus: `
6
- => 8002000009028000002c800006c1
7
- <= 210280ca1bdf81e50b0c09df34557084edafcc9f7e1f749fe47596405bb6d802f0029000
8
- => 8002000015058000002c800006c1800000008000000080000000
9
- <= 2102f7ed85c519f7d39a664935a410d1a41ca302dfa3eee228e92cbe0dc12aba7a189000
10
- => 8002000015058000002c800006c1800000008000000080000001
11
- <= 2102b058662fd530e6463d774e3951a40ddd5e430dbeb62673f90caca0cec58735fd9000
12
- => 8002000009028000002c800006c1
13
- <= 210280ca1bdf81e50b0c09df34557084edafcc9f7e1f749fe47596405bb6d802f0029000
14
- => 8002000011048000002c800006c18000000080000000
15
- <= 210294e8344ae6df2d3123fa100b5abd40cee339c67838b1c34c4f243cc582f4d2d89000
16
- => 8002000011048000002c800006c18000000080000001
17
- <= 2102670e5e92d06e725b68edda589678fdf0f85a582df06ee634d841cf8042db63839000
18
- => 8002000009028000002c800006c1
19
- <= 210280ca1bdf81e50b0c09df34557084edafcc9f7e1f749fe47596405bb6d802f0029000
20
- => 8002000015058000002c800006c1800000008000000080000000
21
- <= 2102f7ed85c519f7d39a664935a410d1a41ca302dfa3eee228e92cbe0dc12aba7a189000
22
- => 8002000015058000002c800006c1800000018000000080000000
23
- <= 2102c26d0da1978b7a7596c9853d80d0beac20519c73e76e7f677540db47165d94f39000
24
- => 8002000015058000002c800006c1800000028000000080000000
25
- <= 21020058c0efd324fa13d778c4b0995f6fa8d9c85e561c1465d770d4011993f557509000
26
- => 8002000015058000002c800006c1800000038000000080000000
27
- <= 21029bfe70b3e94ff23623f6c42f6e081a9ca8cc78f74b0d8da58f0d4cdc41c33c1a9000
28
- => 8002000015058000002c800006c1800000048000000080000000
29
- <= 21021d3b9b84feb81d5215cca4f0a016e99fc6cf86d06e864cb4a5098709f16aa2219000
30
- => 8002000015058000002c800006c1800000058000000080000000
31
- <= 21020162dc75ad3c2b6e097d15a1513033c60d8a033f2312ff5a6ead812228d9d6539000
32
- => 8002000015058000002c800006c1800000068000000080000000
33
- <= 21021831897c4224296519d496d32fdf9e17fb4af680635c5dbbc46cde84fe11dcc99000
34
- => 8002000009028000002c800006c1
35
- <= 210280ca1bdf81e50b0c09df34557084edafcc9f7e1f749fe47596405bb6d802f0029000
36
- => 8002000011048000002c800006c18000000080000000
37
- <= 210294e8344ae6df2d3123fa100b5abd40cee339c67838b1c34c4f243cc582f4d2d89000
38
- => 8002000011048000002c800006c18000000180000000
39
- <= 2102389ffd73423626894cb151416e51c72ec285376673daf83545eb5edb45b261ce9000
40
- => 8002000011048000002c800006c18000000280000000
41
- <= 2102e4c49994c90ffe2e5480826d2f49fb9d0f45280e20bd0a61c488f652d7af0f9c9000
42
- => 8002000011048000002c800006c18000000380000000
43
- <= 2102a9ae8b0ff5f9a43565793ad78e10db6f12177d904d208ada591b8a5b9999e3fd9000
44
- `,
6
+ => 800200000d038000002c800006c180000000
7
+ <= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
8
+ => 8002000015058000002c800006c1800000008000000080000000
9
+ <= 2102f7ed85c519f7d39a664935a410d1a41ca302dfa3eee228e92cbe0dc12aba7a189000
10
+ => 8002000015058000002c800006c1800000008000000080000001
11
+ <= 2102b058662fd530e6463d774e3951a40ddd5e430dbeb62673f90caca0cec58735fd9000
12
+ => 800200000d038000002c800006c180000000
13
+ <= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
14
+ => 8002000011048000002c800006c18000000080000000
15
+ <= 210294e8344ae6df2d3123fa100b5abd40cee339c67838b1c34c4f243cc582f4d2d89000
16
+ => 8002000011048000002c800006c18000000080000001
17
+ <= 2102670e5e92d06e725b68edda589678fdf0f85a582df06ee634d841cf8042db63839000
18
+ => 800200000d038000002c800006c180000000
19
+ <= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
20
+ => 8002000015058000002c800006c1800000008000000080000000
21
+ <= 2102f7ed85c519f7d39a664935a410d1a41ca302dfa3eee228e92cbe0dc12aba7a189000
22
+ => 8002000015058000002c800006c1800000018000000080000000
23
+ <= 2102c26d0da1978b7a7596c9853d80d0beac20519c73e76e7f677540db47165d94f39000
24
+ => 8002000015058000002c800006c1800000028000000080000000
25
+ <= 21020058c0efd324fa13d778c4b0995f6fa8d9c85e561c1465d770d4011993f557509000
26
+ => 8002000015058000002c800006c1800000038000000080000000
27
+ <= 21029bfe70b3e94ff23623f6c42f6e081a9ca8cc78f74b0d8da58f0d4cdc41c33c1a9000
28
+ => 8002000015058000002c800006c1800000048000000080000000
29
+ <= 21021d3b9b84feb81d5215cca4f0a016e99fc6cf86d06e864cb4a5098709f16aa2219000
30
+ => 8002000015058000002c800006c1800000058000000080000000
31
+ <= 21020162dc75ad3c2b6e097d15a1513033c60d8a033f2312ff5a6ead812228d9d6539000
32
+ => 8002000015058000002c800006c1800000068000000080000000
33
+ <= 21021831897c4224296519d496d32fdf9e17fb4af680635c5dbbc46cde84fe11dcc99000
34
+ => 800200000d038000002c800006c180000000
35
+ <= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
36
+ => 8002000011048000002c800006c18000000080000000
37
+ <= 210294e8344ae6df2d3123fa100b5abd40cee339c67838b1c34c4f243cc582f4d2d89000
38
+ => 8002000011048000002c800006c18000000180000000
39
+ <= 2102389ffd73423626894cb151416e51c72ec285376673daf83545eb5edb45b261ce9000
40
+ => 8002000011048000002c800006c18000000280000000
41
+ <= 2102e4c49994c90ffe2e5480826d2f49fb9d0f45280e20bd0a61c488f652d7af0f9c9000
42
+ => 8002000011048000002c800006c18000000380000000
43
+ <= 2102a9ae8b0ff5f9a43565793ad78e10db6f12177d904d208ada591b8a5b9999e3fd9000
44
+ `,
45
45
  };
@@ -40,6 +40,7 @@ import type { Device, Action } from "./types";
40
40
  import { shouldUpgrade } from "../../apps";
41
41
  import { ConnectAppTimeout } from "../../errors";
42
42
  import perFamilyAccount from "../../generated/account";
43
+ import type { DeviceInfo, FirmwareUpdateContext } from "../../types/manager";
43
44
 
44
45
  type State = {
45
46
  isLoading: boolean;
@@ -60,6 +61,8 @@ type State = {
60
61
  allowManagerRequestedWording: string | null | undefined;
61
62
  allowManagerGranted: boolean;
62
63
  device: Device | null | undefined;
64
+ deviceInfo?: DeviceInfo | null | undefined;
65
+ latestFirmware?: FirmwareUpdateContext | null | undefined;
63
66
  error: Error | null | undefined;
64
67
  derivation:
65
68
  | {
@@ -146,6 +149,8 @@ const getInitialState = (device?: Device | null | undefined): State => ({
146
149
  allowManagerRequestedWording: null,
147
150
  allowManagerGranted: false,
148
151
  device: null,
152
+ deviceInfo: null,
153
+ latestFirmware: null,
149
154
  opened: false,
150
155
  appAndVersion: null,
151
156
  error: null,
@@ -160,6 +165,13 @@ const reducer = (state: State, e: Event): State => {
160
165
  case "unresponsiveDevice":
161
166
  return { ...state, unresponsive: true };
162
167
 
168
+ case "device-update-last-seen":
169
+ return {
170
+ ...state,
171
+ deviceInfo: e.deviceInfo,
172
+ latestFirmware: e.latestFirmware,
173
+ };
174
+
163
175
  case "disconnected":
164
176
  return { ...getInitialState(), isLoading: !!e.expected };
165
177
 
@@ -585,7 +597,11 @@ export const createAction = (
585
597
  scan(reducer, getInitialState()), // tap((s) => console.log("connectApp state", s)),
586
598
  // we debounce the UI state to not blink on the UI
587
599
  debounce((s: State) => {
588
- if (s.allowOpeningRequestedWording || s.allowOpeningGranted) {
600
+ if (
601
+ s.allowOpeningRequestedWording ||
602
+ s.allowOpeningGranted ||
603
+ s.deviceInfo
604
+ ) {
589
605
  // no debounce for allow event
590
606
  return EMPTY;
591
607
  }
@@ -11,6 +11,7 @@ type State = {
11
11
  completeExchangeResult: Transaction | null | undefined;
12
12
  completeExchangeError: Error | null | undefined;
13
13
  freezeReduxDevice: boolean;
14
+ completeExchangeRequested: boolean;
14
15
  isLoading: boolean;
15
16
  };
16
17
 
@@ -61,14 +62,19 @@ const mapResult = ({
61
62
  const initialState: State = {
62
63
  completeExchangeResult: null,
63
64
  completeExchangeError: null,
65
+ completeExchangeRequested: false,
64
66
  freezeReduxDevice: false,
65
- isLoading: false,
67
+ isLoading: true,
66
68
  };
67
69
 
68
70
  const reducer = (state: State, e: ExchangeRequestEvent) => {
69
71
  switch (e.type) {
70
72
  case "complete-exchange":
71
- return { ...state, isLoading: true, freezeReduxDevice: true };
73
+ return {
74
+ ...state,
75
+ completeExchangeStarted: true,
76
+ freezeReduxDevice: true,
77
+ };
72
78
 
73
79
  case "complete-exchange-error":
74
80
  return {
@@ -81,7 +87,7 @@ const reducer = (state: State, e: ExchangeRequestEvent) => {
81
87
  return {
82
88
  ...state,
83
89
  completeExchangeRequested: true,
84
- isLoading: true,
90
+ isLoading: false,
85
91
  };
86
92
  case "complete-exchange-result":
87
93
  return {
@@ -1,5 +1,5 @@
1
1
  import semver from "semver";
2
- import { Observable, concat, from, of, throwError, defer } from "rxjs";
2
+ import { Observable, concat, from, of, throwError, defer, merge } from "rxjs";
3
3
  import { mergeMap, concatMap, map, catchError, delay } from "rxjs/operators";
4
4
  import {
5
5
  TransportStatusError,
@@ -55,6 +55,11 @@ export type ConnectAppEvent =
55
55
  type: "disconnected";
56
56
  expected?: boolean;
57
57
  }
58
+ | {
59
+ type: "device-update-last-seen";
60
+ deviceInfo: DeviceInfo;
61
+ latestFirmware: FirmwareUpdateContext | null | undefined;
62
+ }
58
63
  | {
59
64
  type: "device-permission-requested";
60
65
  wording: string;
@@ -102,37 +107,54 @@ export const openAppFromDashboard = (
102
107
  transport: Transport,
103
108
  appName: string
104
109
  ): Observable<ConnectAppEvent> =>
105
- concat(
106
- of<ConnectAppEvent>({
107
- type: "ask-open-app",
108
- appName,
109
- }),
110
- defer(() => from(openApp(transport, appName))).pipe(
111
- concatMap(() =>
112
- of<ConnectAppEvent>({
113
- type: "device-permission-granted",
114
- })
115
- ),
116
- catchError((e) => {
117
- if (e && e instanceof TransportStatusError) {
118
- // @ts-expect-error TransportStatusError to be typed on ledgerjs
119
- switch (e.statusCode) {
120
- case 0x6984:
121
- case 0x6807:
122
- return streamAppInstall({
123
- transport,
124
- appNames: [appName],
125
- onSuccessObs: () =>
126
- from(openAppFromDashboard(transport, appName)),
127
- }) as Observable<ConnectAppEvent>;
128
- case 0x6985:
129
- case 0x5501:
130
- return throwError(new UserRefusedOnDevice());
131
- }
132
- }
110
+ from(getDeviceInfo(transport)).pipe(
111
+ mergeMap((deviceInfo) =>
112
+ merge(
113
+ // Nb Allows LLD/LLM to update lastSeenDevice, this can run in parallel
114
+ // since there are no more device exchanges.
115
+ from(manager.getLatestFirmwareForDevice(deviceInfo)).pipe(
116
+ concatMap((latestFirmware) =>
117
+ of<ConnectAppEvent>({
118
+ type: "device-update-last-seen",
119
+ deviceInfo,
120
+ latestFirmware,
121
+ })
122
+ )
123
+ ),
124
+ concat(
125
+ of<ConnectAppEvent>({
126
+ type: "ask-open-app",
127
+ appName,
128
+ }),
129
+ defer(() => from(openApp(transport, appName))).pipe(
130
+ concatMap(() =>
131
+ of<ConnectAppEvent>({
132
+ type: "device-permission-granted",
133
+ })
134
+ ),
135
+ catchError((e) => {
136
+ if (e && e instanceof TransportStatusError) {
137
+ // @ts-expect-error TransportStatusError to be typed on ledgerjs
138
+ switch (e.statusCode) {
139
+ case 0x6984:
140
+ case 0x6807:
141
+ return streamAppInstall({
142
+ transport,
143
+ appNames: [appName],
144
+ onSuccessObs: () =>
145
+ from(openAppFromDashboard(transport, appName)),
146
+ }) as Observable<ConnectAppEvent>;
147
+ case 0x6985:
148
+ case 0x5501:
149
+ return throwError(new UserRefusedOnDevice());
150
+ }
151
+ }
133
152
 
134
- return throwError(e);
135
- })
153
+ return throwError(e);
154
+ })
155
+ )
156
+ )
157
+ )
136
158
  )
137
159
  );
138
160