@ledgerhq/live-common 21.25.2 → 21.28.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 (253) 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/account/support.d.ts.map +1 -1
  7. package/lib/account/support.js +1 -25
  8. package/lib/account/support.js.map +1 -1
  9. package/lib/api/Ethereum.d.ts.map +1 -1
  10. package/lib/api/Ethereum.js +1 -4
  11. package/lib/api/Ethereum.js.map +1 -1
  12. package/lib/api/explorerConfig/index.d.ts.map +1 -1
  13. package/lib/api/explorerConfig/index.js +0 -4
  14. package/lib/api/explorerConfig/index.js.map +1 -1
  15. package/lib/apps/support.d.ts.map +1 -1
  16. package/lib/apps/support.js +2 -1
  17. package/lib/apps/support.js.map +1 -1
  18. package/lib/bridge/jsHelpers.js +1 -1
  19. package/lib/bridge/jsHelpers.js.map +1 -1
  20. package/lib/data/icons/react/index.d.ts +1 -0
  21. package/lib/data/icons/react/index.d.ts.map +1 -1
  22. package/lib/data/icons/react/index.js +4 -2
  23. package/lib/data/icons/react/index.js.map +1 -1
  24. package/lib/data/icons/react/sol.js +3 -3
  25. package/lib/data/icons/react/sol.js.map +1 -1
  26. package/lib/data/icons/react/tyc.d.ts +8 -0
  27. package/lib/data/icons/react/tyc.d.ts.map +1 -0
  28. package/lib/data/icons/react/tyc.js +33 -0
  29. package/lib/data/icons/react/tyc.js.map +1 -0
  30. package/lib/data/icons/reactNative/index.d.ts +1 -0
  31. package/lib/data/icons/reactNative/index.d.ts.map +1 -1
  32. package/lib/data/icons/reactNative/index.js +4 -2
  33. package/lib/data/icons/reactNative/index.js.map +1 -1
  34. package/lib/data/icons/reactNative/sol.js +3 -3
  35. package/lib/data/icons/reactNative/sol.js.map +1 -1
  36. package/lib/data/icons/reactNative/tyc.d.ts +8 -0
  37. package/lib/data/icons/reactNative/tyc.d.ts.map +1 -0
  38. package/lib/data/icons/reactNative/tyc.js +34 -0
  39. package/lib/data/icons/reactNative/tyc.js.map +1 -0
  40. package/lib/env.d.ts +15 -6
  41. package/lib/env.d.ts.map +1 -1
  42. package/lib/env.js +11 -2
  43. package/lib/env.js.map +1 -1
  44. package/lib/env.react.d.ts +1 -1
  45. package/lib/env.react.d.ts.map +1 -1
  46. package/lib/errors.d.ts +3 -0
  47. package/lib/errors.d.ts.map +1 -1
  48. package/lib/errors.js +3 -2
  49. package/lib/errors.js.map +1 -1
  50. package/lib/exchange/hw-app-exchange/Exchange.d.ts +12 -15
  51. package/lib/exchange/hw-app-exchange/Exchange.d.ts.map +1 -1
  52. package/lib/exchange/hw-app-exchange/Exchange.js +4 -13
  53. package/lib/exchange/hw-app-exchange/Exchange.js.map +1 -1
  54. package/lib/exchange/index.d.ts.map +1 -1
  55. package/lib/exchange/index.js +9 -2
  56. package/lib/exchange/index.js.map +1 -1
  57. package/lib/exchange/platform/completeExchange.d.ts +6 -0
  58. package/lib/exchange/platform/completeExchange.d.ts.map +1 -0
  59. package/lib/exchange/platform/completeExchange.js +24 -0
  60. package/lib/exchange/platform/completeExchange.js.map +1 -0
  61. package/lib/exchange/platform/serialization.d.ts +4 -0
  62. package/lib/exchange/platform/serialization.d.ts.map +1 -0
  63. package/lib/exchange/platform/serialization.js +57 -0
  64. package/lib/exchange/platform/serialization.js.map +1 -0
  65. package/lib/exchange/{swap → platform}/startExchange.d.ts +0 -0
  66. package/lib/exchange/platform/startExchange.d.ts.map +1 -0
  67. package/lib/exchange/{swap → platform}/startExchange.js +3 -3
  68. package/lib/exchange/platform/startExchange.js.map +1 -0
  69. package/lib/exchange/platform/transfer/completeExchange.d.ts +5 -0
  70. package/lib/exchange/platform/transfer/completeExchange.d.ts.map +1 -0
  71. package/lib/exchange/platform/transfer/completeExchange.js +198 -0
  72. package/lib/exchange/platform/transfer/completeExchange.js.map +1 -0
  73. package/lib/exchange/platform/transfer/index.d.ts +5 -0
  74. package/lib/exchange/platform/transfer/index.d.ts.map +1 -0
  75. package/lib/exchange/platform/transfer/index.js +49 -0
  76. package/lib/exchange/platform/transfer/index.js.map +1 -0
  77. package/lib/exchange/platform/types.d.ts +59 -0
  78. package/lib/exchange/platform/types.d.ts.map +1 -0
  79. package/lib/exchange/platform/types.js +3 -0
  80. package/lib/exchange/platform/types.js.map +1 -0
  81. package/lib/exchange/sell/checkSignatureAndPrepare.js +1 -2
  82. package/lib/exchange/sell/checkSignatureAndPrepare.js.map +1 -1
  83. package/lib/exchange/sell/getTransactionId.js +1 -2
  84. package/lib/exchange/sell/getTransactionId.js.map +1 -1
  85. package/lib/exchange/sell/index.d.ts +6 -0
  86. package/lib/exchange/sell/index.d.ts.map +1 -1
  87. package/lib/exchange/sell/index.js +3 -3
  88. package/lib/exchange/sell/index.js.map +1 -1
  89. package/lib/exchange/swap/completeExchange.d.ts +2 -13
  90. package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
  91. package/lib/exchange/swap/completeExchange.js +2 -4
  92. package/lib/exchange/swap/completeExchange.js.map +1 -1
  93. package/lib/exchange/swap/initSwap.d.ts.map +1 -1
  94. package/lib/exchange/swap/initSwap.js +3 -4
  95. package/lib/exchange/swap/initSwap.js.map +1 -1
  96. package/lib/exchange/swap/types.d.ts +0 -12
  97. package/lib/exchange/swap/types.d.ts.map +1 -1
  98. package/lib/exchange/testCurrencyConfig/data/coins.d.ts +8 -0
  99. package/lib/exchange/testCurrencyConfig/data/coins.d.ts.map +1 -0
  100. package/lib/exchange/testCurrencyConfig/data/coins.js +21 -0
  101. package/lib/exchange/testCurrencyConfig/data/coins.js.map +1 -0
  102. package/lib/exchange/testCurrencyConfig/index.d.ts +8 -0
  103. package/lib/exchange/testCurrencyConfig/index.d.ts.map +1 -0
  104. package/lib/exchange/testCurrencyConfig/index.js +68 -0
  105. package/lib/exchange/testCurrencyConfig/index.js.map +1 -0
  106. package/lib/families/algorand/api/algodv2.d.ts +2 -1
  107. package/lib/families/algorand/api/algodv2.d.ts.map +1 -1
  108. package/lib/families/algorand/api/algodv2.js +2 -2
  109. package/lib/families/algorand/api/algodv2.js.map +1 -1
  110. package/lib/families/algorand/js-broadcast.js +1 -1
  111. package/lib/families/algorand/js-broadcast.js.map +1 -1
  112. package/lib/families/algorand/js-signOperation.d.ts.map +1 -1
  113. package/lib/families/algorand/js-signOperation.js +1 -1
  114. package/lib/families/algorand/js-signOperation.js.map +1 -1
  115. package/lib/families/bitcoin/test-dataset.js +1 -1
  116. package/lib/families/bitcoin/test-dataset.js.map +1 -1
  117. package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
  118. package/lib/families/bitcoin/wallet-btc/wallet.js +8 -2
  119. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  120. package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js +1 -1
  121. package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js.map +1 -1
  122. package/lib/families/ethereum/modules/send.d.ts.map +1 -1
  123. package/lib/families/ethereum/modules/send.js +3 -1
  124. package/lib/families/ethereum/modules/send.js.map +1 -1
  125. package/lib/families/ethereum/nft.integration.test.js +1 -36
  126. package/lib/families/ethereum/nft.integration.test.js.map +1 -1
  127. package/lib/families/ethereum/specs.d.ts.map +1 -1
  128. package/lib/families/ethereum/specs.js +2 -0
  129. package/lib/families/ethereum/specs.js.map +1 -1
  130. package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
  131. package/lib/families/ethereum/synchronisation.js +2 -7
  132. package/lib/families/ethereum/synchronisation.js.map +1 -1
  133. package/lib/families/tezos/bridge/js.d.ts.map +1 -1
  134. package/lib/families/tezos/bridge/js.js +19 -20
  135. package/lib/families/tezos/bridge/js.js.map +1 -1
  136. package/lib/families/tezos/hw-getAddress.d.ts.map +1 -1
  137. package/lib/families/tezos/hw-getAddress.js +1 -3
  138. package/lib/families/tezos/hw-getAddress.js.map +1 -1
  139. package/lib/families/tezos/synchronisation.d.ts.map +1 -1
  140. package/lib/families/tezos/synchronisation.js +1 -1
  141. package/lib/families/tezos/synchronisation.js.map +1 -1
  142. package/lib/hw/actions/app.d.ts +3 -0
  143. package/lib/hw/actions/app.d.ts.map +1 -1
  144. package/lib/hw/actions/app.js +7 -1
  145. package/lib/hw/actions/app.js.map +1 -1
  146. package/lib/hw/actions/completeExchange.d.ts +1 -0
  147. package/lib/hw/actions/completeExchange.d.ts.map +1 -1
  148. package/lib/hw/actions/completeExchange.js +4 -3
  149. package/lib/hw/actions/completeExchange.js.map +1 -1
  150. package/lib/hw/connectApp.d.ts +5 -0
  151. package/lib/hw/connectApp.d.ts.map +1 -1
  152. package/lib/hw/connectApp.js +37 -26
  153. package/lib/hw/connectApp.js.map +1 -1
  154. package/lib/market/MarketDataProvider.d.ts +26 -0
  155. package/lib/market/MarketDataProvider.d.ts.map +1 -0
  156. package/lib/market/MarketDataProvider.js +339 -0
  157. package/lib/market/MarketDataProvider.js.map +1 -0
  158. package/lib/market/api/api.d.ts +15 -0
  159. package/lib/market/api/api.d.ts.map +1 -0
  160. package/lib/market/api/api.js +261 -0
  161. package/lib/market/api/api.js.map +1 -0
  162. package/lib/market/api/api.mock.d.ts +15 -0
  163. package/lib/market/api/api.mock.d.ts.map +1 -0
  164. package/lib/market/api/api.mock.js +454 -0
  165. package/lib/market/api/api.mock.js.map +1 -0
  166. package/lib/market/types.d.ts +83 -0
  167. package/lib/market/types.d.ts.map +1 -0
  168. package/lib/market/types.js +3 -0
  169. package/lib/market/types.js.map +1 -0
  170. package/lib/market/utils/countervalueFormatter.d.ts +8 -0
  171. package/lib/market/utils/countervalueFormatter.d.ts.map +1 -0
  172. package/lib/market/utils/countervalueFormatter.js +18 -0
  173. package/lib/market/utils/countervalueFormatter.js.map +1 -0
  174. package/lib/market/utils/rangeDataTable.d.ts +10 -0
  175. package/lib/market/utils/rangeDataTable.d.ts.map +1 -0
  176. package/lib/market/utils/rangeDataTable.js +36 -0
  177. package/lib/market/utils/rangeDataTable.js.map +1 -0
  178. package/lib/nft/support.d.ts.map +1 -1
  179. package/lib/nft/support.js +1 -1
  180. package/lib/nft/support.js.map +1 -1
  181. package/lib/platform/PlatformAppProvider/api/api.mock.d.ts.map +1 -1
  182. package/lib/platform/PlatformAppProvider/api/api.mock.js +27 -0
  183. package/lib/platform/PlatformAppProvider/api/api.mock.js.map +1 -1
  184. package/package.json +10 -10
  185. package/src/__tests__/__snapshots__/all.libcore.ts.snap +221 -212
  186. package/src/__tests__/currencies.ts +1 -1
  187. package/src/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.ts +26 -25
  188. package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +2 -0
  189. package/src/account/support.ts +1 -25
  190. package/src/api/Ethereum.ts +1 -4
  191. package/src/api/explorerConfig/index.ts +0 -4
  192. package/src/apps/support.ts +1 -0
  193. package/src/bridge/jsHelpers.ts +1 -1
  194. package/src/data/icons/react/index.tsx +1 -0
  195. package/src/data/icons/react/sol.tsx +1 -1
  196. package/src/data/icons/react/tyc.tsx +12 -0
  197. package/src/data/icons/reactNative/index.tsx +1 -0
  198. package/src/data/icons/reactNative/sol.tsx +1 -1
  199. package/src/data/icons/reactNative/tyc.tsx +13 -0
  200. package/src/data/icons/svg/SOL.svg +8 -1
  201. package/src/data/icons/svg/TYC.svg +6 -0
  202. package/src/env.ts +11 -2
  203. package/src/errors.ts +3 -0
  204. package/src/exchange/hw-app-exchange/Exchange.ts +22 -18
  205. package/src/exchange/index.ts +19 -1
  206. package/src/exchange/platform/completeExchange.ts +42 -0
  207. package/src/exchange/platform/serialization.ts +78 -0
  208. package/src/exchange/{swap → platform}/startExchange.ts +6 -2
  209. package/src/exchange/platform/transfer/completeExchange.ts +187 -0
  210. package/src/exchange/platform/transfer/index.ts +66 -0
  211. package/src/exchange/platform/types.ts +76 -0
  212. package/src/exchange/sell/checkSignatureAndPrepare.ts +2 -2
  213. package/src/exchange/sell/getTransactionId.ts +2 -2
  214. package/src/exchange/sell/index.ts +1 -1
  215. package/src/exchange/swap/completeExchange.ts +41 -50
  216. package/src/exchange/swap/initSwap.ts +4 -7
  217. package/src/exchange/swap/types.ts +1 -14
  218. package/src/exchange/testCurrencyConfig/data/coins.ts +20 -0
  219. package/src/exchange/testCurrencyConfig/index.ts +24 -0
  220. package/src/families/algorand/api/algodv2.ts +2 -2
  221. package/src/families/algorand/js-broadcast.ts +1 -1
  222. package/src/families/algorand/js-signOperation.ts +8 -3
  223. package/src/families/bitcoin/test-dataset.ts +1 -1
  224. package/src/families/bitcoin/wallet-btc/wallet.ts +6 -2
  225. package/src/families/ethereum/datasets/ethereum.scanAccounts.1.ts +43 -43
  226. package/src/families/ethereum/modules/send.ts +3 -0
  227. package/src/families/ethereum/nft.integration.test.ts +1 -18
  228. package/src/families/ethereum/specs.ts +2 -0
  229. package/src/families/ethereum/synchronisation.ts +1 -6
  230. package/src/families/tezos/bridge/js.ts +41 -40
  231. package/src/families/tezos/hw-getAddress.ts +1 -3
  232. package/src/families/tezos/synchronisation.ts +4 -3
  233. package/src/hw/actions/app.ts +17 -1
  234. package/src/hw/actions/completeExchange.ts +9 -3
  235. package/src/hw/connectApp.ts +53 -31
  236. package/src/market/MarketDataProvider.tsx +440 -0
  237. package/src/market/api/api.mock.ts +374 -0
  238. package/src/market/api/api.ts +227 -0
  239. package/src/market/types.ts +92 -0
  240. package/src/market/utils/countervalueFormatter.ts +24 -0
  241. package/src/market/utils/rangeDataTable.ts +40 -0
  242. package/src/nft/support.ts +1 -3
  243. package/src/platform/PlatformAppProvider/api/api.mock.ts +27 -0
  244. package/lib/exchange/swap/startExchange.d.ts.map +0 -1
  245. package/lib/exchange/swap/startExchange.js.map +0 -1
  246. package/lib/families/ethereum/versions.d.ts +0 -2
  247. package/lib/families/ethereum/versions.d.ts.map +0 -1
  248. package/lib/families/ethereum/versions.js +0 -5
  249. package/lib/families/ethereum/versions.js.map +0 -1
  250. package/src/.DS_Store +0 -0
  251. package/src/__tests__/.DS_Store +0 -0
  252. package/src/currencies/__snapshots__/.DS_Store +0 -0
  253. 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
