@ledgerhq/live-common 27.0.0 → 27.1.0-next.1

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 (565) hide show
  1. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js +2 -2
  2. package/lib/__tests__/test-helpers/environment.d.ts +2 -0
  3. package/lib/__tests__/test-helpers/environment.d.ts.map +1 -0
  4. package/lib/__tests__/test-helpers/environment.js +107 -0
  5. package/lib/__tests__/test-helpers/environment.js.map +1 -0
  6. package/lib/__tests__/test-helpers/setup.d.ts +1 -1
  7. package/lib/__tests__/test-helpers/setup.d.ts.map +1 -1
  8. package/lib/__tests__/test-helpers/setup.js +1 -101
  9. package/lib/__tests__/test-helpers/setup.js.map +1 -1
  10. package/lib/account/serialization.d.ts +2 -0
  11. package/lib/account/serialization.d.ts.map +1 -1
  12. package/lib/account/serialization.js +105 -47
  13. package/lib/account/serialization.js.map +1 -1
  14. package/lib/apps/support.d.ts.map +1 -1
  15. package/lib/apps/support.js +1 -0
  16. package/lib/apps/support.js.map +1 -1
  17. package/lib/bot/bot-test-context.d.ts +3 -0
  18. package/lib/bot/bot-test-context.d.ts.map +1 -0
  19. package/lib/bot/bot-test-context.js +26 -0
  20. package/lib/bot/bot-test-context.js.map +1 -0
  21. package/lib/bot/bot-test-context.test.d.ts +2 -0
  22. package/lib/bot/bot-test-context.test.d.ts.map +1 -0
  23. package/lib/bot/bot-test-context.test.js +41 -0
  24. package/lib/bot/bot-test-context.test.js.map +1 -0
  25. package/lib/bot/cli.d.ts +2 -0
  26. package/lib/bot/cli.d.ts.map +1 -0
  27. package/lib/bot/cli.js +14 -0
  28. package/lib/bot/cli.js.map +1 -0
  29. package/lib/bot/engine.d.ts +5 -5
  30. package/lib/bot/engine.d.ts.map +1 -1
  31. package/lib/bot/engine.js +161 -112
  32. package/lib/bot/engine.js.map +1 -1
  33. package/lib/bot/formatters.d.ts +2 -2
  34. package/lib/bot/formatters.d.ts.map +1 -1
  35. package/lib/bot/formatters.js +41 -15
  36. package/lib/bot/formatters.js.map +1 -1
  37. package/lib/bot/index.d.ts +1 -1
  38. package/lib/bot/index.d.ts.map +1 -1
  39. package/lib/bot/index.js +90 -15
  40. package/lib/bot/index.js.map +1 -1
  41. package/lib/bot/specs.d.ts +2 -1
  42. package/lib/bot/specs.d.ts.map +1 -1
  43. package/lib/bot/specs.js +13 -9
  44. package/lib/bot/specs.js.map +1 -1
  45. package/lib/bot/types.d.ts +5 -2
  46. package/lib/bot/types.d.ts.map +1 -1
  47. package/lib/countervalues/logic.integration.test.js +65 -0
  48. package/lib/countervalues/logic.integration.test.js.map +1 -1
  49. package/lib/countervalues/modules/weth.d.ts.map +1 -1
  50. package/lib/countervalues/modules/weth.js +5 -10
  51. package/lib/countervalues/modules/weth.js.map +1 -1
  52. package/lib/currencies/sortByMarketcap.d.ts +0 -2
  53. package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
  54. package/lib/currencies/sortByMarketcap.js +3 -17
  55. package/lib/currencies/sortByMarketcap.js.map +1 -1
  56. package/lib/currencies/sortByMarketcap.test.js +0 -5
  57. package/lib/currencies/sortByMarketcap.test.js.map +1 -1
  58. package/lib/env.js +1 -1
  59. package/lib/families/algorand/specs.d.ts.map +1 -1
  60. package/lib/families/algorand/specs.js +18 -10
  61. package/lib/families/algorand/specs.js.map +1 -1
  62. package/lib/families/algorand/speculos-deviceActions.d.ts +1 -4
  63. package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
  64. package/lib/families/algorand/speculos-deviceActions.js +25 -8
  65. package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
  66. package/lib/families/bitcoin/bridge/mock.d.ts.map +1 -1
  67. package/lib/families/bitcoin/bridge/mock.js +6 -1
  68. package/lib/families/bitcoin/bridge/mock.js.map +1 -1
  69. package/lib/families/bitcoin/datasets/bitcoin_cash.d.ts.map +1 -1
  70. package/lib/families/bitcoin/datasets/bitcoin_cash.js +1 -1
  71. package/lib/families/bitcoin/datasets/bitcoin_cash.js.map +1 -1
  72. package/lib/families/bitcoin/datasets/dash.d.ts.map +1 -1
  73. package/lib/families/bitcoin/datasets/dash.js +1 -1
  74. package/lib/families/bitcoin/datasets/dash.js.map +1 -1
  75. package/lib/families/bitcoin/datasets/decred.d.ts.map +1 -1
  76. package/lib/families/bitcoin/datasets/decred.js +1 -1
  77. package/lib/families/bitcoin/datasets/decred.js.map +1 -1
  78. package/lib/families/bitcoin/datasets/digibyte.d.ts.map +1 -1
  79. package/lib/families/bitcoin/datasets/digibyte.js +8 -2
  80. package/lib/families/bitcoin/datasets/digibyte.js.map +1 -1
  81. package/lib/families/bitcoin/datasets/dogecoin.d.ts.map +1 -1
  82. package/lib/families/bitcoin/datasets/dogecoin.js +1 -1
  83. package/lib/families/bitcoin/datasets/dogecoin.js.map +1 -1
  84. package/lib/families/bitcoin/datasets/komodo.js +1 -1
  85. package/lib/families/bitcoin/datasets/komodo.js.map +1 -1
  86. package/lib/families/bitcoin/datasets/litecoin.d.ts.map +1 -1
  87. package/lib/families/bitcoin/datasets/litecoin.js +8 -2
  88. package/lib/families/bitcoin/datasets/litecoin.js.map +1 -1
  89. package/lib/families/bitcoin/datasets/peercoin.js +1 -1
  90. package/lib/families/bitcoin/datasets/peercoin.js.map +1 -1
  91. package/lib/families/bitcoin/datasets/pivx.js +1 -1
  92. package/lib/families/bitcoin/datasets/pivx.js.map +1 -1
  93. package/lib/families/bitcoin/datasets/qtum.js +1 -1
  94. package/lib/families/bitcoin/datasets/qtum.js.map +1 -1
  95. package/lib/families/bitcoin/datasets/stakenet.d.ts.map +1 -1
  96. package/lib/families/bitcoin/datasets/stakenet.js +1 -1
  97. package/lib/families/bitcoin/datasets/stakenet.js.map +1 -1
  98. package/lib/families/bitcoin/datasets/vertcoin.d.ts.map +1 -1
  99. package/lib/families/bitcoin/datasets/vertcoin.js +1 -1
  100. package/lib/families/bitcoin/datasets/vertcoin.js.map +1 -1
  101. package/lib/families/bitcoin/datasets/viacoin.d.ts.map +1 -1
  102. package/lib/families/bitcoin/datasets/viacoin.js +1 -1
  103. package/lib/families/bitcoin/datasets/viacoin.js.map +1 -1
  104. package/lib/families/bitcoin/datasets/zcash.d.ts.map +1 -1
  105. package/lib/families/bitcoin/datasets/zcash.js +1 -1
  106. package/lib/families/bitcoin/datasets/zcash.js.map +1 -1
  107. package/lib/families/bitcoin/datasets/zencash.d.ts.map +1 -1
  108. package/lib/families/bitcoin/datasets/zencash.js +1 -1
  109. package/lib/families/bitcoin/datasets/zencash.js.map +1 -1
  110. package/lib/families/bitcoin/platformAdapter.test.d.ts +2 -0
  111. package/lib/families/bitcoin/platformAdapter.test.d.ts.map +1 -0
  112. package/lib/families/bitcoin/platformAdapter.test.js +48 -0
  113. package/lib/families/bitcoin/platformAdapter.test.js.map +1 -0
  114. package/lib/families/bitcoin/specs.d.ts.map +1 -1
  115. package/lib/families/bitcoin/specs.js +62 -24
  116. package/lib/families/bitcoin/specs.js.map +1 -1
  117. package/lib/families/bitcoin/speculos-deviceActions.d.ts +1 -4
  118. package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
  119. package/lib/families/bitcoin/speculos-deviceActions.js +2 -4
  120. package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
  121. package/lib/families/cardano/js-estimateMaxSpendable.js +1 -1
  122. package/lib/families/cardano/js-estimateMaxSpendable.js.map +1 -1
  123. package/lib/families/cardano/specs.d.ts.map +1 -1
  124. package/lib/families/cardano/specs.js +19 -8
  125. package/lib/families/cardano/specs.js.map +1 -1
  126. package/lib/families/cardano/speculos-deviceActions.d.ts +1 -4
  127. package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
  128. package/lib/families/cardano/speculos-deviceActions.js +2 -2
  129. package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
  130. package/lib/families/celo/api/hubble.d.ts +6 -1
  131. package/lib/families/celo/api/hubble.d.ts.map +1 -1
  132. package/lib/families/celo/api/hubble.js +135 -13
  133. package/lib/families/celo/api/hubble.js.map +1 -1
  134. package/lib/families/celo/api/index.d.ts +1 -1
  135. package/lib/families/celo/api/index.d.ts.map +1 -1
  136. package/lib/families/celo/api/index.js +2 -1
  137. package/lib/families/celo/api/index.js.map +1 -1
  138. package/lib/families/celo/api/sdk.d.ts +22 -0
  139. package/lib/families/celo/api/sdk.d.ts.map +1 -1
  140. package/lib/families/celo/api/sdk.js +168 -1
  141. package/lib/families/celo/api/sdk.js.map +1 -1
  142. package/lib/families/celo/bridge/js.d.ts.map +1 -1
  143. package/lib/families/celo/bridge/js.js +4 -42
  144. package/lib/families/celo/bridge/js.js.map +1 -1
  145. package/lib/families/celo/cli-transaction.d.ts +12 -2
  146. package/lib/families/celo/cli-transaction.d.ts.map +1 -1
  147. package/lib/families/celo/cli-transaction.js +38 -4
  148. package/lib/families/celo/cli-transaction.js.map +1 -1
  149. package/lib/families/celo/datasets/celo.scanAccounts.1.d.ts +1 -0
  150. package/lib/families/celo/datasets/celo.scanAccounts.1.d.ts.map +1 -1
  151. package/lib/families/celo/datasets/celo.scanAccounts.1.js +298 -2
  152. package/lib/families/celo/datasets/celo.scanAccounts.1.js.map +1 -1
  153. package/lib/families/celo/errors.d.ts +2 -0
  154. package/lib/families/celo/errors.d.ts.map +1 -0
  155. package/lib/families/celo/errors.js +6 -0
  156. package/lib/families/celo/errors.js.map +1 -0
  157. package/lib/families/celo/js-buildTransaction.d.ts +2 -3
  158. package/lib/families/celo/js-buildTransaction.d.ts.map +1 -1
  159. package/lib/families/celo/js-buildTransaction.js +194 -19
  160. package/lib/families/celo/js-buildTransaction.js.map +1 -1
  161. package/lib/families/celo/js-createTransaction.d.ts.map +1 -1
  162. package/lib/families/celo/js-createTransaction.js +3 -1
  163. package/lib/families/celo/js-createTransaction.js.map +1 -1
  164. package/lib/families/celo/js-estimateMaxSpendable.d.ts.map +1 -1
  165. package/lib/families/celo/js-estimateMaxSpendable.js.map +1 -1
  166. package/lib/families/celo/js-getFeesForTransaction.d.ts +2 -3
  167. package/lib/families/celo/js-getFeesForTransaction.d.ts.map +1 -1
  168. package/lib/families/celo/js-getFeesForTransaction.js +137 -10
  169. package/lib/families/celo/js-getFeesForTransaction.js.map +1 -1
  170. package/lib/families/celo/js-getTransactionStatus.d.ts +2 -3
  171. package/lib/families/celo/js-getTransactionStatus.d.ts.map +1 -1
  172. package/lib/families/celo/js-getTransactionStatus.js +97 -41
  173. package/lib/families/celo/js-getTransactionStatus.js.map +1 -1
  174. package/lib/families/celo/js-prepareTransaction.d.ts +2 -3
  175. package/lib/families/celo/js-prepareTransaction.d.ts.map +1 -1
  176. package/lib/families/celo/js-prepareTransaction.js +8 -3
  177. package/lib/families/celo/js-prepareTransaction.js.map +1 -1
  178. package/lib/families/celo/js-signOperation.d.ts.map +1 -1
  179. package/lib/families/celo/js-signOperation.js +17 -3
  180. package/lib/families/celo/js-signOperation.js.map +1 -1
  181. package/lib/families/celo/js-synchronisation.d.ts.map +1 -1
  182. package/lib/families/celo/js-synchronisation.js +51 -6
  183. package/lib/families/celo/js-synchronisation.js.map +1 -1
  184. package/lib/families/celo/logic.d.ts +21 -0
  185. package/lib/families/celo/logic.d.ts.map +1 -0
  186. package/lib/families/celo/logic.js +132 -0
  187. package/lib/families/celo/logic.js.map +1 -0
  188. package/lib/families/celo/preload.d.ts +10 -0
  189. package/lib/families/celo/preload.d.ts.map +1 -0
  190. package/lib/families/celo/preload.js +118 -0
  191. package/lib/families/celo/preload.js.map +1 -0
  192. package/lib/families/celo/react.d.ts +4 -0
  193. package/lib/families/celo/react.d.ts.map +1 -0
  194. package/lib/families/celo/react.js +47 -0
  195. package/lib/families/celo/react.js.map +1 -0
  196. package/lib/families/celo/serialization.d.ts +4 -0
  197. package/lib/families/celo/serialization.d.ts.map +1 -0
  198. package/lib/families/celo/serialization.js +55 -0
  199. package/lib/families/celo/serialization.js.map +1 -0
  200. package/lib/families/celo/specs/createActivateVoteMutation.d.ts +4 -0
  201. package/lib/families/celo/specs/createActivateVoteMutation.d.ts.map +1 -0
  202. package/lib/families/celo/specs/createActivateVoteMutation.js +38 -0
  203. package/lib/families/celo/specs/createActivateVoteMutation.js.map +1 -0
  204. package/lib/families/celo/specs/createLockMutation.d.ts +4 -0
  205. package/lib/families/celo/specs/createLockMutation.d.ts.map +1 -0
  206. package/lib/families/celo/specs/createLockMutation.js +40 -0
  207. package/lib/families/celo/specs/createLockMutation.js.map +1 -0
  208. package/lib/families/celo/specs/createRegisterAccountMutation.d.ts +4 -0
  209. package/lib/families/celo/specs/createRegisterAccountMutation.d.ts.map +1 -0
  210. package/lib/families/celo/specs/createRegisterAccountMutation.js +31 -0
  211. package/lib/families/celo/specs/createRegisterAccountMutation.js.map +1 -0
  212. package/lib/families/celo/specs/createRevokeVoteMutation.d.ts +4 -0
  213. package/lib/families/celo/specs/createRevokeVoteMutation.d.ts.map +1 -0
  214. package/lib/families/celo/specs/createRevokeVoteMutation.js +39 -0
  215. package/lib/families/celo/specs/createRevokeVoteMutation.js.map +1 -0
  216. package/lib/families/celo/specs/createSendMutation.d.ts +5 -0
  217. package/lib/families/celo/specs/createSendMutation.d.ts.map +1 -0
  218. package/lib/families/celo/specs/createSendMutation.js +44 -0
  219. package/lib/families/celo/specs/createSendMutation.js.map +1 -0
  220. package/lib/families/celo/specs/createUnlockMutation.d.ts +4 -0
  221. package/lib/families/celo/specs/createUnlockMutation.d.ts.map +1 -0
  222. package/lib/families/celo/specs/createUnlockMutation.js +37 -0
  223. package/lib/families/celo/specs/createUnlockMutation.js.map +1 -0
  224. package/lib/families/celo/specs/createVoteMutation.d.ts +4 -0
  225. package/lib/families/celo/specs/createVoteMutation.d.ts.map +1 -0
  226. package/lib/families/celo/specs/createVoteMutation.js +51 -0
  227. package/lib/families/celo/specs/createVoteMutation.js.map +1 -0
  228. package/lib/families/celo/specs/createWithdrawMutation.d.ts +4 -0
  229. package/lib/families/celo/specs/createWithdrawMutation.d.ts.map +1 -0
  230. package/lib/families/celo/specs/createWithdrawMutation.js +36 -0
  231. package/lib/families/celo/specs/createWithdrawMutation.js.map +1 -0
  232. package/lib/families/celo/specs/index.d.ts +9 -0
  233. package/lib/families/celo/specs/index.d.ts.map +1 -0
  234. package/lib/families/celo/specs/index.js +25 -0
  235. package/lib/families/celo/specs/index.js.map +1 -0
  236. package/lib/families/celo/specs.d.ts +1 -1
  237. package/lib/families/celo/specs.d.ts.map +1 -1
  238. package/lib/families/celo/specs.js +22 -37
  239. package/lib/families/celo/specs.js.map +1 -1
  240. package/lib/families/celo/speculos-deviceActions.d.ts +1 -4
  241. package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
  242. package/lib/families/celo/speculos-deviceActions.js +24 -4
  243. package/lib/families/celo/speculos-deviceActions.js.map +1 -1
  244. package/lib/families/celo/transaction.d.ts.map +1 -1
  245. package/lib/families/celo/transaction.js +8 -6
  246. package/lib/families/celo/transaction.js.map +1 -1
  247. package/lib/families/celo/types.d.ts +102 -1
  248. package/lib/families/celo/types.d.ts.map +1 -1
  249. package/lib/families/celo/validators.d.ts +3 -0
  250. package/lib/families/celo/validators.d.ts.map +1 -0
  251. package/lib/families/celo/validators.js +6 -0
  252. package/lib/families/celo/validators.js.map +1 -0
  253. package/lib/families/cosmos/specs.d.ts.map +1 -1
  254. package/lib/families/cosmos/specs.js +41 -25
  255. package/lib/families/cosmos/specs.js.map +1 -1
  256. package/lib/families/cosmos/speculos-deviceActions.d.ts +1 -4
  257. package/lib/families/cosmos/speculos-deviceActions.d.ts.map +1 -1
  258. package/lib/families/cosmos/speculos-deviceActions.js +2 -4
  259. package/lib/families/cosmos/speculos-deviceActions.js.map +1 -1
  260. package/lib/families/crypto_org/specs.d.ts.map +1 -1
  261. package/lib/families/crypto_org/specs.js +3 -0
  262. package/lib/families/crypto_org/specs.js.map +1 -1
  263. package/lib/families/crypto_org/speculos-deviceActions.d.ts +1 -4
  264. package/lib/families/crypto_org/speculos-deviceActions.d.ts.map +1 -1
  265. package/lib/families/crypto_org/speculos-deviceActions.js +2 -2
  266. package/lib/families/crypto_org/speculos-deviceActions.js.map +1 -1
  267. package/lib/families/elrond/specs.d.ts.map +1 -1
  268. package/lib/families/elrond/specs.js +15 -2
  269. package/lib/families/elrond/specs.js.map +1 -1
  270. package/lib/families/elrond/speculos-deviceActions.d.ts +1 -4
  271. package/lib/families/elrond/speculos-deviceActions.d.ts.map +1 -1
  272. package/lib/families/elrond/speculos-deviceActions.js +2 -4
  273. package/lib/families/elrond/speculos-deviceActions.js.map +1 -1
  274. package/lib/families/ethereum/platformAdapter.test.d.ts +2 -0
  275. package/lib/families/ethereum/platformAdapter.test.d.ts.map +1 -0
  276. package/lib/families/ethereum/platformAdapter.test.js +88 -0
  277. package/lib/families/ethereum/platformAdapter.test.js.map +1 -0
  278. package/lib/families/ethereum/specs.d.ts.map +1 -1
  279. package/lib/families/ethereum/specs.js +36 -12
  280. package/lib/families/ethereum/specs.js.map +1 -1
  281. package/lib/families/ethereum/speculos-deviceActions.d.ts +1 -4
  282. package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
  283. package/lib/families/ethereum/speculos-deviceActions.js +2 -4
  284. package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
  285. package/lib/families/filecoin/specs.d.ts.map +1 -1
  286. package/lib/families/filecoin/specs.js +2 -0
  287. package/lib/families/filecoin/specs.js.map +1 -1
  288. package/lib/families/filecoin/speculos-deviceActions.d.ts +1 -4
  289. package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
  290. package/lib/families/filecoin/speculos-deviceActions.js +2 -2
  291. package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
  292. package/lib/families/hedera/specs.d.ts.map +1 -1
  293. package/lib/families/hedera/specs.js +11 -3
  294. package/lib/families/hedera/specs.js.map +1 -1
  295. package/lib/families/hedera/speculos-deviceActions.d.ts +1 -4
  296. package/lib/families/hedera/speculos-deviceActions.d.ts.map +1 -1
  297. package/lib/families/hedera/speculos-deviceActions.js +4 -4
  298. package/lib/families/hedera/speculos-deviceActions.js.map +1 -1
  299. package/lib/families/osmosis/specs.d.ts.map +1 -1
  300. package/lib/families/osmosis/specs.js +13 -5
  301. package/lib/families/osmosis/specs.js.map +1 -1
  302. package/lib/families/osmosis/speculos-deviceActions.d.ts +1 -4
  303. package/lib/families/osmosis/speculos-deviceActions.d.ts.map +1 -1
  304. package/lib/families/osmosis/speculos-deviceActions.js +2 -4
  305. package/lib/families/osmosis/speculos-deviceActions.js.map +1 -1
  306. package/lib/families/polkadot/platformAdapter.test.d.ts +2 -0
  307. package/lib/families/polkadot/platformAdapter.test.d.ts.map +1 -0
  308. package/lib/families/polkadot/platformAdapter.test.js +51 -0
  309. package/lib/families/polkadot/platformAdapter.test.js.map +1 -0
  310. package/lib/families/polkadot/specs.d.ts.map +1 -1
  311. package/lib/families/polkadot/specs.js +12 -1
  312. package/lib/families/polkadot/specs.js.map +1 -1
  313. package/lib/families/polkadot/speculos-deviceActions.d.ts +1 -4
  314. package/lib/families/polkadot/speculos-deviceActions.d.ts.map +1 -1
  315. package/lib/families/polkadot/speculos-deviceActions.js +2 -4
  316. package/lib/families/polkadot/speculos-deviceActions.js.map +1 -1
  317. package/lib/families/ripple/platformAdapter.test.d.ts +2 -0
  318. package/lib/families/ripple/platformAdapter.test.d.ts.map +1 -0
  319. package/lib/families/ripple/platformAdapter.test.js +51 -0
  320. package/lib/families/ripple/platformAdapter.test.js.map +1 -0
  321. package/lib/families/ripple/specs.d.ts.map +1 -1
  322. package/lib/families/ripple/specs.js +9 -4
  323. package/lib/families/ripple/specs.js.map +1 -1
  324. package/lib/families/ripple/speculos-deviceActions.d.ts +1 -4
  325. package/lib/families/ripple/speculos-deviceActions.d.ts.map +1 -1
  326. package/lib/families/ripple/speculos-deviceActions.js +2 -4
  327. package/lib/families/ripple/speculos-deviceActions.js.map +1 -1
  328. package/lib/families/solana/api/chain/instruction/token/types.d.ts +2 -2
  329. package/lib/families/solana/specs.d.ts.map +1 -1
  330. package/lib/families/solana/specs.js +29 -11
  331. package/lib/families/solana/specs.js.map +1 -1
  332. package/lib/families/solana/speculos-deviceActions.d.ts +0 -5
  333. package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -1
  334. package/lib/families/solana/speculos-deviceActions.js +0 -4
  335. package/lib/families/solana/speculos-deviceActions.js.map +1 -1
  336. package/lib/families/stellar/api/horizon.d.ts.map +1 -1
  337. package/lib/families/stellar/api/horizon.js +15 -10
  338. package/lib/families/stellar/api/horizon.js.map +1 -1
  339. package/lib/families/stellar/specs.d.ts.map +1 -1
  340. package/lib/families/stellar/specs.js +30 -12
  341. package/lib/families/stellar/specs.js.map +1 -1
  342. package/lib/families/stellar/speculos-deviceActions.d.ts +1 -4
  343. package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
  344. package/lib/families/stellar/speculos-deviceActions.js +2 -4
  345. package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
  346. package/lib/families/tezos/bakers.whitelist-default.d.ts.map +1 -1
  347. package/lib/families/tezos/bakers.whitelist-default.js +1 -1
  348. package/lib/families/tezos/bakers.whitelist-default.js.map +1 -1
  349. package/lib/families/tezos/specs.d.ts.map +1 -1
  350. package/lib/families/tezos/specs.js +2 -0
  351. package/lib/families/tezos/specs.js.map +1 -1
  352. package/lib/families/tezos/speculos-deviceActions.d.ts +1 -4
  353. package/lib/families/tezos/speculos-deviceActions.d.ts.map +1 -1
  354. package/lib/families/tezos/speculos-deviceActions.js +2 -2
  355. package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
  356. package/lib/families/tron/specs.d.ts.map +1 -1
  357. package/lib/families/tron/specs.js +49 -17
  358. package/lib/families/tron/specs.js.map +1 -1
  359. package/lib/families/tron/speculos-deviceActions.d.ts +1 -4
  360. package/lib/families/tron/speculos-deviceActions.d.ts.map +1 -1
  361. package/lib/families/tron/speculos-deviceActions.js +2 -4
  362. package/lib/families/tron/speculos-deviceActions.js.map +1 -1
  363. package/lib/generated/cli-transaction.d.ts +12 -2
  364. package/lib/generated/cli-transaction.d.ts.map +1 -1
  365. package/lib/hw/getGenuineCheckFromDeviceId.d.ts +22 -0
  366. package/lib/hw/getGenuineCheckFromDeviceId.d.ts.map +1 -0
  367. package/lib/hw/getGenuineCheckFromDeviceId.js +49 -0
  368. package/lib/hw/getGenuineCheckFromDeviceId.js.map +1 -0
  369. package/lib/hw/getGenuineCheckFromDeviceId.test.d.ts +2 -0
  370. package/lib/hw/getGenuineCheckFromDeviceId.test.d.ts.map +1 -0
  371. package/lib/hw/getGenuineCheckFromDeviceId.test.js +84 -0
  372. package/lib/hw/getGenuineCheckFromDeviceId.test.js.map +1 -0
  373. package/lib/hw/getLatestAvailableFirmwareFromDeviceId.d.ts +17 -0
  374. package/lib/hw/getLatestAvailableFirmwareFromDeviceId.d.ts.map +1 -0
  375. package/lib/hw/getLatestAvailableFirmwareFromDeviceId.js +27 -0
  376. package/lib/hw/getLatestAvailableFirmwareFromDeviceId.js.map +1 -0
  377. package/lib/hw/hooks/useGenuineCheck.d.ts +34 -0
  378. package/lib/hw/hooks/useGenuineCheck.d.ts.map +1 -0
  379. package/lib/hw/hooks/useGenuineCheck.js +115 -0
  380. package/lib/hw/hooks/useGenuineCheck.js.map +1 -0
  381. package/lib/hw/hooks/useGenuineCheck.test.d.ts +2 -0
  382. package/lib/hw/hooks/useGenuineCheck.test.d.ts.map +1 -0
  383. package/lib/hw/hooks/useGenuineCheck.test.js +316 -0
  384. package/lib/hw/hooks/useGenuineCheck.test.js.map +1 -0
  385. package/lib/hw/hooks/useGetLatestAvailableFirmware.d.ts +29 -0
  386. package/lib/hw/hooks/useGetLatestAvailableFirmware.d.ts.map +1 -0
  387. package/lib/hw/hooks/useGetLatestAvailableFirmware.js +72 -0
  388. package/lib/hw/hooks/useGetLatestAvailableFirmware.js.map +1 -0
  389. package/lib/hw/hooks/useGetLatestAvailableFirmware.test.d.ts +2 -0
  390. package/lib/hw/hooks/useGetLatestAvailableFirmware.test.d.ts.map +1 -0
  391. package/lib/hw/hooks/useGetLatestAvailableFirmware.test.js +155 -0
  392. package/lib/hw/hooks/useGetLatestAvailableFirmware.test.js.map +1 -0
  393. package/lib/load/speculos.d.ts +1 -0
  394. package/lib/load/speculos.d.ts.map +1 -1
  395. package/lib/load/speculos.js +2 -1
  396. package/lib/load/speculos.js.map +1 -1
  397. package/lib/mock/fixtures/cryptoCurrencies.d.ts +5 -0
  398. package/lib/mock/fixtures/cryptoCurrencies.d.ts.map +1 -0
  399. package/lib/mock/fixtures/cryptoCurrencies.js +91 -0
  400. package/lib/mock/fixtures/cryptoCurrencies.js.map +1 -0
  401. package/lib/operation.d.ts.map +1 -1
  402. package/lib/operation.js +6 -0
  403. package/lib/operation.js.map +1 -1
  404. package/lib/platform/converters.test.js +44 -218
  405. package/lib/platform/converters.test.js.map +1 -1
  406. package/lib/platform/logic.d.ts +44 -0
  407. package/lib/platform/logic.d.ts.map +1 -1
  408. package/lib/platform/logic.js +147 -1
  409. package/lib/platform/logic.js.map +1 -1
  410. package/lib/platform/logic.test.d.ts +2 -0
  411. package/lib/platform/logic.test.d.ts.map +1 -0
  412. package/lib/platform/logic.test.js +903 -0
  413. package/lib/platform/logic.test.js.map +1 -0
  414. package/lib/platform/react.d.ts +6 -0
  415. package/lib/platform/react.d.ts.map +1 -1
  416. package/lib/platform/react.js +6 -0
  417. package/lib/platform/react.js.map +1 -1
  418. package/lib/platform/tracking.d.ts +1 -1
  419. package/lib/platform/tracking.d.ts.map +1 -1
  420. package/lib/platform/tracking.test.js +14 -41
  421. package/lib/platform/tracking.test.js.map +1 -1
  422. package/lib/reconciliation.d.ts.map +1 -1
  423. package/lib/reconciliation.js +39 -10
  424. package/lib/reconciliation.js.map +1 -1
  425. package/package.json +5 -7
  426. package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +2 -2
  427. package/src/__tests__/test-helpers/environment.ts +91 -0
  428. package/src/__tests__/test-helpers/setup.ts +2 -91
  429. package/src/account/serialization.ts +125 -66
  430. package/src/apps/support.ts +1 -0
  431. package/src/bot/bot-test-context.test.ts +37 -0
  432. package/src/bot/bot-test-context.ts +24 -0
  433. package/src/bot/cli.ts +18 -0
  434. package/src/bot/engine.ts +109 -73
  435. package/src/bot/formatters.ts +40 -14
  436. package/src/bot/index.ts +124 -18
  437. package/src/bot/specs.ts +10 -5
  438. package/src/bot/types.ts +7 -3
  439. package/src/countervalues/logic.integration.test.ts +50 -0
  440. package/src/countervalues/modules/weth.ts +9 -12
  441. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +59 -1
  442. package/src/currencies/sortByMarketcap.test.ts +1 -12
  443. package/src/currencies/sortByMarketcap.ts +2 -22
  444. package/src/env.ts +1 -1
  445. package/src/families/algorand/__snapshots__/bridge.integration.test.ts.snap +733 -8
  446. package/src/families/algorand/specs.ts +26 -16
  447. package/src/families/algorand/speculos-deviceActions.ts +31 -10
  448. package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +43309 -7957
  449. package/src/families/bitcoin/bridge/mock.ts +7 -1
  450. package/src/families/bitcoin/datasets/bitcoin_cash.ts +73 -13
  451. package/src/families/bitcoin/datasets/dash.ts +29 -17
  452. package/src/families/bitcoin/datasets/decred.ts +42 -12
  453. package/src/families/bitcoin/datasets/digibyte.ts +9 -3
  454. package/src/families/bitcoin/datasets/dogecoin.ts +29 -17
  455. package/src/families/bitcoin/datasets/komodo.ts +22 -22
  456. package/src/families/bitcoin/datasets/litecoin.ts +9 -3
  457. package/src/families/bitcoin/datasets/peercoin.ts +17 -17
  458. package/src/families/bitcoin/datasets/pivx.ts +17 -17
  459. package/src/families/bitcoin/datasets/qtum.ts +40 -40
  460. package/src/families/bitcoin/datasets/stakenet.ts +56 -26
  461. package/src/families/bitcoin/datasets/vertcoin.ts +43 -55
  462. package/src/families/bitcoin/datasets/viacoin.ts +35 -23
  463. package/src/families/bitcoin/datasets/zcash.ts +78 -12
  464. package/src/families/bitcoin/datasets/zencash.ts +56 -10
  465. package/src/families/bitcoin/platformAdapter.test.ts +58 -0
  466. package/src/families/bitcoin/specs.ts +81 -41
  467. package/src/families/bitcoin/speculos-deviceActions.ts +68 -69
  468. package/src/families/cardano/js-estimateMaxSpendable.ts +1 -1
  469. package/src/families/cardano/specs.ts +28 -11
  470. package/src/families/cardano/speculos-deviceActions.ts +65 -66
  471. package/src/families/celo/__snapshots__/bridge.integration.test.ts.snap +134 -857
  472. package/src/families/celo/api/hubble.ts +113 -16
  473. package/src/families/celo/api/index.ts +1 -1
  474. package/src/families/celo/api/sdk.ts +88 -0
  475. package/src/families/celo/bridge/js.ts +2 -3
  476. package/src/families/celo/cli-transaction.ts +46 -2
  477. package/src/families/celo/datasets/celo.scanAccounts.1.ts +365 -5
  478. package/src/families/celo/errors.ts +5 -0
  479. package/src/families/celo/js-buildTransaction.ts +173 -20
  480. package/src/families/celo/js-createTransaction.ts +2 -0
  481. package/src/families/celo/js-estimateMaxSpendable.ts +2 -2
  482. package/src/families/celo/js-getFeesForTransaction.ts +118 -19
  483. package/src/families/celo/js-getTransactionStatus.ts +72 -17
  484. package/src/families/celo/js-prepareTransaction.ts +13 -7
  485. package/src/families/celo/js-signOperation.ts +22 -5
  486. package/src/families/celo/js-synchronisation.ts +32 -0
  487. package/src/families/celo/logic.ts +184 -0
  488. package/src/families/celo/preload.ts +78 -0
  489. package/src/families/celo/react.ts +35 -0
  490. package/src/families/celo/serialization.ts +61 -0
  491. package/src/families/celo/specs/createActivateVoteMutation.ts +44 -0
  492. package/src/families/celo/specs/createLockMutation.ts +46 -0
  493. package/src/families/celo/specs/createRegisterAccountMutation.ts +34 -0
  494. package/src/families/celo/specs/createRevokeVoteMutation.ts +43 -0
  495. package/src/families/celo/specs/createSendMutation.ts +44 -0
  496. package/src/families/celo/specs/createUnlockMutation.ts +44 -0
  497. package/src/families/celo/specs/createVoteMutation.ts +67 -0
  498. package/src/families/celo/specs/createWithdrawMutation.ts +44 -0
  499. package/src/families/celo/specs/index.ts +8 -0
  500. package/src/families/celo/specs.ts +34 -34
  501. package/src/families/celo/speculos-deviceActions.ts +63 -45
  502. package/src/families/celo/transaction.ts +12 -4
  503. package/src/families/celo/types.ts +113 -0
  504. package/src/families/celo/validators.ts +2 -0
  505. package/src/families/cosmos/__snapshots__/bridge.integration.test.ts.snap +246 -5
  506. package/src/families/cosmos/specs.ts +44 -28
  507. package/src/families/cosmos/speculos-deviceActions.ts +82 -83
  508. package/src/families/crypto_org/specs.ts +3 -0
  509. package/src/families/crypto_org/speculos-deviceActions.ts +58 -59
  510. package/src/families/elrond/specs.ts +21 -4
  511. package/src/families/elrond/speculos-deviceActions.ts +41 -42
  512. package/src/families/ethereum/__snapshots__/bridge.integration.test.ts.snap +90 -90
  513. package/src/families/ethereum/platformAdapter.test.ts +112 -0
  514. package/src/families/ethereum/specs.ts +47 -23
  515. package/src/families/ethereum/speculos-deviceActions.ts +93 -95
  516. package/src/families/filecoin/specs.ts +2 -1
  517. package/src/families/filecoin/speculos-deviceActions.ts +61 -62
  518. package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +57 -2
  519. package/src/families/hedera/specs.ts +13 -5
  520. package/src/families/hedera/speculos-deviceActions.ts +59 -60
  521. package/src/families/osmosis/specs.ts +15 -7
  522. package/src/families/osmosis/speculos-deviceActions.ts +82 -83
  523. package/src/families/polkadot/platformAdapter.test.ts +61 -0
  524. package/src/families/polkadot/specs.ts +20 -2
  525. package/src/families/polkadot/speculos-deviceActions.ts +83 -82
  526. package/src/families/ripple/platformAdapter.test.ts +54 -0
  527. package/src/families/ripple/specs.ts +14 -7
  528. package/src/families/ripple/speculos-deviceActions.ts +72 -73
  529. package/src/families/solana/specs.ts +33 -14
  530. package/src/families/solana/speculos-deviceActions.ts +0 -5
  531. package/src/families/stellar/api/horizon.ts +10 -6
  532. package/src/families/stellar/specs.ts +37 -19
  533. package/src/families/stellar/speculos-deviceActions.ts +85 -87
  534. package/src/families/tezos/bakers.whitelist-default.ts +0 -1
  535. package/src/families/tezos/specs.ts +2 -0
  536. package/src/families/tezos/speculos-deviceActions.ts +76 -77
  537. package/src/families/tron/specs.ts +67 -30
  538. package/src/families/tron/speculos-deviceActions.ts +81 -84
  539. package/src/hw/getGenuineCheckFromDeviceId.test.ts +98 -0
  540. package/src/hw/getGenuineCheckFromDeviceId.ts +61 -0
  541. package/src/hw/getLatestAvailableFirmwareFromDeviceId.ts +37 -0
  542. package/src/hw/hooks/useGenuineCheck.test.ts +232 -0
  543. package/src/hw/hooks/useGenuineCheck.ts +138 -0
  544. package/src/hw/hooks/useGetLatestAvailableFirmware.test.ts +111 -0
  545. package/src/hw/hooks/useGetLatestAvailableFirmware.ts +90 -0
  546. package/src/load/speculos.ts +2 -0
  547. package/src/mock/fixtures/cryptoCurrencies.ts +88 -0
  548. package/src/operation.ts +6 -0
  549. package/src/platform/converters.test.ts +49 -282
  550. package/src/platform/logic.test.ts +756 -0
  551. package/src/platform/logic.ts +285 -0
  552. package/src/platform/react.ts +6 -0
  553. package/src/platform/tracking.test.ts +6 -7
  554. package/src/platform/tracking.ts +1 -1
  555. package/src/reconciliation.ts +88 -43
  556. package/lib/bot/test.bot.d.ts +0 -2
  557. package/lib/bot/test.bot.d.ts.map +0 -1
  558. package/lib/bot/test.bot.js +0 -62
  559. package/lib/bot/test.bot.js.map +0 -1
  560. package/lib/generated/speculos-deviceActions.d.ts +0 -56
  561. package/lib/generated/speculos-deviceActions.d.ts.map +0 -1
  562. package/lib/generated/speculos-deviceActions.js +0 -42
  563. package/lib/generated/speculos-deviceActions.js.map +0 -1
  564. package/src/bot/test.bot.ts +0 -21
  565. package/src/generated/speculos-deviceActions.ts +0 -37
