@ledgerhq/live-common 21.26.3 → 21.30.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 (262) 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/__tests__/test-helpers/bridge.js +1 -1
  7. package/lib/__tests__/test-helpers/bridge.js.map +1 -1
  8. package/lib/apps/hw.d.ts.map +1 -1
  9. package/lib/apps/hw.js +8 -3
  10. package/lib/apps/hw.js.map +1 -1
  11. package/lib/apps/support.d.ts.map +1 -1
  12. package/lib/apps/support.js +2 -1
  13. package/lib/apps/support.js.map +1 -1
  14. package/lib/bridge/jsHelpers.js +1 -1
  15. package/lib/bridge/jsHelpers.js.map +1 -1
  16. package/lib/data/icons/react/index.d.ts +1 -0
  17. package/lib/data/icons/react/index.d.ts.map +1 -1
  18. package/lib/data/icons/react/index.js +4 -2
  19. package/lib/data/icons/react/index.js.map +1 -1
  20. package/lib/data/icons/react/sol.js +3 -3
  21. package/lib/data/icons/react/sol.js.map +1 -1
  22. package/lib/data/icons/react/tyc.d.ts +8 -0
  23. package/lib/data/icons/react/tyc.d.ts.map +1 -0
  24. package/lib/data/icons/react/tyc.js +33 -0
  25. package/lib/data/icons/react/tyc.js.map +1 -0
  26. package/lib/data/icons/reactNative/index.d.ts +1 -0
  27. package/lib/data/icons/reactNative/index.d.ts.map +1 -1
  28. package/lib/data/icons/reactNative/index.js +4 -2
  29. package/lib/data/icons/reactNative/index.js.map +1 -1
  30. package/lib/data/icons/reactNative/sol.js +3 -3
  31. package/lib/data/icons/reactNative/sol.js.map +1 -1
  32. package/lib/data/icons/reactNative/tyc.d.ts +8 -0
  33. package/lib/data/icons/reactNative/tyc.d.ts.map +1 -0
  34. package/lib/data/icons/reactNative/tyc.js +34 -0
  35. package/lib/data/icons/reactNative/tyc.js.map +1 -0
  36. package/lib/env.d.ts +20 -6
  37. package/lib/env.d.ts.map +1 -1
  38. package/lib/env.js +16 -2
  39. package/lib/env.js.map +1 -1
  40. package/lib/env.react.d.ts +1 -1
  41. package/lib/env.react.d.ts.map +1 -1
  42. package/lib/exchange/hw-app-exchange/Exchange.d.ts +12 -15
  43. package/lib/exchange/hw-app-exchange/Exchange.d.ts.map +1 -1
  44. package/lib/exchange/hw-app-exchange/Exchange.js +4 -13
  45. package/lib/exchange/hw-app-exchange/Exchange.js.map +1 -1
  46. package/lib/exchange/index.d.ts.map +1 -1
  47. package/lib/exchange/index.js +9 -2
  48. package/lib/exchange/index.js.map +1 -1
  49. package/lib/exchange/platform/completeExchange.d.ts +6 -0
  50. package/lib/exchange/platform/completeExchange.d.ts.map +1 -0
  51. package/lib/exchange/platform/completeExchange.js +24 -0
  52. package/lib/exchange/platform/completeExchange.js.map +1 -0
  53. package/lib/exchange/platform/serialization.d.ts +4 -0
  54. package/lib/exchange/platform/serialization.d.ts.map +1 -0
  55. package/lib/exchange/platform/serialization.js +57 -0
  56. package/lib/exchange/platform/serialization.js.map +1 -0
  57. package/lib/exchange/{swap → platform}/startExchange.d.ts +0 -0
  58. package/lib/exchange/platform/startExchange.d.ts.map +1 -0
  59. package/lib/exchange/{swap → platform}/startExchange.js +3 -3
  60. package/lib/exchange/platform/startExchange.js.map +1 -0
  61. package/lib/exchange/platform/transfer/completeExchange.d.ts +5 -0
  62. package/lib/exchange/platform/transfer/completeExchange.d.ts.map +1 -0
  63. package/lib/exchange/platform/transfer/completeExchange.js +198 -0
  64. package/lib/exchange/platform/transfer/completeExchange.js.map +1 -0
  65. package/lib/exchange/platform/transfer/index.d.ts +5 -0
  66. package/lib/exchange/platform/transfer/index.d.ts.map +1 -0
  67. package/lib/exchange/platform/transfer/index.js +49 -0
  68. package/lib/exchange/platform/transfer/index.js.map +1 -0
  69. package/lib/exchange/platform/types.d.ts +59 -0
  70. package/lib/exchange/platform/types.d.ts.map +1 -0
  71. package/lib/exchange/platform/types.js +3 -0
  72. package/lib/exchange/platform/types.js.map +1 -0
  73. package/lib/exchange/sell/checkSignatureAndPrepare.js +1 -2
  74. package/lib/exchange/sell/checkSignatureAndPrepare.js.map +1 -1
  75. package/lib/exchange/sell/getTransactionId.js +1 -2
  76. package/lib/exchange/sell/getTransactionId.js.map +1 -1
  77. package/lib/exchange/sell/index.d.ts +6 -0
  78. package/lib/exchange/sell/index.d.ts.map +1 -1
  79. package/lib/exchange/sell/index.js +3 -3
  80. package/lib/exchange/sell/index.js.map +1 -1
  81. package/lib/exchange/swap/completeExchange.d.ts +2 -13
  82. package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
  83. package/lib/exchange/swap/completeExchange.js +2 -4
  84. package/lib/exchange/swap/completeExchange.js.map +1 -1
  85. package/lib/exchange/swap/hooks/usePickDefaultAccount.d.ts.map +1 -1
  86. package/lib/exchange/swap/hooks/usePickDefaultAccount.js +4 -9
  87. package/lib/exchange/swap/hooks/usePickDefaultAccount.js.map +1 -1
  88. package/lib/exchange/swap/initSwap.d.ts.map +1 -1
  89. package/lib/exchange/swap/initSwap.js +3 -4
  90. package/lib/exchange/swap/initSwap.js.map +1 -1
  91. package/lib/exchange/swap/types.d.ts +0 -12
  92. package/lib/exchange/swap/types.d.ts.map +1 -1
  93. package/lib/exchange/swap/utils/index.d.ts +6 -1
  94. package/lib/exchange/swap/utils/index.d.ts.map +1 -1
  95. package/lib/exchange/swap/utils/index.js +8 -1
  96. package/lib/exchange/swap/utils/index.js.map +1 -1
  97. package/lib/exchange/swap/utils/index.test.js +27 -0
  98. package/lib/exchange/swap/utils/index.test.js.map +1 -1
  99. package/lib/exchange/testCurrencyConfig/data/coins.d.ts +8 -0
  100. package/lib/exchange/testCurrencyConfig/data/coins.d.ts.map +1 -0
  101. package/lib/exchange/testCurrencyConfig/data/coins.js +21 -0
  102. package/lib/exchange/testCurrencyConfig/data/coins.js.map +1 -0
  103. package/lib/exchange/testCurrencyConfig/index.d.ts +8 -0
  104. package/lib/exchange/testCurrencyConfig/index.d.ts.map +1 -0
  105. package/lib/exchange/testCurrencyConfig/index.js +68 -0
  106. package/lib/exchange/testCurrencyConfig/index.js.map +1 -0
  107. package/lib/families/algorand/api/algodv2.d.ts +2 -1
  108. package/lib/families/algorand/api/algodv2.d.ts.map +1 -1
  109. package/lib/families/algorand/api/algodv2.js +2 -2
  110. package/lib/families/algorand/api/algodv2.js.map +1 -1
  111. package/lib/families/algorand/js-broadcast.js +1 -1
  112. package/lib/families/algorand/js-broadcast.js.map +1 -1
  113. package/lib/families/algorand/js-signOperation.d.ts.map +1 -1
  114. package/lib/families/algorand/js-signOperation.js +1 -1
  115. package/lib/families/algorand/js-signOperation.js.map +1 -1
  116. package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
  117. package/lib/families/bitcoin/wallet-btc/wallet.js +8 -2
  118. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  119. package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js +1 -1
  120. package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js.map +1 -1
  121. package/lib/families/ethereum/nft.integration.test.js +1 -36
  122. package/lib/families/ethereum/nft.integration.test.js.map +1 -1
  123. package/lib/families/ethereum/specs.d.ts.map +1 -1
  124. package/lib/families/ethereum/specs.js +2 -0
  125. package/lib/families/ethereum/specs.js.map +1 -1
  126. package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
  127. package/lib/families/ethereum/synchronisation.js +2 -7
  128. package/lib/families/ethereum/synchronisation.js.map +1 -1
  129. package/lib/families/solana/api/chain/index.d.ts +2 -2
  130. package/lib/families/solana/api/chain/index.d.ts.map +1 -1
  131. package/lib/families/solana/api/chain/index.js +4 -4
  132. package/lib/families/solana/api/chain/index.js.map +1 -1
  133. package/lib/families/solana/bridge/bridge.js +5 -5
  134. package/lib/families/solana/bridge/bridge.js.map +1 -1
  135. package/lib/families/solana/bridge/js.js +3 -3
  136. package/lib/families/solana/bridge/js.js.map +1 -1
  137. package/lib/families/solana/bridge/mock.js +1 -1
  138. package/lib/families/solana/bridge/mock.js.map +1 -1
  139. package/lib/families/solana/utils.d.ts +1 -2
  140. package/lib/families/solana/utils.d.ts.map +1 -1
  141. package/lib/families/solana/utils.js +11 -9
  142. package/lib/families/solana/utils.js.map +1 -1
  143. package/lib/families/tezos/datasets/tezos.scanAccounts.1.js +1 -1
  144. package/lib/families/tezos/datasets/tezos.scanAccounts.1.js.map +1 -1
  145. package/lib/hw/actions/app.d.ts +3 -0
  146. package/lib/hw/actions/app.d.ts.map +1 -1
  147. package/lib/hw/actions/app.js +7 -1
  148. package/lib/hw/actions/app.js.map +1 -1
  149. package/lib/hw/actions/completeExchange.d.ts +1 -0
  150. package/lib/hw/actions/completeExchange.d.ts.map +1 -1
  151. package/lib/hw/actions/completeExchange.js +4 -3
  152. package/lib/hw/actions/completeExchange.js.map +1 -1
  153. package/lib/hw/connectApp.d.ts +5 -0
  154. package/lib/hw/connectApp.d.ts.map +1 -1
  155. package/lib/hw/connectApp.js +37 -26
  156. package/lib/hw/connectApp.js.map +1 -1
  157. package/lib/market/MarketDataProvider.d.ts +26 -0
  158. package/lib/market/MarketDataProvider.d.ts.map +1 -0
  159. package/lib/market/MarketDataProvider.js +339 -0
  160. package/lib/market/MarketDataProvider.js.map +1 -0
  161. package/lib/market/api/api.d.ts +15 -0
  162. package/lib/market/api/api.d.ts.map +1 -0
  163. package/lib/market/api/api.js +261 -0
  164. package/lib/market/api/api.js.map +1 -0
  165. package/lib/market/api/api.mock.d.ts +15 -0
  166. package/lib/market/api/api.mock.d.ts.map +1 -0
  167. package/lib/market/api/api.mock.js +454 -0
  168. package/lib/market/api/api.mock.js.map +1 -0
  169. package/lib/market/types.d.ts +83 -0
  170. package/lib/market/types.d.ts.map +1 -0
  171. package/lib/market/types.js +3 -0
  172. package/lib/market/types.js.map +1 -0
  173. package/lib/market/utils/countervalueFormatter.d.ts +8 -0
  174. package/lib/market/utils/countervalueFormatter.d.ts.map +1 -0
  175. package/lib/market/utils/countervalueFormatter.js +18 -0
  176. package/lib/market/utils/countervalueFormatter.js.map +1 -0
  177. package/lib/market/utils/rangeDataTable.d.ts +10 -0
  178. package/lib/market/utils/rangeDataTable.d.ts.map +1 -0
  179. package/lib/market/utils/rangeDataTable.js +36 -0
  180. package/lib/market/utils/rangeDataTable.js.map +1 -0
  181. package/lib/nft/support.d.ts.map +1 -1
  182. package/lib/nft/support.js +1 -1
  183. package/lib/nft/support.js.map +1 -1
  184. package/lib/platform/PlatformAppProvider/api/api.mock.d.ts.map +1 -1
  185. package/lib/platform/PlatformAppProvider/api/api.mock.js +27 -0
  186. package/lib/platform/PlatformAppProvider/api/api.mock.js.map +1 -1
  187. package/lib/types/manager.d.ts +7 -0
  188. package/lib/types/manager.d.ts.map +1 -1
  189. package/lib/types/manager.js +7 -0
  190. package/lib/types/manager.js.map +1 -1
  191. package/package.json +17 -17
  192. package/src/.DS_Store +0 -0
  193. package/src/__tests__/__snapshots__/all.libcore.ts.snap +221 -212
  194. package/src/__tests__/currencies.ts +1 -1
  195. package/src/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.ts +26 -25
  196. package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +2 -0
  197. package/src/__tests__/test-helpers/bridge.ts +1 -1
  198. package/src/apps/hw.ts +7 -0
  199. package/src/apps/support.ts +1 -0
  200. package/src/bridge/jsHelpers.ts +1 -1
  201. package/src/data/flags/.DS_Store +0 -0
  202. package/src/data/icons/react/index.tsx +1 -0
  203. package/src/data/icons/react/sol.tsx +1 -1
  204. package/src/data/icons/react/tyc.tsx +12 -0
  205. package/src/data/icons/reactNative/index.tsx +1 -0
  206. package/src/data/icons/reactNative/sol.tsx +1 -1
  207. package/src/data/icons/reactNative/tyc.tsx +13 -0
  208. package/src/data/icons/svg/SOL.svg +8 -1
  209. package/src/data/icons/svg/TYC.svg +6 -0
  210. package/src/env.ts +16 -2
  211. package/src/exchange/hw-app-exchange/Exchange.ts +22 -18
  212. package/src/exchange/index.ts +19 -1
  213. package/src/exchange/platform/completeExchange.ts +42 -0
  214. package/src/exchange/platform/serialization.ts +78 -0
  215. package/src/exchange/{swap → platform}/startExchange.ts +6 -2
  216. package/src/exchange/platform/transfer/completeExchange.ts +187 -0
  217. package/src/exchange/platform/transfer/index.ts +66 -0
  218. package/src/exchange/platform/types.ts +76 -0
  219. package/src/exchange/sell/checkSignatureAndPrepare.ts +2 -2
  220. package/src/exchange/sell/getTransactionId.ts +2 -2
  221. package/src/exchange/sell/index.ts +1 -1
  222. package/src/exchange/swap/completeExchange.ts +41 -50
  223. package/src/exchange/swap/hooks/usePickDefaultAccount.ts +4 -9
  224. package/src/exchange/swap/initSwap.ts +4 -7
  225. package/src/exchange/swap/types.ts +1 -14
  226. package/src/exchange/swap/utils/index.test.ts +44 -1
  227. package/src/exchange/swap/utils/index.ts +12 -1
  228. package/src/exchange/testCurrencyConfig/data/coins.ts +20 -0
  229. package/src/exchange/testCurrencyConfig/index.ts +24 -0
  230. package/src/families/algorand/api/algodv2.ts +2 -2
  231. package/src/families/algorand/js-broadcast.ts +1 -1
  232. package/src/families/algorand/js-signOperation.ts +8 -3
  233. package/src/families/bitcoin/wallet-btc/wallet.ts +6 -2
  234. package/src/families/ethereum/datasets/ethereum.scanAccounts.1.ts +43 -43
  235. package/src/families/ethereum/nft.integration.test.ts +1 -18
  236. package/src/families/ethereum/specs.ts +2 -0
  237. package/src/families/ethereum/synchronisation.ts +1 -6
  238. package/src/families/solana/api/chain/index.ts +8 -7
  239. package/src/families/solana/bridge/bridge.ts +11 -11
  240. package/src/families/solana/bridge/js.ts +3 -3
  241. package/src/families/solana/bridge/mock.ts +1 -1
  242. package/src/families/solana/utils.ts +9 -8
  243. package/src/families/tezos/datasets/tezos.scanAccounts.1.ts +39 -39
  244. package/src/hw/actions/app.ts +17 -1
  245. package/src/hw/actions/completeExchange.ts +9 -3
  246. package/src/hw/connectApp.ts +53 -31
  247. package/src/market/MarketDataProvider.tsx +440 -0
  248. package/src/market/api/api.mock.ts +374 -0
  249. package/src/market/api/api.ts +227 -0
  250. package/src/market/types.ts +92 -0
  251. package/src/market/utils/countervalueFormatter.ts +24 -0
  252. package/src/market/utils/rangeDataTable.ts +40 -0
  253. package/src/nft/support.ts +1 -3
  254. package/src/platform/PlatformAppProvider/api/api.mock.ts +27 -0
  255. package/src/types/manager.ts +7 -0
  256. package/lib/exchange/swap/startExchange.d.ts.map +0 -1
  257. package/lib/exchange/swap/startExchange.js.map +0 -1
  258. package/lib/families/ethereum/versions.d.ts +0 -2
  259. package/lib/families/ethereum/versions.d.ts.map +0 -1
  260. package/lib/families/ethereum/versions.js +0 -5
  261. package/lib/families/ethereum/versions.js.map +0 -1
  262. package/src/families/ethereum/versions.ts +0 -1