+ }, 60000);
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,
@@ -20,31 +20,7 @@ import { getMainAccount } from "../account";
20
20
  import { getAccountBridge } from "../bridge";
21
21
  import jsBridges from "../generated/bridge/js";
22
22
 
23
- const experimentalIntegrations = [
24
- "algorand",
25
- "bitcoin",
26
- "bsc",
27
- "bitcoin_cash",
28
- "litecoin",
29
- "dash",
30
- "qtum",
31
- "zcash",
32
- "bitcoin_gold",
33
- "stratis",
34
- "dogecoin",
35
- "digibyte",
36
- "komodo",
37
- "pivx",
38
- "zencash",
39
- "vertcoin",
40
- "peercoin",
41
- "viacoin",
42
- "stakenet",
43
- "stealthcoin",
44
- "decred",
45
- "bitcoin_testnet",
46
- "tezos",
47
- ];
23
+ const experimentalIntegrations = ["algorand", "tezos"];
48
24
  export function shouldUseJS(currency: CryptoCurrency) {
49
25
  const jsBridge = jsBridges[currency.family];
50
26
  if (!jsBridge) return false;
@@ -10,7 +10,6 @@ import { blockchainBaseURL } from "./Ledger";
10
10
  import { FeeEstimationFailed } from "../errors";
11
11
  import { makeLRUCache } from "../cache";
12
12
  import { getEnv } from "../env";
13
- import { isNFTActive } from "../nft/support";
14
13
 
15
14
  export type Block = {
16
15
  height: BigNumber;
@@ -133,9 +132,7 @@ export const apiForCurrency = (currency: CryptoCurrency): API => {
133
132
  let { data } = await network({
134
133
  method: "GET",
135
134
  url: URL.format({
136
- pathname: isNFTActive(currency)
137
- ? `https://explorers.api-01.live.ledger-stg.com/blockchain/v3/eth/addresses/${address}/transactions`
138
- : `${baseURL}/addresses/${address}/transactions`,
135
+ pathname: `${baseURL}/addresses/${address}/transactions`,
139
136
  query: {
140
137
  batch_size,
141
138
  noinput: true,
@@ -14,10 +14,6 @@ const initialExplorerConfig: FullConfig = {
14
14
  bitcoin_cash: {
15
15
  id: "bch",
16
16
  stable: {
17
- base: "EXPLORER",
18
- version: "v2",
19
- },
20
- experimental: {
21
17
  base: "EXPLORER",
22
18
  version: "v3",
23
19
  },
@@ -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
 
@@ -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
@@ -371,10 +371,14 @@ const envDefinitions = {
371
371
  parser: stringParser,
372
372
  desc: "mock the server response for the exchange KYC check, options are 'open', 'pending', 'closed' or 'approved'.",
373
373
  },
374
- NFT: {
374
+ /**
375
+ * Note: the mocked cryptoassets config and test partner are signed with the
376
+ * Ledger test private key
377
+ */
378
+ MOCK_EXCHANGE_TEST_CONFIG: {
375
379
  def: false,
376
380
  parser: boolParser,
377
- desc: "synchronizing nfts",
381
+ desc: "mock the cryptoassets config and test partner (in the context of app-exchange)",
378
382
  },
379
383
  NFT_CURRENCIES: {
380
384
  def: "ethereum",
@@ -531,6 +535,11 @@ const envDefinitions = {
531
535
  parser: intParser,
532
536
  desc: "version used for the platform api",
533
537
  },
538
+ MARKET_API_URL: {
539
+ def: "https://proxycg.api.live.ledger.com/api/v3",
540
+ parser: stringParser,
541
+ desc: "Market data api",
542
+ },
534
543
  };
535
544
 
536
545
  const getDefinition = (name: string): EnvDef<any> | null | undefined =>
package/src/errors.ts CHANGED
@@ -23,6 +23,9 @@ export const LowerThanMinimumRelayFee = createCustomErrorClass(
23
23
  export const TransactionRefusedOnDevice = createCustomErrorClass(
24
24
  "TransactionRefusedOnDevice"
25
25
  );
26
+ export const InvalidAddressBecauseAlreadyDelegated = createCustomErrorClass(
27
+ "InvalidAddressBecauseAlreadyDelegated"
28
+ );
26
29
  export const TronNoFrozenForBandwidth = createCustomErrorClass(
27
30
  "TronNoFrozenForBandwidth"
28
31
  );
@@ -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,