@@ -7,11 +7,12 @@ import sampleSize from "lodash/sampleSize";
7
7
  import get from "lodash/get";
8
8
  import type { Transaction, TronAccount } from "./types";
9
9
  import { getCryptoCurrencyById, parseCurrencyUnit } from "../../currencies";
10
- import { pickSiblings } from "../../bot/specs";
10
+ import { botTest, pickSiblings } from "../../bot/specs";
11
11
  import type { AppSpec } from "../../bot/types";
12
12
  import { getUnfreezeData, getNextRewardDate } from "./react";
13
13
  import { DeviceModelId } from "@ledgerhq/devices";
14
14
  import { SubAccount } from "@ledgerhq/types-live";
15
+ import { acceptTransaction } from "./speculos-deviceActions";
15
16
  const currency = getCryptoCurrencyById("tron");
16
17
  const minimalAmount = parseCurrencyUnit(currency.units[0], "1");
17
18
  const maxAccount = 10;
@@ -19,6 +20,16 @@ const maxAccount = 10;
19
20
  const getDecimalPart = (value: BigNumber, magnitude: number) =>
20
21
  value.minus(value.modulo(10 ** magnitude));
21
22
 
23
+ const expectedApproximate = (
24
+ value: BigNumber,
25
+ expected: BigNumber,
26
+ delta = 50
27
+ ) => {
28
+ if (value.minus(expected).abs().gt(delta)) {
29
+ expect(value.toString()).toEqual(value.toString());
30
+ }
31
+ };
32
+
22
33
  const tron: AppSpec<Transaction> = {
23
34
  name: "Tron",
24
35
  currency,
@@ -26,6 +37,7 @@ const tron: AppSpec<Transaction> = {
26
37
  model: DeviceModelId.nanoS,
27
38
  appName: "Tron",
28
39
  },
40
+ genericDeviceAction: acceptTransaction,
29
41
  testTimeout: 2 * 60 * 1000,
30
42
  mutations: [
31
43
  {
@@ -49,10 +61,11 @@ const tron: AppSpec<Transaction> = {
49
61
  };
50
62
  },
51
63
  test: ({ accountBeforeTransaction, operation, account }) => {
52
- expect(account.spendableBalance.toString()).toBe(
53
- accountBeforeTransaction.spendableBalance
54
- .minus(operation.value)
55
- .toString()
64
+ botTest("account spendable balance decreased with operation", () =>
65
+ expectedApproximate(
66
+ account.spendableBalance,
67
+ accountBeforeTransaction.spendableBalance.minus(operation.value)
68
+ )
56
69
  );
57
70
  },
58
71
  },
@@ -76,7 +89,9 @@ const tron: AppSpec<Transaction> = {
76
89
  };
77
90
  },
78
91
  test: ({ account }) => {
79
- expect(account.spendableBalance.toString()).toBe("0");
92
+ botTest("account spendable balance is zero", () =>
93
+ expect(account.spendableBalance.toString()).toBe("0")
94
+ );
80
95
  },
81
96
  },
