@ledgerhq/coin-evm 0.3.0 → 0.4.0-next.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 (582) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/jest.config.js +4 -0
  3. package/lib/__tests__/fixtures/common.fixtures.d.ts +9 -0
  4. package/lib/__tests__/fixtures/common.fixtures.d.ts.map +1 -0
  5. package/lib/{testUtils.js → __tests__/fixtures/common.fixtures.js} +40 -9
  6. package/lib/__tests__/fixtures/common.fixtures.js.map +1 -0
  7. package/lib/__tests__/fixtures/etherscan.fixtures.d.ts +86 -0
  8. package/lib/__tests__/fixtures/etherscan.fixtures.d.ts.map +1 -0
  9. package/lib/__tests__/fixtures/etherscan.fixtures.js +267 -0
  10. package/lib/__tests__/fixtures/etherscan.fixtures.js.map +1 -0
  11. package/lib/__tests__/fixtures/prepareTransaction.fixtures.d.ts +10 -0
  12. package/lib/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -0
  13. package/lib/__tests__/fixtures/prepareTransaction.fixtures.js +69 -0
  14. package/lib/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -0
  15. package/lib/__tests__/fixtures/synchronization.fixtures.d.ts +44 -0
  16. package/lib/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -0
  17. package/lib/__tests__/fixtures/synchronization.fixtures.js +219 -0
  18. package/lib/__tests__/fixtures/synchronization.fixtures.js.map +1 -0
  19. package/lib/__tests__/fixtures/transaction.fixtures.d.ts +47 -0
  20. package/lib/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -0
  21. package/lib/__tests__/fixtures/transaction.fixtures.js +182 -0
  22. package/lib/__tests__/fixtures/transaction.fixtures.js.map +1 -0
  23. package/lib/__tests__/integration/bridge.integration.test.d.ts +7 -0
  24. package/lib/__tests__/integration/bridge.integration.test.d.ts.map +1 -0
  25. package/lib/__tests__/integration/bridge.integration.test.js +74 -0
  26. package/lib/__tests__/integration/bridge.integration.test.js.map +1 -0
  27. package/lib/__tests__/unit/adapters.unit.test.d.ts.map +1 -0
  28. package/lib/__tests__/unit/adapters.unit.test.js +989 -0
  29. package/lib/__tests__/unit/adapters.unit.test.js.map +1 -0
  30. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.d.ts +2 -0
  31. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.d.ts.map +1 -0
  32. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js +430 -0
  33. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -0
  34. package/lib/__tests__/unit/api/explorer/index.unit.test.d.ts +2 -0
  35. package/lib/__tests__/unit/api/explorer/index.unit.test.d.ts.map +1 -0
  36. package/lib/__tests__/unit/api/explorer/index.unit.test.js +49 -0
  37. package/lib/__tests__/unit/api/explorer/index.unit.test.js.map +1 -0
  38. package/lib/__tests__/unit/api/gasTracker/index.unit.test.d.ts +2 -0
  39. package/lib/__tests__/unit/api/gasTracker/index.unit.test.d.ts.map +1 -0
  40. package/lib/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.js +3 -3
  41. package/lib/__tests__/unit/api/gasTracker/index.unit.test.js.map +1 -0
  42. package/lib/__tests__/unit/api/gasTracker/ledger.unit.test.d.ts.map +1 -0
  43. package/lib/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.js +2 -2
  44. package/lib/__tests__/unit/api/gasTracker/ledger.unit.test.js.map +1 -0
  45. package/lib/__tests__/unit/api/rpc/rpc.unit.test.d.ts.map +1 -0
  46. package/lib/__tests__/{rpc.unit.test.js → unit/api/rpc/rpc.unit.test.js} +14 -14
  47. package/lib/__tests__/unit/api/rpc/rpc.unit.test.js.map +1 -0
  48. package/lib/__tests__/unit/broadcast.unit.test.d.ts.map +1 -0
  49. package/lib/__tests__/unit/broadcast.unit.test.js +335 -0
  50. package/lib/__tests__/unit/broadcast.unit.test.js.map +1 -0
  51. package/lib/__tests__/unit/buildOptimisticOperation.unit.test.d.ts.map +1 -0
  52. package/lib/__tests__/{buildOptimisticOperation.unit.test.js → unit/buildOptimisticOperation.unit.test.js} +132 -6
  53. package/lib/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -0
  54. package/lib/__tests__/unit/createTransaction.unit.test.d.ts.map +1 -0
  55. package/lib/__tests__/{createTransaction.unit.test.js → unit/createTransaction.unit.test.js} +5 -5
  56. package/lib/__tests__/unit/createTransaction.unit.test.js.map +1 -0
  57. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  58. package/lib/__tests__/{deviceTransactionConfig.unit.test.js → unit/deviceTransactionConfig.unit.test.js} +123 -6
  59. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -0
  60. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  61. package/lib/__tests__/{estimateMaxSpendable.unit.test.js → unit/estimateMaxSpendable.unit.test.js} +6 -6
  62. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -0
  63. package/lib/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
  64. package/lib/__tests__/{getTransactionStatus.unit.test.js → unit/getTransactionStatus.unit.test.js} +76 -6
  65. package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -0
  66. package/lib/__tests__/unit/hw-getAddress.unit.test.d.ts.map +1 -0
  67. package/lib/__tests__/{hw-getAddress.unit.test.js → unit/hw-getAddress.unit.test.js} +5 -1
  68. package/lib/__tests__/unit/hw-getAddress.unit.test.js.map +1 -0
  69. package/lib/__tests__/unit/hw-signMessage.unit.test.d.ts +2 -0
  70. package/lib/__tests__/unit/hw-signMessage.unit.test.d.ts.map +1 -0
  71. package/lib/__tests__/unit/hw-signMessage.unit.test.js +188 -0
  72. package/lib/__tests__/unit/hw-signMessage.unit.test.js.map +1 -0
  73. package/lib/__tests__/unit/logic.unit.test.d.ts.map +1 -0
  74. package/lib/__tests__/{logic.unit.test.js → unit/logic.unit.test.js} +111 -20
  75. package/lib/__tests__/unit/logic.unit.test.js.map +1 -0
  76. package/lib/__tests__/unit/nftResolvers.unit.test.d.ts +2 -0
  77. package/lib/__tests__/unit/nftResolvers.unit.test.d.ts.map +1 -0
  78. package/lib/__tests__/unit/nftResolvers.unit.test.js +163 -0
  79. package/lib/__tests__/unit/nftResolvers.unit.test.js.map +1 -0
  80. package/lib/__tests__/unit/preload.unit.test.d.ts.map +1 -0
  81. package/lib/__tests__/{preload.unit.test.js → unit/preload.unit.test.js} +3 -3
  82. package/lib/__tests__/unit/preload.unit.test.js.map +1 -0
  83. package/lib/__tests__/unit/prepareTransaction.unit.test.d.ts.map +1 -0
  84. package/lib/__tests__/unit/prepareTransaction.unit.test.js +300 -0
  85. package/lib/__tests__/unit/prepareTransaction.unit.test.js.map +1 -0
  86. package/lib/__tests__/unit/signOperation.unit.test.d.ts.map +1 -0
  87. package/lib/__tests__/{signOperation.unit.test.js → unit/signOperation.unit.test.js} +14 -17
  88. package/lib/__tests__/unit/signOperation.unit.test.js.map +1 -0
  89. package/lib/__tests__/unit/synchronization.unit.test.d.ts.map +1 -0
  90. package/lib/__tests__/{synchronization.unit.test.js → unit/synchronization.unit.test.js} +139 -231
  91. package/lib/__tests__/unit/synchronization.unit.test.js.map +1 -0
  92. package/lib/__tests__/unit/transaction.unit.test.d.ts.map +1 -0
  93. package/lib/__tests__/{transaction.unit.test.js → unit/transaction.unit.test.js} +48 -80
  94. package/lib/__tests__/unit/transaction.unit.test.js.map +1 -0
  95. package/lib/abis/erc1155.abi.json +314 -0
  96. package/lib/abis/erc721.abi.json +346 -0
  97. package/lib/adapters.d.ts +18 -7
  98. package/lib/adapters.d.ts.map +1 -1
  99. package/lib/adapters.js +131 -46
  100. package/lib/adapters.js.map +1 -1
  101. package/lib/api/explorer/etherscan.d.ts +39 -11
  102. package/lib/api/explorer/etherscan.d.ts.map +1 -1
  103. package/lib/api/explorer/etherscan.js +151 -9
  104. package/lib/api/explorer/etherscan.js.map +1 -1
  105. package/lib/api/explorer/index.d.ts +7 -16
  106. package/lib/api/explorer/index.d.ts.map +1 -1
  107. package/lib/api/explorer/index.js.map +1 -1
  108. package/lib/api/nft/index.d.ts +24 -0
  109. package/lib/api/nft/index.d.ts.map +1 -0
  110. package/lib/api/nft/index.js +54 -0
  111. package/lib/api/nft/index.js.map +1 -0
  112. package/lib/api/rpc/index.native.d.ts.map +1 -1
  113. package/lib/api/rpc/index.native.js +1 -0
  114. package/lib/api/rpc/index.native.js.map +1 -1
  115. package/lib/api/rpc/rpc.common.d.ts +2 -2
  116. package/lib/api/rpc/rpc.common.d.ts.map +1 -1
  117. package/lib/api/rpc/rpc.common.js +3 -3
  118. package/lib/api/rpc/rpc.common.js.map +1 -1
  119. package/lib/bridge/js.d.ts +1 -1
  120. package/lib/bridge/js.d.ts.map +1 -1
  121. package/lib/bridge/js.js +10 -10
  122. package/lib/bridge/js.js.map +1 -1
  123. package/lib/broadcast.d.ts.map +1 -1
  124. package/lib/broadcast.js +9 -2
  125. package/lib/broadcast.js.map +1 -1
  126. package/lib/buildOptimisticOperation.d.ts +5 -1
  127. package/lib/buildOptimisticOperation.d.ts.map +1 -1
  128. package/lib/buildOptimisticOperation.js +46 -4
  129. package/lib/buildOptimisticOperation.js.map +1 -1
  130. package/lib/cli-transaction.d.ts.map +1 -1
  131. package/lib/cli-transaction.js +1 -0
  132. package/lib/cli-transaction.js.map +1 -1
  133. package/lib/datasets/ethereum1.d.ts.map +1 -1
  134. package/lib/datasets/ethereum1.js +3 -2
  135. package/lib/datasets/ethereum1.js.map +1 -1
  136. package/lib/deviceTransactionConfig.d.ts.map +1 -1
  137. package/lib/deviceTransactionConfig.js +50 -0
  138. package/lib/deviceTransactionConfig.js.map +1 -1
  139. package/lib/errors.d.ts +9 -0
  140. package/lib/errors.d.ts.map +1 -1
  141. package/lib/errors.js +7 -1
  142. package/lib/errors.js.map +1 -1
  143. package/lib/getTransactionStatus.d.ts +1 -0
  144. package/lib/getTransactionStatus.d.ts.map +1 -1
  145. package/lib/getTransactionStatus.js +25 -3
  146. package/lib/getTransactionStatus.js.map +1 -1
  147. package/lib/hw-signMessage.d.ts +15 -0
  148. package/lib/hw-signMessage.d.ts.map +1 -0
  149. package/lib/hw-signMessage.js +86 -0
  150. package/lib/hw-signMessage.js.map +1 -0
  151. package/lib/logic.d.ts +63 -1
  152. package/lib/logic.d.ts.map +1 -1
  153. package/lib/logic.js +98 -2
  154. package/lib/logic.js.map +1 -1
  155. package/lib/nftResolvers.d.ts +19 -0
  156. package/lib/nftResolvers.d.ts.map +1 -0
  157. package/lib/nftResolvers.js +58 -0
  158. package/lib/nftResolvers.js.map +1 -0
  159. package/lib/preload.d.ts.map +1 -1
  160. package/lib/preload.js +7 -3
  161. package/lib/preload.js.map +1 -1
  162. package/lib/prepareTransaction.d.ts +6 -1
  163. package/lib/prepareTransaction.d.ts.map +1 -1
  164. package/lib/prepareTransaction.js +69 -18
  165. package/lib/prepareTransaction.js.map +1 -1
  166. package/lib/signOperation.d.ts +1 -1
  167. package/lib/signOperation.d.ts.map +1 -1
  168. package/lib/signOperation.js +17 -6
  169. package/lib/signOperation.js.map +1 -1
  170. package/lib/signer.d.ts +24 -1
  171. package/lib/signer.d.ts.map +1 -1
  172. package/lib/specs.d.ts +3 -1
  173. package/lib/specs.d.ts.map +1 -1
  174. package/lib/specs.js +3 -3
  175. package/lib/specs.js.map +1 -1
  176. package/lib/speculos-deviceActions.d.ts.map +1 -1
  177. package/lib/speculos-deviceActions.js +2 -1
  178. package/lib/speculos-deviceActions.js.map +1 -1
  179. package/lib/synchronization.d.ts +7 -2
  180. package/lib/synchronization.d.ts.map +1 -1
  181. package/lib/synchronization.js +45 -45
  182. package/lib/synchronization.js.map +1 -1
  183. package/lib/transaction.d.ts +3 -4
  184. package/lib/transaction.d.ts.map +1 -1
  185. package/lib/transaction.js +58 -12
  186. package/lib/transaction.js.map +1 -1
  187. package/lib/types.d.ts +85 -10
  188. package/lib/types.d.ts.map +1 -1
  189. package/lib-es/__tests__/fixtures/common.fixtures.d.ts +9 -0
  190. package/lib-es/__tests__/fixtures/common.fixtures.d.ts.map +1 -0
  191. package/lib-es/{testUtils.js → __tests__/fixtures/common.fixtures.js} +36 -8
  192. package/lib-es/__tests__/fixtures/common.fixtures.js.map +1 -0
  193. package/lib-es/__tests__/fixtures/etherscan.fixtures.d.ts +86 -0
  194. package/lib-es/__tests__/fixtures/etherscan.fixtures.d.ts.map +1 -0
  195. package/lib-es/__tests__/fixtures/etherscan.fixtures.js +264 -0
  196. package/lib-es/__tests__/fixtures/etherscan.fixtures.js.map +1 -0
  197. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.d.ts +10 -0
  198. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -0
  199. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js +62 -0
  200. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -0
  201. package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts +44 -0
  202. package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -0
  203. package/lib-es/__tests__/fixtures/synchronization.fixtures.js +190 -0
  204. package/lib-es/__tests__/fixtures/synchronization.fixtures.js.map +1 -0
  205. package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts +47 -0
  206. package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -0
  207. package/lib-es/__tests__/fixtures/transaction.fixtures.js +176 -0
  208. package/lib-es/__tests__/fixtures/transaction.fixtures.js.map +1 -0
  209. package/lib-es/__tests__/integration/bridge.integration.test.d.ts +7 -0
  210. package/lib-es/__tests__/integration/bridge.integration.test.d.ts.map +1 -0
  211. package/lib-es/__tests__/integration/bridge.integration.test.js +71 -0
  212. package/lib-es/__tests__/integration/bridge.integration.test.js.map +1 -0
  213. package/lib-es/__tests__/unit/adapters.unit.test.d.ts.map +1 -0
  214. package/lib-es/__tests__/unit/adapters.unit.test.js +984 -0
  215. package/lib-es/__tests__/unit/adapters.unit.test.js.map +1 -0
  216. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.d.ts +2 -0
  217. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.d.ts.map +1 -0
  218. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js +402 -0
  219. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -0
  220. package/lib-es/__tests__/unit/api/explorer/index.unit.test.d.ts.map +1 -0
  221. package/lib-es/__tests__/unit/api/explorer/index.unit.test.js +44 -0
  222. package/lib-es/__tests__/unit/api/explorer/index.unit.test.js.map +1 -0
  223. package/lib-es/__tests__/unit/api/gasTracker/index.unit.test.d.ts.map +1 -0
  224. package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.js +3 -3
  225. package/lib-es/__tests__/unit/api/gasTracker/index.unit.test.js.map +1 -0
  226. package/lib-es/__tests__/unit/api/gasTracker/ledger.unit.test.d.ts.map +1 -0
  227. package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.js +2 -2
  228. package/lib-es/__tests__/unit/api/gasTracker/ledger.unit.test.js.map +1 -0
  229. package/lib-es/__tests__/unit/api/rpc/rpc.unit.test.d.ts.map +1 -0
  230. package/lib-es/__tests__/{rpc.unit.test.js → unit/api/rpc/rpc.unit.test.js} +13 -13
  231. package/lib-es/__tests__/unit/api/rpc/rpc.unit.test.js.map +1 -0
  232. package/lib-es/__tests__/unit/broadcast.unit.test.d.ts.map +1 -0
  233. package/lib-es/__tests__/unit/broadcast.unit.test.js +307 -0
  234. package/lib-es/__tests__/unit/broadcast.unit.test.js.map +1 -0
  235. package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.d.ts.map +1 -0
  236. package/lib-es/__tests__/{buildOptimisticOperation.unit.test.js → unit/buildOptimisticOperation.unit.test.js} +130 -4
  237. package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -0
  238. package/lib-es/__tests__/unit/createTransaction.unit.test.d.ts.map +1 -0
  239. package/lib-es/__tests__/{createTransaction.unit.test.js → unit/createTransaction.unit.test.js} +3 -3
  240. package/lib-es/__tests__/unit/createTransaction.unit.test.js.map +1 -0
  241. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  242. package/lib-es/__tests__/{deviceTransactionConfig.unit.test.js → unit/deviceTransactionConfig.unit.test.js} +121 -4
  243. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -0
  244. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  245. package/lib-es/__tests__/{estimateMaxSpendable.unit.test.js → unit/estimateMaxSpendable.unit.test.js} +4 -4
  246. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -0
  247. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
  248. package/lib-es/__tests__/{getTransactionStatus.unit.test.js → unit/getTransactionStatus.unit.test.js} +74 -4
  249. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -0
  250. package/lib-es/__tests__/unit/hw-getAddress.unit.test.d.ts.map +1 -0
  251. package/lib-es/__tests__/{hw-getAddress.unit.test.js → unit/hw-getAddress.unit.test.js} +5 -1
  252. package/lib-es/__tests__/unit/hw-getAddress.unit.test.js.map +1 -0
  253. package/lib-es/__tests__/unit/hw-signMessage.unit.test.d.ts +2 -0
  254. package/lib-es/__tests__/unit/hw-signMessage.unit.test.d.ts.map +1 -0
  255. package/lib-es/__tests__/unit/hw-signMessage.unit.test.js +186 -0
  256. package/lib-es/__tests__/unit/hw-signMessage.unit.test.js.map +1 -0
  257. package/lib-es/__tests__/unit/logic.unit.test.d.ts.map +1 -0
  258. package/lib-es/__tests__/{logic.unit.test.js → unit/logic.unit.test.js} +97 -6
  259. package/lib-es/__tests__/unit/logic.unit.test.js.map +1 -0
  260. package/lib-es/__tests__/unit/nftResolvers.unit.test.d.ts +2 -0
  261. package/lib-es/__tests__/unit/nftResolvers.unit.test.d.ts.map +1 -0
  262. package/lib-es/__tests__/unit/nftResolvers.unit.test.js +158 -0
  263. package/lib-es/__tests__/unit/nftResolvers.unit.test.js.map +1 -0
  264. package/lib-es/__tests__/unit/preload.unit.test.d.ts.map +1 -0
  265. package/lib-es/__tests__/{preload.unit.test.js → unit/preload.unit.test.js} +3 -3
  266. package/lib-es/__tests__/unit/preload.unit.test.js.map +1 -0
  267. package/lib-es/__tests__/unit/prepareTransaction.unit.test.d.ts.map +1 -0
  268. package/lib-es/__tests__/{prepareTransaction.unit.test.js → unit/prepareTransaction.unit.test.js} +134 -82
  269. package/lib-es/__tests__/unit/prepareTransaction.unit.test.js.map +1 -0
  270. package/lib-es/__tests__/unit/signOperation.unit.test.d.ts.map +1 -0
  271. package/lib-es/__tests__/{signOperation.unit.test.js → unit/signOperation.unit.test.js} +13 -16
  272. package/lib-es/__tests__/unit/signOperation.unit.test.js.map +1 -0
  273. package/lib-es/__tests__/unit/synchronization.unit.test.d.ts.map +1 -0
  274. package/lib-es/__tests__/{synchronization.unit.test.js → unit/synchronization.unit.test.js} +115 -207
  275. package/lib-es/__tests__/unit/synchronization.unit.test.js.map +1 -0
  276. package/lib-es/__tests__/unit/transaction.unit.test.d.ts.map +1 -0
  277. package/lib-es/__tests__/{transaction.unit.test.js → unit/transaction.unit.test.js} +40 -72
  278. package/lib-es/__tests__/unit/transaction.unit.test.js.map +1 -0
  279. package/lib-es/abis/erc1155.abi.json +314 -0
  280. package/lib-es/abis/erc721.abi.json +346 -0
  281. package/lib-es/adapters.d.ts +18 -7
  282. package/lib-es/adapters.d.ts.map +1 -1
  283. package/lib-es/adapters.js +127 -44
  284. package/lib-es/adapters.js.map +1 -1
  285. package/lib-es/api/explorer/etherscan.d.ts +39 -11
  286. package/lib-es/api/explorer/etherscan.d.ts.map +1 -1
  287. package/lib-es/api/explorer/etherscan.js +146 -10
  288. package/lib-es/api/explorer/etherscan.js.map +1 -1
  289. package/lib-es/api/explorer/index.d.ts +7 -16
  290. package/lib-es/api/explorer/index.d.ts.map +1 -1
  291. package/lib-es/api/explorer/index.js.map +1 -1
  292. package/lib-es/api/nft/index.d.ts +24 -0
  293. package/lib-es/api/nft/index.d.ts.map +1 -0
  294. package/lib-es/api/nft/index.js +46 -0
  295. package/lib-es/api/nft/index.js.map +1 -0
  296. package/lib-es/api/rpc/index.native.d.ts.map +1 -1
  297. package/lib-es/api/rpc/index.native.js +1 -0
  298. package/lib-es/api/rpc/index.native.js.map +1 -1
  299. package/lib-es/api/rpc/rpc.common.d.ts +2 -2
  300. package/lib-es/api/rpc/rpc.common.d.ts.map +1 -1
  301. package/lib-es/api/rpc/rpc.common.js +3 -3
  302. package/lib-es/api/rpc/rpc.common.js.map +1 -1
  303. package/lib-es/bridge/js.d.ts +1 -1
  304. package/lib-es/bridge/js.d.ts.map +1 -1
  305. package/lib-es/bridge/js.js +10 -10
  306. package/lib-es/bridge/js.js.map +1 -1
  307. package/lib-es/broadcast.d.ts.map +1 -1
  308. package/lib-es/broadcast.js +9 -2
  309. package/lib-es/broadcast.js.map +1 -1
  310. package/lib-es/buildOptimisticOperation.d.ts +5 -1
  311. package/lib-es/buildOptimisticOperation.d.ts.map +1 -1
  312. package/lib-es/buildOptimisticOperation.js +45 -4
  313. package/lib-es/buildOptimisticOperation.js.map +1 -1
  314. package/lib-es/cli-transaction.d.ts.map +1 -1
  315. package/lib-es/cli-transaction.js +1 -0
  316. package/lib-es/cli-transaction.js.map +1 -1
  317. package/lib-es/datasets/ethereum1.d.ts.map +1 -1
  318. package/lib-es/datasets/ethereum1.js +3 -2
  319. package/lib-es/datasets/ethereum1.js.map +1 -1
  320. package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
  321. package/lib-es/deviceTransactionConfig.js +50 -0
  322. package/lib-es/deviceTransactionConfig.js.map +1 -1
  323. package/lib-es/errors.d.ts +9 -0
  324. package/lib-es/errors.d.ts.map +1 -1
  325. package/lib-es/errors.js +6 -0
  326. package/lib-es/errors.js.map +1 -1
  327. package/lib-es/getTransactionStatus.d.ts +1 -0
  328. package/lib-es/getTransactionStatus.d.ts.map +1 -1
  329. package/lib-es/getTransactionStatus.js +23 -2
  330. package/lib-es/getTransactionStatus.js.map +1 -1
  331. package/lib-es/hw-signMessage.d.ts +15 -0
  332. package/lib-es/hw-signMessage.d.ts.map +1 -0
  333. package/lib-es/hw-signMessage.js +81 -0
  334. package/lib-es/hw-signMessage.js.map +1 -0
  335. package/lib-es/logic.d.ts +63 -1
  336. package/lib-es/logic.d.ts.map +1 -1
  337. package/lib-es/logic.js +95 -1
  338. package/lib-es/logic.js.map +1 -1
  339. package/lib-es/nftResolvers.d.ts +19 -0
  340. package/lib-es/nftResolvers.d.ts.map +1 -0
  341. package/lib-es/nftResolvers.js +50 -0
  342. package/lib-es/nftResolvers.js.map +1 -0
  343. package/lib-es/preload.d.ts.map +1 -1
  344. package/lib-es/preload.js +7 -3
  345. package/lib-es/preload.js.map +1 -1
  346. package/lib-es/prepareTransaction.d.ts +6 -1
  347. package/lib-es/prepareTransaction.d.ts.map +1 -1
  348. package/lib-es/prepareTransaction.js +68 -18
  349. package/lib-es/prepareTransaction.js.map +1 -1
  350. package/lib-es/signOperation.d.ts +1 -1
  351. package/lib-es/signOperation.d.ts.map +1 -1
  352. package/lib-es/signOperation.js +17 -6
  353. package/lib-es/signOperation.js.map +1 -1
  354. package/lib-es/signer.d.ts +24 -1
  355. package/lib-es/signer.d.ts.map +1 -1
  356. package/lib-es/specs.d.ts +3 -1
  357. package/lib-es/specs.d.ts.map +1 -1
  358. package/lib-es/specs.js +3 -3
  359. package/lib-es/specs.js.map +1 -1
  360. package/lib-es/speculos-deviceActions.d.ts.map +1 -1
  361. package/lib-es/speculos-deviceActions.js +2 -1
  362. package/lib-es/speculos-deviceActions.js.map +1 -1
  363. package/lib-es/synchronization.d.ts +7 -2
  364. package/lib-es/synchronization.d.ts.map +1 -1
  365. package/lib-es/synchronization.js +46 -46
  366. package/lib-es/synchronization.js.map +1 -1
  367. package/lib-es/transaction.d.ts +3 -4
  368. package/lib-es/transaction.d.ts.map +1 -1
  369. package/lib-es/transaction.js +58 -12
  370. package/lib-es/transaction.js.map +1 -1
  371. package/lib-es/types.d.ts +85 -10
  372. package/lib-es/types.d.ts.map +1 -1
  373. package/package.json +13 -12
  374. package/src/{testUtils.ts → __tests__/fixtures/common.fixtures.ts} +78 -11
  375. package/src/__tests__/fixtures/etherscan.fixtures.ts +266 -0
  376. package/src/__tests__/fixtures/prepareTransaction.fixtures.ts +86 -0
  377. package/src/__tests__/fixtures/synchronization.fixtures.ts +229 -0
  378. package/src/__tests__/fixtures/transaction.fixtures.ts +229 -0
  379. package/src/__tests__/integration/bridge.integration.test.ts +74 -0
  380. package/src/__tests__/unit/adapters.unit.test.ts +1076 -0
  381. package/src/__tests__/unit/api/explorer/etherscan.unit.test.ts +563 -0
  382. package/src/__tests__/unit/api/explorer/index.unit.test.ts +36 -0
  383. package/src/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.ts +3 -3
  384. package/src/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.ts +3 -3
  385. package/src/__tests__/{rpc.unit.test.ts → unit/api/rpc/rpc.unit.test.ts} +17 -14
  386. package/src/__tests__/unit/broadcast.unit.test.ts +332 -0
  387. package/src/__tests__/{buildOptimisticOperation.unit.test.ts → unit/buildOptimisticOperation.unit.test.ts} +144 -5
  388. package/src/__tests__/{createTransaction.unit.test.ts → unit/createTransaction.unit.test.ts} +4 -4
  389. package/src/__tests__/{deviceTransactionConfig.unit.test.ts → unit/deviceTransactionConfig.unit.test.ts} +130 -5
  390. package/src/__tests__/{estimateMaxSpendable.unit.test.ts → unit/estimateMaxSpendable.unit.test.ts} +5 -5
  391. package/src/__tests__/{getTransactionStatus.unit.test.ts → unit/getTransactionStatus.unit.test.ts} +121 -5
  392. package/src/__tests__/{hw-getAddress.unit.test.ts → unit/hw-getAddress.unit.test.ts} +6 -2
  393. package/src/__tests__/unit/hw-signMessage.unit.test.ts +192 -0
  394. package/src/__tests__/{logic.unit.test.ts → unit/logic.unit.test.ts} +143 -8
  395. package/src/__tests__/unit/nftResolvers.unit.test.ts +179 -0
  396. package/src/__tests__/{preload.unit.test.ts → unit/preload.unit.test.ts} +4 -4
  397. package/src/__tests__/{prepareTransaction.unit.test.ts → unit/prepareTransaction.unit.test.ts} +284 -109
  398. package/src/__tests__/{signOperation.unit.test.ts → unit/signOperation.unit.test.ts} +18 -20
  399. package/src/__tests__/{synchronization.unit.test.ts → unit/synchronization.unit.test.ts} +202 -280
  400. package/src/__tests__/unit/transaction.unit.test.ts +198 -0
  401. package/src/abis/erc1155.abi.json +314 -0
  402. package/src/abis/erc20.abi.json +4 -12
  403. package/src/abis/erc721.abi.json +346 -0
  404. package/src/adapters.ts +177 -64
  405. package/src/api/explorer/etherscan.ts +265 -49
  406. package/src/api/explorer/index.ts +24 -10
  407. package/src/api/nft/index.ts +49 -0
  408. package/src/api/rpc/index.native.ts +2 -0
  409. package/src/api/rpc/rpc.common.ts +3 -3
  410. package/src/bridge/js.ts +13 -16
  411. package/src/broadcast.ts +29 -2
  412. package/src/buildOptimisticOperation.ts +71 -6
  413. package/src/cli-transaction.ts +2 -0
  414. package/src/datasets/ethereum1.ts +4 -2
  415. package/src/deviceTransactionConfig.ts +65 -0
  416. package/src/errors.ts +8 -0
  417. package/src/getTransactionStatus.ts +26 -0
  418. package/src/hw-signMessage.ts +92 -0
  419. package/src/logic.ts +118 -2
  420. package/src/nftResolvers.ts +71 -0
  421. package/src/preload.ts +9 -3
  422. package/src/prepareTransaction.ts +102 -24
  423. package/src/signOperation.ts +21 -8
  424. package/src/signer.ts +44 -1
  425. package/src/specs.ts +11 -6
  426. package/src/speculos-deviceActions.ts +3 -1
  427. package/src/synchronization.ts +73 -59
  428. package/src/transaction.ts +68 -15
  429. package/src/types.ts +108 -10
  430. package/.eslintrc.js +0 -22
  431. package/lib/__tests__/adapters.unit.test.d.ts.map +0 -1
  432. package/lib/__tests__/adapters.unit.test.js +0 -455
  433. package/lib/__tests__/adapters.unit.test.js.map +0 -1
  434. package/lib/__tests__/broadcast.unit.test.d.ts.map +0 -1
  435. package/lib/__tests__/broadcast.unit.test.js +0 -181
  436. package/lib/__tests__/broadcast.unit.test.js.map +0 -1
  437. package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts.map +0 -1
  438. package/lib/__tests__/buildOptimisticOperation.unit.test.js.map +0 -1
  439. package/lib/__tests__/createTransaction.unit.test.d.ts.map +0 -1
  440. package/lib/__tests__/createTransaction.unit.test.js.map +0 -1
  441. package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts.map +0 -1
  442. package/lib/__tests__/deviceTransactionConfig.unit.test.js.map +0 -1
  443. package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts.map +0 -1
  444. package/lib/__tests__/estimateMaxSpendable.unit.test.js.map +0 -1
  445. package/lib/__tests__/gasTracker/index.unit.test.d.ts.map +0 -1
  446. package/lib/__tests__/gasTracker/index.unit.test.js.map +0 -1
  447. package/lib/__tests__/gasTracker/ledger.unit.test.d.ts.map +0 -1
  448. package/lib/__tests__/gasTracker/ledger.unit.test.js.map +0 -1
  449. package/lib/__tests__/getTransactionStatus.unit.test.d.ts.map +0 -1
  450. package/lib/__tests__/getTransactionStatus.unit.test.js.map +0 -1
  451. package/lib/__tests__/hw-getAddress.unit.test.d.ts.map +0 -1
  452. package/lib/__tests__/hw-getAddress.unit.test.js.map +0 -1
  453. package/lib/__tests__/logic.unit.test.d.ts.map +0 -1
  454. package/lib/__tests__/logic.unit.test.js.map +0 -1
  455. package/lib/__tests__/preload.unit.test.d.ts.map +0 -1
  456. package/lib/__tests__/preload.unit.test.js.map +0 -1
  457. package/lib/__tests__/prepareTransaction.unit.test.d.ts.map +0 -1
  458. package/lib/__tests__/prepareTransaction.unit.test.js +0 -248
  459. package/lib/__tests__/prepareTransaction.unit.test.js.map +0 -1
  460. package/lib/__tests__/rpc.unit.test.d.ts.map +0 -1
  461. package/lib/__tests__/rpc.unit.test.js.map +0 -1
  462. package/lib/__tests__/signOperation.unit.test.d.ts.map +0 -1
  463. package/lib/__tests__/signOperation.unit.test.js.map +0 -1
  464. package/lib/__tests__/synchronization.unit.test.d.ts.map +0 -1
  465. package/lib/__tests__/synchronization.unit.test.js.map +0 -1
  466. package/lib/__tests__/transaction.unit.test.d.ts.map +0 -1
  467. package/lib/__tests__/transaction.unit.test.js.map +0 -1
  468. package/lib/bridge.integration.test.d.ts +0 -14
  469. package/lib/bridge.integration.test.d.ts.map +0 -1
  470. package/lib/bridge.integration.test.js +0 -85
  471. package/lib/bridge.integration.test.js.map +0 -1
  472. package/lib/datasets/ethereum.scanAccounts.1.d.ts +0 -7
  473. package/lib/datasets/ethereum.scanAccounts.1.d.ts.map +0 -1
  474. package/lib/datasets/ethereum.scanAccounts.1.js +0 -51
  475. package/lib/datasets/ethereum.scanAccounts.1.js.map +0 -1
  476. package/lib/datasets/ethereum2.d.ts +0 -3
  477. package/lib/datasets/ethereum2.d.ts.map +0 -1
  478. package/lib/datasets/ethereum2.js +0 -22
  479. package/lib/datasets/ethereum2.js.map +0 -1
  480. package/lib/datasets/ethereum_classic.d.ts +0 -5
  481. package/lib/datasets/ethereum_classic.d.ts.map +0 -1
  482. package/lib/datasets/ethereum_classic.js +0 -69
  483. package/lib/datasets/ethereum_classic.js.map +0 -1
  484. package/lib/testUtils.d.ts +0 -6
  485. package/lib/testUtils.d.ts.map +0 -1
  486. package/lib/testUtils.js.map +0 -1
  487. package/lib-es/__tests__/adapters.unit.test.d.ts.map +0 -1
  488. package/lib-es/__tests__/adapters.unit.test.js +0 -450
  489. package/lib-es/__tests__/adapters.unit.test.js.map +0 -1
  490. package/lib-es/__tests__/broadcast.unit.test.d.ts.map +0 -1
  491. package/lib-es/__tests__/broadcast.unit.test.js +0 -153
  492. package/lib-es/__tests__/broadcast.unit.test.js.map +0 -1
  493. package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts.map +0 -1
  494. package/lib-es/__tests__/buildOptimisticOperation.unit.test.js.map +0 -1
  495. package/lib-es/__tests__/createTransaction.unit.test.d.ts.map +0 -1
  496. package/lib-es/__tests__/createTransaction.unit.test.js.map +0 -1
  497. package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts.map +0 -1
  498. package/lib-es/__tests__/deviceTransactionConfig.unit.test.js.map +0 -1
  499. package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts.map +0 -1
  500. package/lib-es/__tests__/estimateMaxSpendable.unit.test.js.map +0 -1
  501. package/lib-es/__tests__/gasTracker/index.unit.test.d.ts.map +0 -1
  502. package/lib-es/__tests__/gasTracker/index.unit.test.js.map +0 -1
  503. package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts.map +0 -1
  504. package/lib-es/__tests__/gasTracker/ledger.unit.test.js.map +0 -1
  505. package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts.map +0 -1
  506. package/lib-es/__tests__/getTransactionStatus.unit.test.js.map +0 -1
  507. package/lib-es/__tests__/hw-getAddress.unit.test.d.ts.map +0 -1
  508. package/lib-es/__tests__/hw-getAddress.unit.test.js.map +0 -1
  509. package/lib-es/__tests__/logic.unit.test.d.ts.map +0 -1
  510. package/lib-es/__tests__/logic.unit.test.js.map +0 -1
  511. package/lib-es/__tests__/preload.unit.test.d.ts.map +0 -1
  512. package/lib-es/__tests__/preload.unit.test.js.map +0 -1
  513. package/lib-es/__tests__/prepareTransaction.unit.test.d.ts.map +0 -1
  514. package/lib-es/__tests__/prepareTransaction.unit.test.js.map +0 -1
  515. package/lib-es/__tests__/rpc.unit.test.d.ts.map +0 -1
  516. package/lib-es/__tests__/rpc.unit.test.js.map +0 -1
  517. package/lib-es/__tests__/signOperation.unit.test.d.ts.map +0 -1
  518. package/lib-es/__tests__/signOperation.unit.test.js.map +0 -1
  519. package/lib-es/__tests__/synchronization.unit.test.d.ts.map +0 -1
  520. package/lib-es/__tests__/synchronization.unit.test.js.map +0 -1
  521. package/lib-es/__tests__/transaction.unit.test.d.ts.map +0 -1
  522. package/lib-es/__tests__/transaction.unit.test.js.map +0 -1
  523. package/lib-es/bridge.integration.test.d.ts +0 -14
  524. package/lib-es/bridge.integration.test.d.ts.map +0 -1
  525. package/lib-es/bridge.integration.test.js +0 -79
  526. package/lib-es/bridge.integration.test.js.map +0 -1
  527. package/lib-es/datasets/ethereum.scanAccounts.1.d.ts +0 -7
  528. package/lib-es/datasets/ethereum.scanAccounts.1.d.ts.map +0 -1
  529. package/lib-es/datasets/ethereum.scanAccounts.1.js +0 -49
  530. package/lib-es/datasets/ethereum.scanAccounts.1.js.map +0 -1
  531. package/lib-es/datasets/ethereum2.d.ts +0 -3
  532. package/lib-es/datasets/ethereum2.d.ts.map +0 -1
  533. package/lib-es/datasets/ethereum2.js +0 -19
  534. package/lib-es/datasets/ethereum2.js.map +0 -1
  535. package/lib-es/datasets/ethereum_classic.d.ts +0 -5
  536. package/lib-es/datasets/ethereum_classic.d.ts.map +0 -1
  537. package/lib-es/datasets/ethereum_classic.js +0 -67
  538. package/lib-es/datasets/ethereum_classic.js.map +0 -1
  539. package/lib-es/testUtils.d.ts +0 -6
  540. package/lib-es/testUtils.d.ts.map +0 -1
  541. package/lib-es/testUtils.js.map +0 -1
  542. package/src/__tests__/adapters.unit.test.ts +0 -497
  543. package/src/__tests__/broadcast.unit.test.ts +0 -163
  544. package/src/__tests__/transaction.unit.test.ts +0 -188
  545. package/src/bridge.integration.test.ts +0 -86
  546. package/src/datasets/ethereum.scanAccounts.1.ts +0 -48
  547. package/src/datasets/ethereum2.ts +0 -20
  548. package/src/datasets/ethereum_classic.ts +0 -68
  549. /package/lib/__tests__/{adapters.unit.test.d.ts → unit/adapters.unit.test.d.ts} +0 -0
  550. /package/lib/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.d.ts +0 -0
  551. /package/lib/__tests__/{rpc.unit.test.d.ts → unit/api/rpc/rpc.unit.test.d.ts} +0 -0
  552. /package/lib/__tests__/{broadcast.unit.test.d.ts → unit/broadcast.unit.test.d.ts} +0 -0
  553. /package/lib/__tests__/{buildOptimisticOperation.unit.test.d.ts → unit/buildOptimisticOperation.unit.test.d.ts} +0 -0
  554. /package/lib/__tests__/{createTransaction.unit.test.d.ts → unit/createTransaction.unit.test.d.ts} +0 -0
  555. /package/lib/__tests__/{deviceTransactionConfig.unit.test.d.ts → unit/deviceTransactionConfig.unit.test.d.ts} +0 -0
  556. /package/lib/__tests__/{estimateMaxSpendable.unit.test.d.ts → unit/estimateMaxSpendable.unit.test.d.ts} +0 -0
  557. /package/lib/__tests__/{getTransactionStatus.unit.test.d.ts → unit/getTransactionStatus.unit.test.d.ts} +0 -0
  558. /package/lib/__tests__/{hw-getAddress.unit.test.d.ts → unit/hw-getAddress.unit.test.d.ts} +0 -0
  559. /package/lib/__tests__/{logic.unit.test.d.ts → unit/logic.unit.test.d.ts} +0 -0
  560. /package/lib/__tests__/{preload.unit.test.d.ts → unit/preload.unit.test.d.ts} +0 -0
  561. /package/lib/__tests__/{prepareTransaction.unit.test.d.ts → unit/prepareTransaction.unit.test.d.ts} +0 -0
  562. /package/lib/__tests__/{signOperation.unit.test.d.ts → unit/signOperation.unit.test.d.ts} +0 -0
  563. /package/lib/__tests__/{synchronization.unit.test.d.ts → unit/synchronization.unit.test.d.ts} +0 -0
  564. /package/lib/__tests__/{transaction.unit.test.d.ts → unit/transaction.unit.test.d.ts} +0 -0
  565. /package/lib-es/__tests__/{adapters.unit.test.d.ts → unit/adapters.unit.test.d.ts} +0 -0
  566. /package/lib-es/__tests__/{gasTracker → unit/api/explorer}/index.unit.test.d.ts +0 -0
  567. /package/{lib/__tests__ → lib-es/__tests__/unit/api}/gasTracker/index.unit.test.d.ts +0 -0
  568. /package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.d.ts +0 -0
  569. /package/lib-es/__tests__/{rpc.unit.test.d.ts → unit/api/rpc/rpc.unit.test.d.ts} +0 -0
  570. /package/lib-es/__tests__/{broadcast.unit.test.d.ts → unit/broadcast.unit.test.d.ts} +0 -0
  571. /package/lib-es/__tests__/{buildOptimisticOperation.unit.test.d.ts → unit/buildOptimisticOperation.unit.test.d.ts} +0 -0
  572. /package/lib-es/__tests__/{createTransaction.unit.test.d.ts → unit/createTransaction.unit.test.d.ts} +0 -0
  573. /package/lib-es/__tests__/{deviceTransactionConfig.unit.test.d.ts → unit/deviceTransactionConfig.unit.test.d.ts} +0 -0
  574. /package/lib-es/__tests__/{estimateMaxSpendable.unit.test.d.ts → unit/estimateMaxSpendable.unit.test.d.ts} +0 -0
  575. /package/lib-es/__tests__/{getTransactionStatus.unit.test.d.ts → unit/getTransactionStatus.unit.test.d.ts} +0 -0
  576. /package/lib-es/__tests__/{hw-getAddress.unit.test.d.ts → unit/hw-getAddress.unit.test.d.ts} +0 -0
  577. /package/lib-es/__tests__/{logic.unit.test.d.ts → unit/logic.unit.test.d.ts} +0 -0
  578. /package/lib-es/__tests__/{preload.unit.test.d.ts → unit/preload.unit.test.d.ts} +0 -0
  579. /package/lib-es/__tests__/{prepareTransaction.unit.test.d.ts → unit/prepareTransaction.unit.test.d.ts} +0 -0
  580. /package/lib-es/__tests__/{signOperation.unit.test.d.ts → unit/signOperation.unit.test.d.ts} +0 -0
  581. /package/lib-es/__tests__/{synchronization.unit.test.d.ts → unit/synchronization.unit.test.d.ts} +0 -0
  582. /package/lib-es/__tests__/{transaction.unit.test.d.ts → unit/transaction.unit.test.d.ts} +0 -0
