@ledgerhq/coin-evm 5.4.1 → 8.0.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 (355) hide show
  1. package/.oxlintrc.json +1 -1
  2. package/CHANGELOG.md +234 -0
  3. package/docs/evm-family-integration-process/README.md +1 -1
  4. package/knip.json +2 -3
  5. package/lib/adapters/blockOperations.js +6 -6
  6. package/lib/adapters/blockOperations.js.map +1 -1
  7. package/lib/adapters/etherscan.js +23 -23
  8. package/lib/adapters/etherscan.js.map +1 -1
  9. package/lib/adapters/ledger.js +17 -17
  10. package/lib/adapters/ledger.js.map +1 -1
  11. package/lib/api/index.js +4 -4
  12. package/lib/api/index.js.map +1 -1
  13. package/lib/config.d.ts +21 -16
  14. package/lib/config.d.ts.map +1 -1
  15. package/lib/config.js +5 -25
  16. package/lib/config.js.map +1 -1
  17. package/lib/errors.d.ts +9 -0
  18. package/lib/errors.d.ts.map +1 -1
  19. package/lib/errors.js +15 -1
  20. package/lib/errors.js.map +1 -1
  21. package/lib/logic/broadcast.js +1 -1
  22. package/lib/logic/broadcast.js.map +1 -1
  23. package/lib/logic/common.d.ts +2 -1
  24. package/lib/logic/common.d.ts.map +1 -1
  25. package/lib/logic/common.js +4 -4
  26. package/lib/logic/common.js.map +1 -1
  27. package/lib/logic/craftTransaction.d.ts.map +1 -1
  28. package/lib/logic/craftTransaction.js +2 -2
  29. package/lib/logic/craftTransaction.js.map +1 -1
  30. package/lib/logic/estimateFees.d.ts.map +1 -1
  31. package/lib/logic/estimateFees.js +9 -9
  32. package/lib/logic/estimateFees.js.map +1 -1
  33. package/lib/logic/getBalance.d.ts.map +1 -1
  34. package/lib/logic/getBalance.js +50 -16
  35. package/lib/logic/getBalance.js.map +1 -1
  36. package/lib/logic/getBlock.d.ts.map +1 -1
  37. package/lib/logic/getBlock.js +19 -11
  38. package/lib/logic/getBlock.js.map +1 -1
  39. package/lib/logic/getBlockInfo.js +1 -1
  40. package/lib/logic/getBlockInfo.js.map +1 -1
  41. package/lib/logic/getNextSequence.d.ts.map +1 -1
  42. package/lib/logic/getNextSequence.js +1 -1
  43. package/lib/logic/getNextSequence.js.map +1 -1
  44. package/lib/logic/index.d.ts +2 -0
  45. package/lib/logic/index.d.ts.map +1 -1
  46. package/lib/logic/index.js +4 -0
  47. package/lib/logic/index.js.map +1 -1
  48. package/lib/logic/lastBlock.js +1 -1
  49. package/lib/logic/lastBlock.js.map +1 -1
  50. package/lib/logic/listOperations.d.ts.map +1 -1
  51. package/lib/logic/listOperations.js +10 -1
  52. package/lib/logic/listOperations.js.map +1 -1
  53. package/lib/logic/validateIntent.d.ts.map +1 -1
  54. package/lib/logic/validateIntent.js +12 -12
  55. package/lib/logic/validateIntent.js.map +1 -1
  56. package/lib/logic-public/index.d.ts +3 -0
  57. package/lib/logic-public/index.d.ts.map +1 -0
  58. package/lib/logic-public/index.js +19 -0
  59. package/lib/logic-public/index.js.map +1 -0
  60. package/lib/{utils.d.ts → logic-public/utils.d.ts} +0 -44
  61. package/lib/logic-public/utils.d.ts.map +1 -0
  62. package/lib/logic-public/utils.js +166 -0
  63. package/lib/logic-public/utils.js.map +1 -0
  64. package/lib/logic.d.ts +2 -1
  65. package/lib/logic.d.ts.map +1 -1
  66. package/lib/logic.js +3 -3
  67. package/lib/logic.js.map +1 -1
  68. package/lib/network/explorer/etherscan.d.ts +16 -3
  69. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  70. package/lib/network/explorer/etherscan.js +61 -6
  71. package/lib/network/explorer/etherscan.js.map +1 -1
  72. package/lib/network/explorer/ledger.d.ts +50 -4
  73. package/lib/network/explorer/ledger.d.ts.map +1 -1
  74. package/lib/network/explorer/ledger.js +286 -37
  75. package/lib/network/explorer/ledger.js.map +1 -1
  76. package/lib/network/explorer/none.d.ts +1 -0
  77. package/lib/network/explorer/none.d.ts.map +1 -1
  78. package/lib/network/explorer/none.js +4 -1
  79. package/lib/network/explorer/none.js.map +1 -1
  80. package/lib/network/explorer/types.d.ts +15 -2
  81. package/lib/network/explorer/types.d.ts.map +1 -1
  82. package/lib/network/explorer/types.js.map +1 -1
  83. package/lib/network/index.d.ts +5 -0
  84. package/lib/network/index.d.ts.map +1 -0
  85. package/lib/network/index.js +23 -0
  86. package/lib/network/index.js.map +1 -0
  87. package/lib/network/node/explorerProxy.d.ts +27 -0
  88. package/lib/network/node/explorerProxy.d.ts.map +1 -0
  89. package/lib/network/node/explorerProxy.js +262 -0
  90. package/lib/network/node/explorerProxy.js.map +1 -0
  91. package/lib/network/node/index.d.ts +2 -1
  92. package/lib/network/node/index.d.ts.map +1 -1
  93. package/lib/network/node/index.js +11 -10
  94. package/lib/network/node/index.js.map +1 -1
  95. package/lib/network/node/ledger.js +7 -7
  96. package/lib/network/node/ledger.js.map +1 -1
  97. package/lib/network/node/rpc.common.d.ts +2 -2
  98. package/lib/network/node/rpc.common.js +19 -19
  99. package/lib/network/node/rpc.common.js.map +1 -1
  100. package/lib/network/node/withNodeSources.d.ts +21 -0
  101. package/lib/network/node/withNodeSources.d.ts.map +1 -0
  102. package/lib/network/node/withNodeSources.js +78 -0
  103. package/lib/network/node/withNodeSources.js.map +1 -0
  104. package/lib/nodeSources.d.ts +15 -0
  105. package/lib/nodeSources.d.ts.map +1 -0
  106. package/lib/nodeSources.js +33 -0
  107. package/lib/nodeSources.js.map +1 -0
  108. package/lib/staking/contracts.js +1 -1
  109. package/lib/staking/contracts.js.map +1 -1
  110. package/lib/staking/fetchers.js +1 -1
  111. package/lib/staking/fetchers.js.map +1 -1
  112. package/lib/staking/operations/sei.js +1 -1
  113. package/lib/staking/operations/sei.js.map +1 -1
  114. package/lib/staking/prepareIntents.js +3 -3
  115. package/lib/staking/prepareIntents.js.map +1 -1
  116. package/lib/staking/rewards.js +1 -1
  117. package/lib/staking/rewards.js.map +1 -1
  118. package/lib/staking/transactionData.js +2 -2
  119. package/lib/staking/transactionData.js.map +1 -1
  120. package/lib/staking/utils.d.ts +45 -0
  121. package/lib/staking/utils.d.ts.map +1 -0
  122. package/lib/{utils.js → staking/utils.js} +5 -164
  123. package/lib/staking/utils.js.map +1 -0
  124. package/lib/staking/validators/sei.js +1 -1
  125. package/lib/staking/validators/sei.js.map +1 -1
  126. package/lib/types/staking.d.ts +2 -2
  127. package/lib-es/adapters/blockOperations.js +1 -1
  128. package/lib-es/adapters/blockOperations.js.map +1 -1
  129. package/lib-es/adapters/etherscan.js +1 -1
  130. package/lib-es/adapters/etherscan.js.map +1 -1
  131. package/lib-es/adapters/ledger.js +1 -1
  132. package/lib-es/adapters/ledger.js.map +1 -1
  133. package/lib-es/api/index.js +2 -2
  134. package/lib-es/api/index.js.map +1 -1
  135. package/lib-es/config.d.ts +21 -16
  136. package/lib-es/config.d.ts.map +1 -1
  137. package/lib-es/config.js +1 -21
  138. package/lib-es/config.js.map +1 -1
  139. package/lib-es/errors.d.ts +9 -0
  140. package/lib-es/errors.d.ts.map +1 -1
  141. package/lib-es/errors.js +13 -0
  142. package/lib-es/errors.js.map +1 -1
  143. package/lib-es/logic/broadcast.js +1 -1
  144. package/lib-es/logic/broadcast.js.map +1 -1
  145. package/lib-es/logic/common.d.ts +2 -1
  146. package/lib-es/logic/common.d.ts.map +1 -1
  147. package/lib-es/logic/common.js +3 -3
  148. package/lib-es/logic/common.js.map +1 -1
  149. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  150. package/lib-es/logic/craftTransaction.js +2 -2
  151. package/lib-es/logic/craftTransaction.js.map +1 -1
  152. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  153. package/lib-es/logic/estimateFees.js +6 -6
  154. package/lib-es/logic/estimateFees.js.map +1 -1
  155. package/lib-es/logic/getBalance.d.ts.map +1 -1
  156. package/lib-es/logic/getBalance.js +50 -16
  157. package/lib-es/logic/getBalance.js.map +1 -1
  158. package/lib-es/logic/getBlock.d.ts.map +1 -1
  159. package/lib-es/logic/getBlock.js +16 -8
  160. package/lib-es/logic/getBlock.js.map +1 -1
  161. package/lib-es/logic/getBlockInfo.js +1 -1
  162. package/lib-es/logic/getBlockInfo.js.map +1 -1
  163. package/lib-es/logic/getNextSequence.d.ts.map +1 -1
  164. package/lib-es/logic/getNextSequence.js +1 -1
  165. package/lib-es/logic/getNextSequence.js.map +1 -1
  166. package/lib-es/logic/index.d.ts +2 -0
  167. package/lib-es/logic/index.d.ts.map +1 -1
  168. package/lib-es/logic/index.js +4 -0
  169. package/lib-es/logic/index.js.map +1 -1
  170. package/lib-es/logic/lastBlock.js +1 -1
  171. package/lib-es/logic/lastBlock.js.map +1 -1
  172. package/lib-es/logic/listOperations.d.ts.map +1 -1
  173. package/lib-es/logic/listOperations.js +10 -1
  174. package/lib-es/logic/listOperations.js.map +1 -1
  175. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  176. package/lib-es/logic/validateIntent.js +4 -4
  177. package/lib-es/logic/validateIntent.js.map +1 -1
  178. package/lib-es/logic-public/index.d.ts +3 -0
  179. package/lib-es/logic-public/index.d.ts.map +1 -0
  180. package/lib-es/logic-public/index.js +4 -0
  181. package/lib-es/logic-public/index.js.map +1 -0
  182. package/lib-es/{utils.d.ts → logic-public/utils.d.ts} +0 -44
  183. package/lib-es/logic-public/utils.d.ts.map +1 -0
  184. package/lib-es/logic-public/utils.js +150 -0
  185. package/lib-es/logic-public/utils.js.map +1 -0
  186. package/lib-es/logic.d.ts +2 -1
  187. package/lib-es/logic.d.ts.map +1 -1
  188. package/lib-es/logic.js +3 -3
  189. package/lib-es/logic.js.map +1 -1
  190. package/lib-es/network/explorer/etherscan.d.ts +16 -3
  191. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  192. package/lib-es/network/explorer/etherscan.js +60 -5
  193. package/lib-es/network/explorer/etherscan.js.map +1 -1
  194. package/lib-es/network/explorer/ledger.d.ts +50 -4
  195. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  196. package/lib-es/network/explorer/ledger.js +283 -37
  197. package/lib-es/network/explorer/ledger.js.map +1 -1
  198. package/lib-es/network/explorer/none.d.ts +1 -0
  199. package/lib-es/network/explorer/none.d.ts.map +1 -1
  200. package/lib-es/network/explorer/none.js +2 -0
  201. package/lib-es/network/explorer/none.js.map +1 -1
  202. package/lib-es/network/explorer/types.d.ts +15 -2
  203. package/lib-es/network/explorer/types.d.ts.map +1 -1
  204. package/lib-es/network/explorer/types.js.map +1 -1
  205. package/lib-es/network/index.d.ts +5 -0
  206. package/lib-es/network/index.d.ts.map +1 -0
  207. package/lib-es/network/index.js +7 -0
  208. package/lib-es/network/index.js.map +1 -0
  209. package/lib-es/network/node/explorerProxy.d.ts +27 -0
  210. package/lib-es/network/node/explorerProxy.d.ts.map +1 -0
  211. package/lib-es/network/node/explorerProxy.js +254 -0
  212. package/lib-es/network/node/explorerProxy.js.map +1 -0
  213. package/lib-es/network/node/index.d.ts +2 -1
  214. package/lib-es/network/node/index.d.ts.map +1 -1
  215. package/lib-es/network/node/index.js +11 -10
  216. package/lib-es/network/node/index.js.map +1 -1
  217. package/lib-es/network/node/ledger.js +1 -1
  218. package/lib-es/network/node/ledger.js.map +1 -1
  219. package/lib-es/network/node/rpc.common.d.ts +2 -2
  220. package/lib-es/network/node/rpc.common.js +3 -3
  221. package/lib-es/network/node/rpc.common.js.map +1 -1
  222. package/lib-es/network/node/withNodeSources.d.ts +21 -0
  223. package/lib-es/network/node/withNodeSources.d.ts.map +1 -0
  224. package/lib-es/network/node/withNodeSources.js +74 -0
  225. package/lib-es/network/node/withNodeSources.js.map +1 -0
  226. package/lib-es/nodeSources.d.ts +15 -0
  227. package/lib-es/nodeSources.d.ts.map +1 -0
  228. package/lib-es/nodeSources.js +28 -0
  229. package/lib-es/nodeSources.js.map +1 -0
  230. package/lib-es/staking/contracts.js +1 -1
  231. package/lib-es/staking/contracts.js.map +1 -1
  232. package/lib-es/staking/fetchers.js +1 -1
  233. package/lib-es/staking/fetchers.js.map +1 -1
  234. package/lib-es/staking/operations/sei.js +1 -1
  235. package/lib-es/staking/operations/sei.js.map +1 -1
  236. package/lib-es/staking/prepareIntents.js +1 -1
  237. package/lib-es/staking/prepareIntents.js.map +1 -1
  238. package/lib-es/staking/rewards.js +1 -1
  239. package/lib-es/staking/rewards.js.map +1 -1
  240. package/lib-es/staking/transactionData.js +1 -1
  241. package/lib-es/staking/transactionData.js.map +1 -1
  242. package/lib-es/staking/utils.d.ts +45 -0
  243. package/lib-es/staking/utils.d.ts.map +1 -0
  244. package/lib-es/{utils.js → staking/utils.js} +1 -147
  245. package/lib-es/staking/utils.js.map +1 -0
  246. package/lib-es/staking/validators/sei.js +1 -1
  247. package/lib-es/staking/validators/sei.js.map +1 -1
  248. package/lib-es/types/staking.d.ts +2 -2
  249. package/package.json +75 -9
  250. package/src/adapters/blockOperations.ts +1 -1
  251. package/src/adapters/etherscan.ts +1 -1
  252. package/src/adapters/ledger.ts +1 -1
  253. package/src/api/getBlock.integ.test.ts +10 -4
  254. package/src/api/index.arbitrum.integ.test.ts +1 -0
  255. package/src/api/index.arc.integ.test.ts +1 -0
  256. package/src/api/index.avalanche_c_chain_fuji.integ.test.ts +1 -0
  257. package/src/api/index.cronos.integ.test.ts +1 -0
  258. package/src/api/index.flare.integ.test.ts +4 -2
  259. package/src/api/index.linea.integ.test.ts +4 -2
  260. package/src/api/index.monad_testnet.integ.test.ts +95 -4
  261. package/src/api/index.optimism.integ.test.ts +1 -0
  262. package/src/api/index.rsk.integ.test.ts +1 -0
  263. package/src/api/index.shape.integ.test.ts +4 -2
  264. package/src/api/index.somnia.integ.test.ts +1 -0
  265. package/src/api/index.ts +2 -2
  266. package/src/config.ts +22 -35
  267. package/src/errors.ts +13 -0
  268. package/src/fixtures/context.fixtures.ts +9 -4
  269. package/src/logic/broadcast.ts +1 -1
  270. package/src/logic/common.ts +4 -2
  271. package/src/logic/craftTransaction.ts +2 -1
  272. package/src/logic/estimateFees.ts +20 -6
  273. package/src/logic/getBalance.ts +72 -26
  274. package/src/logic/getBlock.ts +26 -14
  275. package/src/logic/getBlockInfo.ts +1 -1
  276. package/src/logic/getNextSequence.ts +4 -1
  277. package/src/logic/index.ts +4 -0
  278. package/src/logic/lastBlock.ts +1 -1
  279. package/src/logic/listOperations.ts +14 -1
  280. package/src/logic/tests/broadcast.integ.test.ts +53 -0
  281. package/src/logic/{broadcast.test.ts → tests/broadcast.test.ts} +7 -7
  282. package/src/logic/{broadcastSource.test.ts → tests/broadcastSource.test.ts} +6 -6
  283. package/src/logic/{combine.test.ts → tests/combine.test.ts} +1 -1
  284. package/src/logic/{common.test.ts → tests/common.test.ts} +45 -21
  285. package/src/logic/{computeGasLimit.test.ts → tests/computeGasLimit.test.ts} +2 -2
  286. package/src/logic/{craftTransaction.test.ts → tests/craftTransaction.test.ts} +7 -7
  287. package/src/logic/{craftTransactionData.test.ts → tests/craftTransactionData.test.ts} +4 -4
  288. package/src/logic/{estimateFees.test.ts → tests/estimateFees.test.ts} +12 -12
  289. package/src/logic/tests/getBalance.test.ts +602 -0
  290. package/src/logic/{getBlock.test.ts → tests/getBlock.test.ts} +182 -89
  291. package/src/logic/{getBlockInfo.test.ts → tests/getBlockInfo.test.ts} +8 -8
  292. package/src/logic/{getErc20Data.test.ts → tests/getErc20Data.test.ts} +1 -1
  293. package/src/logic/{getNextSequence.test.ts → tests/getNextSequence.test.ts} +7 -7
  294. package/src/logic/{getStakes.test.ts → tests/getStakes.test.ts} +13 -13
  295. package/src/logic/{internalTransactionsFetcher.test.ts → tests/internalTransactionsFetcher.test.ts} +8 -8
  296. package/src/logic/{lastBlock.test.ts → tests/lastBlock.test.ts} +7 -7
  297. package/src/logic/{listOperations.test.ts → tests/listOperations.test.ts} +125 -6
  298. package/src/logic/{validateAddress.test.ts → tests/validateAddress.test.ts} +1 -1
  299. package/src/logic/{validateIntent.test.ts → tests/validateIntent.test.ts} +80 -78
  300. package/src/logic/validateIntent.ts +7 -4
  301. package/src/logic-public/index.ts +18 -0
  302. package/src/{utils.test.ts → logic-public/tests/utils.test.ts} +1 -27
  303. package/src/logic-public/utils.ts +184 -0
  304. package/src/logic.test.ts +5 -59
  305. package/src/logic.ts +5 -3
  306. package/src/network/explorer/etherscan.test.ts +403 -195
  307. package/src/network/explorer/etherscan.ts +99 -10
  308. package/src/network/explorer/index.test.ts +27 -0
  309. package/src/network/explorer/ledger.test.ts +792 -62
  310. package/src/network/explorer/ledger.ts +426 -54
  311. package/src/network/explorer/none.ts +3 -0
  312. package/src/network/explorer/types.ts +29 -5
  313. package/src/network/index.ts +7 -0
  314. package/src/network/node/explorerProxy.test.ts +673 -0
  315. package/src/network/node/explorerProxy.ts +308 -0
  316. package/src/network/node/index.memoization.test.ts +22 -10
  317. package/src/network/node/index.test.ts +6 -3
  318. package/src/network/node/index.ts +11 -7
  319. package/src/network/node/ledger.ts +1 -1
  320. package/src/network/node/node.fixtures.ts +2 -1
  321. package/src/network/node/rpc.common.ts +3 -3
  322. package/src/network/node/rpc.test.ts +66 -105
  323. package/src/network/node/withNodeSources.test.ts +240 -0
  324. package/src/network/node/withNodeSources.ts +95 -0
  325. package/src/nodeSources.ts +38 -0
  326. package/src/staking/contracts.ts +1 -1
  327. package/src/staking/encoder.test.ts +1 -1
  328. package/src/staking/fetchers.ts +1 -1
  329. package/src/staking/operations/sei.ts +1 -1
  330. package/src/staking/prepareIntents.ts +1 -1
  331. package/src/staking/redelegations.test.ts +3 -1
  332. package/src/staking/rewards.test.ts +1 -1
  333. package/src/staking/rewards.ts +1 -1
  334. package/src/staking/transactionData.ts +1 -1
  335. package/src/staking/unbondings.test.ts +2 -1
  336. package/src/staking/utils.test.ts +25 -0
  337. package/src/{utils.ts → staking/utils.ts} +2 -182
  338. package/src/staking/validators/sei.ts +1 -1
  339. package/src/staking/validators.test.ts +1 -0
  340. package/src/types/staking.ts +2 -2
  341. package/lib/constants.d.ts +0 -2
  342. package/lib/constants.d.ts.map +0 -1
  343. package/lib/constants.js +0 -11
  344. package/lib/constants.js.map +0 -1
  345. package/lib/utils.d.ts.map +0 -1
  346. package/lib/utils.js.map +0 -1
  347. package/lib-es/constants.d.ts +0 -2
  348. package/lib-es/constants.d.ts.map +0 -1
  349. package/lib-es/constants.js +0 -7
  350. package/lib-es/constants.js.map +0 -1
  351. package/lib-es/utils.d.ts.map +0 -1
  352. package/lib-es/utils.js.map +0 -1
  353. package/src/constants.ts +0 -9
  354. package/src/logic/broadcast.integ.test.ts +0 -46
  355. package/src/logic/getBalance.test.ts +0 -362
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-evm",
3
- "version": "5.4.1",
3
+ "version": "8.0.0",
4
4
  "description": "Ledger EVM Coin integration",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -28,6 +28,27 @@