82
97
  {
@@ -124,8 +139,10 @@ const tron: AppSpec<Transaction> = {
124
139
  `tronResources.frozen.${resourceType}.amount`,
125
140
  new BigNumber(0)
126
141
  );
127
- expect(expectedAmount.toString()).toBe(
128
- currentRessourceAmount.toString()
142
+ botTest("frozen amount is accumulated in resources", () =>
143
+ expect(expectedAmount.toString()).toBe(
144
+ currentRessourceAmount.toString()
145
+ )
129
146
  );
130
147
  },
131
148
  },
@@ -164,7 +181,9 @@ const tron: AppSpec<Transaction> = {
164
181
  `tronResources.frozen.${TxResource}`,
165
182
  undefined
166
183
  );
167
- expect(currentFrozen).toBeUndefined();
184
+ botTest("no current frozen", () =>
185
+ expect(currentFrozen).toBeUndefined()
186
+ );
168
187
  const TPBeforeTx = new BigNumber(
169
188
  get(accountBeforeTransaction, "tronResources.tronPower", 0)
170
189
  );
@@ -172,7 +191,9 @@ const tron: AppSpec<Transaction> = {
172
191
  get(account, "tronResources.tronPower", 0)
173
192
  );
174
193
  const expectedTronPower = TPBeforeTx.minus(transaction.amount);
