@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
@@ -2,26 +2,20 @@ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
2
2
  import BigNumber from "bignumber.js";
3
3
  import { ethers } from "ethers";
4
4
  import ERC20ABI from "../abis/erc20.abi.json";
5
- import * as rpcAPI from "../api/rpc.common";
6
- import {
7
- prepareForSignOperation,
8
- prepareTransaction,
9
- } from "../prepareTransaction";
5
+ import * as rpcAPI from "../api/rpc/rpc.common";
6
+ import { prepareForSignOperation, prepareTransaction } from "../prepareTransaction";
10
7
  import { makeAccount, makeTokenAccount } from "../testUtils";
11
- import { Transaction as EvmTransaction } from "../types";
8
+ import { Transaction as EvmTransaction, GasOptions } from "../types";
12
9
 
13
10
  const currency = getCryptoCurrencyById("ethereum");
14
- const tokenAccount = makeTokenAccount(
15
- "0xkvn",
16
- getTokenById("ethereum/erc20/usd__coin")
17
- );
11
+ const tokenAccount = makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin"));
18
12
  const account = makeAccount("0xkvn", currency, [tokenAccount]);
19
13
  const transaction: EvmTransaction = {
20
14
  amount: new BigNumber(100),
21
15
  useAllAmount: false,
22
16
  subAccountId: "id",
23
17
  recipient: "0x6bfD74C0996F269Bcece59191EFf667b3dFD73b9",
24
- feesStrategy: "custom",
18
+ feesStrategy: "medium",
25
19
  family: "evm",
26
20
  mode: "send",
27
21
  gasPrice: new BigNumber(0),
@@ -38,16 +32,14 @@ const expectedData = (recipient: string, amount: BigNumber): Buffer =>
38
32
  new ethers.utils.Interface(ERC20ABI)
39
33
  .encodeFunctionData("transfer", [recipient, amount.toFixed()])
40
34
  .slice(2),
41
- "hex"
35
+ "hex",
42
36
  );
43
37
 