28
28
  "lib-es/*": [
29
29
  "lib-es/*"
30
30
  ],
31
+ "abis": [
32
+ "lib/abis/index"
33
+ ],
34
+ "api": [
35
+ "lib/api/index"
36
+ ],
37
+ "logic": [
38
+ "lib/logic/index"
39
+ ],
40
+ "logic-public": [
41
+ "lib/logic-public/index"
42
+ ],
43
+ "network": [
44
+ "lib/network/index"
45
+ ],
46
+ "staking": [
47
+ "lib/staking/index"
48
+ ],
49
+ "types": [
50
+ "lib/types/index"
51
+ ],
31
52
  "*": [
32
53
  "lib/*"
33
54
  ]
@@ -36,10 +57,55 @@
36
57
  "exports": {
37
58
  "./lib/*": "./lib/*.js",
38
59
  "./lib-es/*": "./lib-es/*.js",
39
- "./*": {
40
- "@ledgerhq/source": "./src/*.ts",
41
- "require": "./lib/*.js",
42
- "default": "./lib-es/*.js"
60
+ "./logic-public": {
61
+ "@ledgerhq/source": "./src/logic-public/index.ts",
62
+ "require": "./lib/logic-public/index.js",
63
+ "default": "./lib-es/logic-public/index.js"
64
+ },
65
+ "./abis": {
66
+ "@ledgerhq/source": "./src/abis/index.ts",
67
+ "require": "./lib/abis/index.js",
68
+ "default": "./lib-es/abis/index.js"
69
+ },
70
+ "./api": {
71
+ "@ledgerhq/source": "./src/api/index.ts",
72
+ "require": "./lib/api/index.js",
73
+ "default": "./lib-es/api/index.js"
74
+ },
75
+ "./api/index": {
76
+ "@ledgerhq/source": "./src/api/index.ts",
77
+ "require": "./lib/api/index.js",
78
+ "default": "./lib-es/api/index.js"
79
+ },
80
+ "./config": {
81
+ "@ledgerhq/source": "./src/config.ts",
82
+ "require": "./lib/config.js",
83
+ "default": "./lib-es/config.js"
84
+ },
85
+ "./errors": {
86
+ "@ledgerhq/source": "./src/errors.ts",
87
+ "require": "./lib/errors.js",
88
+ "default": "./lib-es/errors.js"
89
+ },
90
+ "./logic": {
91
+ "@ledgerhq/source": "./src/logic/index.ts",
92
+ "require": "./lib/logic/index.js",
93
+ "default": "./lib-es/logic/index.js"
94
+ },
95
+ "./network": {
96
+ "@ledgerhq/source": "./src/network/index.ts",
97
+ "require": "./lib/network/index.js",
98
+ "default": "./lib-es/network/index.js"
99
+ },
100
+ "./types": {
101
+ "@ledgerhq/source": "./src/types/index.ts",
102
+ "require": "./lib/types/index.js",
103
+ "default": "./lib-es/types/index.js"
104
+ },
105
+ "./staking": {
106
+ "@ledgerhq/source": "./src/staking/index.ts",
107
+ "require": "./lib/staking/index.js",
108
+ "default": "./lib-es/staking/index.js"
43
109
  },
44
110
  "./package.json": "./package.json"
45
111
  },
@@ -51,11 +117,11 @@
51
117
  "eip55": "^2.1.1",
52
118
  "ethers": "6.15.0",
53
119
  "react-native-get-random-values": "^1.8.0",
54
- "@ledgerhq/coin-module-framework": "^9.1.0"
120
+ "@ledgerhq/coin-module-framework": "^10.0.0"
55
121
  },