@@ -0,0 +1,563 @@
1
+ import axios from "axios";
2
+ import { AssertionError, fail } from "assert";
3
+ import { delay } from "@ledgerhq/live-promise";
4
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
5
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
6
+ import * as ETHERSCAN_API from "../../../../api/explorer/etherscan";
7
+ import { makeAccount } from "../../../fixtures/common.fixtures";
8
+ import {
9
+ etherscanCoinOperations,
10
+ etherscanERC1155Operations,
11
+ etherscanERC721Operations,
12
+ etherscanTokenOperations,
13
+ } from "../../../fixtures/etherscan.fixtures";
14
+ import {
15
+ etherscanERC1155EventToOperations,
16
+ etherscanERC20EventToOperations,
17
+ etherscanERC721EventToOperations,
18
+ etherscanOperationToOperations,
19
+ } from "../../../../adapters";
20
+
21
+ jest.mock("axios");
22
+ jest.mock("@ledgerhq/live-promise");
23
+ (delay as jest.Mock).mockImplementation(
24
+ () => new Promise(resolve => setTimeout(resolve, 1)), // mocking the delay supposed to happen after each try
25
+ );
26
+
27
+ const currency: CryptoCurrency = {
28
+ ...getCryptoCurrencyById("ethereum"),
29
+ ethereumLikeInfo: {
30
+ chainId: 1,
31
+ explorer: {
32
+ type: "etherscan",
33
+ uri: "mock",
34
+ },
35
+ },
36
+ };
37
+ const account = makeAccount("0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d", currency);
38
+
39
+ describe("EVM Family", () => {
40
+ describe("api/explorer/etherscan.ts", () => {
41
+ afterAll(() => {
42
+ jest.restoreAllMocks();
43
+ });
44
+
45
+ describe("fetchWithRetries", () => {
46
+ afterEach(() => {
47
+ jest.clearAllMocks();
48
+ });
49
+
50
+ it("should retry on fail", async () => {
51
+ let retries = 2;
52
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => {
53
+ if (retries) {
54
+ --retries;
55
+ throw new Error();
56
+ }
57
+ return { data: { result: true } };
58
+ });
59
+ const response = await ETHERSCAN_API.fetchWithRetries({}, retries);
60
+
61
+ expect(response).toBe(true);
62
+ // it should fail 2 times and succeed on the next try
63
+ expect(spy).toBeCalledTimes(3);
64
+ });
65
+
66
+ it("should throw after too many retries", async () => {
67
+ const SpyError = class SpyError extends Error {};
68
+
69
+ let retries = ETHERSCAN_API.DEFAULT_RETRIES_API + 1;
70
+ jest.spyOn(axios, "request").mockImplementation(async () => {
71
+ if (retries) {
72
+ --retries;
73
+ throw new SpyError();
74
+ }
75
+ return { data: { result: true } };
76
+ });
77
+ try {
78
+ await ETHERSCAN_API.fetchWithRetries({});
79
+ fail("Promise should have been rejected");
80
+ } catch (e) {
81
+ if (e instanceof AssertionError) {
82
+ throw e;
83
+ }
84
+ expect(e).toBeInstanceOf(SpyError);
85
+ }
86
+ });
87
+
88
+ it("should also retry if the Etherscan reponse is a 200 w/ a NOTOK message (used for rate limit)", async () => {
89
+ let retries = 2;
90
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => {
91
+ if (retries) {
92
+ --retries;
93
+ return { data: { message: "NOTOK" } };
94
+ }
95
+ return { data: { result: true } };
96
+ });
97
+ const response = await ETHERSCAN_API.fetchWithRetries({}, retries);
98
+
99
+ expect(response).toBe(true);
100
+ // it should fail 2 times and succeed on the next try
101
+ expect(spy).toBeCalledTimes(3);
102
+ });
103
+ });
104
+
105
+ describe("getLastCoinOperations", () => {
106
+ afterEach(() => {
107
+ jest.clearAllMocks();
108
+ });
109
+
110
+ it("should return an empty array if the currency is misconfigured", async () => {
111
+ jest.spyOn(axios, "request").mockImplementation(async () => ({
112
+ data: {
113
+ result: etherscanCoinOperations,
114
+ },
115
+ }));
116
+
117
+ const response = await ETHERSCAN_API.getLastCoinOperations(
118
+ {
119
+ ...currency,
120
+ ethereumLikeInfo: {
121
+ chainId: 1,
122
+ // no explorer
123
+ },
124
+ },
125
+ account.freshAddress,
126
+ account.id,
127
+ 0,
128
+ );
129
+
130
+ expect(response).toEqual([]);
131
+ });
132
+
133
+ it("should return a flat list of coin transactions from block 0", async () => {
134
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
135
+ data: {
136
+ result: etherscanCoinOperations,
137
+ },
138
+ }));
139
+
140
+ const response = await ETHERSCAN_API.getLastCoinOperations(
141
+ currency,
142
+ account.freshAddress,
143
+ account.id,
144
+ 0,
145
+ );
146
+
147
+ expect(response).toEqual(
148
+ etherscanCoinOperations.map(op => etherscanOperationToOperations(account.id, op)).flat(),
149
+ );
150
+ expect(response.length).toBe(4);
151
+ expect(spy).toBeCalledWith({
152
+ method: "GET",
153
+ url: `mock/api?module=account&action=txlist&address=${account.freshAddress}&tag=latest&page=1&sort=desc`,
154
+ });
155
+ });
156
+
157
+ it("should return a flat list of coin transactions from block 50", async () => {
158
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
159
+ data: {
160
+ result: etherscanCoinOperations,
161
+ },
162
+ }));
163
+
164
+ const response = await ETHERSCAN_API.getLastCoinOperations(
165
+ currency,
166
+ account.freshAddress,
167
+ account.id,
168
+ 50,
169
+ );
170
+
171
+ expect(response).toEqual(
172
+ etherscanCoinOperations.map(op => etherscanOperationToOperations(account.id, op)).flat(),
173
+ );
174
+ expect(response.length).toBe(4);
175
+ expect(spy).toBeCalledWith({
176
+ method: "GET",
177
+ url: `mock/api?module=account&action=txlist&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50`,
178
+ });
179
+ });
180
+
181
+ it("should return a flat list of coin transactions from block 50 to block 100", async () => {
182
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
183
+ data: {
184
+ result: etherscanCoinOperations,
185
+ },
186
+ }));
187
+
188
+ const response = await ETHERSCAN_API.getLastCoinOperations(
189
+ currency,
190
+ account.freshAddress,
191
+ account.id,
192
+ 50,
193
+ 100,
194
+ );
195
+
196
+ expect(response).toEqual(
197
+ etherscanCoinOperations.map(op => etherscanOperationToOperations(account.id, op)).flat(),
198
+ );
199
+ expect(response.length).toBe(4);
200
+ expect(spy).toBeCalledWith({
201
+ method: "GET",
202
+ url: `mock/api?module=account&action=txlist&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50&endBlock=100`,
203
+ });
204
+ });
205
+ });
206
+
207
+ describe("getLastTokenOperations", () => {
208
+ afterEach(() => {
209
+ jest.clearAllMocks();
210
+ });
211
+
212
+ it("should return an empty array if the currency is misconfigured", async () => {
213
+ jest.spyOn(axios, "request").mockImplementation(async () => ({
214
+ data: {
215
+ result: etherscanTokenOperations,
216
+ },
217
+ }));
218
+
219
+ const response = await ETHERSCAN_API.getLastTokenOperations(
220
+ {
221
+ ...currency,
222
+ ethereumLikeInfo: {
223
+ chainId: 1,
224
+ // no explorer
225
+ },
226
+ },
227
+ account.freshAddress,
228
+ account.id,
229
+ 0,
230
+ );
231
+
232
+ expect(response).toEqual([]);
233
+ });
234
+
235
+ it("should return a flat list of token transactions from block 0", async () => {
236
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
237
+ data: {
238
+ result: etherscanTokenOperations,
239
+ },
240
+ }));
241
+
242
+ const response = await ETHERSCAN_API.getLastTokenOperations(
243
+ currency,
244
+ account.freshAddress,
245
+ account.id,
246
+ 0,
247
+ );
248
+
249
+ expect(response).toEqual(
250
+ [
251
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[0], 0),
252
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[1], 0),
253
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[2], 1),
254
+ ].flat(),
255
+ );
256
+ expect(spy).toBeCalledWith({
257
+ method: "GET",
258
+ url: `mock/api?module=account&action=tokentx&address=${account.freshAddress}&tag=latest&page=1&sort=desc`,
259
+ });
260
+ });
261
+
262
+ it("should return a flat list of token transactions from block 50", async () => {
263
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
264
+ data: {
265
+ result: etherscanTokenOperations,
266
+ },
267
+ }));
268
+
269
+ const response = await ETHERSCAN_API.getLastTokenOperations(
270
+ currency,
271
+ account.freshAddress,
272
+ account.id,
273
+ 50,
274
+ );
275
+
276
+ expect(response).toEqual(
277
+ [
278
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[0], 0),
279
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[1], 0),
280
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[2], 1),
281
+ ].flat(),
282
+ );
283
+ expect(spy).toBeCalledWith({
284
+ method: "GET",
285
+ url: `mock/api?module=account&action=tokentx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50`,
286
+ });
287
+ });
288
+
289
+ it("should return a flat list of token transactions from block 50 to block 100", async () => {
290
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
291
+ data: {
292
+ result: etherscanTokenOperations,
293
+ },
294
+ }));
295
+
296
+ const response = await ETHERSCAN_API.getLastTokenOperations(
297
+ currency,
298
+ account.freshAddress,
299
+ account.id,
300
+ 50,
301
+ 100,
302
+ );
303
+
304
+ expect(response).toEqual(
305
+ [
306
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[0], 0),
307
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[1], 0),
308
+ etherscanERC20EventToOperations(account.id, etherscanTokenOperations[2], 1),
309
+ ].flat(),
310
+ );
311
+ expect(spy).toBeCalledWith({
312
+ method: "GET",
313
+ url: `mock/api?module=account&action=tokentx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50&endBlock=100`,
314
+ });
315
+ });
316
+ });
317
+
318
+ describe("getLastERC721Operations", () => {
319
+ afterEach(() => {
320
+ jest.clearAllMocks();
321
+ });
322
+
323
+ it("should return an empty array if the currency is misconfigured", async () => {
324
+ jest.spyOn(axios, "request").mockImplementation(async () => ({
325
+ data: {
326
+ result: etherscanERC721Operations,
327
+ },
328
+ }));
329
+
330
+ const response = await ETHERSCAN_API.getLastERC721Operations(
331
+ {
332
+ ...currency,
333
+ ethereumLikeInfo: {
334
+ chainId: 1,
335
+ // no explorer
336
+ },
337
+ },
338
+ account.freshAddress,
339
+ account.id,
340
+ 0,
341
+ );
342
+
343
+ expect(response).toEqual([]);
344
+ });
345
+
346
+ it("should return a flat list of erc721 transactions from block 0", async () => {
347
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
348
+ data: {
349
+ result: etherscanERC721Operations,
350
+ },
351
+ }));
352
+
353
+ const response = await ETHERSCAN_API.getLastERC721Operations(
354
+ currency,
355
+ account.freshAddress,
356
+ account.id,
357
+ 0,
358
+ );
359
+
360
+ expect(response).toEqual(
361
+ [
362
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[0], 0),
363
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[1], 0),
364
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[2], 1),
365
+ ].flat(),
366
+ );
367
+ expect(spy).toBeCalledWith({
368
+ method: "GET",
369
+ url: `mock/api?module=account&action=tokennfttx&address=${account.freshAddress}&tag=latest&page=1&sort=desc`,
370
+ });
371
+ });
372
+
373
+ it("should return a flat list of erc721 transactions from block 50", async () => {
374
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
375
+ data: {
376
+ result: etherscanERC721Operations,
377
+ },
378
+ }));
379
+
380
+ const response = await ETHERSCAN_API.getLastERC721Operations(
381
+ currency,
382
+ account.freshAddress,
383
+ account.id,
384
+ 50,
385
+ );
386
+
387
+ expect(response).toEqual(
388
+ [
389
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[0], 0),
390
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[1], 0),
391
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[2], 1),
392
+ ].flat(),
393
+ );
394
+ expect(spy).toBeCalledWith({
395
+ method: "GET",
396
+ url: `mock/api?module=account&action=tokennfttx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50`,
397
+ });
398
+ });
399
+
400
+ it("should return a flat list of erc721 transactions from block 50 to block 100", async () => {
401
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
402
+ data: {
403
+ result: etherscanERC721Operations,
404
+ },
405
+ }));
406
+
407
+ const response = await ETHERSCAN_API.getLastERC721Operations(
408
+ currency,
409
+ account.freshAddress,
410
+ account.id,
411
+ 50,
412
+ 100,
413
+ );
414
+
415
+ expect(response).toEqual(
416
+ [
417
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[0], 0),
418
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[1], 0),
419
+ etherscanERC721EventToOperations(account.id, etherscanERC721Operations[2], 1),
420
+ ].flat(),
421
+ );
422
+ expect(spy).toBeCalledWith({
423
+ method: "GET",
424
+ url: `mock/api?module=account&action=tokennfttx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50&endBlock=100`,
425
+ });
426
+ });
427
+ });
428
+
429
+ describe("getLastERC1155Operations", () => {
430
+ afterEach(() => {
431
+ jest.clearAllMocks();
432
+ });
433
+
434
+ it("should return an empty array if the currency is misconfigured", async () => {
435
+ jest.spyOn(axios, "request").mockImplementation(async () => ({
436
+ data: {
437
+ result: etherscanERC721Operations,
438
+ },
439
+ }));
440
+
441
+ const response = await ETHERSCAN_API.getLastERC1155Operations(
442
+ {
443
+ ...currency,
444
+ ethereumLikeInfo: {
445
+ chainId: 1,
446
+ // no explorer
447
+ },
448
+ },
449
+ account.freshAddress,
450
+ account.id,
451
+ 0,
452
+ );
453
+
454
+ expect(response).toEqual([]);
455
+ });
456
+
457
+ it("should return a flat list of erc1155 transactions from block 0", async () => {
458
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
459
+ data: {
460
+ result: etherscanERC1155Operations,
461
+ },
462
+ }));
463
+
464
+ const response = await ETHERSCAN_API.getLastERC1155Operations(
465
+ currency,
466
+ account.freshAddress,
467
+ account.id,
468
+ 0,
469
+ );
470
+
471
+ expect(response).toEqual(
472
+ [
473
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[0], 0),
474
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[1], 0),
475
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[2], 1),
476
+ ].flat(),
477
+ );
478
+ expect(spy).toBeCalledWith({
479
+ method: "GET",
480
+ url: `mock/api?module=account&action=token1155tx&address=${account.freshAddress}&tag=latest&page=1&sort=desc`,
481
+ });
482
+ });
483
+
484
+ it("should return a flat list of erc1155 transactions from block 50", async () => {
485
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
486
+ data: {
487
+ result: etherscanERC1155Operations,
488
+ },
489
+ }));
490
+
491
+ const response = await ETHERSCAN_API.getLastERC1155Operations(
492
+ currency,
493
+ account.freshAddress,
494
+ account.id,
495
+ 50,
496
+ );
497
+
498
+ expect(response).toEqual(
499
+ [
500
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[0], 0),
501
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[1], 0),
502
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[2], 1),
503
+ ].flat(),
504
+ );
505
+ expect(spy).toBeCalledWith({
506
+ method: "GET",
507
+ url: `mock/api?module=account&action=token1155tx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50`,
508
+ });
509
+ });
510
+
511
+ it("should return a flat list of erc1155 transactions from block 50 to block 100", async () => {
512
+ const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
513
+ data: {
514
+ result: etherscanERC1155Operations,
515
+ },
516
+ }));
517
+
518
+ const response = await ETHERSCAN_API.getLastERC1155Operations(
519
+ currency,
520
+ account.freshAddress,
521
+ account.id,
522
+ 50,
523
+ 100,
524
+ );
525
+
526
+ expect(response).toEqual(
527
+ [
528
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[0], 0),
529
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[1], 0),
530
+ etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[2], 1),
531
+ ].flat(),
532
+ );
533
+ expect(spy).toBeCalledWith({
534
+ method: "GET",
535
+ url: `mock/api?module=account&action=token1155tx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50&endBlock=100`,
536
+ });
537
+ });
538
+ });
539
+
540
+ describe("getLastNftOperations", () => {
541
+ it("should return a sorted array of nft transactions", async () => {
542
+ jest.spyOn(axios, "request").mockImplementation(async params => ({
543
+ data: {
544
+ result: params.url?.includes("tokennfttx")
545
+ ? etherscanERC721Operations
546
+ : etherscanERC1155Operations,
547
+ },
548
+ }));
549
+
550
+ const response = await ETHERSCAN_API.getLastNftOperations(
551
+ currency,
552
+ account.freshAddress,
553
+ account.id,
554
+ 0,
555
+ );
556
+
557
+ expect(response).toEqual(
558
+ response.slice().sort((a, b) => b.date.getTime() - a.date.getTime()),
559
+ );
560
+ });
561
+ });
562
+ });
563
+ });
@@ -0,0 +1,36 @@
1
+ import { AssertionError, fail } from "assert";
2
+ import { getExplorerApi } from "../../../../api/explorer";
3
+ import etherscanLikeApi from "../../../../api/explorer/etherscan";
4
+
5
+ describe("EVM Family", () => {
6
+ describe("api/explorer/index.ts", () => {
7
+ describe("getExplorerApi", () => {
8
+ it("should throw when requesting a non existing explorer", async () => {
9
+ try {
10
+ await getExplorerApi({
11
+ id: "not-existing",
12
+ ethereumLikeInfo: { explorer: { type: "anything", uri: "notworking" } },
13
+ } as any);
14
+ fail("Promise should have been rejected");
15
+ } catch (e) {
16
+ if (e instanceof AssertionError) {
17
+ throw e;
18
+ }
19
+ expect((e as Error).message).toEqual(`No explorer found for currency "not-existing"`);
20
+ }
21
+ });
22
+
23
+ it("should return the etherscan api", async () => {
24
+ const explorerA = await getExplorerApi({
25
+ ethereumLikeInfo: { explorer: { type: "etherscan", uri: "working" } },
26
+ } as any);
27
+ const explorerB = await getExplorerApi({
28
+ ethereumLikeInfo: { explorer: { type: "blockscout", uri: "working" } },
29
+ } as any);
30
+
31
+ expect(explorerA).toBe(etherscanLikeApi);
32
+ expect(explorerB).toBe(etherscanLikeApi);
33
+ });
34
+ });
35
+ });
36
+ });
@@ -1,6 +1,6 @@
1
1
  import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