44
38
  describe("EVM Family", () => {
45
39
  describe("prepareTransaction.ts", () => {
46
40
  beforeEach(() => {
47
41
  // These mocks will be overriden in some tests
48
- jest
49
- .spyOn(rpcAPI, "getGasEstimation")
50
- .mockImplementation(async () => new BigNumber(21000));
42
+ jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => new BigNumber(21000));
51
43
  // These mocks will be overriden in some tests
52
44
  jest.spyOn(rpcAPI, "getFeesEstimation").mockImplementation(async () => ({
53
45
  gasPrice: new BigNumber(1),
@@ -63,11 +55,9 @@ describe("EVM Family", () => {
63
55
  describe("prepareTransaction", () => {
64
56
  describe("Coins", () => {
65
57
  it("should have a gasLimit = 0 when recipient has an error", async () => {
66
- jest
67
- .spyOn(rpcAPI, "getGasEstimation")
68
- .mockImplementation(async () => {
69
- throw new Error();
70
- });
58
+ jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
59
+ throw new Error();
60
+ });
71
61
 
72
62
  const tx = await prepareTransaction(account, {
73
63
  ...transaction,
@@ -86,11 +76,9 @@ describe("EVM Family", () => {
86
76
  });
87
77
 
88
78
  it("should have a gasLimit = 0 when amount has an error", async () => {
89
- jest
90
- .spyOn(rpcAPI, "getGasEstimation")
91
- .mockImplementation(async () => {
92
- throw new Error();
93
- });
79
+ jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
80
+ throw new Error();
81
+ });
94
82
 
95
83
  const tx = await prepareTransaction(account, {
96
84
  ...transaction,
@@ -120,13 +108,11 @@ describe("EVM Family", () => {
120
108
  });
121
109
 
122
110
  it("should return a legacy coin transaction", async () => {
123
- jest
124
- .spyOn(rpcAPI, "getFeesEstimation")
125
- .mockImplementationOnce(async () => ({
126
- gasPrice: new BigNumber(1),
127
- maxFeePerGas: null,
128
- maxPriorityFeePerGas: null,
129
- }));
111
+ jest.spyOn(rpcAPI, "getFeesEstimation").mockImplementationOnce(async () => ({
112
+ gasPrice: new BigNumber(1),
113
+ maxFeePerGas: null,
114
+ maxPriorityFeePerGas: null,
115
+ }));
130
116
 
131
117
  const tx = await prepareTransaction(account, transaction);
132
118
 
@@ -147,10 +133,7 @@ describe("EVM Family", () => {
147
133
  useAllAmount: true,
148
134
  };
149
135
 
150
- const tx = await prepareTransaction(
151
- accountWithBalance,
152
- transactionWithUseAllAmount
153
- );
136
+ const tx = await prepareTransaction(accountWithBalance, transactionWithUseAllAmount);
154
137
  const estimatedFees = new BigNumber(21000); // 21000 gasLimit * 1 maxFeePerGas
155
138
 
156
139
  expect(tx).toEqual({
@@ -189,11 +172,9 @@ describe("EVM Family", () => {
189
172
 
190
173
  describe("Tokens", () => {
191
174
  it("should have a gasLimit = 0 and no data when recipient has an error", async () => {
192
- jest
193
- .spyOn(rpcAPI, "getGasEstimation")
194
- .mockImplementation(async () => {
195
- throw new Error();
196
- });
175
+ jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
176
+ throw new Error();
177
+ });
197
178
 
198
179
  const tx = await prepareTransaction(account, {
199
180
  ...tokenTransaction,
@@ -213,11 +194,9 @@ describe("EVM Family", () => {
213
194
  });
214
195
 
215
196
  it("should have a gasLimit = 0 when amount has an error", async () => {
216
- jest
217
- .spyOn(rpcAPI, "getGasEstimation")
218
- .mockImplementation(async () => {
219
- throw new Error();
220
- });
197
+ jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
198
+ throw new Error();
199
+ });
221
200
 
222
201
  const tx = await prepareTransaction(account, {
223
202
  ...tokenTransaction,
@@ -262,10 +241,7 @@ describe("EVM Family", () => {
262
241
  amount: tokenAccountWithBalance.balance,
263
242
  useAllAmount: true,
264
243
  subAccountId: tokenAccountWithBalance.id,
265
- data: expectedData(
266
- tokenTransaction.recipient,
267
- tokenAccountWithBalance.balance
268
- ),
244
+ data: expectedData(tokenTransaction.recipient, tokenAccountWithBalance.balance),
269
245
  maxFeePerGas: new BigNumber(1),
270
246
  maxPriorityFeePerGas: new BigNumber(1),
271
247
  gasPrice: undefined,
@@ -299,11 +275,8 @@ describe("EVM Family", () => {
299
275
  expect.objectContaining({
300
276
  recipient: tokenAccount.token.contractAddress,
301
277
  amount: new BigNumber(0),
302
- data: expectedData(
303
- tokenTransaction.recipient,
304
- tokenAccountWithBalance.balance
305
- ),
306
- })
278
+ data: expectedData(tokenTransaction.recipient, tokenAccountWithBalance.balance),
279
+ }),
307
280
  );
308
281
  });
309
282
 
@@ -320,10 +293,7 @@ describe("EVM Family", () => {
320
293
 
321
294
  expect(tx).toEqual({
322
295
  ...tokenTransaction,
323
- data: expectedData(
324
- tokenTransaction.recipient,
325
- tokenTransaction.amount
326
- ),
296
+ data: expectedData(tokenTransaction.recipient, tokenTransaction.amount),
327
297
  maxFeePerGas: new BigNumber(1),
328
298
  maxPriorityFeePerGas: new BigNumber(1),
329
299
  type: 2,
@@ -331,13 +301,11 @@ describe("EVM Family", () => {
331
301
  });
332
302
 
333
303
  it("should return a legacy token transaction", async () => {
334
- jest
335
- .spyOn(rpcAPI, "getFeesEstimation")
336
- .mockImplementationOnce(async () => ({
337
- gasPrice: new BigNumber(1),
338
- maxFeePerGas: null,
339
- maxPriorityFeePerGas: null,
340
- }));
304
+ jest.spyOn(rpcAPI, "getFeesEstimation").mockImplementationOnce(async () => ({
305
+ gasPrice: new BigNumber(1),
306
+ maxFeePerGas: null,
307
+ maxPriorityFeePerGas: null,
308
+ }));
341
309
 
342
310
  const tokenAccountWithBalance = {
343
311
  ...tokenAccount,
@@ -351,22 +319,111 @@ describe("EVM Family", () => {
351
319
 
352
320
  expect(tx).toEqual({
353
321
  ...tokenTransaction,
354
- data: expectedData(
355
- tokenTransaction.recipient,
356
- tokenTransaction.amount
357
- ),
322
+ data: expectedData(tokenTransaction.recipient, tokenTransaction.amount),
358
323
  gasPrice: new BigNumber(1),
359
324
  type: 0,
360
325
  });
361
326
  });
362
327
  });
328
+
329
+ describe("When feesStrategy provided", () => {
330
+ it("should call getFeesEstimation once", async () => {
331
+ const tx = await prepareTransaction(account, {
332
+ ...transaction,
333
+ feesStrategy: undefined,
334
+ });
335
+
336
+ expect(rpcAPI.getFeesEstimation).toBeCalledTimes(1);
337
+
338
+ expect(tx).toEqual({
339
+ ...transaction,
340
+ feesStrategy: undefined,
341
+ additionalFees: undefined,
342
+ maxFeePerGas: new BigNumber(1),
343
+ maxPriorityFeePerGas: new BigNumber(1),
344
+ type: 2,
345
+ });
346
+ });
347
+ });
348
+
349
+ describe("When custom feesStrategy provided", () => {
350
+ it("should use transaction provided data for fees", async () => {
351
+ const tx = await prepareTransaction(account, {
352
+ ...transaction,
353
+ feesStrategy: "custom",
354
+ });
355
+
356
+ expect(rpcAPI.getFeesEstimation).toBeCalledTimes(0);
357
+
358
+ expect(tx).toEqual({
359
+ ...transaction,
360
+ additionalFees: undefined,
361
+ feesStrategy: "custom",
362
+ gasPrice: new BigNumber(0),
363
+ type: 0,
364
+ });
365
+ });
366
+ });
367
+
368
+ describe("When gasOptions provided", () => {
369
+ it("should call getFeesEstimation once", async () => {
370
+ const tx = await prepareTransaction(account, {
371
+ ...transaction,
372
+ gasOptions: undefined,
373
+ });
374
+
375
+ expect(rpcAPI.getFeesEstimation).toBeCalledTimes(1);
376
+
377
+ expect(tx).toEqual({
378
+ ...transaction,
379
+ maxFeePerGas: new BigNumber(1),
380
+ maxPriorityFeePerGas: new BigNumber(1),
381
+ type: 2,
382
+ });
383
+ });
384
+ });
385
+
386
+ describe("When gasOptions provided", () => {
387
+ const gasOptions: GasOptions = {
388
+ slow: {
389
+ maxFeePerGas: new BigNumber(10),
390
+ maxPriorityFeePerGas: new BigNumber(1),
391
+ gasPrice: null,
392
+ },
393
+ medium: {
394
+ maxFeePerGas: new BigNumber(20),
395
+ maxPriorityFeePerGas: new BigNumber(2),
396
+ gasPrice: null,
397
+ },
398
+ fast: {
399
+ maxFeePerGas: new BigNumber(30),
400
+ maxPriorityFeePerGas: new BigNumber(3),
401
+ gasPrice: null,
402
+ },
403
+ };
404
+ it("should use gasOptions values for fee data", async () => {
405
+ const tx = await prepareTransaction(account, {
406
+ ...transaction,
407
+ gasOptions,
408
+ });
409
+
410
+ expect(rpcAPI.getFeesEstimation).toBeCalledTimes(0);
411
+
412
+ expect(tx).toEqual({
413
+ ...transaction,
414
+ gasOptions,
415
+ additionalFees: undefined,
416
+ maxFeePerGas: new BigNumber(20),
417
+ maxPriorityFeePerGas: new BigNumber(2),
418
+ type: 2,
419
+ });
420
+ });
421
+ });
363
422
  });
364
423
 
365
424
  describe("prepareForSignOperation", () => {
366
425
  beforeEach(() => {
367
- jest
368
- .spyOn(rpcAPI, "getTransactionCount")
369
- .mockImplementation(() => Promise.resolve(10));
426
+ jest.spyOn(rpcAPI, "getTransactionCount").mockImplementation(() => Promise.resolve(10));
370
427
  });
371
428
  afterEach(() => {
372
429
  jest.restoreAllMocks();
@@ -380,9 +437,7 @@ describe("EVM Family", () => {
380
437
  });
381
438
 
382
439
  it("should update a token transaction with the correct recipient", async () => {
383
- expect(
384
- await prepareForSignOperation(account, tokenTransaction)
385
- ).toEqual({
440
+ expect(await prepareForSignOperation(account, tokenTransaction)).toEqual({
386
441
  ...tokenTransaction,
387
442
  amount: new BigNumber(0),
388
443
  recipient: tokenAccount.token.contractAddress,
@@ -3,7 +3,7 @@ import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
3
3
  import { AssertionError, fail } from "assert";
4
4
  import BigNumber from "bignumber.js";
5
5
  import { ethers } from "ethers";
6
- import * as RPC_API from "../api/rpc.common";
6
+ import * as RPC_API from "../api/rpc/rpc.common";
7
7
  import { GasEstimationError, InsufficientFunds } from "../errors";
8
8
  import { makeAccount } from "../testUtils";
9
9
  import { Transaction as EvmTransaction, EvmTransactionLegacy } from "../types";
@@ -25,7 +25,7 @@ const fakeCurrencyWithoutRPC: Partial<CryptoCurrency> = {
25
25
  };
26
26
  const account = makeAccount(
27
27
  "0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d",
28
- fakeCurrency as CryptoCurrency
28
+ fakeCurrency as CryptoCurrency,
29
29
  );
30
30
 
31
31
  const mockedNetwork = {
@@ -35,7 +35,7 @@ const mockedNetwork = {
35
35
 
36
36
  jest.mock("@ledgerhq/live-promise");
37
37
  (delay as jest.Mock).mockImplementation(
38
- () => new Promise((resolve) => setTimeout(resolve, 1)) // mocking the delay supposed to happen after each try
38
+ () => new Promise(resolve => setTimeout(resolve, 1)), // mocking the delay supposed to happen after each try
39
39
  );
40
40
 
41
41
  describe("EVM Family", () => {
@@ -52,7 +52,7 @@ describe("EVM Family", () => {
52
52
  .mockResolvedValue(null);
53
53
  jest
54
54
  .spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "resolveName")
55
- .mockImplementation(async (address) => address);
55
+ .mockImplementation(async address => address);
56
56
  jest
57
57
  .spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "perform")
58
58
  .mockImplementation(async (method, params) => {
@@ -80,8 +80,7 @@ describe("EVM Family", () => {
80
80
  return ethers.BigNumber.from(5);
81
81
  case "getBlock":
82
82
  return {
83
- parentHash:
84
- "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
83
+ parentHash: "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
85
84
  number: 1,
86
85
  timestamp: 123,
87
86
  difficulty: null,
@@ -119,18 +118,13 @@ describe("EVM Family", () => {
119
118
  describe("withApi", () => {
120
119
  it("should throw if the currency doesn't have an RPC node", async () => {
121
120
  try {
122
- await RPC_API.withApi(
123
- fakeCurrencyWithoutRPC as CryptoCurrency,
124
- (() => {}) as any
125
- );
121
+ await RPC_API.withApi(fakeCurrencyWithoutRPC as CryptoCurrency, (() => {}) as any);
126
122
  fail("Promise should have been rejected");
127
123
  } catch (e) {
128
124
  if (e instanceof AssertionError) {
129
125
  throw e;
130
126
  }
131
- expect((e as Error).message).toEqual(
132
- "Currency doesn't have an RPC node provided"
133
- );
127
+ expect((e as Error).message).toEqual("Currency doesn't have an RPC node provided");
134
128
  }
135
129
  });
136
130
 
@@ -143,10 +137,7 @@ describe("EVM Family", () => {
143
137
  }
144
138
  return true;
145
139
  });
146
- const response = await RPC_API.withApi(
147
- fakeCurrency as CryptoCurrency,
148
- spy
149
- );
140
+ const response = await RPC_API.withApi(fakeCurrency as CryptoCurrency, spy);
150
141
 
151
142
  expect(response).toBe(true);
152
143
  // it should fail DEFAULT_RETRIES_RPC_METHODS times and succeed on the next try, therefore the +1
@@ -179,12 +170,7 @@ describe("EVM Family", () => {
179
170
 
180
171
  describe("getBalanceAndBlock", () => {
181
172
  it("should return the expected payload", async () => {
182
- expect(
183
- await RPC_API.getBalanceAndBlock(
184
- fakeCurrency as CryptoCurrency,
185
- "0xkvn"
186
- )
187
- ).toEqual({
173
+ expect(await RPC_API.getBalanceAndBlock(fakeCurrency as CryptoCurrency, "0xkvn")).toEqual({
188
174
  blockHeight: 69,
189
175
  balance: new BigNumber(420),
190
176
  });
@@ -196,8 +182,8 @@ describe("EVM Family", () => {
196
182
  expect(
197
183
  await RPC_API.getTransaction(
198
184
  fakeCurrency as CryptoCurrency,
199
- "0x435b00d28a10febbcfefbdea080134d08ef843df122d5bc9174b09de7fce6a59"
200
- )
185
+ "0x435b00d28a10febbcfefbdea080134d08ef843df122d5bc9174b09de7fce6a59",
186
+ ),
201
187
  ).toEqual({
202
188
  accessList: null,
203
189
  blockHash: null,
@@ -224,8 +210,8 @@ describe("EVM Family", () => {
224
210
  expect(
225
211
  await RPC_API.getCoinBalance(
226
212
  fakeCurrency as CryptoCurrency,
227
- "0x435b00d28a10febbcfefbdea080134d08ef843df122d5bc9174b09de7fce6a59"
228
- )
213
+ "0x435b00d28a10febbcfefbdea080134d08ef843df122d5bc9174b09de7fce6a59",
214
+ ),
229
215
  ).toEqual(new BigNumber(420));
230
216
  });
231
217
  });
@@ -237,8 +223,8 @@ describe("EVM Family", () => {
237
223
  await RPC_API.getTokenBalance(
238
224
  fakeCurrency as CryptoCurrency,
239
225
  "0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d",
240
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
241
- )
226
+ "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
227
+ ),
242
228
  ).toEqual(new BigNumber(420));
243
229
  });
244
230
  });
@@ -248,8 +234,8 @@ describe("EVM Family", () => {
248
234
  expect(
249
235
  await RPC_API.getTransactionCount(
250
236
  fakeCurrency as CryptoCurrency,
251
- "0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"
252
- )
237
+ "0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d",
238
+ ),
253
239
  ).toEqual(5);
254
240
  });
255
241
  });
@@ -264,7 +250,7 @@ describe("EVM Family", () => {
264
250
  gasPrice: new BigNumber(0),
265
251
  data: Buffer.from(""),
266
252
  type: 0,
267
- } as EvmTransactionLegacy)
253
+ } as EvmTransactionLegacy),
268
254
  ).toEqual(new BigNumber(5));
269
255
  });
270
256
 
@@ -292,7 +278,7 @@ describe("EVM Family", () => {
292
278
  it("should return the expected payload for an EIP1559 tx", async () => {
293
279
  jest
294
280
  .spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "send")
295
- .mockImplementationOnce(async (method) => {
281
+ .mockImplementationOnce(async method => {
296
282
  if (method === "eth_feeHistory") {
297
283
  return {
298
284
  reward: [
@@ -307,9 +293,7 @@ describe("EVM Family", () => {
307
293
  }
308
294
  });
309
295
 
310
- expect(
311
- await RPC_API.getFeesEstimation(fakeCurrency as CryptoCurrency)
312
- ).toEqual({
296
+ expect(await RPC_API.getFeesEstimation(fakeCurrency as CryptoCurrency)).toEqual({
313
297
  maxFeePerGas: new BigNumber("6000000014"),
314
298
  maxPriorityFeePerGas: new BigNumber("5999999988"),
315
299
  gasPrice: null,
@@ -319,7 +303,7 @@ describe("EVM Family", () => {
319
303
  it("should return the expected payload for an EIP1559 tx when network returns 0 priority fee", async () => {
320
304
  jest
321
305
  .spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "send")
322
- .mockImplementationOnce(async (method) => {
306
+ .mockImplementationOnce(async method => {
323
307
  if (method === "eth_feeHistory") {
324
308
  return {
325
309
  reward: [
@@ -334,9 +318,7 @@ describe("EVM Family", () => {
334
318
  }
335
319
  });
336
320
 
337
- expect(
338
- await RPC_API.getFeesEstimation(fakeCurrency as CryptoCurrency)
339
- ).toEqual({
321
+ expect(await RPC_API.getFeesEstimation(fakeCurrency as CryptoCurrency)).toEqual({
340
322
  maxFeePerGas: new BigNumber("1000000026"),
341
323
  maxPriorityFeePerGas: new BigNumber(1e9),
342
324
  gasPrice: null,
@@ -346,12 +328,11 @@ describe("EVM Family", () => {
346
328
  it("should return the expected payload for a legacy tx", async () => {
347
329
  jest
348
330
  .spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "perform")
349
- .mockImplementationOnce(async (method) => {
331
+ .mockImplementationOnce(async method => {
350
332
  switch (method) {
351
333
  case "getBlock":
352
334
  return {
353
- parentHash:
354
- "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
335
+ parentHash: "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
355
336
  number: 1,
356
337
  timestamp: 123,
357
338
  difficulty: null,
@@ -368,7 +349,7 @@ describe("EVM Family", () => {
368
349
  await RPC_API.getFeesEstimation({
369
350
  ...fakeCurrency,
370
351
  id: "optimism",
371
- } as CryptoCurrency)
352
+ } as CryptoCurrency),
372
353
  ).toEqual({
373
354
  maxFeePerGas: null,
374
355
  maxPriorityFeePerGas: null,
@@ -382,10 +363,7 @@ describe("EVM Family", () => {
382
363
  const serializedTransaction =
383
364
  "0x02f873012d85010c388d0085077715912682520894c2907efcce4011c491bbeda8a0fa63ba7aab596c87038d7ea4c6800080c001a0bbffe7ba303ab03f697d64672c4a288ae863df8a62ffc67ba72872ce8c227f6fa01261e7c9f06af13631f03fad9b88d3c48931d353b6b41b4072fddcca5ec41629";
384
365
  expect(
385
- await RPC_API.broadcastTransaction(
386
- fakeCurrency as CryptoCurrency,
387
- serializedTransaction
388
- )
366
+ await RPC_API.broadcastTransaction(fakeCurrency as CryptoCurrency, serializedTransaction),
389
367
  ).toEqual({
390
368
  ...ethers.utils.parseTransaction(serializedTransaction),
391
369
  confirmations: 0,
@@ -398,10 +376,7 @@ describe("EVM Family", () => {
398
376
  "0x02f873012d85010c388d0085077715912682520894c2907efcce4011c491bbeda8a0fa63ba7aab596c87038d7ea4c6800080c001a0bbffe7ba303ab03f697d64672c4a288ae863df8a62ffc67ba72872ce8c227f6fa01261e7c9f06af13631f03fad9b88d3c48931d353b6b41b4072fddcca5ec41628";
399
377
 
400
378
  try {
401
- await RPC_API.broadcastTransaction(
402
- fakeCurrency as CryptoCurrency,
403
- serializedTransaction
404
- );
379
+ await RPC_API.broadcastTransaction(fakeCurrency as CryptoCurrency, serializedTransaction);
405
380
  fail("Promise should have been rejected");
406
381
  } catch (e) {
407
382
  if (e instanceof AssertionError) {
@@ -416,10 +391,7 @@ describe("EVM Family", () => {
416
391
  "0x02f873012d85010c388d0085077715912682520894c2907efcce4011c491bbeda8a0fa63ba7aab596c87038d7ea4c6800080c001a0bbffe7ba303ab03f697d64672c4a288ae863df8a62ffc67ba72872ce8c227f6fa01261e7c9f06af13631f03fad9b88d3c48931d353b6b41b4072fddcca5ec41625";
417
392
 
418
393
  try {
419
- await RPC_API.broadcastTransaction(
420
- fakeCurrency as CryptoCurrency,
421
- serializedTransaction
422
- );
394
+ await RPC_API.broadcastTransaction(fakeCurrency as CryptoCurrency, serializedTransaction);
423
395
  fail("Promise should have been rejected");
424
396
  } catch (e) {
425
397
  if (e instanceof AssertionError) {
@@ -432,30 +404,24 @@ describe("EVM Family", () => {
432
404
 
433
405
  describe("getBlock", () => {
434
406
  it("should return the expected payload", async () => {
435
- expect(await RPC_API.getBlock(fakeCurrency as CryptoCurrency, 0)).toEqual(
436
- {
437
- parentHash:
438
- "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
439
- number: 1,
440
- timestamp: 123,
441
- difficulty: null,
442
- _difficulty: null,
443
- gasLimit: ethers.BigNumber.from(1),
444
- gasUsed: ethers.BigNumber.from(2),
445
- extraData: "0x",
446
- baseFeePerGas: ethers.BigNumber.from(123),
447
- }
448
- );
407
+ expect(await RPC_API.getBlock(fakeCurrency as CryptoCurrency, 0)).toEqual({
408
+ parentHash: "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
409
+ number: 1,
410
+ timestamp: 123,
411
+ difficulty: null,
412
+ _difficulty: null,
413
+ gasLimit: ethers.BigNumber.from(1),
414
+ gasUsed: ethers.BigNumber.from(2),
415
+ extraData: "0x",
416
+ baseFeePerGas: ethers.BigNumber.from(123),
417
+ });
449
418
  });
450
419
  });
451
420
 
452
421
  describe("getSubAccount", () => {
453
422
  it("should return the expected payload", async () => {
454
423
  expect(
455
- await RPC_API.getSubAccount(
456
- fakeCurrency as CryptoCurrency,
457
- account.freshAddress
458
- )
424
+ await RPC_API.getSubAccount(fakeCurrency as CryptoCurrency, account.freshAddress),
459
425
  ).toEqual({
460
426
  balance: new BigNumber(420),
461
427
  blockHeight: 69,
@@ -482,8 +448,8 @@ describe("EVM Family", () => {
482
448
  type: 2,
483
449
  chainId: 1,
484
450
  nonce: 52,
485
- } as EvmTransaction
486
- )
451
+ } as EvmTransaction,
452
+ ),
487
453
  ).toEqual(new BigNumber(420));
488
454
  });
489
455
 
@@ -503,8 +469,8 @@ describe("EVM Family", () => {
503
469
  type: 2,
504
470
  chainId: 1,
505
471
  nonce: 52,
506
- } as EvmTransaction
507
- )
472
+ } as EvmTransaction,
473
+ ),
508
474
  ).toEqual(new BigNumber(0));
509
475
  });
510
476
 
@@ -524,8 +490,8 @@ describe("EVM Family", () => {
524
490
  type: 2,
525
491
  chainId: 1,
526
492
  nonce: 52,
527
- } as EvmTransaction
528
- )
493
+ } as EvmTransaction,
494
+ ),
529
495
  ).toEqual(new BigNumber(0));
530
496
  });
531
497
  });