56
122
  "peerDependencies": {
57
- "@ledgerhq/live-network": "^3.0.0",
58
- "@ledgerhq/logs": "^6.17.0"
123
+ "@ledgerhq/live-network": "^3.1.0",
124
+ "@ledgerhq/logs": "^6.19.0"
59
125
  },
60
126
  "devDependencies": {
61
127
  "@swc/core": "1.15.11",
@@ -63,6 +129,7 @@
63
129
  "@types/jest": "^30.0.0",
64
130
  "@types/node": "^24.0.0",
65
131
  "dotenv": "^16.4.5",
132
+ "jest-sonar": "0.2.16",
66
133
  "jest": "30.2.0",
67
134
  "jest-expect-message": "^1.1.3",
68
135
  "oxfmt": "0.36.0",
@@ -76,7 +143,6 @@
76
143
  "prewatch": "pnpm build",
77
144
  "watch": "tsc --watch --project tsconfig.build.json",
78
145
  "watch:es": "tsc --watch --project tsconfig.build.json -m esnext --moduleResolution bundler --outDir lib-es",
79
- "doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
80
146
  "lint": "oxlint src",
81
147
  "lint:fix": "oxfmt src && oxlint src --fix --quiet",
82
148
  "typecheck": "tsc --noEmit --customConditions node",
@@ -8,8 +8,8 @@ import type {
8
8
  BlockOperation,
9
9
  TransferBlockOperation,
10
10
  } from '@ledgerhq/coin-module-framework/api/index'
11
+ import { safeEncodeEIP55 } from '../logic-public'
11
12
  import { isTraceBlockCallAction } from '../network/node/types'
12
- import { safeEncodeEIP55 } from '../utils'
13
13
  import { NON_VALUE_TRANSFER_CALL_TYPES } from './nonValueTransferCallTypes'
14
14
 
15
15
  /**
@@ -16,9 +16,9 @@ import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framewor
16
16
  import BigNumber from 'bignumber.js'
17
17
  import eip55 from 'eip55'
18
18
  import { InvalidExplorerResponse } from '../errors'
19
+ import { buildSmartContractDetails, safeBigInt, safeEncodeEIP55 } from '../logic-public'
19
20
  import { NO_TOKEN } from '../network/explorer/types'
20
21
  import { detectEvmStakingOperationType } from '../staking/detectOperationType'
21
- import { buildSmartContractDetails, safeBigInt, safeEncodeEIP55 } from '../utils'
22
22
  import { NON_VALUE_TRANSFER_CALL_TYPES } from './nonValueTransferCallTypes'
23
23
 
24
24
  /**
@@ -10,8 +10,8 @@ import type {
10
10
  } from '../types'
11
11
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
12
12
  import eip55 from 'eip55'
13
+ import { safeBigInt, safeEncodeEIP55 } from '../logic-public'
13
14
  import { detectEvmStakingOperationType } from '../staking/detectOperationType'
14
- import { safeBigInt, safeEncodeEIP55 } from '../utils'
15
15
 
16
16
  /**
17
17
  * Adapter to convert a Ledger Explorer operation
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfig } from '../config'
4
+ import type { EvmConfigInfo } from '../config'
5
5
  import { createMockEvmContext } from '../fixtures/context.fixtures'
6
6
  import { createApi } from './index'
7
7
 
@@ -25,9 +25,11 @@ describe('getBlock ERC20 transfers', () => {
25
25
 
26
26
  let module: ReturnType<typeof createApi>
27
27
 
28
- const velasEvmConfig: EvmConfig = {
28
+ const velasEvmConfig: EvmConfigInfo = {
29
+ status: { type: 'active' },
29
30
  chainId: 111,
30
31
  name: 'Velas EVM',
32
+ unit: { name: 'VLX', code: 'VLX', magnitude: 18 },
31
33
  node: {
32
34
  type: 'external',
33
35
  uri: 'https://evmexplorer.velas.com/rpc',
@@ -87,9 +89,11 @@ describe('getBlock ERC20 transfers', () => {
87
89
 
88
90
  let module: ReturnType<typeof createApi>
89
91
 
90
- const bscConfig: EvmConfig = {
92
+ const bscConfig: EvmConfigInfo = {
93
+ status: { type: 'active' },
91
94
  chainId: 56,
92
95
  name: 'Binance Smart Chain',
96
+ unit: { name: 'BNB', code: 'BNB', magnitude: 18 },
93
97
  node: {
94
98
  type: 'ledger',
95
99
  explorerId: 'bnb',
@@ -143,9 +147,11 @@ describe('getBlock ERC20 transfers', () => {
143
147
  describe.skip('External RPC Node (zkSync)', () => {
144
148
  let module: ReturnType<typeof createApi>
145
149
 
146
- const zkSyncConfig: EvmConfig = {
150
+ const zkSyncConfig: EvmConfigInfo = {
151
+ status: { type: 'active' },
147
152
  chainId: 324,
148
153
  name: 'zkSync Era',
154
+ unit: { name: 'ETH', code: 'ETH', magnitude: 18 },
149
155
  node: {
150
156
  type: 'external',
151
157
  uri: 'https://zksync.coin.ledger.com',
@@ -9,6 +9,7 @@ describe('EVM Arbitrum Network', () => {
9
9
  let module: ReturnType<typeof createApi>
10
10
 
11
11
  const config: Partial<EvmConfigInfo> = {
12
+ chainId: 42161,
12
13
  node: {
13
14
  type: 'external',
14
15
  uri: 'https://arbitrum.coin.ledger.com',
@@ -20,6 +20,7 @@ describe('EVM Api (Arc)', () => {
20
20
  let operations: Operation[]
21
21
 
22
22
  const config: Partial<EvmConfigInfo> = {
23
+ chainId: 5042,
23
24
  node: {
24
25
  type: 'external',
25
26
  uri: 'https://arc.coin.ledger.com',
@@ -9,6 +9,7 @@ describe('EVM Avalanche C-Chain Fuji', () => {
9
9
  let module: ReturnType<typeof createApi>
10
10
 
11
11
  const config: Partial<EvmConfigInfo> = {
12
+ chainId: 43113,
12
13
  node: {
13
14
  type: 'external',
14
15
  uri: 'https://avalanche-fuji-c-chain-rpc.publicnode.com',
@@ -9,6 +9,7 @@ describe('EVM Cronos Network (blockscout explorer)', () => {
9
9
  let module: ReturnType<typeof createApi>
10
10
 
11
11
  const config: Partial<EvmConfigInfo> = {
12
+ chainId: 25,
12
13
  node: {
13
14
  type: 'external',
14
15
  uri: 'https://cronos.coin.ledger.com',
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfig } from '../config'
4
+ import type { EvmConfigInfo } from '../config'
5
5
  import { createMockEvmContext } from '../fixtures/context.fixtures'
6
6
  import { createApi } from './index'
7
7
 
@@ -9,9 +9,11 @@ describe('Flare (external node)', () => {
9
9
  describe('getBlock', () => {
10
10
  let module: ReturnType<typeof createApi>
11
11
 
12
- const flareConfig: EvmConfig = {
12
+ const flareConfig: EvmConfigInfo = {
13
+ status: { type: 'active' },
13
14
  chainId: 14,
14
15
  name: 'Flare',
16
+ unit: { name: 'FLR', code: 'FLR', magnitude: 18 },
15
17
  node: {
16
18
  type: 'external',
17
19
  uri: 'https://rpc.au.cc/flare',
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfig } from '../config'
4
+ import type { EvmConfigInfo } from '../config'
5
5
  import { createMockEvmContext } from '../fixtures/context.fixtures'
6
6
  import { createApi } from './index'
7
7
 
@@ -25,9 +25,11 @@ describe('Linea (etherscan explorer)', () => {
25
25
  const TO = '0x9F41fE989C556d8b312Ce398b7f7B5Ac90919a73'
26
26
 
27
27
  let module: ReturnType<typeof createApi>
28
- const lineaConfig: EvmConfig = {
28
+ const lineaConfig: EvmConfigInfo = {
29
+ status: { type: 'active' },
29
30
  chainId: 59144,
30
31
  name: 'Linea',
32
+ unit: { name: 'ETH', code: 'ETH', magnitude: 18 },
31
33
  node: {
32
34
  type: 'external',
33
35
  uri: 'https://linea.coin.ledger.com',
@@ -1,20 +1,27 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
5
- import { createMockEvmContext } from '../fixtures/context.fixtures'
4
+ import {
5
+ createMockEvmConfigInfo,
6
+ createMockEvmContext,
7
+ testLogger,
8
+ } from '../fixtures/context.fixtures'
9
+ import { getNodeApi } from '../network/node'
10
+ import { nodeSourcesFromList } from '../nodeSources'
6
11
  import { createApi } from './index'
7
12
 
8
13
  describe('EVM Api (Monad Testnet)', () => {
9
14
  let module: ReturnType<typeof createApi>
10
15
 
11
- const config: Partial<EvmConfigInfo> = {
16
+ const config = createMockEvmConfigInfo({
17
+ chainId: 10143,
12
18
  node: { type: 'external', uri: 'https://monad-testnet.coin.ledger.com' },
13
19
  explorer: {
14
20
  type: 'etherscan',
15
21
  uri: 'https://proxyetherscan.api.live.ledger.com/v2/api/10143',
16
22
  },
17
- }
23
+ nodeSources: nodeSourcesFromList(['explorer-proxy', 'node']),
24
+ })
18
25
  beforeAll(() => {
19
26
  module = createApi('monad_testnet')
20
27
  })
@@ -46,4 +53,88 @@ describe('EVM Api (Monad Testnet)', () => {
46
53
  })
47
54
  })
48
55
  })
56
+
57
+ describe('getBlockInfo', () => {
58
+ /**
59
+ * Non-regression: the Monad Testnet RPC node is pruned and does not serve historical
60
+ * blocks. A call to /v1/monad_testnet/block/{height} used to return HTTP 500 with
61
+ * "Block N not found from @ledgerhq/coin-evm getBlockByHeight" for any block that
62
+ * predates the current pruning window.
63
+ *
64
+ * The fix falls back to the Etherscan explorer proxy (`module=proxy&action=eth_getBlockByNumber`)
65
+ * which is backed by an archive node and returns the real block hash.
66
+ *
67
+ * Block 14817811 surfaces via listOperations on 0x981a3e333eac954b4048dc2a2228de41868ea822.
68
+ */
69
+ it('returns a real block hash for a pruned block via explorer fallback', async () => {
70
+ const info = await module.getBlockInfo(createMockEvmContext(config), 14817811)
71
+
72
+ expect(info.height).toBe(14817811)
73
+ // A valid 32-byte block hash — exact value is not pinned because the Monad testnet
74
+ // can be reset, changing the canonical block at this height.
75
+ expect(info.hash).toMatch(/^0x[0-9a-f]{64}$/i)
76
+ expect(info.time).toBeInstanceOf(Date)
77
+ expect(info.time.getTime()).toBeGreaterThan(0)
78
+ })
79
+ })
80
+
81
+ describe('getBlock', () => {
82
+ /**
83
+ * Non-regression: getBlock is the full path backing GET /block/{height}.
84
+ * It calls getBlockByHeight (which may use the explorer proxy fallback) and then
85
+ * fetches transaction receipts via individual getTransaction calls (also wrapped).
86
+ * This test exercises the complete fallback chain on a pruned historical block
87
+ * that has at least one transaction.
88
+ *
89
+ * Block 14817811 is the pruned block surfaced by listOperations on
90
+ * 0x981a3e333eac954b4048dc2a2228de41868ea822 and is known to contain transactions.
91
+ */
92
+ it('returns block data with transactions for a pruned block via explorer fallback', async () => {
93
+ const ctx = createMockEvmContext(config)
94
+ const block = await module.getBlock(ctx, 14817811)
95
+
96
+ expect(block.info.height).toBe(14817811)
97
+ expect(block.info.hash).toMatch(/^0x[0-9a-f]{64}$/i)
98
+ expect(block.info.time).toBeInstanceOf(Date)
99
+ expect(block.info.time.getTime()).toBeGreaterThan(0)
100
+ expect(block.transactions.length).toBeGreaterThan(0)
101
+ })
102
+ })
103
+
104
+ describe('getTransaction', () => {
105
+ /**
106
+ * Non-regression: the Monad Testnet RPC node is pruned and cannot serve receipts for
107
+ * historical transactions. getTransaction used to throw "Transaction or receipt not found"
108
+ * for any tx in a pruned block.
109
+ *
110
+ * The fix falls back to the Etherscan explorer proxy using eth_getTransactionByHash +
111
+ * eth_getTransactionReceipt, both backed by an archive node.
112
+ *
113
+ * We derive a real tx hash from listOperations so the test stays self-contained.
114
+ */
115
+ it('returns transaction data for a tx in a pruned block via explorer fallback', async () => {
116
+ const ctx = createMockEvmContext(config)
117
+
118
+ // Get a tx hash from the known pruned address — any op hash is from a pruned block
119
+ const { items } = await module.listOperations(
120
+ ctx,
121
+ '0x981a3e333eac954b4048dc2a2228de41868ea822',
122
+ {
123
+ minHeight: 0,
124
+ order: 'asc',
125
+ limit: 5,
126
+ }
127
+ )
128
+ expect(items.length).toBeGreaterThan(0)
129
+ const txHash = items[0].tx.hash
130
+
131
+ const api = getNodeApi(config, 'monad_testnet', testLogger)
132
+ const txInfo = await api.getTransaction('monad_testnet', txHash)
133
+
134
+ expect(txInfo.hash).toBe(txHash)
135
+ expect(txInfo.from).toMatch(/^0x[A-Fa-f0-9]{40}$/i)
136
+ expect(txInfo.gasUsed).toMatch(/^\d+$/)
137
+ expect(typeof txInfo.nonce).toBe('number')
138
+ })
139
+ })
49
140
  })
