@ledgerhq/coin-evm 0.2.1 → 0.2.2-nightly.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (462) hide show
  1. package/.eslintrc.js +11 -46
  2. package/.turbo/turbo-build.log +1 -1
  3. package/CHANGELOG.md +29 -1
  4. package/lib/__tests__/adapters.unit.test.d.ts +2 -0
  5. package/lib/__tests__/adapters.unit.test.d.ts.map +1 -0
  6. package/lib/__tests__/adapters.unit.test.js +455 -0
  7. package/lib/__tests__/adapters.unit.test.js.map +1 -0
  8. package/lib/__tests__/broadcast.unit.test.d.ts +2 -0
  9. package/lib/__tests__/broadcast.unit.test.d.ts.map +1 -0
  10. package/lib/__tests__/broadcast.unit.test.js +181 -0
  11. package/lib/__tests__/broadcast.unit.test.js.map +1 -0
  12. package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts +2 -0
  13. package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts.map +1 -0
  14. package/lib/__tests__/buildOptimisticOperation.unit.test.js +166 -0
  15. package/lib/__tests__/buildOptimisticOperation.unit.test.js.map +1 -0
  16. package/lib/__tests__/createTransaction.unit.test.d.ts +2 -0
  17. package/lib/__tests__/createTransaction.unit.test.d.ts.map +1 -0
  18. package/lib/__tests__/createTransaction.unit.test.js +50 -0
  19. package/lib/__tests__/createTransaction.unit.test.js.map +1 -0
  20. package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts +2 -0
  21. package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  22. package/lib/__tests__/deviceTransactionConfig.unit.test.js +231 -0
  23. package/lib/__tests__/deviceTransactionConfig.unit.test.js.map +1 -0
  24. package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts +2 -0
  25. package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  26. package/lib/__tests__/estimateMaxSpendable.unit.test.js +145 -0
  27. package/lib/__tests__/estimateMaxSpendable.unit.test.js.map +1 -0
  28. package/lib/__tests__/gasTracker/index.unit.test.d.ts +2 -0
  29. package/lib/__tests__/gasTracker/index.unit.test.d.ts.map +1 -0
  30. package/lib/__tests__/gasTracker/index.unit.test.js +35 -0
  31. package/lib/__tests__/gasTracker/index.unit.test.js.map +1 -0
  32. package/lib/__tests__/gasTracker/ledger.unit.test.d.ts +2 -0
  33. package/lib/__tests__/gasTracker/ledger.unit.test.d.ts.map +1 -0
  34. package/lib/__tests__/gasTracker/ledger.unit.test.js +110 -0
  35. package/lib/__tests__/gasTracker/ledger.unit.test.js.map +1 -0
  36. package/lib/__tests__/getTransactionStatus.unit.test.d.ts +2 -0
  37. package/lib/__tests__/getTransactionStatus.unit.test.d.ts.map +1 -0
  38. package/lib/__tests__/getTransactionStatus.unit.test.js +216 -0
  39. package/lib/__tests__/getTransactionStatus.unit.test.js.map +1 -0
  40. package/lib/__tests__/hw-getAddress.unit.test.d.ts +2 -0
  41. package/lib/__tests__/hw-getAddress.unit.test.d.ts.map +1 -0
  42. package/lib/__tests__/hw-getAddress.unit.test.js +47 -0
  43. package/lib/__tests__/hw-getAddress.unit.test.js.map +1 -0
  44. package/lib/__tests__/logic.unit.test.d.ts +2 -0
  45. package/lib/__tests__/logic.unit.test.d.ts.map +1 -0
  46. package/lib/__tests__/logic.unit.test.js +296 -0
  47. package/lib/__tests__/logic.unit.test.js.map +1 -0
  48. package/lib/__tests__/preload.unit.test.d.ts +2 -0
  49. package/lib/__tests__/preload.unit.test.d.ts.map +1 -0
  50. package/lib/__tests__/preload.unit.test.js +149 -0
  51. package/lib/__tests__/preload.unit.test.js.map +1 -0
  52. package/lib/__tests__/prepareTransaction.unit.test.d.ts +2 -0
  53. package/lib/__tests__/prepareTransaction.unit.test.d.ts.map +1 -0
  54. package/lib/__tests__/prepareTransaction.unit.test.js +248 -0
  55. package/lib/__tests__/prepareTransaction.unit.test.js.map +1 -0
  56. package/lib/__tests__/rpc.unit.test.d.ts +2 -0
  57. package/lib/__tests__/rpc.unit.test.d.ts.map +1 -0
  58. package/lib/__tests__/rpc.unit.test.js +444 -0
  59. package/lib/__tests__/rpc.unit.test.js.map +1 -0
  60. package/lib/__tests__/signOperation.unit.test.d.ts +2 -0
  61. package/lib/__tests__/signOperation.unit.test.d.ts.map +1 -0
  62. package/lib/__tests__/signOperation.unit.test.js +160 -0
  63. package/lib/__tests__/signOperation.unit.test.js.map +1 -0
  64. package/lib/__tests__/synchronization.unit.test.d.ts +2 -0
  65. package/lib/__tests__/synchronization.unit.test.d.ts.map +1 -0
  66. package/lib/__tests__/synchronization.unit.test.js +499 -0
  67. package/lib/__tests__/synchronization.unit.test.js.map +1 -0
  68. package/lib/__tests__/transaction.unit.test.d.ts +2 -0
  69. package/lib/__tests__/transaction.unit.test.d.ts.map +1 -0
  70. package/lib/__tests__/transaction.unit.test.js +201 -0
  71. package/lib/__tests__/transaction.unit.test.js.map +1 -0
  72. package/lib/abis/erc20.abi.json +222 -0
  73. package/lib/abis/optimismGasPriceOracle.abi.json +252 -0
  74. package/lib/adapters.d.ts +21 -0
  75. package/lib/adapters.d.ts.map +1 -0
  76. package/lib/adapters.js +118 -0
  77. package/lib/adapters.js.map +1 -0
  78. package/lib/api/explorer/etherscan.d.ts +24 -0
  79. package/lib/api/explorer/etherscan.d.ts.map +1 -0
  80. package/lib/api/explorer/etherscan.js +90 -0
  81. package/lib/api/explorer/etherscan.js.map +1 -0
  82. package/lib/api/explorer/index.d.ts +26 -0
  83. package/lib/api/explorer/index.d.ts.map +1 -0
  84. package/lib/api/explorer/index.js +23 -0
  85. package/lib/api/explorer/index.js.map +1 -0
  86. package/lib/api/gasTracker/index.d.ts +13 -0
  87. package/lib/api/gasTracker/index.d.ts.map +1 -0
  88. package/lib/api/gasTracker/index.js +21 -0
  89. package/lib/api/gasTracker/index.js.map +1 -0
  90. package/lib/api/gasTracker/ledger.d.ts +9 -0
  91. package/lib/api/gasTracker/ledger.d.ts.map +1 -0
  92. package/lib/api/gasTracker/ledger.js +90 -0
  93. package/lib/api/gasTracker/ledger.js.map +1 -0
  94. package/lib/api/rpc/index.d.ts +3 -0
  95. package/lib/api/rpc/index.d.ts.map +1 -0
  96. package/lib/api/rpc/index.js +32 -0
  97. package/lib/api/rpc/index.js.map +1 -0
  98. package/lib/api/rpc/rpc.common.d.ts +93 -0
  99. package/lib/api/rpc/rpc.common.d.ts.map +1 -0
  100. package/lib/api/rpc/rpc.common.js +284 -0
  101. package/lib/api/rpc/rpc.common.js.map +1 -0
  102. package/lib/api/rpc/rpc.native.d.ts +6 -0
  103. package/lib/api/rpc/rpc.native.d.ts.map +1 -0
  104. package/lib/api/rpc/rpc.native.js +35 -0
  105. package/lib/api/rpc/rpc.native.js.map +1 -0
  106. package/lib/bridge/js.d.ts +11 -0
  107. package/lib/bridge/js.d.ts.map +1 -0
  108. package/lib/bridge/js.js +58 -0
  109. package/lib/bridge/js.js.map +1 -0
  110. package/lib/bridge.integration.test.d.ts +14 -0
  111. package/lib/bridge.integration.test.d.ts.map +1 -0
  112. package/lib/bridge.integration.test.js +85 -0
  113. package/lib/bridge.integration.test.js.map +1 -0
  114. package/lib/broadcast.d.ts +8 -0
  115. package/lib/broadcast.d.ts.map +1 -0
  116. package/lib/broadcast.js +25 -0
  117. package/lib/broadcast.js.map +1 -0
  118. package/lib/buildOptimisticOperation.d.ts +16 -0
  119. package/lib/buildOptimisticOperation.d.ts.map +1 -0
  120. package/lib/buildOptimisticOperation.js +80 -0
  121. package/lib/buildOptimisticOperation.js.map +1 -0
  122. package/lib/cli-transaction.d.ts +2 -0
  123. package/lib/cli-transaction.d.ts.map +1 -0
  124. package/lib/cli-transaction.js +9 -0
  125. package/lib/cli-transaction.js.map +1 -0
  126. package/lib/createTransaction.d.ts +9 -0
  127. package/lib/createTransaction.d.ts.map +1 -0
  128. package/lib/createTransaction.js +32 -0
  129. package/lib/createTransaction.js.map +1 -0
  130. package/lib/datasets/ethereum.scanAccounts.1.d.ts +7 -0
  131. package/lib/datasets/ethereum.scanAccounts.1.d.ts.map +1 -0
  132. package/lib/datasets/ethereum.scanAccounts.1.js +51 -0
  133. package/lib/datasets/ethereum.scanAccounts.1.js.map +1 -0
  134. package/lib/datasets/ethereum1.d.ts +3 -0
  135. package/lib/datasets/ethereum1.d.ts.map +1 -0
  136. package/lib/datasets/ethereum1.js +22 -0
  137. package/lib/datasets/ethereum1.js.map +1 -0
  138. package/lib/datasets/ethereum2.d.ts +3 -0
  139. package/lib/datasets/ethereum2.d.ts.map +1 -0
  140. package/lib/datasets/ethereum2.js +22 -0
  141. package/lib/datasets/ethereum2.js.map +1 -0
  142. package/lib/datasets/ethereum_classic.d.ts +5 -0
  143. package/lib/datasets/ethereum_classic.d.ts.map +1 -0
  144. package/lib/datasets/ethereum_classic.js +69 -0
  145. package/lib/datasets/ethereum_classic.js.map +1 -0
  146. package/lib/deviceTransactionConfig.d.ts +15 -0
  147. package/lib/deviceTransactionConfig.d.ts.map +1 -0
  148. package/lib/deviceTransactionConfig.js +44 -0
  149. package/lib/deviceTransactionConfig.js.map +1 -0
  150. package/lib/errors.d.ts +16 -0
  151. package/lib/errors.d.ts.map +1 -0
  152. package/lib/errors.js +11 -0
  153. package/lib/errors.js.map +1 -0
  154. package/lib/estimateMaxSpendable.d.ts +4 -0
  155. package/lib/estimateMaxSpendable.d.ts.map +1 -0
  156. package/lib/estimateMaxSpendable.js +23 -0
  157. package/lib/estimateMaxSpendable.js.map +1 -0
  158. package/lib/getTransactionStatus.d.ts +23 -0
  159. package/lib/getTransactionStatus.d.ts.map +1 -0
  160. package/lib/getTransactionStatus.js +132 -0
  161. package/lib/getTransactionStatus.js.map +1 -0
  162. package/lib/hw-getAddress.d.ts +6 -0
  163. package/lib/hw-getAddress.d.ts.map +1 -0
  164. package/lib/hw-getAddress.js +28 -0
  165. package/lib/hw-getAddress.js.map +1 -0
  166. package/lib/logic.d.ts +31 -0
  167. package/lib/logic.d.ts.map +1 -0
  168. package/lib/logic.js +131 -0
  169. package/lib/logic.js.map +1 -0
  170. package/lib/preload.d.ts +6 -0
  171. package/lib/preload.d.ts.map +1 -0
  172. package/lib/preload.js +58 -0
  173. package/lib/preload.js.map +1 -0
  174. package/lib/prepareTransaction.d.ts +26 -0
  175. package/lib/prepareTransaction.d.ts.map +1 -0
  176. package/lib/prepareTransaction.js +128 -0
  177. package/lib/prepareTransaction.js.map +1 -0
  178. package/lib/signOperation.d.ts +18 -0
  179. package/lib/signOperation.d.ts.map +1 -0
  180. package/lib/signOperation.js +88 -0
  181. package/lib/signOperation.js.map +1 -0
  182. package/lib/signer.d.ts +27 -0
  183. package/lib/signer.d.ts.map +1 -0
  184. package/lib/signer.js +3 -0
  185. package/lib/signer.js.map +1 -0
  186. package/lib/specs.d.ts +3 -0
  187. package/lib/specs.d.ts.map +1 -0
  188. package/lib/specs.js +238 -0
  189. package/lib/specs.js.map +1 -0
  190. package/lib/speculos-deviceActions.d.ts +8 -0
  191. package/lib/speculos-deviceActions.d.ts.map +1 -0
  192. package/lib/speculos-deviceActions.js +66 -0
  193. package/lib/speculos-deviceActions.js.map +1 -0
  194. package/lib/synchronization.d.ts +27 -0
  195. package/lib/synchronization.d.ts.map +1 -0
  196. package/lib/synchronization.js +220 -0
  197. package/lib/synchronization.js.map +1 -0
  198. package/lib/testUtils.d.ts +6 -0
  199. package/lib/testUtils.d.ts.map +1 -0
  200. package/lib/testUtils.js +111 -0
  201. package/lib/testUtils.js.map +1 -0
  202. package/lib/transaction.d.ts +43 -0
  203. package/lib/transaction.d.ts.map +1 -0
  204. package/lib/transaction.js +124 -0
  205. package/lib/transaction.js.map +1 -0
  206. package/lib/types.d.ts +111 -0
  207. package/lib/types.d.ts.map +1 -0
  208. package/lib/types.js +3 -0
  209. package/lib/types.js.map +1 -0
  210. package/lib-es/__tests__/adapters.unit.test.d.ts +2 -0
  211. package/lib-es/__tests__/adapters.unit.test.d.ts.map +1 -0
  212. package/lib-es/__tests__/adapters.unit.test.js +450 -0
  213. package/lib-es/__tests__/adapters.unit.test.js.map +1 -0
  214. package/lib-es/__tests__/broadcast.unit.test.d.ts +2 -0
  215. package/lib-es/__tests__/broadcast.unit.test.d.ts.map +1 -0
  216. package/lib-es/__tests__/broadcast.unit.test.js +153 -0
  217. package/lib-es/__tests__/broadcast.unit.test.js.map +1 -0
  218. package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts +2 -0
  219. package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts.map +1 -0
  220. package/lib-es/__tests__/buildOptimisticOperation.unit.test.js +161 -0
  221. package/lib-es/__tests__/buildOptimisticOperation.unit.test.js.map +1 -0
  222. package/lib-es/__tests__/createTransaction.unit.test.d.ts +2 -0
  223. package/lib-es/__tests__/createTransaction.unit.test.d.ts.map +1 -0
  224. package/lib-es/__tests__/createTransaction.unit.test.js +45 -0
  225. package/lib-es/__tests__/createTransaction.unit.test.js.map +1 -0
  226. package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts +2 -0
  227. package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  228. package/lib-es/__tests__/deviceTransactionConfig.unit.test.js +226 -0
  229. package/lib-es/__tests__/deviceTransactionConfig.unit.test.js.map +1 -0
  230. package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts +2 -0
  231. package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  232. package/lib-es/__tests__/estimateMaxSpendable.unit.test.js +117 -0
  233. package/lib-es/__tests__/estimateMaxSpendable.unit.test.js.map +1 -0
  234. package/lib-es/__tests__/gasTracker/index.unit.test.d.ts +2 -0
  235. package/lib-es/__tests__/gasTracker/index.unit.test.d.ts.map +1 -0
  236. package/lib-es/__tests__/gasTracker/index.unit.test.js +33 -0
  237. package/lib-es/__tests__/gasTracker/index.unit.test.js.map +1 -0
  238. package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts +2 -0
  239. package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts.map +1 -0
  240. package/lib-es/__tests__/gasTracker/ledger.unit.test.js +105 -0
  241. package/lib-es/__tests__/gasTracker/ledger.unit.test.js.map +1 -0
  242. package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts +2 -0
  243. package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts.map +1 -0
  244. package/lib-es/__tests__/getTransactionStatus.unit.test.js +211 -0
  245. package/lib-es/__tests__/getTransactionStatus.unit.test.js.map +1 -0
  246. package/lib-es/__tests__/hw-getAddress.unit.test.d.ts +2 -0
  247. package/lib-es/__tests__/hw-getAddress.unit.test.d.ts.map +1 -0
  248. package/lib-es/__tests__/hw-getAddress.unit.test.js +42 -0
  249. package/lib-es/__tests__/hw-getAddress.unit.test.js.map +1 -0
  250. package/lib-es/__tests__/logic.unit.test.d.ts +2 -0
  251. package/lib-es/__tests__/logic.unit.test.d.ts.map +1 -0
  252. package/lib-es/__tests__/logic.unit.test.js +268 -0
  253. package/lib-es/__tests__/logic.unit.test.js.map +1 -0
  254. package/lib-es/__tests__/preload.unit.test.d.ts +2 -0
  255. package/lib-es/__tests__/preload.unit.test.d.ts.map +1 -0
  256. package/lib-es/__tests__/preload.unit.test.js +121 -0
  257. package/lib-es/__tests__/preload.unit.test.js.map +1 -0
  258. package/lib-es/__tests__/prepareTransaction.unit.test.d.ts +2 -0
  259. package/lib-es/__tests__/prepareTransaction.unit.test.d.ts.map +1 -0
  260. package/lib-es/__tests__/prepareTransaction.unit.test.js +220 -0
  261. package/lib-es/__tests__/prepareTransaction.unit.test.js.map +1 -0
  262. package/lib-es/__tests__/rpc.unit.test.d.ts +2 -0
  263. package/lib-es/__tests__/rpc.unit.test.d.ts.map +1 -0
  264. package/lib-es/__tests__/rpc.unit.test.js +416 -0
  265. package/lib-es/__tests__/rpc.unit.test.js.map +1 -0
  266. package/lib-es/__tests__/signOperation.unit.test.d.ts +2 -0
  267. package/lib-es/__tests__/signOperation.unit.test.d.ts.map +1 -0
  268. package/lib-es/__tests__/signOperation.unit.test.js +132 -0
  269. package/lib-es/__tests__/signOperation.unit.test.js.map +1 -0
  270. package/lib-es/__tests__/synchronization.unit.test.d.ts +2 -0
  271. package/lib-es/__tests__/synchronization.unit.test.d.ts.map +1 -0
  272. package/lib-es/__tests__/synchronization.unit.test.js +471 -0
  273. package/lib-es/__tests__/synchronization.unit.test.js.map +1 -0
  274. package/lib-es/__tests__/transaction.unit.test.d.ts +2 -0
  275. package/lib-es/__tests__/transaction.unit.test.d.ts.map +1 -0
  276. package/lib-es/__tests__/transaction.unit.test.js +173 -0
  277. package/lib-es/__tests__/transaction.unit.test.js.map +1 -0
  278. package/lib-es/abis/erc20.abi.json +222 -0
  279. package/lib-es/abis/optimismGasPriceOracle.abi.json +252 -0
  280. package/lib-es/adapters.d.ts +21 -0
  281. package/lib-es/adapters.d.ts.map +1 -0
  282. package/lib-es/adapters.js +109 -0
  283. package/lib-es/adapters.js.map +1 -0
  284. package/lib-es/api/explorer/etherscan.d.ts +24 -0
  285. package/lib-es/api/explorer/etherscan.d.ts.map +1 -0
  286. package/lib-es/api/explorer/etherscan.js +84 -0
  287. package/lib-es/api/explorer/etherscan.js.map +1 -0
  288. package/lib-es/api/explorer/index.d.ts +26 -0
  289. package/lib-es/api/explorer/index.d.ts.map +1 -0
  290. package/lib-es/api/explorer/index.js +16 -0
  291. package/lib-es/api/explorer/index.js.map +1 -0
  292. package/lib-es/api/gasTracker/index.d.ts +13 -0
  293. package/lib-es/api/gasTracker/index.d.ts.map +1 -0
  294. package/lib-es/api/gasTracker/index.js +17 -0
  295. package/lib-es/api/gasTracker/index.js.map +1 -0
  296. package/lib-es/api/gasTracker/ledger.d.ts +9 -0
  297. package/lib-es/api/gasTracker/ledger.d.ts.map +1 -0
  298. package/lib-es/api/gasTracker/ledger.js +83 -0
  299. package/lib-es/api/gasTracker/ledger.js.map +1 -0
  300. package/lib-es/api/rpc/index.d.ts +3 -0
  301. package/lib-es/api/rpc/index.d.ts.map +1 -0
  302. package/lib-es/api/rpc/index.js +4 -0
  303. package/lib-es/api/rpc/index.js.map +1 -0
  304. package/lib-es/api/rpc/rpc.common.d.ts +93 -0
  305. package/lib-es/api/rpc/rpc.common.d.ts.map +1 -0
  306. package/lib-es/api/rpc/rpc.common.js +267 -0
  307. package/lib-es/api/rpc/rpc.common.js.map +1 -0
  308. package/lib-es/api/rpc/rpc.native.d.ts +6 -0
  309. package/lib-es/api/rpc/rpc.native.d.ts.map +1 -0
  310. package/lib-es/api/rpc/rpc.native.js +7 -0
  311. package/lib-es/api/rpc/rpc.native.js.map +1 -0
  312. package/lib-es/bridge/js.d.ts +11 -0
  313. package/lib-es/bridge/js.d.ts.map +1 -0
  314. package/lib-es/bridge/js.js +49 -0
  315. package/lib-es/bridge/js.js.map +1 -0
  316. package/lib-es/bridge.integration.test.d.ts +14 -0
  317. package/lib-es/bridge.integration.test.d.ts.map +1 -0
  318. package/lib-es/bridge.integration.test.js +79 -0
  319. package/lib-es/bridge.integration.test.js.map +1 -0
  320. package/lib-es/broadcast.d.ts +8 -0
  321. package/lib-es/broadcast.d.ts.map +1 -0
  322. package/lib-es/broadcast.js +21 -0
  323. package/lib-es/broadcast.js.map +1 -0
  324. package/lib-es/buildOptimisticOperation.d.ts +16 -0
  325. package/lib-es/buildOptimisticOperation.d.ts.map +1 -0
  326. package/lib-es/buildOptimisticOperation.js +71 -0
  327. package/lib-es/buildOptimisticOperation.js.map +1 -0
  328. package/lib-es/cli-transaction.d.ts +2 -0
  329. package/lib-es/cli-transaction.d.ts.map +1 -0
  330. package/lib-es/cli-transaction.js +6 -0
  331. package/lib-es/cli-transaction.js.map +1 -0
  332. package/lib-es/createTransaction.d.ts +9 -0
  333. package/lib-es/createTransaction.d.ts.map +1 -0
  334. package/lib-es/createTransaction.js +25 -0
  335. package/lib-es/createTransaction.js.map +1 -0
  336. package/lib-es/datasets/ethereum.scanAccounts.1.d.ts +7 -0
  337. package/lib-es/datasets/ethereum.scanAccounts.1.d.ts.map +1 -0
  338. package/lib-es/datasets/ethereum.scanAccounts.1.js +49 -0
  339. package/lib-es/datasets/ethereum.scanAccounts.1.js.map +1 -0
  340. package/lib-es/datasets/ethereum1.d.ts +3 -0
  341. package/lib-es/datasets/ethereum1.d.ts.map +1 -0
  342. package/lib-es/datasets/ethereum1.js +19 -0
  343. package/lib-es/datasets/ethereum1.js.map +1 -0
  344. package/lib-es/datasets/ethereum2.d.ts +3 -0
  345. package/lib-es/datasets/ethereum2.d.ts.map +1 -0
  346. package/lib-es/datasets/ethereum2.js +19 -0
  347. package/lib-es/datasets/ethereum2.js.map +1 -0
  348. package/lib-es/datasets/ethereum_classic.d.ts +5 -0
  349. package/lib-es/datasets/ethereum_classic.d.ts.map +1 -0
  350. package/lib-es/datasets/ethereum_classic.js +67 -0
  351. package/lib-es/datasets/ethereum_classic.js.map +1 -0
  352. package/lib-es/deviceTransactionConfig.d.ts +15 -0
  353. package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
  354. package/lib-es/deviceTransactionConfig.js +42 -0
  355. package/lib-es/deviceTransactionConfig.js.map +1 -0
  356. package/lib-es/errors.d.ts +16 -0
  357. package/lib-es/errors.d.ts.map +1 -0
  358. package/lib-es/errors.js +8 -0
  359. package/lib-es/errors.js.map +1 -0
  360. package/lib-es/estimateMaxSpendable.d.ts +4 -0
  361. package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
  362. package/lib-es/estimateMaxSpendable.js +19 -0
  363. package/lib-es/estimateMaxSpendable.js.map +1 -0
  364. package/lib-es/getTransactionStatus.d.ts +23 -0
  365. package/lib-es/getTransactionStatus.d.ts.map +1 -0
  366. package/lib-es/getTransactionStatus.js +125 -0
  367. package/lib-es/getTransactionStatus.js.map +1 -0
  368. package/lib-es/hw-getAddress.d.ts +6 -0
  369. package/lib-es/hw-getAddress.d.ts.map +1 -0
  370. package/lib-es/hw-getAddress.js +23 -0
  371. package/lib-es/hw-getAddress.js.map +1 -0
  372. package/lib-es/logic.d.ts +31 -0
  373. package/lib-es/logic.d.ts.map +1 -0
  374. package/lib-es/logic.js +119 -0
  375. package/lib-es/logic.js.map +1 -0
  376. package/lib-es/preload.d.ts +6 -0
  377. package/lib-es/preload.d.ts.map +1 -0
  378. package/lib-es/preload.js +49 -0
  379. package/lib-es/preload.js.map +1 -0
  380. package/lib-es/prepareTransaction.d.ts +26 -0
  381. package/lib-es/prepareTransaction.d.ts.map +1 -0
  382. package/lib-es/prepareTransaction.js +118 -0
  383. package/lib-es/prepareTransaction.js.map +1 -0
  384. package/lib-es/signOperation.d.ts +18 -0
  385. package/lib-es/signOperation.d.ts.map +1 -0
  386. package/lib-es/signOperation.js +83 -0
  387. package/lib-es/signOperation.js.map +1 -0
  388. package/lib-es/signer.d.ts +27 -0
  389. package/lib-es/signer.d.ts.map +1 -0
  390. package/lib-es/signer.js +2 -0
  391. package/lib-es/signer.js.map +1 -0
  392. package/lib-es/specs.d.ts +3 -0
  393. package/lib-es/specs.d.ts.map +1 -0
  394. package/lib-es/specs.js +233 -0
  395. package/lib-es/specs.js.map +1 -0
  396. package/lib-es/speculos-deviceActions.d.ts +8 -0
  397. package/lib-es/speculos-deviceActions.d.ts.map +1 -0
  398. package/lib-es/speculos-deviceActions.js +63 -0
  399. package/lib-es/speculos-deviceActions.js.map +1 -0
  400. package/lib-es/synchronization.d.ts +27 -0
  401. package/lib-es/synchronization.d.ts.map +1 -0
  402. package/lib-es/synchronization.js +212 -0
  403. package/lib-es/synchronization.js.map +1 -0
  404. package/lib-es/testUtils.d.ts +6 -0
  405. package/lib-es/testUtils.d.ts.map +1 -0
  406. package/lib-es/testUtils.js +102 -0
  407. package/lib-es/testUtils.js.map +1 -0
  408. package/lib-es/transaction.d.ts +43 -0
  409. package/lib-es/transaction.d.ts.map +1 -0
  410. package/lib-es/transaction.js +112 -0
  411. package/lib-es/transaction.js.map +1 -0
  412. package/lib-es/types.d.ts +111 -0
  413. package/lib-es/types.d.ts.map +1 -0
  414. package/lib-es/types.js +2 -0
  415. package/lib-es/types.js.map +1 -0
  416. package/package.json +8 -23
  417. package/src/__tests__/adapters.unit.test.ts +22 -52
  418. package/src/__tests__/broadcast.unit.test.ts +9 -27
  419. package/src/__tests__/buildOptimisticOperation.unit.test.ts +4 -4
  420. package/src/__tests__/deviceTransactionConfig.unit.test.ts +7 -7
  421. package/src/__tests__/estimateMaxSpendable.unit.test.ts +2 -4
  422. package/src/__tests__/gasTracker/index.unit.test.ts +36 -0
  423. package/src/__tests__/gasTracker/ledger.unit.test.ts +108 -0
  424. package/src/__tests__/getTransactionStatus.unit.test.ts +35 -40
  425. package/src/__tests__/hw-getAddress.unit.test.ts +15 -2
  426. package/src/__tests__/logic.unit.test.ts +25 -72
  427. package/src/__tests__/preload.unit.test.ts +3 -9
  428. package/src/__tests__/prepareTransaction.unit.test.ts +131 -76
  429. package/src/__tests__/rpc.unit.test.ts +46 -80
  430. package/src/__tests__/signOperation.unit.test.ts +27 -25
  431. package/src/__tests__/synchronization.unit.test.ts +101 -153
  432. package/src/__tests__/transaction.unit.test.ts +6 -14
  433. package/src/adapters.ts +8 -18
  434. package/src/api/{etherscan.ts → explorer/etherscan.ts} +14 -29
  435. package/src/api/explorer/index.ts +34 -0
  436. package/src/api/gasTracker/index.ts +31 -0
  437. package/src/api/gasTracker/ledger.ts +103 -0
  438. package/src/api/{rpc.common.ts → rpc/rpc.common.ts} +41 -64
  439. package/src/bridge/js.ts +15 -22
  440. package/src/bridge.integration.test.ts +3 -10
  441. package/src/broadcast.ts +3 -7
  442. package/src/buildOptimisticOperation.ts +7 -17
  443. package/src/cli-transaction.ts +1 -7
  444. package/src/createTransaction.ts +14 -15
  445. package/src/deviceTransactionConfig.ts +1 -1
  446. package/src/errors.ts +6 -0
  447. package/src/estimateMaxSpendable.ts +14 -11
  448. package/src/getTransactionStatus.ts +41 -52
  449. package/src/hw-getAddress.ts +18 -19
  450. package/src/logic.ts +5 -15
  451. package/src/preload.ts +6 -16
  452. package/src/prepareTransaction.ts +30 -31
  453. package/src/signOperation.ts +57 -69
  454. package/src/signer.ts +35 -0
  455. package/src/specs.ts +27 -52
  456. package/src/speculos-deviceActions.ts +56 -65
  457. package/src/synchronization.ts +21 -60
  458. package/src/testUtils.ts +5 -19
  459. package/src/transaction.ts +6 -10
  460. package/src/types.ts +6 -0
  461. /package/src/api/{rpc.ts → rpc/index.ts} +0 -0
  462. /package/src/api/{rpc.native.ts → rpc/rpc.native.ts} +0 -0
