@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,13 +1,14 @@
1
- import { DeviceCommunication } from "@ledgerhq/coin-framework/bridge/jsHelpers";
2
1
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
3
2
  import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
4
3
  import { Account } from "@ledgerhq/types-live";
5
4
  import BigNumber from "bignumber.js";
6
5
  import { buildSignOperation, applyEIP155 } from "../signOperation";
7
6
  import { Transaction as EvmTransaction } from "../types";
8
- import * as rpcAPI from "../api/rpc.common";
7
+ import * as rpcAPI from "../api/rpc/rpc.common";
9
8
  import { getEstimatedFees } from "../logic";
10
9
  import { makeAccount } from "../testUtils";
10
+ import { EvmAddress, EvmSignature, EvmSigner } from "../signer";
11
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
11
12
 
12
13
  const currency: CryptoCurrency = {
13
14
  ...getCryptoCurrencyById("ethereum"),
@@ -18,7 +19,7 @@ const currency: CryptoCurrency = {
18
19
  };
19
20
  const account: Account = makeAccount(
20
21
  "0x7265a60acAeaf3A5E18E10BC1128e72F27B2e176", // trump.eth
21
- currency
22
+ currency,
22
23
  );
23
24
 
24
25
  const transactionEIP1559: EvmTransaction = {
@@ -38,21 +39,24 @@ const transactionEIP1559: EvmTransaction = {
38
39
  };
39
40
  const estimatedFees = getEstimatedFees(transactionEIP1559);
40
41
 
41
- const mockWithDevice: DeviceCommunication =
42
- () =>
43
- (job: any): any =>
44
- job({});
42
+ const mockSignerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature> = (
43
+ _: string,
44
+ fn: (signer: EvmSigner) => Promise<EvmAddress | EvmSignature>,
45
+ ) => {
46
+ return fn({
47
+ getAddress: jest.fn(),
48
+ signTransaction: () =>
49
+ Promise.resolve({
50
+ r: "123",
51
+ s: "abc",
52
+ v: "27",
53
+ }),
54
+ });
55
+ };
45
56
 
46
57
  // Mocking here in order to be ack by the signOperation.ts file
47
58
  jest.mock("@ledgerhq/hw-app-eth", () => ({
48
59
  __esModule: true,
49
- default: class {
50
- signTransaction = () => ({
51
- r: "123",
52
- s: "abc",
53
- v: "27",
54
- });
55
- },
56
60
  ledgerService: {
57
61
  resolveTransaction: () =>
58
62
  Promise.resolve({
@@ -68,17 +72,15 @@ describe("EVM Family", () => {
68
72
  describe("signOperation.ts", () => {
69
73
  describe("signOperation", () => {
70
74
  beforeAll(() => {
71
- jest
72
- .spyOn(rpcAPI, "getTransactionCount")
73
- .mockImplementation(async () => 1);
75
+ jest.spyOn(rpcAPI, "getTransactionCount").mockImplementation(async () => 1);
74
76
  });
75
77
 
76
78
  afterAll(() => {
77
79
  jest.restoreAllMocks();
78
80
  });
79
81
 
80
- it("should return an optimistic operation and a signed hash based on hardware ECDSA signatures returned by the app bindings", (done) => {
81
- const signOperation = buildSignOperation(mockWithDevice);
82
+ it("should return an optimistic operation and a signed hash based on hardware ECDSA signatures returned by the app bindings", done => {
83
+ const signOperation = buildSignOperation(mockSignerContext);
82
84
 
83
85
  const signOpObservable = signOperation({
84
86
  account,
@@ -86,7 +88,7 @@ describe("EVM Family", () => {
86
88
  deviceId: "",
87
89
  });
88
90
 
89
- signOpObservable.subscribe((obs) => {
91
+ signOpObservable.subscribe(obs => {
90
92
  if (obs.type === "signed") {
91
93
  const {
92
94
  signedOperation: { signature, operation },
@@ -108,7 +110,7 @@ describe("EVM Family", () => {
108
110
  extra: {},
109
111
  });
110
112
  expect(signature).toBe(
111
- "0x02e601016464825208946775e49108cb77cda06fc3bef51bcd497602ad886480c080820123820abc"
113
+ "0x02e601016464825208946775e49108cb77cda06fc3bef51bcd497602ad886480c080820123820abc",
112
114
  );
113
115
  done();
114
116
  }
@@ -135,15 +137,15 @@ describe("EVM Family", () => {
135
137
  "1c", // 28
136
138
  ];
137
139
 
138
- chainIds.forEach((chainId) => {
139
- possibleHexV.forEach((v) => {
140
+ chainIds.forEach(chainId => {
141
+ possibleHexV.forEach(v => {
140
142
  it(`should return an EIP155 compatible v for chain id ${chainId} with v = ${parseInt(
141
143
  v,
142
- 16
144
+ 16,
143
145
  )}`, () => {
144
146
  const eip155Logic = chainId * 2 + 35;
145
147
  expect(
146
- [eip155Logic, eip155Logic + 1] // eip155 + parity
148
+ [eip155Logic, eip155Logic + 1], // eip155 + parity
147
149
  ).toContain(applyEIP155(v, chainId));
148
150
  });
149
151
  });
@@ -5,8 +5,8 @@ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
5
5
  import { AssertionError, fail } from "assert";
6
6
  import BigNumber from "bignumber.js";
7
7
  import { getEnv } from "../../../env";
8
- import * as etherscanAPI from "../api/etherscan";
9
- import * as rpcAPI from "../api/rpc.common";
8
+ import * as etherscanAPI from "../api/explorer/etherscan";
9
+ import * as rpcAPI from "../api/rpc/rpc.common";
10
10
  import * as logic from "../logic";
11
11
  import * as synchronization from "../synchronization";
12
12
  import { makeAccount, makeOperation, makeTokenAccount } from "../testUtils";
@@ -41,8 +41,7 @@ const account = {
41
41
  const coinOperation1 = makeOperation({
42
42
  hash: "0xH4sH",
43
43
  accountId: "js:2:ethereum:0xkvn:",
44
- blockHash:
45
- "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
44
+ blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
46
45
  senders: ["0xd48f2332Eeed88243Cb6b1D0d65a10368A5370f0"], // johnnyhallyday.eth
47
46
  transactionSequenceNumber: 1,
48
47
  date: new Date(),
@@ -65,8 +64,7 @@ const coinOperation3 = makeOperation({
65
64
  const tokenOperation1 = makeOperation({
66
65
  hash: "0xH4sHT0k3n",
67
66
  accountId: "js:2:ethereum:0xkvn:+ethereum%2Ferc20%2Fusd__coin",
68
- blockHash:
69
- "0x95dc138a02c1b0e3fd49305f785e8e27e88a885004af13a9b4c62ad94eed07dd",
67
+ blockHash: "0x95dc138a02c1b0e3fd49305f785e8e27e88a885004af13a9b4c62ad94eed07dd",
70
68
  recipients: ["0xB0B"],
71
69
  senders: ["0x9b744C0451D73C0958d8aA566dAd33022E4Ee797"], // sbf.eth
72
70
  contract: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
@@ -117,14 +115,14 @@ describe("EVM Family", () => {
117
115
  Promise.resolve({
118
116
  blockHeight: 10,
119
117
  balance: new BigNumber(100),
120
- })
118
+ }),
121
119
  );
122
120
  jest.spyOn(rpcAPI, "getSubAccount").mockImplementation(() =>
123
121
  Promise.resolve({
124
122
  blockHeight: 10,
125
123
  balance: new BigNumber(100),
126
124
  nonce: 1,
127
- })
125
+ }),
128
126
  );
129
127
  });
130
128
 
@@ -142,14 +140,14 @@ describe("EVM Family", () => {
142
140
  ethereumLikeInfo: undefined,
143
141
  },
144
142
  },
145
- {} as any
143
+ {} as any,
146
144
  );
147
145
  fail("Promise should have been rejected");
148
146
  } catch (e: any) {
149
147
  if (e instanceof AssertionError) {
150
148
  throw e;
151
149
  }
152
- expect(e.message).toEqual("API type not supported");
150
+ expect(e.message).toMatch("No explorer found for currency");
153
151
  }
154
152
  });
155
153
 
@@ -169,14 +167,14 @@ describe("EVM Family", () => {
169
167
  },
170
168
  },
171
169
  },
172
- {} as any
170
+ {} as any,
173
171
  );
174
172
  fail("Promise should have been rejected");
175
173
  } catch (e: any) {
176
174
  if (e instanceof AssertionError) {
177
175
  throw e;
178
176
  }
179
- expect(e.message).toEqual("API type not supported");
177
+ expect(e.message).toMatch("No explorer found for currency");
180
178
  }
181
179
  });
182
180
 
@@ -203,7 +201,7 @@ describe("EVM Family", () => {
203
201
  it("should return an account with a valid id", async () => {
204
202
  const account = await synchronization.getAccountShape(
205
203
  getAccountShapeParameters,
206
- {} as any
204
+ {} as any,
207
205
  );
208
206
  expect(decodeAccountId(account.id || "")).toEqual({
209
207
  type: "js",
@@ -217,7 +215,7 @@ describe("EVM Family", () => {
217
215
  it("should return an account with the correct balance", async () => {
218
216
  const account = await synchronization.getAccountShape(
219
217
  getAccountShapeParameters,
220
- {} as any
218
+ {} as any,
221
219
  );
222
220
  expect(account.balance).toEqual(new BigNumber(100));
223
221
  });
@@ -225,7 +223,7 @@ describe("EVM Family", () => {
225
223
  it("should return an account with the correct operations count", async () => {
226
224
  const account = await synchronization.getAccountShape(
227
225
  getAccountShapeParameters,
228
- {} as any
226
+ {} as any,
229
227
  );
230
228
  expect(account.operationsCount).toBe(account.operations?.length);
231
229
  });
@@ -233,7 +231,7 @@ describe("EVM Family", () => {
233
231
  it("should return an account with the correct block height", async () => {
234
232
  const account = await synchronization.getAccountShape(
235
233
  getAccountShapeParameters,
236
- {} as any
234
+ {} as any,
237
235
  );
238
236
  expect(account.blockHeight).toBe(10);
239
237
  });
@@ -250,18 +248,14 @@ describe("EVM Family", () => {
250
248
  subAccounts: [{ ...tokenAccount, operations: tokenOperations }],
251
249
  },
252
250
  },
253
- {} as any
251
+ {} as any,
254
252
  );
255
253
  expect(accountWithSubAccount.operations).toBe(operations);
256
- expect(accountWithSubAccount?.subAccounts?.[0].operations).toBe(
257
- tokenOperations
258
- );
254
+ expect(accountWithSubAccount?.subAccounts?.[0].operations).toBe(tokenOperations);
259
255
  });
260
256
 
261
257
  it("should do a full sync when syncHash changes", async () => {
262
- jest
263
- .spyOn(logic, "getSyncHash")
264
- .mockImplementationOnce(() => "0xNope");
258
+ jest.spyOn(logic, "getSyncHash").mockImplementationOnce(() => "0xNope");
265
259
 
266
260
  await synchronization.getAccountShape(
267
261
  {
@@ -269,29 +263,23 @@ describe("EVM Family", () => {
269
263
  initialAccount: {
270
264
  ...account,
271
265
  operations: [coinOperation1],
272
- subAccounts: [
273
- { ...tokenAccount, operations: [tokenOperation1] },
274
- ],
266
+ subAccounts: [{ ...tokenAccount, operations: [tokenOperation1] }],
275
267
  },
276
268
  },
277
- {} as any
269
+ {} as any,
278
270
  );
279
271
 
280
- expect(
281
- etherscanAPI?.default.getLastCoinOperations
282
- ).toHaveBeenCalledWith(
272
+ expect(etherscanAPI?.default.getLastCoinOperations).toHaveBeenCalledWith(
283
273
  getAccountShapeParameters.currency,
284
274
  getAccountShapeParameters.address,
285
275
  account.id,
286
- 0
276
+ 0,
287
277
  );
288
- expect(
289
- etherscanAPI?.default.getLastTokenOperations
290
- ).toHaveBeenCalledWith(
278
+ expect(etherscanAPI?.default.getLastTokenOperations).toHaveBeenCalledWith(
291
279
  getAccountShapeParameters.currency,
292
280
  getAccountShapeParameters.address,
293
281
  account.id,
294
- 0
282
+ 0,
295
283
  );
296
284
  });
297
285
 
@@ -302,29 +290,23 @@ describe("EVM Family", () => {
302
290
  initialAccount: {
303
291
  ...account,
304
292
  operations: [coinOperation1],
305
- subAccounts: [
306
- { ...tokenAccount, operations: [tokenOperation1] },
307
- ],
293
+ subAccounts: [{ ...tokenAccount, operations: [tokenOperation1] }],
308
294
  },
309
295
  },
310
- {} as any
296
+ {} as any,
311
297
  );
312
298
 
313
- expect(
314
- etherscanAPI?.default.getLastCoinOperations
315
- ).toHaveBeenCalledWith(
299
+ expect(etherscanAPI?.default.getLastCoinOperations).toHaveBeenCalledWith(
316
300
  getAccountShapeParameters.currency,
317
301
  getAccountShapeParameters.address,
318
302
  account.id,
319
- coinOperation1.blockHeight
303
+ coinOperation1.blockHeight,
320
304
  );
321
- expect(
322
- etherscanAPI?.default.getLastTokenOperations
323
- ).toHaveBeenCalledWith(
305
+ expect(etherscanAPI?.default.getLastTokenOperations).toHaveBeenCalledWith(
324
306
  getAccountShapeParameters.currency,
325
307
  getAccountShapeParameters.address,
326
308
  account.id,
327
- tokenOperation1.blockHeight
309
+ tokenOperation1.blockHeight,
328
310
  );
329
311
  });
330
312
  });
@@ -333,32 +315,26 @@ describe("EVM Family", () => {
333
315
  beforeAll(() => {
334
316
  jest
335
317
  .spyOn(etherscanAPI?.default, "getLastCoinOperations")
336
- .mockImplementation(() =>
337
- Promise.resolve([coinOperation1, coinOperation2])
338
- );
339
- jest
340
- .spyOn(etherscanAPI?.default, "getLastTokenOperations")
341
- .mockImplementation(() =>
342
- Promise.resolve([
343
- {
344
- tokenCurrency: tokenCurrency1,
345
- operation: tokenOperation1,
346
- },
347
- {
348
- tokenCurrency: tokenCurrency1,
349
- operation: tokenOperation2,
350
- },
351
- ])
352
- );
318
+ .mockImplementation(() => Promise.resolve([coinOperation1, coinOperation2]));
319
+ jest.spyOn(etherscanAPI?.default, "getLastTokenOperations").mockImplementation(() =>
320
+ Promise.resolve([
321
+ {
322
+ tokenCurrency: tokenCurrency1,
323
+ operation: tokenOperation1,
324
+ },
325
+ {
326
+ tokenCurrency: tokenCurrency1,
327
+ operation: tokenOperation2,
328
+ },
329
+ ]),
330
+ );
353
331
  jest
354
332
  .spyOn(rpcAPI, "getTokenBalance")
355
333
  .mockImplementation(async (a, b, contractAddress) => {
356
334
  if (contractAddress === tokenCurrency1.contractAddress) {
357
335
  return new BigNumber(10000);
358
336
  }
359
- throw new Error(
360
- "Shouldn't be trying to fetch this token balance"
361
- );
337
+ throw new Error("Shouldn't be trying to fetch this token balance");
362
338
  });
363
339
  });
364
340
 
@@ -372,12 +348,9 @@ describe("EVM Family", () => {
372
348
  ...getAccountShapeParameters,
373
349
  initialAccount: account,
374
350
  },
375
- {} as any
351
+ {} as any,
376
352
  );
377
- expect(accountShape.operations).toEqual([
378
- coinOperation2,
379
- coinOperation1,
380
- ]);
353
+ expect(accountShape.operations).toEqual([coinOperation2, coinOperation1]);
381
354
  expect(accountShape?.subAccounts?.[0]?.operations).toEqual([
382
355
  tokenOperation2,
383
356
  tokenOperation1,
@@ -397,7 +370,7 @@ describe("EVM Family", () => {
397
370
  operations,
398
371
  },
399
372
  },
400
- {} as any
373
+ {} as any,
401
374
  );
402
375
 
403
376
  expect(accountShape).toEqual({
@@ -440,7 +413,7 @@ describe("EVM Family", () => {
440
413
  jest
441
414
  .spyOn(synchronization, "getOperationStatus")
442
415
  .mockImplementation((currency, op) =>
443
- Promise.resolve(op.hash === "0xH4sH" ? coinOperation1 : null)
416
+ Promise.resolve(op.hash === "0xH4sH" ? coinOperation1 : null),
444
417
  );
445
418
  });
446
419
 
@@ -465,7 +438,7 @@ describe("EVM Family", () => {
465
438
  ],
466
439
  },
467
440
  },
468
- {} as any
441
+ {} as any,
469
442
  );
470
443
 
471
444
  expect(accountShape.operations).toEqual([coinOperation1]);
@@ -475,42 +448,38 @@ describe("EVM Family", () => {
475
448
 
476
449
  describe("getSubAccounts", () => {
477
450
  beforeEach(() => {
478
- jest
479
- .spyOn(rpcAPI, "getTokenBalance")
480
- .mockImplementation(async (a, b, contractAddress) => {
481
- switch (contractAddress) {
482
- case "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": // usdc
483
- return new BigNumber(1);
484
- case "0xdAC17F958D2ee523a2206206994597C13D831ec7": // usdt
485
- return new BigNumber(2);
486
- default:
487
- return new BigNumber(0);
488
- }
489
- });
451
+ jest.spyOn(rpcAPI, "getTokenBalance").mockImplementation(async (a, b, contractAddress) => {
452
+ switch (contractAddress) {
453
+ case "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": // usdc
454
+ return new BigNumber(1);
455
+ case "0xdAC17F958D2ee523a2206206994597C13D831ec7": // usdt
456
+ return new BigNumber(2);
457
+ default:
458
+ return new BigNumber(0);
459
+ }
460
+ });
490
461
  });
491
462
  afterEach(() => {
492
463
  jest.restoreAllMocks();
493
464
  });
494
465
 
495
466
  it("should return the right subAccounts", async () => {
496
- jest
497
- .spyOn(etherscanAPI?.default, "getLastTokenOperations")
498
- .mockImplementation(async () => [
499
- { tokenCurrency: tokenCurrency1, operation: tokenOperation1 },
500
- { tokenCurrency: tokenCurrency1, operation: tokenOperation2 },
501
- { tokenCurrency: tokenCurrency2, operation: tokenOperation4 },
502
- {
503
- tokenCurrency: undefined as any,
504
- operation: ignoredTokenOperation,
505
- },
506
- ]);
467
+ jest.spyOn(etherscanAPI?.default, "getLastTokenOperations").mockImplementation(async () => [
468
+ { tokenCurrency: tokenCurrency1, operation: tokenOperation1 },
469
+ { tokenCurrency: tokenCurrency1, operation: tokenOperation2 },
470
+ { tokenCurrency: tokenCurrency2, operation: tokenOperation4 },
471
+ {
472
+ tokenCurrency: undefined as any,
473
+ operation: ignoredTokenOperation,
474
+ },
475
+ ]);
507
476
 
508
477
  const tokenAccounts = await synchronization.getSubAccounts(
509
478
  {
510
479
  ...getAccountShapeParameters,
511
480
  initialAccount: account,
512
481
  },
513
- account.id
482
+ account.id,
514
483
  );
515
484
 
516
485
  const expectedUsdcAccount = {
@@ -532,10 +501,7 @@ describe("EVM Family", () => {
532
501
  swapHistory: [],
533
502
  };
534
503
 
535
- expect(tokenAccounts).toEqual([
536
- expectedUsdcAccount,
537
- expectedUsdtAccount,
538
- ]);
504
+ expect(tokenAccounts).toEqual([expectedUsdcAccount, expectedUsdtAccount]);
539
505
  });
540
506
 
541
507
  it("should return a partial sub account based on blockHeight", async () => {
@@ -562,7 +528,7 @@ describe("EVM Family", () => {
562
528
  ...getAccountShapeParameters,
563
529
  initialAccount: accountWithIncompleteSubAccount,
564
530
  },
565
- account.id
531
+ account.id,
566
532
  );
567
533
 
568
534
  const expectedUsdcAccount = {
@@ -581,7 +547,7 @@ describe("EVM Family", () => {
581
547
  currency,
582
548
  account.freshAddress,
583
549
  account.id,
584
- tokenOperation2.blockHeight
550
+ tokenOperation2.blockHeight,
585
551
  );
586
552
  });
587
553
 
@@ -601,32 +567,30 @@ describe("EVM Family", () => {
601
567
  },
602
568
  },
603
569
  },
604
- account.id
570
+ account.id,
605
571
  );
606
572
  fail("Promise should have been rejected");
607
573
  } catch (e: any) {
608
574
  if (e instanceof AssertionError) {
609
575
  throw e;
610
576
  }
611
- expect(e.message).toEqual("API type not supported");
577
+ expect(e.message).toMatch("No explorer found for currency");
612
578
  }
613
579
  });
614
580
  });
615
581
 
616
582
  describe("getSubAccountShape", () => {
617
583
  beforeEach(() => {
618
- jest
619
- .spyOn(rpcAPI, "getTokenBalance")
620
- .mockImplementation(async (a, b, contractAddress) => {
621
- switch (contractAddress) {
622
- case "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": // usdc
623
- return new BigNumber(1);
624
- case "0xdAC17F958D2ee523a2206206994597C13D831ec7": // usdt
625
- return new BigNumber(2);
626
- default:
627
- return new BigNumber(0);
628
- }
629
- });
584
+ jest.spyOn(rpcAPI, "getTokenBalance").mockImplementation(async (a, b, contractAddress) => {
585
+ switch (contractAddress) {
586
+ case "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": // usdc
587
+ return new BigNumber(1);
588
+ case "0xdAC17F958D2ee523a2206206994597C13D831ec7": // usdt
589
+ return new BigNumber(2);
590
+ default:
591
+ return new BigNumber(0);
592
+ }
593
+ });
630
594
  });
631
595
  afterEach(() => {
632
596
  jest.restoreAllMocks();
@@ -637,7 +601,7 @@ describe("EVM Family", () => {
637
601
  currency,
638
602
  account.id,
639
603
  tokenCurrency1,
640
- [tokenOperation1, tokenOperation2, tokenOperation3]
604
+ [tokenOperation1, tokenOperation2, tokenOperation3],
641
605
  );
642
606
 
643
607
  expect(subAccount).toEqual({
@@ -658,9 +622,7 @@ describe("EVM Family", () => {
658
622
  throw new Error();
659
623
  });
660
624
 
661
- expect(
662
- await synchronization.getOperationStatus(currency, coinOperation1)
663
- ).toBe(null);
625
+ expect(await synchronization.getOperationStatus(currency, coinOperation1)).toBe(null);
664
626
  });
665
627
 
666
628
  it("should return null if retrieved transaction has no blockHeight", async () => {
@@ -670,12 +632,10 @@ describe("EVM Family", () => {
670
632
  blockHash: "hash",
671
633
  timestamp: 101010010,
672
634
  nonce: 1,
673
- } as any)
635
+ } as any),
674
636
  );
675
637
 
676
- expect(
677
- await synchronization.getOperationStatus(currency, coinOperation1)
678
- ).toBe(null);
638
+ expect(await synchronization.getOperationStatus(currency, coinOperation1)).toBe(null);
679
639
  });
680
640
 
681
641
  it("should return the retrieved operation with network properties", async () => {
@@ -686,12 +646,10 @@ describe("EVM Family", () => {
686
646
  blockHash: "hash",
687
647
  timestamp: Date.now() / 1000,
688
648
  nonce: 123,
689
- } as any)
649
+ } as any),
690
650
  );
691
651
 
692
- expect(
693
- await synchronization.getOperationStatus(currency, coinOperation1)
694
- ).toEqual({
652
+ expect(await synchronization.getOperationStatus(currency, coinOperation1)).toEqual({
695
653
  ...coinOperation1,
696
654
  blockHash: "hash",
697
655
  blockHeight: 10,
@@ -707,17 +665,13 @@ describe("EVM Family", () => {
707
665
  blockNumber: 10,
708
666
  blockHash: "hash",
709
667
  nonce: 123,
710
- } as any)
668
+ } as any),
711
669
  );
712
670
  jest
713
671
  .spyOn(rpcAPI, "getBlock")
714
- .mockImplementationOnce(
715
- async () => ({ timestamp: Date.now() / 1000 } as any)
716
- );
672
+ .mockImplementationOnce(async () => ({ timestamp: Date.now() / 1000 } as any));
717
673
 
718
- expect(
719
- await synchronization.getOperationStatus(currency, coinOperation1)
720
- ).toEqual({
674
+ expect(await synchronization.getOperationStatus(currency, coinOperation1)).toEqual({
721
675
  ...coinOperation1,
722
676
  blockHash: "hash",
723
677
  blockHeight: 10,
@@ -739,10 +693,7 @@ describe("EVM Family", () => {
739
693
  };
740
694
 
741
695
  expect(
742
- synchronization.postSync(
743
- { ...account, subAccounts: [] },
744
- accountWithTokenAccount
745
- )
696
+ synchronization.postSync({ ...account, subAccounts: [] }, accountWithTokenAccount),
746
697
  ).toEqual(accountWithTokenAccount);
747
698
  });
748
699
 
@@ -758,15 +709,15 @@ describe("EVM Family", () => {
758
709
  };
759
710
 
760
711
  // should not change anything if we maintain the pending op
761
- expect(
762
- synchronization.postSync(accountWithPending, accountWithPending)
763
- ).toEqual(accountWithPending);
712
+ expect(synchronization.postSync(accountWithPending, accountWithPending)).toEqual(
713
+ accountWithPending,
714
+ );
764
715
  // Should remove the pending from tokenAccount as well if removed from main account
765
716
  expect(
766
717
  synchronization.postSync(accountWithPending, {
767
718
  ...accountWithPending,
768
719
  pendingOperations: [],
769
- })
720
+ }),
770
721
  ).toEqual(account);
771
722
  });
772
723
 
@@ -792,7 +743,7 @@ describe("EVM Family", () => {
792
743
  operations: [pendingOperation],
793
744
  },
794
745
  ],
795
- })
746
+ }),
796
747
  ).toEqual({
797
748
  ...accountWithPending,
798
749
  subAccounts: [
@@ -820,12 +771,9 @@ describe("EVM Family", () => {
820
771
  };
821
772
 
822
773
  // Should remove the pending from tokenAccount if it was confirmed in the tokenAccount ops
823
- expect(
824
- synchronization.postSync(
825
- accountWithTokenAccount,
826
- accountWithTokenAccount
827
- )
828
- ).toEqual(account);
774
+ expect(synchronization.postSync(accountWithTokenAccount, accountWithTokenAccount)).toEqual(
775
+ account,
776
+ );
829
777
  });
830
778
  });
831
779
  });