@@ -66,7 +66,7 @@ test("sort by marketcap", () => {
66
66
  "ethereum",
67
67
  "ethereum/erc20/0x_project",
68
68
  "ethereum/erc20/holotoken",
69
- "ethereum/erc20/xstable.protocol",
69
+ "ethereum/erc20/xstable_protocol",
70
70
  "ethereum/erc20/hydro_protocol",
71
71
  "ethereum/erc20/xensor",
72
72
  "polygon/erc20/holotoken",
@@ -7,21 +7,21 @@ import { zipObject } from "lodash";
7
7
  import { DerivationModes } from "../../../../families/bitcoin/wallet-btc/types";
8
8
  import BitcoinLikeStorage from "../../../../families/bitcoin/wallet-btc/storage";
9
9
  import BitcoinLikeExplorer from "../../../../families/bitcoin/wallet-btc/explorer";
10
- import Crypto from "../../../../families/bitcoin/wallet-btc/crypto/bitcoin";
10
+ import Crypto from "../../../../families/bitcoin/wallet-btc/crypto/bitcoincash";
11
11
  import Xpub from "../../../../families/bitcoin/wallet-btc/xpub";
12
12
 
13
13
  describe("synced xpub utilites functions", () => {
14
14
  const explorer = new BitcoinLikeExplorer({
15
- explorerURI: "https://explorers.api.vault.ledger.com/blockchain/v3/btc",
15
+ explorerURI: "https://explorers.api.vault.ledger.com/blockchain/v3/bch",
16
16
  explorerVersion: "v3",
17
17
  });
18
18
  const crypto = new Crypto({
19
- network: coininfo.bitcoin.main.toBitcoinJS(),
19
+ network: coininfo.bitcoincash.main.toBitcoinJS(),
20
20
  });
21
21
 
22
- describe("xpub xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz Legacy", () => {
22
+ describe("xpub xpub6BvNdfGcyMB9Usq88ibXUt3KhbaEJVLFMbhTSNNfTm8Qf1sX9inTv3xL6pA6KofW4WF9GpdxwGDoYRwRDjHEir3Av23m2wHb7AqhxJ9ohE8 Legacy", () => {
23
23
  const xpubraw =
24
- "xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz";
24
+ "xpub6BvNdfGcyMB9Usq88ibXUt3KhbaEJVLFMbhTSNNfTm8Qf1sX9inTv3xL6pA6KofW4WF9GpdxwGDoYRwRDjHEir3Av23m2wHb7AqhxJ9ohE8";
25
25
  // const truthDump = path.join(__dirname, 'data', 'sync', `${xpubraw}.json`);
26
26
  const storage = new BitcoinLikeStorage();
27
27
  const xpub = new Xpub({
@@ -34,16 +34,16 @@ describe("synced xpub utilites functions", () => {
34
34
 
35
35
  beforeAll(async () => {
36
36
  await xpub.sync();
37
- }, 30000);
37
+ }, 120000);
38
38
 
39
39
  it("should compute accounts/addresses/balances correctly", async () => {
40
40
  const addresses = await xpub.getXpubAddresses();
41
- expect(addresses.length).toEqual(15);
41
+ expect(addresses.length).toEqual(16);
42
42
 
43
- expect((await xpub.getAccountAddresses(0)).length).toEqual(15);
43
+ expect((await xpub.getAccountAddresses(0)).length).toEqual(7);
44
44
 
45
- expect((await xpub.getXpubBalance()).toNumber()).toEqual(12688908);
46
- expect((await xpub.getAccountBalance(0)).toNumber()).toEqual(12688908);
45
+ expect((await xpub.getXpubBalance()).toNumber()).toEqual(360615);
46
+ expect((await xpub.getAccountBalance(0)).toNumber()).toEqual(10000);
47
47
  const addressesBalances = await Promise.all(
48
48
  addresses.map((address) => xpub.getAddressBalance(address))
49
49
  );
@@ -53,21 +53,22 @@ describe("synced xpub utilites functions", () => {
53
53
  addressesBalances.map((balance) => balance.toNumber())
54
54
  )
55
55
  ).toEqual({
56
- "12iNxzdF6KFZ14UyRTYCRuptxkKSSVHzqF": 0,
57
- "15NvG6YpVh2aUc3DroVttEcWa1Z99qhACP": 1000,
58
- "15xANZb5vJv5RGL263NFuh8UGgHT7noXeZ": 100000,
59
- "1687EJf5YEmeEtcscnuJPiV5b8HkM1o98q": 40160,
60
- "16HH35ASv5rL8ZaaqdzvrJKTAKTucdKKNP": 656,
61
- "16ZBYSHkLkRFHAuZvyzosXYgU1UDJxRV1R": 100000,
62
- "1Ahipz531XtbzGC1bEKbhHZXmyfWKPNy32": 1000,
63
- "1CcEugXu9Yf9Qw5cpB8gHUK4X9683WyghM": 8747,
64
- "1EHeVKfjjq6FJpix86G2yzFeRbZ6RNg2Zm": 100000,
65
- "1EfgV2Hr5CDjXPavHDpDMjmU33BA2veHy6": 10665,
66
- "1HqsYkwczwvkMXCobk5WPZmhj2S2TK613Z": 40161,
67
- "1KhVznhEQHumfmMQWnkgXLT4BmvtNpwLN9": 12183719,
68
- "1LDPJCMZhYZjTvTGYahdhMXLuMfjfi6Kua": 1000,
69
- "1MS6eGqD4iUGyJPbEsjqmoNaRhApgtmF8J": 1800,
70
- "1PJMBXKBYEBMRDmpAoBRbDff26gHJrawSp": 100000,
56
+ "bitcoincash:qp2ujnlxjmkwtc299zwat3vt7j0jgltwls3q5avzsj": 0,
57
+ "bitcoincash:qp62d8j6ng0jhenc97dnnyn6qev24vykev5pea7jd3": 0,
58
+ "bitcoincash:qp64rlh8jf82kxsvh2rhjr8wnltt3vu5ccna7zygun": 0,
59
+ "bitcoincash:qpguw9mwet4aamye4texdrvje5wj7twhss5agzwzwa": 0,
60
+ "bitcoincash:qpvezzthl2075alur9y53tqsqcm3z8t4rgq6vcalun": 0,
61
+ "bitcoincash:qq3ch5aymjxvlt2q646gxtnrqeq45h269yt7l2yl0k": 350615,
62
+ "bitcoincash:qq6u57s2nc5zuywmwrw9tnkjvvw5rzs40vk6q5jjaz": 10000,
63
+ "bitcoincash:qqk8v7daqpl2fe4qezw5uzhueqxrj9eahvnhz2v39e": 0,
64
+ "bitcoincash:qqu0nek90hahl0sezqz8cf8yc7hmqvgseykqyp3awm": 0,
65
+ "bitcoincash:qqufmrqunkr3avkswhn378fjhwl3ueawag9e3htc49": 0,
66
+ "bitcoincash:qrkmvwx8y4lprh8xzz0fhnrmqpqvpssqnqle8lds8k": 0,
67
+ "bitcoincash:qzadqth7znrc7e5s5p40kadpu4lj9lkahvja522rh2": 0,
68
+ "bitcoincash:qzgah58nthe50jau20y67s4zq9u0xqvxeyqrv2aewk": 0,
69
+ "bitcoincash:qzj2q6yrxmxedffsz2rvpy067pcdvwhy9gcyhsne48": 0,
70
+ "bitcoincash:qzjgtadhd6j96a9mvlt5cj2ewgljyjzrlq4nplva5l": 0,
71
+ "bitcoincash:qzmwszdjh6h9crvk65zlravhal50rnwtfu6pacsdsn": 0,
71
72
  });
72
73
  });
73
74
  });
@@ -62,6 +62,7 @@ describe("xpub integration sync", () => {
62
62
  coin: "dgb",
63
63
  explorerVersion: "v3",
64
64
  },
65
+ /*
65
66
  {
66
67
  xpub: "xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz", // 3000ms
67
68
  derivationMode: DerivationModes.LEGACY,
@@ -71,6 +72,7 @@ describe("xpub integration sync", () => {
71
72
  coin: "btc",
72
73
  explorerVersion: "v3",
73
74
  },
75
+ */
74
76
  {
75
77
  xpub: "xpub6D4waFVPfPCpRvPkQd9A6n65z3hTp6TvkjnBHG5j2MCKytMuadKgfTUHqwRH77GQqCKTTsUXSZzGYxMGpWpJBdYAYVH75x7yMnwJvra1BUJ", // 5400ms
76
78
  derivationMode: DerivationModes.LEGACY,
@@ -478,7 +478,7 @@ export function testBridge<T extends Transaction>(
478
478
 
479
479
  // existing ops are keeping refs
480
480
  synced.operations.slice(count).forEach((op, i) => {
481
- expect(op).toBe(operations[i]);
481
+ expect(op).toStrictEqual(operations[i]);
482
482
  });
483
483
  }
484
484
  );
package/src/apps/hw.ts CHANGED
@@ -5,6 +5,7 @@ import { concat, of, EMPTY, from, Observable, throwError, defer } from "rxjs";
5
5
  import { mergeMap, map } from "rxjs/operators";
6
6
  import type { Exec, AppOp, ListAppsEvent, ListAppsResult } from "./types";
7
7
  import type { App, DeviceInfo } from "../types/manager";
8
+ import { AppType } from "../types/manager";
8
9
  import manager, { getProviderId } from "../manager";
9
10
  import installApp from "../hw/installApp";
10
11
  import uninstallApp from "../hw/uninstallApp";
@@ -313,6 +314,11 @@ export const listApps = (
313
314
  }
314
315
  }
315
316
 
317
+ const type =
318
+ application.description === AppType.PLUGIN
319
+ ? AppType.PLUGIN
320
+ : AppType.APP;
321
+
316
322
  const app: App = polyfillApp({
317
323
  id: version.id,
318
324
  name: version.name,
@@ -320,6 +326,7 @@ export const listApps = (
320
326
  version: version.version,
321
327
  currencyId,
322
328
  description: version.description,
329
+ type,
323
330
  dateModified: version.date_last_modified,
324
331
  icon: version.icon,
325
332
  authorName: application.authorName,
@@ -31,6 +31,7 @@ const appVersionsRequired = {
31
31
  Algorand: ">= 1.2.9",
32
32
  Polkadot: ">= 9.9140.0",
33
33
  Elrond: ">= 1.0.11",
34
+ Ethereum: ">= 1.9.17",
34
35
  };
35
36
  export function mustUpgrade(
36
37
  deviceModel: DeviceModelId,
@@ -100,7 +100,7 @@ Operation[] {
100
100
  // return existins when there is no real new operations
101
101
  if (newOps.length === 0) return existing;
102
102
  // edge case, existing can be empty. return the sorted list.
103
- if (existing.length === 0) return newOps;
103
+ if (existing.length === 0) return Object.values(newOpsIds);
104
104
  // building up merging the ops
105
105
  const all: Operation[] = [];
106
106
 
Binary file
@@ -383,6 +383,7 @@ export { default as trig } from "./trig";
383
383
  export { default as trtl } from "./trtl";
384
384
  export { default as trx } from "./trx";
385
385
  export { default as tusd } from "./tusd";
386
+ export { default as tyc } from "./tyc";
386
387
  export { default as tzc } from "./tzc";
387
388
  export { default as ubq } from "./ubq";
388
389
  export { default as uma } from "./uma";
@@ -6,7 +6,7 @@ interface Props {
6
6
  };
7
7
 
8
8
  function sol({size, color = "currentColor"}: Props) {
9
- return <svg width={size} height={size} viewBox="0 0 24 24"><path d="M2.41,7.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,7.1A.4.4,0,0,0,2.41,7.77Z" /><path d="M2.41,20.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,20.1A.4.4,0,0,0,2.41,20.77Z" /><path d="M21.59,14.27H5.91a.51.51,0,0,1-.37-.16L2.11,10.44a.4.4,0,0,1,.3-.67H18.09a.51.51,0,0,1,.37.16l3.43,3.67A.4.4,0,0,1,21.59,14.27Z" /></svg>;
9
+ return <svg width={size} height={size} viewBox="0 0 24 24"><path fill={color} d="M2.41,7.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,7.1A.4.4,0,0,0,2.41,7.77Z" /><path fill={color} d="M2.41,20.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,20.1A.4.4,0,0,0,2.41,20.77Z" /><path fill={color} d="M21.59,14.27H5.91a.51.51,0,0,1-.37-.16L2.11,10.44a.4.4,0,0,1,.3-.67H18.09a.51.51,0,0,1,.37.16l3.43,3.67A.4.4,0,0,1,21.59,14.27Z" /></svg>;
10
10
  }
11
11
 
12
12
  export default sol;
@@ -0,0 +1,12 @@
1
+
2
+ import * as React from "react";
3
+ interface Props {
4
+ size: number;
5
+ color?: string;
6
+ };
7
+
8
+ function tyc({size, color = "currentColor"}: Props) {
9
+ return <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 12.1L15.7 10.7L15.9 10.6L16.7 9.1L13.9 10.2L12 11L8.7 9.7L7.3 9.1L8.1 10.6L8.2 10.7L12 12.1Z" fill={color} /><path d="M12 9.2L6.1 6.9L6.9 8.3L12 10.3L17.1 8.3L17.9 6.9L12 9.2Z" fill={color} /><path d="M12.3 17.1L13.1 16.8L13.9 12L12.3 12.7V17.1Z" fill={color} /><path d="M10.9 16.8L11.7 17.1V12.7L10.1 12L10.9 16.8Z" fill={color} /></svg>;
10
+ }
11
+
12
+ export default tyc;
@@ -383,6 +383,7 @@ export { default as trig } from "./trig";
383
383
  export { default as trtl } from "./trtl";
384
384
  export { default as trx } from "./trx";
385
385
  export { default as tusd } from "./tusd";
386
+ export { default as tyc } from "./tyc";
386
387
  export { default as tzc } from "./tzc";
387
388
  export { default as ubq } from "./ubq";
388
389
  export { default as uma } from "./uma";
@@ -7,7 +7,7 @@ interface Props {
7
7
  };
8
8
 
9
9
  function sol({ size, color }: Props) {
10
- return <Svg width={size} height={size} viewBox="0 0 24 24"><Path d="M2.41,7.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,7.1A.4.4,0,0,0,2.41,7.77Z" /><Path d="M2.41,20.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,20.1A.4.4,0,0,0,2.41,20.77Z" /><Path d="M21.59,14.27H5.91a.51.51,0,0,1-.37-.16L2.11,10.44a.4.4,0,0,1,.3-.67H18.09a.51.51,0,0,1,.37.16l3.43,3.67A.4.4,0,0,1,21.59,14.27Z" /></Svg>;
10
+ return <Svg width={size} height={size} viewBox="0 0 24 24"><Path fill={color} d="M2.41,7.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,7.1A.4.4,0,0,0,2.41,7.77Z" /><Path fill={color} d="M2.41,20.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,20.1A.4.4,0,0,0,2.41,20.77Z" /><Path fill={color} d="M21.59,14.27H5.91a.51.51,0,0,1-.37-.16L2.11,10.44a.4.4,0,0,1,.3-.67H18.09a.51.51,0,0,1,.37.16l3.43,3.67A.4.4,0,0,1,21.59,14.27Z" /></Svg>;
11
11
  }
12
12
 
13
13
  export default sol;
@@ -0,0 +1,13 @@
1
+
2
+ import * as React from "react";
3
+ import Svg, { Path } from "react-native-svg";
4
+ interface Props {
5
+ size: number;
6
+ color: string;
7
+ };
8
+
9
+ function tyc({ size, color }: Props) {
10
+ return <Svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><Path d="M12 12.1L15.7 10.7L15.9 10.6L16.7 9.1L13.9 10.2L12 11L8.7 9.7L7.3 9.1L8.1 10.6L8.2 10.7L12 12.1Z" fill={color} /><Path d="M12 9.2L6.1 6.9L6.9 8.3L12 10.3L17.1 8.3L17.9 6.9L12 9.2Z" fill={color} /><Path d="M12.3 17.1L13.1 16.8L13.9 12L12.3 12.7V17.1Z" fill={color} /><Path d="M10.9 16.8L11.7 17.1V12.7L10.1 12L10.9 16.8Z" fill={color} /></Svg>;
11
+ }
12
+
13
+ export default tyc;
@@ -1 +1,8 @@
1
- <svg width="24" height="24" viewBox="0 0 24 24"><path d="M2.41,7.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,7.1A.4.4,0,0,0,2.41,7.77Z"/><path d="M2.41,20.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,20.1A.4.4,0,0,0,2.41,20.77Z"/><path d="M21.59,14.27H5.91a.51.51,0,0,1-.37-.16L2.11,10.44a.4.4,0,0,1,.3-.67H18.09a.51.51,0,0,1,.37.16l3.43,3.67A.4.4,0,0,1,21.59,14.27Z"/></svg>
1
+ <svg width="24" height="24" viewBox="0 0 24 24">
2
+ <path fill="#000000"
3
+ d="M2.41,7.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,7.1A.4.4,0,0,0,2.41,7.77Z" />
4
+ <path fill="#000000"
5
+ d="M2.41,20.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,20.1A.4.4,0,0,0,2.41,20.77Z" />
6
+ <path fill="#000000"
7
+ d="M21.59,14.27H5.91a.51.51,0,0,1-.37-.16L2.11,10.44a.4.4,0,0,1,.3-.67H18.09a.51.51,0,0,1,.37.16l3.43,3.67A.4.4,0,0,1,21.59,14.27Z" />
8
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M12 12.1L15.7 10.7L15.9 10.6L16.7 9.1L13.9 10.2L12 11L8.7 9.7L7.3 9.1L8.1 10.6L8.2 10.7L12 12.1Z" fill="#005B9F"/>
3
+ <path d="M12 9.2L6.1 6.9L6.9 8.3L12 10.3L17.1 8.3L17.9 6.9L12 9.2Z" fill="#005B9F"/>
4
+ <path d="M12.3 17.1L13.1 16.8L13.9 12L12.3 12.7V17.1Z" fill="#005B9F"/>
5
+ <path d="M10.9 16.8L11.7 17.1V12.7L10.1 12L10.9 16.8Z" fill="#005B9F"/>
6
+ </svg>
package/src/env.ts CHANGED
@@ -120,6 +120,11 @@ const envDefinitions = {
120
120
  def: "https://tron.coin.ledger.com",
121
121
  desc: "proxy url for trongrid API",
122
122
  },
123
+ API_SOLANA_PROXY: {
124
+ parser: stringParser,
125
+ def: "https://solana.coin.ledger.com",
126
+ desc: "proxy url for solana API",
127
+ },
123
128
  BASE_SOCKET_URL: {
124
129
  def: "wss://scriptrunner.api.live.ledger.com/update",
125
130
  parser: stringParser,
@@ -371,10 +376,14 @@ const envDefinitions = {
371
376
  parser: stringParser,
372
377
  desc: "mock the server response for the exchange KYC check, options are 'open', 'pending', 'closed' or 'approved'.",
373
378
  },
374
- NFT: {
379
+ /**
380
+ * Note: the mocked cryptoassets config and test partner are signed with the
381
+ * Ledger test private key
382
+ */
383
+ MOCK_EXCHANGE_TEST_CONFIG: {
375
384
  def: false,
376
385
  parser: boolParser,
377
- desc: "synchronizing nfts",
386
+ desc: "mock the cryptoassets config and test partner (in the context of app-exchange)",
378
387
  },
379
388
  NFT_CURRENCIES: {
380
389
  def: "ethereum",
@@ -531,6 +540,11 @@ const envDefinitions = {
531
540
  parser: intParser,
532
541
  desc: "version used for the platform api",
533
542
  },
543
+ MARKET_API_URL: {
544
+ def: "https://proxycg.api.live.ledger.com/api/v3",
545
+ parser: stringParser,
546
+ desc: "Market data api",
547
+ },
534
548
  };
535
549
 
536
550
  const getDefinition = (name: string): EnvDef<any> | null | undefined =>
@@ -2,17 +2,18 @@ import Transport from "@ledgerhq/hw-transport";
2
2
  import { BigNumber } from "bignumber.js";
3
3
  import { TransportStatusError } from "@ledgerhq/errors";
4
4
  import invariant from "invariant";
5
- export const TRANSACTION_RATES = {
6
- FIXED: 0x00,
7
- FLOATING: 0x01,
8
- };
9
- export const TRANSACTION_TYPES = {
10
- SWAP: 0x00,
11
- SELL: 0x01,
12
- FUND: 0x02,
13
- };
14
- type TransactionRate = typeof TRANSACTION_RATES[keyof typeof TRANSACTION_RATES];
15
- type TransactionType = typeof TRANSACTION_TYPES[keyof typeof TRANSACTION_TYPES];
5
+
6
+ export const enum RateTypes {
7
+ Fixed = 0x00,
8
+ Floating = 0x01,
9
+ }
10
+
11
+ export const enum ExchangeTypes {
12
+ Swap = 0x00,
13
+ Sell = 0x01,
14
+ Fund = 0x02,
15
+ }
16
+
16
17
  const START_NEW_TRANSACTION_COMMAND = 0x03;
17
18
  const SET_PARTNER_KEY_COMMAND = 0x04;
18
19
  const CHECK_PARTNER_COMMAND = 0x05;
@@ -34,8 +35,8 @@ const maybeThrowProtocolError = (result: Buffer): void => {
34
35
 
35
36
  export default class Exchange {
36
37
  transport: Transport;
37
- transactionType: TransactionType;
38
- transactionRate: TransactionRate;
38
+ transactionType: ExchangeTypes;
39
+ transactionRate: RateTypes;
39
40
  allowedStatuses: Array<number> = [
40
41
  0x9000, 0x6a80, 0x6a81, 0x6a82, 0x6a83, 0x6a84, 0x6a85, 0x6e00, 0x6d00,
41
42
  0x9d1a,
@@ -43,11 +44,11 @@ export default class Exchange {
43
44
 
44
45
  constructor(
45
46
  transport: Transport,
46
- transactionType: TransactionType,
47
- transactionRate?: TransactionRate
47
+ transactionType: ExchangeTypes,
48
+ transactionRate?: RateTypes
48
49
  ) {
49
50
  this.transactionType = transactionType;
50
- this.transactionRate = transactionRate || TRANSACTION_RATES.FIXED;
51
+ this.transactionRate = transactionRate || RateTypes.Fixed;
51
52
  this.transport = transport;
52
53
  }
53
54
 
@@ -62,7 +63,10 @@ export default class Exchange {
62
63
  );
63
64
  maybeThrowProtocolError(result);
64
65
 
65
- if (this.transactionType === TRANSACTION_TYPES.SELL) {
66
+ if (
67
+ this.transactionType === ExchangeTypes.Sell ||
68
+ this.transactionType === ExchangeTypes.Fund
69
+ ) {
66
70
  return result.subarray(0, 32).toString("base64");
67
71
  }
68
72
 
@@ -147,7 +151,7 @@ export default class Exchange {
147
151
  ]);
148
152
  const result: Buffer = await this.transport.send(
149
153
  0xe0,
150
- this.transactionType === TRANSACTION_TYPES.SWAP
154
+ this.transactionType === ExchangeTypes.Swap
151
155
  ? CHECK_PAYOUT_ADDRESS
152
156
  : CHECK_ASSET_IN,
153
157
  this.transactionRate,
@@ -1,6 +1,8 @@
1
1
  import { valid, gte } from "semver";
2
2
  import type { CryptoCurrency, TokenCurrency } from "../types/currencies";
3
- import { findExchangeCurrencyConfig } from "@ledgerhq/cryptoassets";
3
+ import { findExchangeCurrencyConfig as findProdExchangeCurrencyConfig } from "@ledgerhq/cryptoassets";
4
+ import { getEnv } from "../env";
5
+ import { findTestExchangeCurrencyConfig } from "./testCurrencyConfig";
4
6
  // Minimum version of a currency app which has exchange capabilities, meaning it can be used
5
7
  // for sell/swap, and do silent signing.
6
8
  const exchangeSupportAppVersions = {
@@ -20,6 +22,22 @@ const exchangeSupportAppVersions = {
20
22
  zcash: "1.5.0",
21
23
  zencash: "1.5.0",
22
24
  };
25
+
26
+ const findExchangeCurrencyConfig = (
27
+ id: string
28
+ ):
29
+ | {
30
+ config: string;
31
+
32
+ signature: string;
33
+ }
34
+ | null
35
+ | undefined => {
36
+ return getEnv("MOCK_EXCHANGE_TEST_CONFIG")
37
+ ? findTestExchangeCurrencyConfig(id)
38
+ : findProdExchangeCurrencyConfig(id);
39
+ };
40
+
23
41
  export type ExchangeCurrencyNameAndSignature = {
24
42
  config: Buffer;
25
43
  signature: Buffer;
@@ -0,0 +1,42 @@
1
+ import { Observable } from "rxjs";
2
+
3
+ import type {
4
+ CompleteExchangeInputFund,
5
+ CompleteExchangeInputSell,
6
+ CompleteExchangeInputSwap,
7
+ CompleteExchangeRequestEvent,
8
+ } from "./types";
9
+
10
+ import completeExchangeSwap from "../swap/completeExchange";
11
+ import completeExchangeTransfer from "./transfer/completeExchange";
12
+
13
+ import { ExchangeTypes } from "../hw-app-exchange/Exchange";
14
+
15
+ type CompleteExchangeInput =
16
+ | CompleteExchangeInputSell
17
+ | CompleteExchangeInputSwap
18
+ | CompleteExchangeInputFund;
19
+
20
+ const completeExchange = (
21
+ input: CompleteExchangeInput
22
+ ): Observable<CompleteExchangeRequestEvent> => {
23
+ switch (input.exchangeType) {
24
+ case ExchangeTypes.Swap:
25
+ if (!input.exchange.toAccount) {
26
+ throw new Error("'toAccount' requested for Swap exchange");
27
+ }
28
+
29
+ return completeExchangeSwap(input);
30
+
31
+ case ExchangeTypes.Sell:
32
+ return completeExchangeTransfer(input);
33
+
34
+ case ExchangeTypes.Fund:
35
+ return completeExchangeTransfer(input);
36
+
37
+ default:
38
+ throw new Error("exchangeType not handled");
39
+ }
40
+ };
41
+
42
+ export default completeExchange;
@@ -0,0 +1,78 @@
1
+ import type {
2
+ Exchange,
3
+ ExchangeRaw,
4
+ ExchangeSell,
5
+ ExchangeSellRaw,
6
+ ExchangeSwap,
7
+ ExchangeSwapRaw,
8
+ } from "./types";
9
+ import {
10
+ fromAccountLikeRaw,
11
+ fromAccountRaw,
12
+ toAccountLikeRaw,
13
+ toAccountRaw,
14
+ } from "../../account";
15
+
16
+ const isExchangeSwapRaw = (
17
+ exchangeRaw: ExchangeSwapRaw | ExchangeSellRaw
18
+ ): exchangeRaw is ExchangeSwapRaw => {
19
+ return (exchangeRaw as ExchangeSwapRaw).toAccount !== undefined;
20
+ };
21
+
22
+ const isExchangeSwap = (
23
+ exchange: ExchangeSwap | ExchangeSell
24
+ ): exchange is ExchangeSwap => {
25
+ return (exchange as ExchangeSwap).toAccount !== undefined;
26
+ };
27
+
28
+ export const fromExchangeRaw = (exchangeRaw: ExchangeRaw): Exchange => {
29
+ const fromAccount = fromAccountLikeRaw(exchangeRaw.fromAccount);
30
+ const fromParentAccount = exchangeRaw.fromParentAccount
31
+ ? fromAccountRaw(exchangeRaw.fromParentAccount)
32
+ : null;
33
+
34
+ if (!isExchangeSwapRaw(exchangeRaw)) {
35
+ return {
36
+ fromAccount,
37
+ fromParentAccount,
38
+ };
39
+ }
40
+
41
+ const toAccount = fromAccountLikeRaw(exchangeRaw.toAccount);
42
+ const toParentAccount = exchangeRaw.toParentAccount
43
+ ? fromAccountRaw(exchangeRaw.toParentAccount)
44
+ : null;
45
+
46
+ return {
47
+ fromAccount,
48
+ fromParentAccount,
49
+ toAccount,
50
+ toParentAccount,
51
+ };
52
+ };
53
+
54
+ export const toExchangeRaw = (exchange: Exchange): ExchangeRaw => {
55
+ const fromAccount = toAccountLikeRaw(exchange.fromAccount);
56
+ const fromParentAccount = exchange.fromParentAccount
57
+ ? toAccountRaw(exchange.fromParentAccount)
58
+ : null;
59
+
60
+ if (!isExchangeSwap(exchange)) {
61
+ return {
62
+ fromAccount,
63
+ fromParentAccount,
64
+ };
65
+ }
66
+
67
+ const toAccount = toAccountLikeRaw(exchange.toAccount);
68
+ const toParentAccount = exchange.toParentAccount
69
+ ? toAccountRaw(exchange.toParentAccount)
70
+ : null;
71
+
72
+ return {
73
+ fromAccount,
74
+ fromParentAccount,
75
+ toAccount,
76
+ toParentAccount,
77
+ };
78
+ };
@@ -23,8 +23,12 @@ const startExchange = (
23
23
  await withDevicePromise(deviceId, async (transport) => {
24
24
  log("exchange", `attempt to connect to ${deviceId}`);
25
25
  if (unsubscribed) return;
26
- const swap = new Exchange(transport, exchangeType, 0x00); // TODO Pass fixed/float for UI switch ?
27
- const nonce: string = await swap.startNewTransaction();
26
+ /**
27
+ * Note: `transactionRate` is not needed at this stage. It is only used
28
+ * at the `completeExchange` step
29
+ */
30
+ const exchange = new Exchange(transport, exchangeType);
31
+ const nonce: string = await exchange.startNewTransaction();
28
32
  o.next({
29
33
  type: "start-exchange-result",
30
34
  nonce,