@@ -1,11 +1,7 @@
1
1
  import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
2
2
  import { Account, TokenAccount } from "@ledgerhq/types-live";
3
3
  import BigNumber from "bignumber.js";
4
- import {
5
- getFeesEstimation,
6
- getGasEstimation,
7
- getTransactionCount,
8
- } from "./api/rpc";
4
+ import { getFeesEstimation, getGasEstimation, getTransactionCount } from "./api/rpc";
9
5
  import { validateRecipient } from "./getTransactionStatus";
10
6
  import { getAdditionalLayer2Fees, getEstimatedFees } from "./logic";
11
7
  import { getTransactionData, getTypedTransaction } from "./transaction";
@@ -18,7 +14,7 @@ import { Transaction as EvmTransaction } from "./types";
18
14
  */
19
15
  export const prepareCoinTransaction = async (
20
16
  account: Account,
21
- typedTransaction: EvmTransaction
17
+ typedTransaction: EvmTransaction,
22
18
  ): Promise<EvmTransaction> => {
23
19
  // A `useAllAmount` transaction is a specific case of the live, and because we're in the
24
20
  // context of a coinTransaction, no smart contract should be involed
@@ -36,13 +32,10 @@ export const prepareCoinTransaction = async (
36
32
  gasLimit,
37
33
  };
38
34
  const estimatedFees = getEstimatedFees(draftTransaction);
39
- const additionalFees = await getAdditionalLayer2Fees(
40
- account.currency,
41
- draftTransaction
42
- );
35
+ const additionalFees = await getAdditionalLayer2Fees(account.currency, draftTransaction);
43
36
  const amount = BigNumber.max(
44
37
  account.balance.minus(estimatedFees).minus(additionalFees || 0),
45
- 0
38
+ 0,
46
39
  );
47
40
 
48
41
  return {
@@ -58,7 +51,7 @@ export const prepareCoinTransaction = async (
58
51
  // E.g. A DApp is creating an invalid transaction, swaping more Tokens than the user actually have -> fail
59
52
  // This value of 0 should be catched by `getTransactionStatus`
60
53
  // and displayed in the UI as `set the gas manually`
61
- () => new BigNumber(0)
54
+ () => new BigNumber(0),
62
55
  );
63
56
  const additionalFees = await getAdditionalLayer2Fees(account.currency, {
64
57
  ...typedTransaction,
@@ -79,12 +72,10 @@ export const prepareCoinTransaction = async (
79
72
  export const prepareTokenTransaction = async (
80
73
  account: Account,
81
74
  tokenAccount: TokenAccount,
82
- typedTransaction: EvmTransaction
75
+ typedTransaction: EvmTransaction,
83
76
  ): Promise<EvmTransaction> => {
84
77
  const [recipientErrors] = validateRecipient(account, typedTransaction);
85
- const amount = typedTransaction.useAllAmount
86
- ? tokenAccount.balance
87
- : typedTransaction.amount;
78
+ const amount = typedTransaction.useAllAmount ? tokenAccount.balance : typedTransaction.amount;
88
79
  const data = !Object.keys(recipientErrors).length
89
80
  ? getTransactionData({ ...typedTransaction, amount })
90
81
  : undefined;
@@ -123,15 +114,29 @@ export const prepareTokenTransaction = async (
123
114
  */
124
115
  export const prepareTransaction = async (
125
116
  account: Account,
126
- transaction: EvmTransaction
117
+ transaction: EvmTransaction,
127
118
  ): Promise<EvmTransaction> => {
128
119
  const { currency } = account;
129
120
  // Get the current network status fees
130
- const feeData = await getFeesEstimation(currency);
131
- const subAccount = findSubAccountById(
132
- account,
133
- transaction.subAccountId || ""
134
- );
121
+ const feeData = await (async () => {
122
+ if (transaction.feesStrategy === "custom") {
123
+ return {
124
+ gasPrice: transaction.gasPrice ?? null,
125
+ maxFeePerGas: transaction.maxFeePerGas ?? null,
126
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ?? null,
127
+ };
128
+ }
129
+
130
+ if (!transaction.feesStrategy) {
131
+ return getFeesEstimation(currency);
132
+ }
133
+
134
+ const gasOption = transaction.gasOptions?.[transaction.feesStrategy];
135
+
136
+ return gasOption ?? getFeesEstimation(currency);
137
+ })();
138
+
139
+ const subAccount = findSubAccountById(account, transaction.subAccountId || "");
135
140
  const isTokenTransaction = subAccount?.type === "TokenAccount";
136
141
  const typedTransaction = getTypedTransaction(transaction, feeData);
137
142
 
@@ -148,17 +153,11 @@ export const prepareTransaction = async (
148
153
  */
149
154
  export const prepareForSignOperation = async (
150
155
  account: Account,
151
- transaction: EvmTransaction
156
+ transaction: EvmTransaction,
152
157
  ): Promise<EvmTransaction> => {
153
- const nonce = await getTransactionCount(
154
- account.currency,
155
- account.freshAddress
156
- );
158
+ const nonce = await getTransactionCount(account.currency, account.freshAddress);
157
159
 
158
- const subAccount = findSubAccountById(
159
- account,
160
- transaction.subAccountId || ""
161
- );
160
+ const subAccount = findSubAccountById(account, transaction.subAccountId || "");
162
161
  const isTokenTransaction = subAccount?.type === "TokenAccount";
163
162
 
164
163
  return isTokenTransaction
@@ -1,16 +1,18 @@
1
1
  import { Observable } from "rxjs";
2
- import Eth, { ledgerService } from "@ledgerhq/hw-app-eth";
3
2
  import {
4
3
  Account,
5
4
  SignOperationFnSignature,
6
5
  SignOperationEvent,
6
+ DeviceId,
7
7
  } from "@ledgerhq/types-live";
8
+ import { ledgerService } from "@ledgerhq/hw-app-eth";
8
9
  import { ResolutionConfig } from "@ledgerhq/hw-app-eth/lib/services/types";
10
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
9
11
  import { buildOptimisticOperation } from "./buildOptimisticOperation";
10
12
  import { prepareForSignOperation } from "./prepareTransaction";
11
13
  import { getSerializedTransaction } from "./transaction";
12
14
  import { Transaction } from "./types";
13
- import { DeviceCommunication } from "@ledgerhq/coin-framework/bridge/jsHelpers";
15
+ import { EvmAddress, EvmSignature, EvmSigner } from "./signer";
14
16
 
15
17
  /**
16
18
  * Transforms the ECDSA signature paremeter v hexadecimal string received
@@ -42,86 +44,72 @@ export const applyEIP155 = (vAsHex: string, chainId: number): number => {
42
44
  * Sign Transaction with Ledger hardware
43
45
  */
44
46
  export const buildSignOperation =
45
- (withDevice: DeviceCommunication): SignOperationFnSignature<Transaction> =>
47
+ (
48
+ signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>,
49
+ ): SignOperationFnSignature<Transaction> =>
46
50
  ({
47
51
  account,
48
52
  deviceId,
49
53
  transaction,
50
54
  }: {
51
55
  account: Account;
52
- deviceId: any;
56
+ deviceId: DeviceId;
53
57
  transaction: Transaction;
54
58
  }): Observable<SignOperationEvent> =>
55
- withDevice(deviceId)(
56
- (transport) =>
57
- new Observable((o) => {
58
- async function main() {
59
- const preparedTransaction = await prepareForSignOperation(
60
- account,
61
- transaction
62
- );
63
- const serializedTxHexString =
64
- getSerializedTransaction(preparedTransaction).slice(2); // Remove 0x prefix
59
+ new Observable(o => {
60
+ async function main() {
61
+ const preparedTransaction = await prepareForSignOperation(account, transaction);
62
+ const serializedTxHexString = getSerializedTransaction(preparedTransaction).slice(2); // Remove 0x prefix
65
63
 
66
- // Configure type of resolutions necessary for the clear signing
67
- const resolutionConfig: ResolutionConfig = {
68
- externalPlugins: true,
69
- erc20: true,
70
- domains: transaction.recipientDomain
71
- ? [transaction.recipientDomain]
72
- : [],
73
- };
74
- // Look for resolutions for external plugins and ERC20
75
- const resolution = await ledgerService.resolveTransaction(
76
- serializedTxHexString,
77
- {},
78
- resolutionConfig
79
- );
64
+ // Configure type of resolutions necessary for the clear signing
65
+ const resolutionConfig: ResolutionConfig = {
66
+ externalPlugins: true,
67
+ erc20: true,
68
+ domains: transaction.recipientDomain ? [transaction.recipientDomain] : [],
69
+ };
70
+ // Look for resolutions for external plugins and ERC20
71
+ const resolution = await ledgerService.resolveTransaction(
72
+ serializedTxHexString,
73
+ {},
74
+ resolutionConfig,
75
+ );
80
76
 
81
- o.next({
82
- type: "device-signature-requested",
83
- });
77
+ o.next({
78
+ type: "device-signature-requested",
79
+ });
84
80
 
85
- // Instanciate Eth app bindings
86
- const eth = new Eth(transport);
87
- // Request signature on the nano
88
- const sig = await eth.signTransaction(
89
- account.freshAddressPath,
90
- serializedTxHexString,
91
- resolution
92
- );
81
+ const sig = (await signerContext(deviceId, signer =>
82
+ // Request signature on the nano
83
+ signer.signTransaction(account.freshAddressPath, serializedTxHexString, resolution),
84
+ )) as EvmSignature;
93
85
 
94
- o.next({ type: "device-signature-granted" }); // Signature is done
86
+ o.next({ type: "device-signature-granted" }); // Signature is done
95
87
 
96
- const { chainId = 0 } = account.currency.ethereumLikeInfo || {};
97
- // Create a new serialized tx with the signature now
98
- const signature = await getSerializedTransaction(
99
- preparedTransaction,
100
- {
101
- r: "0x" + sig.r,
102
- s: "0x" + sig.s,
103
- v: applyEIP155(sig.v, chainId),
104
- }
105
- );
88
+ const { chainId = 0 } = account.currency.ethereumLikeInfo || {};
89
+ // Create a new serialized tx with the signature now
90
+ const signature = await getSerializedTransaction(preparedTransaction, {
91
+ r: "0x" + sig.r,
92
+ s: "0x" + sig.s,
93
+ v: applyEIP155(sig.v, chainId),
94
+ });
106
95
 
107
- const operation = buildOptimisticOperation(account, {
108
- ...transaction,
109
- nonce: preparedTransaction.nonce,
110
- });
96
+ const operation = buildOptimisticOperation(account, {
97
+ ...transaction,
98
+ nonce: preparedTransaction.nonce,
99
+ });
111
100
 
112
- o.next({
113
- type: "signed",
114
- signedOperation: {
115
- operation,
116
- signature,
117
- expirationDate: null,
118
- },
119
- });
120
- }
101
+ o.next({
102
+ type: "signed",
103
+ signedOperation: {
104
+ operation,
105
+ signature,
106
+ expirationDate: null,
107
+ },
108
+ });
109
+ }
121
110
 
122
- main().then(
123
- () => o.complete(),
124
- (e) => o.error(e)
125
- );
126
- })
127
- );
111
+ main().then(
112
+ () => o.complete(),
113
+ e => o.error(e),
114
+ );
115
+ });
package/src/signer.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { DomainServiceResolution } from "@ledgerhq/domain-service/types";
2
+
3
+ export type EvmAddress = {
4
+ publicKey: string;
5
+ address: string;
6
+ chainCode?: string;
7
+ };
8
+ export type EvmSignature = {
9
+ s: string;
10
+ v: string;
11
+ r: string;
12
+ };
13
+
14
+ // Duplicate type definition from hw-app-eth.
15
+ type LedgerEthTransactionResolution = {
16
+ // device serialized data that contains ERC20 data (hex format)
17
+ erc20Tokens: Array<string>;
18
+ // device serialized data that contains NFT data (hex format)
19
+ nfts: Array<string>;
20
+ // device serialized data that contains external plugin data (hex format)
21
+ externalPlugin: Array<{ payload: string; signature: string }>;
22
+ // device serialized data that contains plugin data (hex format)
23
+ plugin: Array<string>;
24
+ // device serialized data that contain trusted names data (hex format)
25
+ domains: DomainServiceResolution[];
26
+ };
27
+
28
+ export interface EvmSigner {
29
+ getAddress(path: string, boolDisplay?: boolean, boolChaincode?: boolean): Promise<EvmAddress>;
30
+ signTransaction(
31
+ path: string,
32
+ rawTxHex: string,
33
+ resolution?: LedgerEthTransactionResolution | null,
34
+ ): Promise<EvmSignature>;
35
+ }
package/src/specs.ts CHANGED
@@ -2,18 +2,11 @@ import expect from "expect";
2
2
  import invariant from "invariant";
3
3
  import sample from "lodash/sample";
4
4
  import BigNumber from "bignumber.js";
5
- import {
6
- MutationSpec,
7
- TransactionDestinationTestInput,
8
- } from "@ledgerhq/coin-framework/bot/types";
5
+ import { MutationSpec, TransactionDestinationTestInput } from "@ledgerhq/coin-framework/bot/types";
9
6
  import { DeviceModelId } from "@ledgerhq/devices";
10
7
  import { CryptoCurrencyIds } from "@ledgerhq/types-live";
11
8
  import { cryptocurrenciesById } from "@ledgerhq/cryptoassets/currencies";
12
- import {
13
- botTest,
14
- genericTestDestination,
15
- pickSiblings,
16
- } from "@ledgerhq/coin-framework/bot/specs";
9
+ import { botTest, genericTestDestination, pickSiblings } from "@ledgerhq/coin-framework/bot/specs";
17
10
  import {
18
11
  getCryptoCurrencyById,
19
12
  parseCurrencyUnit,
@@ -43,9 +36,7 @@ const minBalancePerCurrencyId: Record<CryptoCurrencyIds, BigNumber> = {
43
36
  *
44
37
  * ⚠️ Some blockchains specific rules are included
45
38
  */
46
- const testCoinDestination = (
47
- args: TransactionDestinationTestInput<EvmTransaction>
48
- ) => {
39
+ const testCoinDestination = (args: TransactionDestinationTestInput<EvmTransaction>) => {
49
40
  const { sendingAccount } = args;
50
41
  const { currency } = sendingAccount;
51
42
 
@@ -83,17 +74,14 @@ const testCoinBalance: MutationSpec<EvmTransaction>["test"] = ({
83
74
  // value + gasLimit * gasPrice <-- gasPrice can be wrong here.
84
75
  const underValuedFeesCurrencies = ["optimism", "optimism_goerli"];
85
76
  const overValuedFeesCurrencies = ["arbitrum", "arbitrum_goerli"];
86
- const currenciesWithFlakyBehaviour = [
87
- ...underValuedFeesCurrencies,
88
- ...overValuedFeesCurrencies,
89
- ];
77
+ const currenciesWithFlakyBehaviour = [...underValuedFeesCurrencies, ...overValuedFeesCurrencies];
90
78
 
91
79
  // Classic test verifying exactly the balance
92
80
  if (!currenciesWithFlakyBehaviour.includes(account.currency.id)) {
93
81
  botTest("account balance moved with operation value", () =>
94
82
  expect(account.balance.toString()).toBe(
95
- accountBeforeTransaction.balance.minus(operation.value).toString()
96
- )
83
+ accountBeforeTransaction.balance.minus(operation.value).toString(),
84
+ ),
97
85
  );
98
86
  } else {
99
87
  // fallback test verifying the balance moved between the maximum and minimum possible values of the operation
@@ -105,7 +93,7 @@ const testCoinBalance: MutationSpec<EvmTransaction>["test"] = ({
105
93
  // has lost *at least* the operation value + fee
106
94
  if (underValuedFeesCurrencies.includes(account.currency.id)) {
107
95
  const maxBalance = accountBeforeTransaction.balance.minus(
108
- operation.value.minus(operation.fee) // type OUT operations value includes fees so we remove it
96
+ operation.value.minus(operation.fee), // type OUT operations value includes fees so we remove it
109
97
  );
110
98
 
111
99
  expect({
@@ -121,10 +109,10 @@ const testCoinBalance: MutationSpec<EvmTransaction>["test"] = ({
121
109
  // previous balance minus operation value + fee
122
110
  if (overValuedFeesCurrencies.includes(account.currency.id)) {
123
111
  const minBalance = accountBeforeTransaction.balance.minus(
124
- operation.value // type OUT operations value includes fees
112
+ operation.value, // type OUT operations value includes fees
125
113
  );
126
114
  const maxBalance = accountBeforeTransaction.balance.minus(
127
- operation.value.minus(operation.fee)
115
+ operation.value.minus(operation.fee),
128
116
  );
129
117
 
130
118
  expect({
@@ -135,7 +123,7 @@ const testCoinBalance: MutationSpec<EvmTransaction>["test"] = ({
135
123
  lessThanMaxBalance: true,
136
124
  });
137
125
  }
138
- }
126
+ },
139
127
  );
140
128
  }
141
129
  };
@@ -146,10 +134,9 @@ const transactionCheck =
146
134
  const currency = getCryptoCurrencyById(currencyId);
147
135
  invariant(
148
136
  maxSpendable.gt(
149
- minBalancePerCurrencyId[currency.id] ||
150
- parseCurrencyUnit(currency.units[0], "1")
137
+ minBalancePerCurrencyId[currency.id] || parseCurrencyUnit(currency.units[0], "1"),
151
138
  ),
152
- `${currencyId} balance is too low`
139
+ `${currencyId} balance is too low`,
153
140
  );
154
141
  };
155
142
 
@@ -187,15 +174,13 @@ const evmBasicMutations: ({
187
174
  // workaround for buggy explorer behavior (nodes desync)
188
175
  invariant(
189
176
  Date.now() - operation.date.getTime() > 60000,
190
- "operation time to be older than 60s"
177
+ "operation time to be older than 60s",
191
178
  );
192
179
  const estimatedGas = transaction.gasLimit.times(
193
- transaction.gasPrice || transaction.maxFeePerGas || 0
180
+ transaction.gasPrice || transaction.maxFeePerGas || 0,
194
181
  );
195
182
  botTest("operation fee is not exceeding estimated gas", () =>
196
- expect(operation.fee.toNumber()).toBeLessThanOrEqual(
197
- estimatedGas.toNumber()
198
- )
183
+ expect(operation.fee.toNumber()).toBeLessThanOrEqual(estimatedGas.toNumber()),
199
184
  );
200
185
 
201
186
  testCoinBalance({
@@ -239,15 +224,13 @@ const evmBasicMutations: ({
239
224
  // workaround for buggy explorer behavior (nodes desync)
240
225
  invariant(
241
226
  Date.now() - operation.date.getTime() > 60000,
242
- "operation time to be older than 60s"
227
+ "operation time to be older than 60s",
243
228
  );
244
229
  const estimatedGas = transaction.gasLimit.times(
245
- transaction.gasPrice || transaction.maxFeePerGas || 0
230
+ transaction.gasPrice || transaction.maxFeePerGas || 0,
246
231
  );
247
232
  botTest("operation fee is not exceeding estimated gas", () =>
248
- expect(operation.fee.toNumber()).toBeLessThanOrEqual(
249
- estimatedGas.toNumber()
250
- )
233
+ expect(operation.fee.toNumber()).toBeLessThanOrEqual(estimatedGas.toNumber()),
251
234
  );
252
235
 
253
236
  testCoinBalance({
@@ -264,9 +247,7 @@ const evmBasicMutations: ({
264
247
  name: "move some ERC20",
265
248
  maxRun: 1,
266
249
  transaction: ({ account, siblings, bridge }) => {
267
- const erc20Account = sample(
268
- (account.subAccounts || []).filter((a) => a.balance.gt(0))
269
- );
250
+ const erc20Account = sample((account.subAccounts || []).filter(a => a.balance.gt(0)));
270
251
  invariant(erc20Account, "no erc20 account");
271
252
  const sibling = pickSiblings(siblings, 3);
272
253
  const recipient = sibling.freshAddress;
@@ -282,9 +263,7 @@ const evmBasicMutations: ({
282
263
  useAllAmount: true,
283
264
  }
284
265
  : {
285
- amount: erc20Account!.balance
286
- .times(Math.random())
287
- .integerValue(),
266
+ amount: erc20Account!.balance.times(Math.random()).integerValue(),
288
267
  },
289
268
  ],
290
269
  };
@@ -293,28 +272,24 @@ const evmBasicMutations: ({
293
272
  // workaround for buggy explorer behavior (nodes desync)
294
273
  invariant(
295
274
  Date.now() - operation.date.getTime() > 60000,
296
- "operation time to be older than 60s"
275
+ "operation time to be older than 60s",
297
276
  );
298
277
  invariant(accountBeforeTransaction.subAccounts, "sub accounts before");
299
278
  const erc20accountBefore = accountBeforeTransaction.subAccounts?.find(
300
- (s) => s.id === transaction.subAccountId
279
+ s => s.id === transaction.subAccountId,
301
280
  );
302
281
  invariant(erc20accountBefore, "erc20 acc was here before");
303
282
  invariant(account.subAccounts, "sub accounts");
304
- const erc20account = account.subAccounts!.find(
305
- (s) => s.id === transaction.subAccountId
306
- );
283
+ const erc20account = account.subAccounts!.find(s => s.id === transaction.subAccountId);
307
284
  invariant(erc20account, "erc20 acc is still here");
308
285
 
309
286
  if (transaction.useAllAmount) {
310
- botTest("erc20 account is empty", () =>
311
- expect(erc20account!.balance.toString()).toBe("0")
312
- );
287
+ botTest("erc20 account is empty", () => expect(erc20account!.balance.toString()).toBe("0"));
313
288
  } else {
314
289
  botTest("account balance moved with tx amount", () =>
315
290
  expect(erc20account!.balance.toString()).toBe(
316
- erc20accountBefore!.balance.minus(transaction.amount).toString()
317
- )
291
+ erc20accountBefore!.balance.minus(transaction.amount).toString(),
292
+ ),
318
293
  );
319
294
  }
320
295
  },
@@ -322,7 +297,7 @@ const evmBasicMutations: ({
322
297
  ];
323
298
 
324
299
  export default Object.values(cryptocurrenciesById)
325
- .filter((currency) => currency.family === "evm")
300
+ .filter(currency => currency.family === "evm")
326
301
  .reduce((acc, currency) => {
327
302
  // @ts-expect-error FIXME: fix typings
328
303
  acc[currency.id] = {
@@ -8,75 +8,66 @@ import type { DeviceAction } from "@ledgerhq/coin-framework/bot/types";
8
8
  import type { Transaction } from "./types";
9
9
 
10
10
  // FIXME: fix types
11
- const maxFeesExpectedValue = ({
12
- account,
13
- status,
14
- }: {
15
- account: any;
16
- status: any;
17
- }) => formatDeviceAmount(account.currency, status.estimatedFees);
11
+ const maxFeesExpectedValue = ({ account, status }: { account: any; status: any }) =>
12
+ formatDeviceAmount(account.currency, status.estimatedFees);
18
13
 
19
- export const acceptTransaction: DeviceAction<Transaction, any> =
20
- deviceActionFlow({
21
- steps: [
22
- {
23
- title: "Review",
24
- button: SpeculosButton.RIGHT,
25
- },
26
- {
27
- title: "Type",
28
- button: SpeculosButton.RIGHT,
29
- },
30
- {
31
- title: "Amount",
32
- button: SpeculosButton.RIGHT,
33
- expectedValue: ({ account, status, transaction }) => {
34
- const subAccount = findSubAccountById(
35
- account,
36
- transaction.subAccountId || ""
37
- );
14
+ export const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
15
+ steps: [
16
+ {
17
+ title: "Review",
18
+ button: SpeculosButton.RIGHT,
19
+ },
20
+ {
21
+ title: "Type",
22
+ button: SpeculosButton.RIGHT,
23
+ },
24
+ {
25
+ title: "Amount",
26
+ button: SpeculosButton.RIGHT,
27
+ expectedValue: ({ account, status, transaction }) => {
28
+ const subAccount = findSubAccountById(account, transaction.subAccountId || "");
38
29
 
39
- if (subAccount && subAccount.type === "TokenAccount") {
40
- return formatDeviceAmount(subAccount.token, status.amount);
41
- }
30
+ if (subAccount && subAccount.type === "TokenAccount") {
31
+ return formatDeviceAmount(subAccount.token, status.amount);
32
+ }
42
33
 
43
- return formatDeviceAmount(account.currency, status.amount);
44
- },
45
- },
46
- {
47
- title: "Contract",
48
- button: SpeculosButton.RIGHT,
49
- },
50
- {
51
- title: "Network",
52
- button: SpeculosButton.RIGHT,
53
- },
54
- {
55
- title: "Max fees",
56
- button: SpeculosButton.RIGHT,
57
- expectedValue: maxFeesExpectedValue,
58
- },
59
- {
60
- // Legacy (ETC..)
61
- title: "Max Fees",
62
- button: SpeculosButton.RIGHT,
63
- expectedValue: maxFeesExpectedValue,
64
- },
65
- {
66
- title: "Address",
67
- button: SpeculosButton.RIGHT,
68
- expectedValue: ({ transaction }) => transaction.recipient,
69
- },
70
- {
71
- title: "Accept",
72
- button: SpeculosButton.BOTH,
73
- },
74
- {
75
- title: "Approve",
76
- button: SpeculosButton.BOTH,
34
+ return formatDeviceAmount(account.currency, status.amount);
77
35
  },
78
- ],
79
- });
36
+ },
37
+ {
38
+ title: "Contract",
39
+ button: SpeculosButton.RIGHT,
40
+ },
41
+ {
42
+ title: "Network",
43
+ button: SpeculosButton.RIGHT,
44
+ },
45
+ {
46
+ title: "Max fees",
47
+ button: SpeculosButton.RIGHT,
48
+ expectedValue: maxFeesExpectedValue,
49
+ },
50
+ {
51
+ // Legacy (ETC..)
52
+ title: "Max Fees",
53
+ button: SpeculosButton.RIGHT,
54
+ expectedValue: maxFeesExpectedValue,
55
+ },
56
+ {
57
+ title: "Address",
58
+ button: SpeculosButton.RIGHT,
59
+ expectedValue: ({ transaction }) => transaction.recipient,
60
+ },
61
+ {
62
+ title: "Accept",
63
+ button: SpeculosButton.BOTH,
64
+ },
65
+ {
66
+ title: "Approve",
67
+ button: SpeculosButton.BOTH,
68
+ },
69
+ ],
70
+ });
80
71
 
81
72
  export default {
82
73
  acceptTransaction,