2
- import { getGasTracker } from "../../api/gasTracker";
3
- import { getGasOptions as ledgerGetGasOptions } from "../../api/gasTracker/ledger";
2
+ import { getGasTracker } from "../../../../api/gasTracker";
3
+ import { getGasOptions as ledgerGetGasOptions } from "../../../../api/gasTracker/ledger";
4
4
 
5
5
  const fakeCurrency: Partial<CryptoCurrency> = {
6
6
  id: "my_new_chain" as CryptoCurrencyId,
@@ -22,7 +22,7 @@ const fakeCurrencyWithoutGasTracker: Partial<CryptoCurrency> = {
22
22
  };
23
23
 
24
24
  describe("EVM Family", () => {
25
- describe("gasTracker", () => {
25
+ describe("api/gasTracker/index.ts", () => {
26
26
  it("should return null if no gas tracker is found", () => {
27
27
  expect(getGasTracker(fakeCurrencyWithoutGasTracker as CryptoCurrency)).toBeNull();
28
28
  });
@@ -1,9 +1,9 @@
1
1
  import network from "@ledgerhq/live-network/network";
2
2
  import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
3
3
  import BigNumber from "bignumber.js";
4
- import { GasOptions } from "../../types";
4
+ import { GasOptions } from "../../../../types";
5
5
  import { getEnv, setEnv } from "@ledgerhq/live-env";
6
- import { getGasOptions } from "../../api/gasTracker/ledger";
6
+ import { getGasOptions } from "../../../../api/gasTracker/ledger";
7
7
  jest.mock("@ledgerhq/live-network/network");
8
8
 
9
9
  const fakeCurrency: Partial<CryptoCurrency> = {
@@ -19,7 +19,7 @@ const fakeCurrency: Partial<CryptoCurrency> = {
19
19
  };
20
20
 
21
21
  describe("EVM Family", () => {
22
- describe("gasTracker", () => {
22
+ describe("api/gasTracker/index.ts", () => {
23
23
  const originalEIP1559_BASE_FEE_MULTIPLIER: number = getEnv("EIP1559_BASE_FEE_MULTIPLIER");
24
24
 
25
25
  beforeAll(() => {
@@ -1,12 +1,12 @@
1
+ import { ethers } from "ethers";
2
+ import BigNumber from "bignumber.js";
3
+ import { AssertionError, fail } from "assert";
1
4
  import { delay } from "@ledgerhq/live-promise";
2
5
  import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
3
- import { AssertionError, fail } from "assert";
4
- import BigNumber from "bignumber.js";
5
- import { ethers } from "ethers";
6
- import * as RPC_API from "../api/rpc/rpc.common";
7
- import { GasEstimationError, InsufficientFunds } from "../errors";
8
- import { makeAccount } from "../testUtils";
9
- import { Transaction as EvmTransaction, EvmTransactionLegacy } from "../types";
6
+ import { EvmTransactionLegacy, Transaction as EvmTransaction } from "../../../../types";
7
+ import { GasEstimationError, InsufficientFunds } from "../../../../errors";
8
+ import { makeAccount } from "../../../fixtures/common.fixtures";
9
+ import * as RPC_API from "../../../../api/rpc/rpc.common";
10
10
 
11
11
  const fakeCurrency: Partial<CryptoCurrency> = {
12
12
  id: "my_new_chain" as CryptoCurrencyId,
@@ -114,11 +114,14 @@ describe("EVM Family", () => {
114
114
  });
115
115
  });
116
116
 
117
- describe("api/rpc.common.ts", () => {
117
+ describe("api/rpc/rpc.common.ts", () => {
118
118
  describe("withApi", () => {
119
119
  it("should throw if the currency doesn't have an RPC node", async () => {
120
120
  try {
121
- await RPC_API.withApi(fakeCurrencyWithoutRPC as CryptoCurrency, (() => {}) as any);
121
+ await RPC_API.withApi(
122
+ fakeCurrencyWithoutRPC as CryptoCurrency,
123
+ (() => Promise.resolve()) as any,
124
+ );
122
125
  fail("Promise should have been rejected");
123
126
  } catch (e) {
124
127
  if (e instanceof AssertionError) {
@@ -128,8 +131,8 @@ describe("EVM Family", () => {
128
131
  }
129
132
  });
130
133
 
131
- it("should retry on fail as many times as the DEFAULT_RETRIES_RPC_METHODS constant is set to", async () => {
132
- let retries = RPC_API.DEFAULT_RETRIES_RPC_METHODS;
134
+ it("should retry on fail", async () => {
135
+ let retries = 2;
133
136
  const spy = jest.fn(async () => {
134
137
  if (retries) {
135
138
  --retries;
@@ -137,11 +140,11 @@ describe("EVM Family", () => {
137
140
  }
138
141
  return true;
139
142
  });
140
- const response = await RPC_API.withApi(fakeCurrency as CryptoCurrency, spy);
143
+ const response = await RPC_API.withApi(fakeCurrency as CryptoCurrency, spy, retries);
141
144
 
142
145
  expect(response).toBe(true);
143
- // it should fail DEFAULT_RETRIES_RPC_METHODS times and succeed on the next try, therefore the +1
144
- expect(spy).toBeCalledTimes(RPC_API.DEFAULT_RETRIES_RPC_METHODS + 1);
146
+ // it should fail 2 times and succeed on the next try
147
+ expect(spy).toBeCalledTimes(3);
145
148
  });
146
149
 
147
150
  it("should throw after too many retries", async () => {