175
- expect(currentTP.toString()).toBe(expectedTronPower.toString());
194
+ botTest("tron power", () =>
195
+ expectedApproximate(currentTP, expectedTronPower)
196
+ );
176
197
  },
177
198
  },
178
199
  {
@@ -225,7 +246,7 @@ const tron: AppSpec<Transaction> = {
225
246
  const currentVotes = sortBy(get(account, "tronResources.votes", []), [
226
247
  "address",
227
248
  ]);
228
- expect(currentVotes).toEqual(votes);
249
+ botTest("current votes", () => expect(currentVotes).toEqual(votes));
229
250
  },
230
251
  },
231
252
  {
@@ -277,10 +298,14 @@ const tron: AppSpec<Transaction> = {
277
298
  if (!trc10account) throw new Error("no trc10 account");
278
299
 
279
300
  if (transaction.useAllAmount) {
280
- expect(trc10account.balance.toString()).toBe("0");
301
+ botTest("trc10 balance became zero", () =>
302
+ expect(trc10account.balance.toString()).toBe("0")
303
+ );
281
304
  } else {
282
- expect(trc10account.balance.toString()).toBe(
283
- trc10accountBefore.balance.minus(transaction.amount).toString()
305
+ botTest("trc10 balance decreased with operation", () =>
306
+ expect(trc10account.balance.toString()).toBe(
307
+ trc10accountBefore.balance.minus(transaction.amount).toString()
308
+ )
284
309
  );
285
310
  }
286
311
  },
@@ -337,10 +362,14 @@ const tron: AppSpec<Transaction> = {
337
362
  if (!trc20account) throw new Error("no trc20 account");
338
363
 
339
364
  if (transaction.useAllAmount) {
340
- expect(trc20account.balance.toString()).toBe("0");
365
+ botTest("trc10 balance became zero", () =>
366
+ expect(trc20account.balance.toString()).toBe("0")
367
+ );
341
368
  } else {
342
- expect(trc20account.balance.toString()).toBe(
343
- trc20accountBefore.balance.minus(transaction.amount).toString()
369
+ botTest("trc10 balance decreased with operation", () =>
370
+ expect(trc20account.balance.toString()).toBe(
371
+ trc20accountBefore.balance.minus(transaction.amount).toString()
372
+ )
344
373
  );
345
374
  }
346
375
 
@@ -349,21 +378,27 @@ const tron: AppSpec<Transaction> = {
349
378
  0
350
379
  )
351
380
  ) {
352
- expect(account.balance.lt(accountBeforeTransaction.balance)).toBe(
353
- true
381
+ botTest("account balance decreased", () =>
382
+ expect(account.balance.lt(accountBeforeTransaction.balance)).toBe(
383
+ true
384
+ )
354
385
  );
355
386
  } else {
356
- expect(
357
- get(account, "tronResources.energy", new BigNumber(0)).lt(
358
- get(
359
- accountBeforeTransaction,
360
- "tronResources.energy",
361
- new BigNumber(0)
387
+ botTest("energy decreased", () =>
388
+ expect(
389
+ get(account, "tronResources.energy", new BigNumber(0)).lt(
390
+ get(
391
+ accountBeforeTransaction,
392
+ "tronResources.energy",
393
+ new BigNumber(0)
394
+ )
362
395
  )
396
+ ).toBe(true)
397
+ );
398
+ botTest("balance didn't change", () =>
399
+ expect(account.balance.eq(accountBeforeTransaction.balance)).toBe(
400
+ true
363
401
  )
364
- ).toBe(true);
365
- expect(account.balance.eq(accountBeforeTransaction.balance)).toBe(
366
- true
367
402
  );
368
403
  }
369
404
  },
@@ -396,8 +431,10 @@ const tron: AppSpec<Transaction> = {
396
431
  get(account, "tronResources.unwithdrawnReward", "0")
397
432
  );
398
433
  const nextRewardDate = getNextRewardDate(account as TronAccount);
399
- expect(rewards.eq(0)).toBe(true);
400
- expect(nextRewardDate && nextRewardDate > Date.now()).toBe(true);
434
+ botTest("rewards is zero", () => expect(rewards.eq(0)).toBe(true));
435
+ botTest("next reward date settled", () =>
436
+ expect(nextRewardDate && nextRewardDate > Date.now()).toBe(true)
437
+ );
401
438
  },
402
439
  },
403
440
  ],
@@ -15,89 +15,90 @@ const resourceExpected = ({ transaction: { resource } }) =>
15
15
  ? resource.slice(0, 1).toUpperCase() + resource.slice(1).toLowerCase()
16
16
  : "";
17
17
 
18
- const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
19
- steps: [
20
- {
21
- title: "Review",
22
- button: "Rr", // TODO define expectedValue
23
- },
24
- {
25
- title: "Claim",
26
- button: "Rr",
27
- },
28
- {
29
- title: "Gain",
30
- button: "Rr",
31
- expectedValue: (arg) => resourceExpected(arg),
32
- },
33
- {
34
- title: "Resource",
35
- button: "Rr",
36
- expectedValue: (arg) => resourceExpected(arg),
37
- },
38
- {
39
- title: "Amount",
40
- button: "Rr",
41
- expectedValue: ({ account, status }) =>
42
- formatCurrencyUnit(
43
- {
44
- ...account.unit,
45
- code: account.currency.deviceTicker || account.unit.code,
46
- },
47
- status.amount,
48
- {
49
- disableRounding: true,
50
- }
51
- ),
52
- },
53
- {
54
- title: "Token",
55
- button: "Rr",
56
- expectedValue: ({ account, transaction }) =>
57
- transaction.subAccountId
58
- ? subAccount(transaction.subAccountId, account).token.ticker
59
- : "TRX",
60
- },
61
- {
62
- title: "From Address",
63
- button: "Rr",
64
- expectedValue: ({ account }) => account.freshAddress,
65
- },
66
- {
67
- title: "Freeze To",
68
- button: "Rr",
69
- expectedValue: ({ account }) => account.freshAddress,
70
- },
71
- {
72
- title: "Delegated To",
73
- button: "Rr",
74
- expectedValue: ({ account }) => account.freshAddress,
75
- },
76
- {
77
- title: "Send To",
78
- button: "Rr",
79
- expectedValue: ({ transaction }) => transaction.recipient,
80
- },
81
- {
82
- title: "Sign",
83
- button: "LRlr",
84
- final: true,
85
- },
86
- ],
87
- fallback: ({ event, transaction }) => {
88
- if (transaction.mode === "vote") {
89
- for (const vote of transaction.votes) {
90
- const title = `${vote.address.slice(0, 5)}...${vote.address.slice(
91
- vote.address.length - 5
92
- )}`;
18
+ export const acceptTransaction: DeviceAction<Transaction, any> =
19
+ deviceActionFlow({
20
+ steps: [
21
+ {
22
+ title: "Review",
23
+ button: "Rr", // TODO define expectedValue
24
+ },
25
+ {
26
+ title: "Claim",
27
+ button: "Rr",
28
+ },
29
+ {
30
+ title: "Gain",
31
+ button: "Rr",
32
+ expectedValue: (arg) => resourceExpected(arg),
33
+ },
34
+ {
35
+ title: "Resource",
36
+ button: "Rr",
37
+ expectedValue: (arg) => resourceExpected(arg),
38
+ },
39
+ {
40
+ title: "Amount",
41
+ button: "Rr",
42
+ expectedValue: ({ account, status }) =>
43
+ formatCurrencyUnit(
44
+ {
45
+ ...account.unit,
46
+ code: account.currency.deviceTicker || account.unit.code,
47
+ },
48
+ status.amount,
49
+ {
50
+ disableRounding: true,
51
+ }
52
+ ),
53
+ },
54
+ {
55
+ title: "Token",
56
+ button: "Rr",
57
+ expectedValue: ({ account, transaction }) =>
58
+ transaction.subAccountId
59
+ ? subAccount(transaction.subAccountId, account).token.ticker
60
+ : "TRX",
61
+ },
62
+ {
63
+ title: "From Address",
64
+ button: "Rr",
65
+ expectedValue: ({ account }) => account.freshAddress,
66
+ },
67
+ {
68
+ title: "Freeze To",
69
+ button: "Rr",
70
+ expectedValue: ({ account }) => account.freshAddress,
71
+ },
72
+ {
73
+ title: "Delegated To",
74
+ button: "Rr",
75
+ expectedValue: ({ account }) => account.freshAddress,
76
+ },
77
+ {
78
+ title: "Send To",
79
+ button: "Rr",
80
+ expectedValue: ({ transaction }) => transaction.recipient,
81
+ },
82
+ {
83
+ title: "Sign",
84
+ button: "LRlr",
85
+ final: true,
86
+ },
87
+ ],
88
+ fallback: ({ event, transaction }) => {
89
+ if (transaction.mode === "vote") {
90
+ for (const vote of transaction.votes) {
91
+ const title = `${vote.address.slice(0, 5)}...${vote.address.slice(
92
+ vote.address.length - 5
93
+ )}`;
93
94
 
94
- if (event.text === title) {
95
- return voteAction(vote, title);
95
+ if (event.text === title) {
96
+ return voteAction(vote, title);
97
+ }
96
98
  }
97
99
  }
98
- }
99
- },
100
- });
100
+ },
101
+ });
101
102
 
102
103
  function voteAction(
103
104
  vote: Vote,
@@ -109,7 +110,3 @@ function voteAction(
109
110
  expectedValue: () => String(vote.voteCount),
110
111
  };
111
112
  }
112
-
113
- export default {
114
- acceptTransaction,
115
- };
@@ -0,0 +1,98 @@
1
+ import { from, of } from "rxjs";
2
+ import { delay } from "rxjs/operators";
3
+ import Transport from "@ledgerhq/hw-transport";
4
+ import { withDevice } from "./deviceAccess";
5
+ import getDeviceInfo from "./getDeviceInfo";
6
+ import genuineCheck from "./genuineCheck";
7
+ import { DeviceInfo } from "@ledgerhq/types-live";
8
+ import {
9
+ getGenuineCheckFromDeviceId,
10
+ GetGenuineCheckFromDeviceIdResult,
11
+ } from "./getGenuineCheckFromDeviceId";
12
+
13
+ jest.mock("./deviceAccess");
14
+ jest.mock("./getDeviceInfo");
15
+ jest.mock("./genuineCheck");
16
+ jest.useFakeTimers();
17
+
18
+ const mockedGetDeviceInfo = jest.mocked(getDeviceInfo);
19
+ const mockedGenuineCheck = jest.mocked(genuineCheck);
20
+ const mockedWithDevice = jest.mocked(withDevice);
21
+
22
+ mockedWithDevice.mockReturnValue((job) => from(job(new Transport())));
23
+
24
+ const aDeviceInfo = {
25
+ mcuVersion: "A_MCU_VERSION",
26
+ version: "A_VERSION",
27
+ majMin: "A_MAJ_MIN",
28
+ targetId: "0.0",
29
+ isBootloader: true,
30
+ isOSU: true,
31
+ providerName: undefined,
32
+ managerAllowed: false,
33
+ pinValidated: true,
34
+ };
35
+
36
+ describe("getGenuineCheckFromDeviceId", () => {
37
+ beforeEach(() => {
38
+ mockedGetDeviceInfo.mockResolvedValue(aDeviceInfo);
39
+ });
40
+
41
+ afterEach(() => {
42
+ mockedGetDeviceInfo.mockClear();
43
+ mockedGenuineCheck.mockClear();
44
+ jest.clearAllTimers();
45
+ });
46
+
47
+ describe("When the device is locked before doing a genuine check, and it timed out", () => {
48
+ it("should notify the function consumer of the need to unlock the device, and once done, continue the genuine check flow", (done) => {
49
+ // Delays the device info response
50
+ mockedGetDeviceInfo.mockReturnValue(
51
+ of(aDeviceInfo as DeviceInfo)
52
+ .pipe(delay(1001))
53
+ .toPromise()
54
+ );
55
+
56
+ mockedGenuineCheck.mockReturnValue(
57
+ of({
58
+ type: "device-permission-requested",
59
+ wording: "",
60
+ })
61
+ );
62
+
63
+ let step = 0;
64
+ getGenuineCheckFromDeviceId({
65
+ deviceId: "A_DEVICE_ID",
66
+ lockedDeviceTimeoutMs: 1000,
67
+ }).subscribe({
68
+ next: ({
69
+ socketEvent,
70
+ deviceIsLocked,
71
+ }: GetGenuineCheckFromDeviceIdResult) => {
72
+ switch (step) {
73
+ case 0:
74
+ expect(socketEvent).toBeNull();
75
+ expect(deviceIsLocked).toBe(true);
76
+ break;
77
+ case 1:
78
+ expect(socketEvent).toBeNull();
79
+ expect(deviceIsLocked).toBe(false);
80
+ break;
81
+ case 2:
82
+ expect(socketEvent).toEqual({
83
+ type: "device-permission-requested",
84
+ wording: "",
85
+ });
86
+ expect(deviceIsLocked).toBe(false);
87
+ done();
88
+ break;
89
+ }
90
+ jest.advanceTimersByTime(1);
91
+ step += 1;
92
+ },
93
+ });
94
+
95
+ jest.advanceTimersByTime(1000);
96
+ });
97
+ });
98
+ });
@@ -0,0 +1,61 @@
1
+ import type { SocketEvent } from "@ledgerhq/types-live";
2
+ import { from, Observable } from "rxjs";
3
+ import { mergeMap } from "rxjs/operators";
4
+ import getDeviceInfo from "./getDeviceInfo";
5
+ import { withDevice } from "./deviceAccess";
6
+ import genuineCheck from "./genuineCheck";
7
+
8
+ export type GetGenuineCheckFromDeviceIdArgs = {
9
+ deviceId: string;
10
+ lockedDeviceTimeoutMs?: number;
11
+ };
12
+
13
+ export type GetGenuineCheckFromDeviceIdResult = {
14
+ socketEvent: SocketEvent | null;
15
+ deviceIsLocked: boolean;
16
+ };
17
+
18
+ export type GetGenuineCheckFromDeviceIdOutput =
19
+ Observable<GetGenuineCheckFromDeviceIdResult>;
20
+
21
+ /**
22
+ * Get a genuine check for a device only from its id
23
+ * @param deviceId A device id, or an empty string if device is usb plugged
24
+ * @param lockedDeviceTimeoutMs Time of no response from device after which the device is considered locked, in ms. Default 1000ms.
25
+ * @returns An Observable pushing objects containing:
26
+ * - socketEvent: a SocketEvent giving the current status of the genuine check,
27
+ * null if the genuine check process did not reach any state yet
28
+ * - deviceIsLocked: a boolean set to true if the device is currently locked, false otherwise
29
+ */
30
+ export const getGenuineCheckFromDeviceId = ({
31
+ deviceId,
32
+ lockedDeviceTimeoutMs = 1000,
33
+ }: GetGenuineCheckFromDeviceIdArgs): GetGenuineCheckFromDeviceIdOutput => {
34
+ return new Observable((o) => {
35
+ // In order to know if a device is locked or not.
36
+ // As we're not timing out inside the genuineCheckObservable flow (with rxjs timeout for ex)
37
+ // once the device is unlock, getDeviceInfo should return the device info and
38
+ // the flow will continue. No need to handle a retry strategy
39
+ const lockedDeviceTimeout = setTimeout(() => {
40
+ o.next({ socketEvent: null, deviceIsLocked: true });
41
+ }, lockedDeviceTimeoutMs);
42
+
43
+ // withDevice handles the unsubscribing cleaning when leaving the useEffect
44
+ withDevice(deviceId)((t) =>
45
+ from(getDeviceInfo(t)).pipe(
46
+ mergeMap((deviceInfo) => {
47
+ clearTimeout(lockedDeviceTimeout);
48
+ o.next({ socketEvent: null, deviceIsLocked: false });
49
+ return genuineCheck(t, deviceInfo);
50
+ })
51
+ )
52
+ ).subscribe({
53
+ next: (socketEvent: SocketEvent) => {
54
+ o.next({ socketEvent, deviceIsLocked: false });
55
+ },
56
+ error: (e) => {
57
+ o.error(e);
58
+ },
59
+ });
60
+ });
61
+ };
@@ -0,0 +1,37 @@
1
+ import { from, Observable } from "rxjs";
2
+ import { map, mergeMap } from "rxjs/operators";
3
+ import type { FirmwareUpdateContext, DeviceId } from "@ledgerhq/types-live";
4
+ import manager from "../manager";
5
+ import { withDevice } from "./deviceAccess";
6
+ import getDeviceInfo from "./getDeviceInfo";
7
+
8
+ export type GetLatestAvailableFirmwareFromDeviceIdArgs = {
9
+ deviceId: DeviceId;
10
+ };
11
+
12
+ export type GetLatestAvailableFirmwareFromDeviceIdResult = {
13
+ firmwareUpdateContext: FirmwareUpdateContext | null | undefined;
14
+ };
15
+
16
+ export type GetLatestAvailableFirmwareFromDeviceIdOutput =
17
+ Observable<GetLatestAvailableFirmwareFromDeviceIdResult>;
18
+
19
+ /**
20
+ * Get the latest available firmware for a device only from its id
21
+ * @param deviceId A device id, or an empty string if device is usb plugged
22
+ * @returns An Observable pushing objects containing:
23
+ * - firmwareUpdateContext A FirmwareUpdateContext if found, or null or undefined otherwise
24
+ */
25
+ export const getLatestAvailableFirmwareFromDeviceId = ({
26
+ deviceId,
27
+ }: GetLatestAvailableFirmwareFromDeviceIdArgs): GetLatestAvailableFirmwareFromDeviceIdOutput => {
28
+ return withDevice(deviceId)((t) =>
29
+ from(getDeviceInfo(t)).pipe(
30
+ mergeMap((deviceInfo) =>
31
+ from(manager.getLatestFirmwareForDevice(deviceInfo)).pipe(
32
+ map((firmwareUpdateContext) => ({ firmwareUpdateContext }))
33
+ )
34
+ )
35
+ )
36
+ );
37
+ };