@@ -10,6 +10,7 @@ describe('EVM Optimism Network', () => {
10
10
  let module: ReturnType<typeof createApi>
11
11
 
12
12
  const config: Partial<EvmConfigInfo> = {
13
+ chainId: 10,
13
14
  node: {
14
15
  type: 'external',
15
16
  uri: 'https://optimism.coin.ledger.com',
@@ -9,6 +9,7 @@ describe('EVM RSK Network', () => {
9
9
  let module: ReturnType<typeof createApi>
10
10
 
11
11
  const config: Partial<EvmConfigInfo> = {
12
+ chainId: 30,
12
13
  node: {
13
14
  type: 'external',
14
15
  uri: 'https://rsk.coin.ledger.com',
@@ -1,16 +1,18 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfig } from '../config'
4
+ import type { EvmConfigInfo } from '../config'
5
5
  import { fail } from 'assert'
6
6
  import { createMockEvmContext } from '../fixtures/context.fixtures'
7
7
  import { createApi } from './index'
8
8
 
9
9
  describe('Shape (external node)', () => {
10
10
  describe('getBlock', () => {
11
- const shapeConfig: EvmConfig = {
11
+ const shapeConfig: EvmConfigInfo = {
12
+ status: { type: 'active' },
12
13
  chainId: 360,
13
14
  name: 'Shape',
15
+ unit: { name: 'ETH', code: 'ETH', magnitude: 18 },
14
16
  node: {
15
17
  type: 'external',
16
18
  uri: 'https://mainnet.shape.network',
@@ -9,6 +9,7 @@ describe('EVM Api (Somnia)', () => {
9
9
  let module: ReturnType<typeof createApi>
10
10
 
11
11
  const config: Partial<EvmConfigInfo> = {
12
+ chainId: 5031,
12
13
  node: { type: 'external', uri: 'https://api.infra.mainnet.somnia.network' },
13
14
  explorer: { type: 'blockscout', uri: 'https://explorer.somnia.network/api/' },
14
15
  }
package/src/api/index.ts CHANGED
@@ -23,6 +23,7 @@ import type {
23
23
  Validator,
24
24
  BalanceOptions,
25
25
  } from '@ledgerhq/coin-module-framework/api/index'
26
+ import { isHexString } from '../logic-public'
26
27
  import { craftTransactionData } from '../logic/craftTransactionData'
27
28
  import {
28
29
  broadcast,
@@ -40,7 +41,6 @@ import {
40
41
  import { validateAddress } from '../logic/validateAddress'
41
42
  import { getNodeApi } from '../network/node'
42
43
  import { getValidatorsPage } from '../staking/validators'
43
- import { isHexString } from '../utils'
44
44
 
45
45
  // NOTE Celo still relies on the EVM coin config and injects its own
46
46
  // while creating an unused instance of API
@@ -76,7 +76,7 @@ export function createApi(currencyId: string) {
76
76
  call: async (context: EvmContext, params: CallParams): Promise<string> => {
77
77
  const config = await context.config(currencyId)
78
78
  const callParams = parseCallParams(params)
79
- return getNodeApi(config, currencyId).call(currencyId, callParams)
79
+ return getNodeApi(config, currencyId, context.logger).call(currencyId, callParams)
80
80
  },
81
81
  combine: (
82
82
  _context: EvmContext,
package/src/config.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { InternalTxSourceList } from './internalTxSources'
5
+ import type { NodeSourceList } from './nodeSources'
5
6
  import type { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
6
- import { log } from '@ledgerhq/logs'
7
7
 
8
8
  export type { InternalTxSource, InternalTxSourceList, NonEmptySource } from './internalTxSources'
9
9
  export {
@@ -12,6 +12,9 @@ export {
12
12
  isInternalTxSource,
13
13
  } from './internalTxSources'
14
14
 
15
+ export type { NodeSource, NodeSourceList } from './nodeSources'
16
+ export { DEFAULT_NODE_SOURCES, isNodeSource, nodeSourcesFromList } from './nodeSources'
17
+
15
18
  /**
16
19
  * Block finalization levels supported by EVM JSON-RPC API, used to fetch the latest block.
17
20
  */
@@ -25,7 +28,6 @@ export const DEFAULT_EIP1559_BASE_FEE_MULTIPLIER = 1.6
25
28
 
26
29
  export type EvmConfig = {
27
30
  chainId: number
28
- name: string
29
31
  node:
30
32
  | {
31
33
  type: 'external'
@@ -51,6 +53,11 @@ export type EvmConfig = {
51
53
  * so that the underlying `limit + 1` request never exceeds `M`.
52
54
  */
53
55
  maxLimit?: number | undefined
56
+ /**
57
+ * Maximum extra pages `exhaustEndpoint` fetches to drain a boundary block before giving up.
58
+ * Defaults to `DEFAULT_MAX_BOUNDARY_EXHAUSTION_PAGES`.
59
+ */
60
+ maxBoundaryExhaustionPages?: number | undefined
54
61
  uri: string
55
62
  /** Number of retries for explorer API calls. Defaults to 8 if not set. Set to 0 for no retries. */
56
63
  retries?: number
@@ -135,6 +142,19 @@ export type EvmConfig = {
135
142
  * @see https://ledgerhq.atlassian.net/wiki/spaces/CF/pages/7297957892
136
143
  */
137
144
  getBlockInternalTxsSources?: InternalTxSourceList
145
+ /**
146
+ * Ordered list of node sources for read operations (`getBlockByHeight`, `getTransaction`).
147
+ * Sources are tried in order; the first successful result is returned.
148
+ * Built via `nodeSourcesFromList()`.
149
+ *
150
+ * - `'node'` — direct RPC call to the configured node
151
+ * - `'explorer-proxy'` — Etherscan-like explorer proxy (`module=proxy`); requires an
152
+ * Etherscan-like explorer to be configured
153
+ *
154
+ * Defaults to `['node']`. For chains with a pruned RPC node (e.g. monad_testnet),
155
+ * configure `['explorer-proxy', 'node']` to avoid a failed RPC round-trip.
156
+ */
157
+ nodeSources?: NodeSourceList
138
158
  }
139
159
 
140
160
  export type ExternalNodeConfig = Extract<EvmConfig['node'], { type: 'external' }>
@@ -146,40 +166,7 @@ export type EvmCoinConfig = {
146
166
  info: EvmConfigInfo
147
167
  }
148
168
 
149
- export type CoinConfig = (currencyId: string) => EvmCoinConfig
150
-
151
- let coinConfig: CoinConfig | undefined
152
-
153
- export const setCoinConfig = (config: CoinConfig): void => {
154
- coinConfig = config
155
- }
156
-
157
- export const getCoinConfig = (currencyId: string): EvmCoinConfig => {
158
- if (!coinConfig) {
159
- throw new Error('EVM module config not set')
160
- }
161
-
162
- return coinConfig(currencyId)
163
- }
164
-
165
169
  /**
166
170
  * The {@link Context} threaded through the coin-evm public API (ADR-019).
167
- *
168
- * NOTE: The EVM low layers still resolve configuration through the module-level singleton
169
- * (keyed by `currency.id`), so `context` is currently threaded for framework conformance but
170
- * the config it carries mirrors the singleton. `config`/`logger` are provided for completeness
171
- * and for callers that build a context explicitly.
172
171
  */
173
172
  export type EvmContext = Context<EvmConfigInfo>
174
-
175
- /**
176
- * Builds an {@link EvmContext} from the module-level singleton and `@ledgerhq/logs`.
177
- *
178
- * The returned `config` accessor reads from the singleton (`getCoinConfig`), preserving the
179
- * existing `setCoinConfig` side-effect flow used by external consumers of `createApi`.
180
- */
181
- export const createContext = (): EvmContext => ({
182
- config: async (currencyId?: string): Promise<EvmConfigInfo> =>
183
- getCoinConfig(currencyId ?? '').info,
184
- logger: (...args: unknown[]): void => log('coin-evm', args.map(String).join(' ')),
185
- })
package/src/errors.ts CHANGED
@@ -54,6 +54,19 @@ export class RateLimitError extends Error {
54
54
  }
55
55
  }
56
56
 
57
+ /**
58
+ * A single block holds more records than the Ledger explorer will ever serve in one page, and a
59
+ * height-plus-hash cursor has no per-block offset to page through it. Raised instead of silently
60
+ * reporting end of stream, which would be indistinguishable from a genuinely complete history.
61
+ */
62
+ export class UnpageableLedgerExplorerBlock extends Error {
63
+ override name = 'UnpageableLedgerExplorerBlock'
64
+ constructor(message?: string, fields?: Record<string, unknown>) {
65
+ super(message || 'UnpageableLedgerExplorerBlock')
66
+ if (fields) Object.assign(this, fields)
67
+ }
68
+ }
69
+
57
70
  // Node
58
71
  export class UnknownNode extends Error {
59
72
  override name = 'UnknownNode'
@@ -10,7 +10,6 @@ import type {
10
10
  LedgerNodeConfig,
11
11
  } from '../config'
12
12
  import type { Logger } from '@ledgerhq/coin-module-framework/config'
13
- import { log } from '@ledgerhq/logs'
14
13
 
15
14
  /** Returns an external (JSON-RPC) node config for use in tests. */
16
15
  export const mkExternalNode = (partial?: {
@@ -36,10 +35,12 @@ export const mkLedgerNode = (partial?: {
36
35
  export const mkEtherscanExplorer = (partial?: {
37
36
  uri?: string
38
37
  noCache?: boolean
38
+ retries?: number
39
39
  }): EvmConfig['explorer'] => ({
40
40
  type: 'etherscan',
41
41
  uri: partial?.uri ?? 'http://explorer.test',
42
42
  ...(typeof partial?.noCache === 'boolean' && { noCache: partial.noCache }),
43
+ ...(typeof partial?.retries === 'number' && { retries: partial.retries }),
43
44
  })
44
45
 
45
46
  /** Returns a Ledger explorer config for use in tests. */
@@ -68,6 +69,7 @@ export const createMockEvmConfigInfo = (
68
69
  ): EvmConfigInfo => ({
69
70
  status: { type: 'active' },
70
71
  name: 'test',
72
+ unit: { name: 'test', code: 'TEST', magnitude: 18 },
71
73
  explorer: { type: 'none' },
72
74
  ...config,
73
75
  })
@@ -75,7 +77,7 @@ export const createMockEvmConfigInfo = (
75
77
  /**
76
78
  * Builds an {@link EvmCoinConfig} for tests.
77
79
  *
78
- * Wraps {@link createMockEvmConfigInfo} in the `{ info }` shape expected by `setCoinConfig`.
80
+ * Wraps {@link createMockEvmConfigInfo} in the `{ info }` shape of {@link EvmCoinConfig}.
79
81
  */
80
82
  export const createMockEvmCoinConfig = (
81
83
  config: Pick<EvmConfigInfo, 'chainId' | 'node'> & Partial<Omit<EvmConfigInfo, 'chainId' | 'node'>>
@@ -94,9 +96,12 @@ export const createMockEvmCoinConfig = (
94
96
  */
95
97
  export const createMockEvmContext = (config?: Partial<EvmConfigInfo>): EvmContext => ({
96
98
  config: async (_currencyId?: string): Promise<EvmConfigInfo> =>
97
- ({ status: { type: 'active' }, ...config }) as EvmConfigInfo,
98
- logger: log as unknown as Logger,
99
+ createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode(), ...config }),
100
+ logger: jest.fn(),
99
101
  })
100
102
 
101
103
  /** A ready-to-use mock {@link EvmContext} for tests that don't need a custom config. */
102
104
  export const mockEvmContext: EvmContext = createMockEvmContext()
105
+
106
+ /** A mock {@link Logger} for use in tests. */
107
+ export const testLogger: Logger = jest.fn()
@@ -17,7 +17,7 @@ export async function broadcast(
17
17
  }
18
18
  ): Promise<string> {
19
19
  const config = await context.config(currencyId)
20
- const nodeApi = getNodeApi(config, currencyId)
20
+ const nodeApi = getNodeApi(config, currencyId, context.logger)
21
21
  return await nodeApi.broadcastTransaction(currencyId, signature, broadcastConfig)
22
22
  }
23
23