@ledgerhq/coin-evm 5.4.0 → 7.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 (342) hide show
  1. package/CHANGELOG.md +197 -0
  2. package/docs/evm-family-integration-process/README.md +1 -1
  3. package/knip.json +2 -3
  4. package/lib/adapters/blockOperations.js +6 -6
  5. package/lib/adapters/blockOperations.js.map +1 -1
  6. package/lib/adapters/etherscan.js +23 -23
  7. package/lib/adapters/etherscan.js.map +1 -1
  8. package/lib/adapters/ledger.js +17 -17
  9. package/lib/adapters/ledger.js.map +1 -1
  10. package/lib/api/index.js +4 -4
  11. package/lib/api/index.js.map +1 -1
  12. package/lib/config.d.ts +21 -15
  13. package/lib/config.d.ts.map +1 -1
  14. package/lib/config.js +5 -25
  15. package/lib/config.js.map +1 -1
  16. package/lib/errors.d.ts +9 -0
  17. package/lib/errors.d.ts.map +1 -1
  18. package/lib/errors.js +15 -1
  19. package/lib/errors.js.map +1 -1
  20. package/lib/logic/broadcast.js +1 -1
  21. package/lib/logic/broadcast.js.map +1 -1
  22. package/lib/logic/common.d.ts +2 -1
  23. package/lib/logic/common.d.ts.map +1 -1
  24. package/lib/logic/common.js +4 -4
  25. package/lib/logic/common.js.map +1 -1
  26. package/lib/logic/craftTransaction.d.ts.map +1 -1
  27. package/lib/logic/craftTransaction.js +2 -2
  28. package/lib/logic/craftTransaction.js.map +1 -1
  29. package/lib/logic/estimateFees.d.ts.map +1 -1
  30. package/lib/logic/estimateFees.js +9 -9
  31. package/lib/logic/estimateFees.js.map +1 -1
  32. package/lib/logic/getBalance.d.ts.map +1 -1
  33. package/lib/logic/getBalance.js +50 -16
  34. package/lib/logic/getBalance.js.map +1 -1
  35. package/lib/logic/getBlock.d.ts.map +1 -1
  36. package/lib/logic/getBlock.js +19 -11
  37. package/lib/logic/getBlock.js.map +1 -1
  38. package/lib/logic/getBlockInfo.js +1 -1
  39. package/lib/logic/getBlockInfo.js.map +1 -1
  40. package/lib/logic/getNextSequence.d.ts.map +1 -1
  41. package/lib/logic/getNextSequence.js +1 -1
  42. package/lib/logic/getNextSequence.js.map +1 -1
  43. package/lib/logic/index.d.ts +2 -0
  44. package/lib/logic/index.d.ts.map +1 -1
  45. package/lib/logic/index.js +4 -0
  46. package/lib/logic/index.js.map +1 -1
  47. package/lib/logic/lastBlock.js +1 -1
  48. package/lib/logic/lastBlock.js.map +1 -1
  49. package/lib/logic/listOperations.d.ts.map +1 -1
  50. package/lib/logic/listOperations.js +10 -1
  51. package/lib/logic/listOperations.js.map +1 -1
  52. package/lib/logic/validateIntent.d.ts.map +1 -1
  53. package/lib/logic/validateIntent.js +12 -12
  54. package/lib/logic/validateIntent.js.map +1 -1
  55. package/lib/logic-public/index.d.ts +3 -0
  56. package/lib/logic-public/index.d.ts.map +1 -0
  57. package/lib/logic-public/index.js +19 -0
  58. package/lib/logic-public/index.js.map +1 -0
  59. package/lib/{utils.d.ts → logic-public/utils.d.ts} +0 -44
  60. package/lib/logic-public/utils.d.ts.map +1 -0
  61. package/lib/logic-public/utils.js +166 -0
  62. package/lib/logic-public/utils.js.map +1 -0
  63. package/lib/logic.d.ts +2 -1
  64. package/lib/logic.d.ts.map +1 -1
  65. package/lib/logic.js +3 -3
  66. package/lib/logic.js.map +1 -1
  67. package/lib/network/explorer/etherscan.d.ts +16 -3
  68. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  69. package/lib/network/explorer/etherscan.js +61 -6
  70. package/lib/network/explorer/etherscan.js.map +1 -1
  71. package/lib/network/explorer/ledger.d.ts +50 -4
  72. package/lib/network/explorer/ledger.d.ts.map +1 -1
  73. package/lib/network/explorer/ledger.js +286 -37
  74. package/lib/network/explorer/ledger.js.map +1 -1
  75. package/lib/network/explorer/none.d.ts +1 -0
  76. package/lib/network/explorer/none.d.ts.map +1 -1
  77. package/lib/network/explorer/none.js +4 -1
  78. package/lib/network/explorer/none.js.map +1 -1
  79. package/lib/network/explorer/types.d.ts +15 -2
  80. package/lib/network/explorer/types.d.ts.map +1 -1
  81. package/lib/network/explorer/types.js.map +1 -1
  82. package/lib/network/index.d.ts +5 -0
  83. package/lib/network/index.d.ts.map +1 -0
  84. package/lib/network/index.js +23 -0
  85. package/lib/network/index.js.map +1 -0
  86. package/lib/network/node/explorerProxy.d.ts +27 -0
  87. package/lib/network/node/explorerProxy.d.ts.map +1 -0
  88. package/lib/network/node/explorerProxy.js +262 -0
  89. package/lib/network/node/explorerProxy.js.map +1 -0
  90. package/lib/network/node/index.d.ts +2 -1
  91. package/lib/network/node/index.d.ts.map +1 -1
  92. package/lib/network/node/index.js +11 -10
  93. package/lib/network/node/index.js.map +1 -1
  94. package/lib/network/node/ledger.js +7 -7
  95. package/lib/network/node/ledger.js.map +1 -1
  96. package/lib/network/node/rpc.common.d.ts +2 -2
  97. package/lib/network/node/rpc.common.js +19 -19
  98. package/lib/network/node/rpc.common.js.map +1 -1
  99. package/lib/network/node/withNodeSources.d.ts +21 -0
  100. package/lib/network/node/withNodeSources.d.ts.map +1 -0
  101. package/lib/network/node/withNodeSources.js +78 -0
  102. package/lib/network/node/withNodeSources.js.map +1 -0
  103. package/lib/nodeSources.d.ts +15 -0
  104. package/lib/nodeSources.d.ts.map +1 -0
  105. package/lib/nodeSources.js +33 -0
  106. package/lib/nodeSources.js.map +1 -0
  107. package/lib/staking/contracts.js +1 -1
  108. package/lib/staking/contracts.js.map +1 -1
  109. package/lib/staking/fetchers.js +1 -1
  110. package/lib/staking/fetchers.js.map +1 -1
  111. package/lib/staking/operations/sei.js +1 -1
  112. package/lib/staking/operations/sei.js.map +1 -1
  113. package/lib/staking/prepareIntents.js +3 -3
  114. package/lib/staking/prepareIntents.js.map +1 -1
  115. package/lib/staking/rewards.js +1 -1
  116. package/lib/staking/rewards.js.map +1 -1
  117. package/lib/staking/transactionData.js +2 -2
  118. package/lib/staking/transactionData.js.map +1 -1
  119. package/lib/staking/utils.d.ts +45 -0
  120. package/lib/staking/utils.d.ts.map +1 -0
  121. package/lib/{utils.js → staking/utils.js} +5 -164
  122. package/lib/staking/utils.js.map +1 -0
  123. package/lib/staking/validators/sei.js +1 -1
  124. package/lib/staking/validators/sei.js.map +1 -1
  125. package/lib/types/staking.d.ts +2 -2
  126. package/lib-es/adapters/blockOperations.js +1 -1
  127. package/lib-es/adapters/blockOperations.js.map +1 -1
  128. package/lib-es/adapters/etherscan.js +1 -1
  129. package/lib-es/adapters/etherscan.js.map +1 -1
  130. package/lib-es/adapters/ledger.js +1 -1
  131. package/lib-es/adapters/ledger.js.map +1 -1
  132. package/lib-es/api/index.js +2 -2
  133. package/lib-es/api/index.js.map +1 -1
  134. package/lib-es/config.d.ts +21 -15
  135. package/lib-es/config.d.ts.map +1 -1
  136. package/lib-es/config.js +1 -21
  137. package/lib-es/config.js.map +1 -1
  138. package/lib-es/errors.d.ts +9 -0
  139. package/lib-es/errors.d.ts.map +1 -1
  140. package/lib-es/errors.js +13 -0
  141. package/lib-es/errors.js.map +1 -1
  142. package/lib-es/logic/broadcast.js +1 -1
  143. package/lib-es/logic/broadcast.js.map +1 -1
  144. package/lib-es/logic/common.d.ts +2 -1
  145. package/lib-es/logic/common.d.ts.map +1 -1
  146. package/lib-es/logic/common.js +3 -3
  147. package/lib-es/logic/common.js.map +1 -1
  148. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  149. package/lib-es/logic/craftTransaction.js +2 -2
  150. package/lib-es/logic/craftTransaction.js.map +1 -1
  151. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  152. package/lib-es/logic/estimateFees.js +6 -6
  153. package/lib-es/logic/estimateFees.js.map +1 -1
  154. package/lib-es/logic/getBalance.d.ts.map +1 -1
  155. package/lib-es/logic/getBalance.js +50 -16
  156. package/lib-es/logic/getBalance.js.map +1 -1
  157. package/lib-es/logic/getBlock.d.ts.map +1 -1
  158. package/lib-es/logic/getBlock.js +16 -8
  159. package/lib-es/logic/getBlock.js.map +1 -1
  160. package/lib-es/logic/getBlockInfo.js +1 -1
  161. package/lib-es/logic/getBlockInfo.js.map +1 -1
  162. package/lib-es/logic/getNextSequence.d.ts.map +1 -1
  163. package/lib-es/logic/getNextSequence.js +1 -1
  164. package/lib-es/logic/getNextSequence.js.map +1 -1
  165. package/lib-es/logic/index.d.ts +2 -0
  166. package/lib-es/logic/index.d.ts.map +1 -1
  167. package/lib-es/logic/index.js +4 -0
  168. package/lib-es/logic/index.js.map +1 -1
  169. package/lib-es/logic/lastBlock.js +1 -1
  170. package/lib-es/logic/lastBlock.js.map +1 -1
  171. package/lib-es/logic/listOperations.d.ts.map +1 -1
  172. package/lib-es/logic/listOperations.js +10 -1
  173. package/lib-es/logic/listOperations.js.map +1 -1
  174. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  175. package/lib-es/logic/validateIntent.js +4 -4
  176. package/lib-es/logic/validateIntent.js.map +1 -1
  177. package/lib-es/logic-public/index.d.ts +3 -0
  178. package/lib-es/logic-public/index.d.ts.map +1 -0
  179. package/lib-es/logic-public/index.js +4 -0
  180. package/lib-es/logic-public/index.js.map +1 -0
  181. package/lib-es/{utils.d.ts → logic-public/utils.d.ts} +0 -44
  182. package/lib-es/logic-public/utils.d.ts.map +1 -0
  183. package/lib-es/logic-public/utils.js +150 -0
  184. package/lib-es/logic-public/utils.js.map +1 -0
  185. package/lib-es/logic.d.ts +2 -1
  186. package/lib-es/logic.d.ts.map +1 -1
  187. package/lib-es/logic.js +3 -3
  188. package/lib-es/logic.js.map +1 -1
  189. package/lib-es/network/explorer/etherscan.d.ts +16 -3
  190. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  191. package/lib-es/network/explorer/etherscan.js +60 -5
  192. package/lib-es/network/explorer/etherscan.js.map +1 -1
  193. package/lib-es/network/explorer/ledger.d.ts +50 -4
  194. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  195. package/lib-es/network/explorer/ledger.js +283 -37
  196. package/lib-es/network/explorer/ledger.js.map +1 -1
  197. package/lib-es/network/explorer/none.d.ts +1 -0
  198. package/lib-es/network/explorer/none.d.ts.map +1 -1
  199. package/lib-es/network/explorer/none.js +2 -0
  200. package/lib-es/network/explorer/none.js.map +1 -1
  201. package/lib-es/network/explorer/types.d.ts +15 -2
  202. package/lib-es/network/explorer/types.d.ts.map +1 -1
  203. package/lib-es/network/explorer/types.js.map +1 -1
  204. package/lib-es/network/index.d.ts +5 -0
  205. package/lib-es/network/index.d.ts.map +1 -0
  206. package/lib-es/network/index.js +7 -0
  207. package/lib-es/network/index.js.map +1 -0
  208. package/lib-es/network/node/explorerProxy.d.ts +27 -0
  209. package/lib-es/network/node/explorerProxy.d.ts.map +1 -0
  210. package/lib-es/network/node/explorerProxy.js +254 -0
  211. package/lib-es/network/node/explorerProxy.js.map +1 -0
  212. package/lib-es/network/node/index.d.ts +2 -1
  213. package/lib-es/network/node/index.d.ts.map +1 -1
  214. package/lib-es/network/node/index.js +11 -10
  215. package/lib-es/network/node/index.js.map +1 -1
  216. package/lib-es/network/node/ledger.js +1 -1
  217. package/lib-es/network/node/ledger.js.map +1 -1
  218. package/lib-es/network/node/rpc.common.d.ts +2 -2
  219. package/lib-es/network/node/rpc.common.js +3 -3
  220. package/lib-es/network/node/rpc.common.js.map +1 -1
  221. package/lib-es/network/node/withNodeSources.d.ts +21 -0
  222. package/lib-es/network/node/withNodeSources.d.ts.map +1 -0
  223. package/lib-es/network/node/withNodeSources.js +74 -0
  224. package/lib-es/network/node/withNodeSources.js.map +1 -0
  225. package/lib-es/nodeSources.d.ts +15 -0
  226. package/lib-es/nodeSources.d.ts.map +1 -0
  227. package/lib-es/nodeSources.js +28 -0
  228. package/lib-es/nodeSources.js.map +1 -0
  229. package/lib-es/staking/contracts.js +1 -1
  230. package/lib-es/staking/contracts.js.map +1 -1
  231. package/lib-es/staking/fetchers.js +1 -1
  232. package/lib-es/staking/fetchers.js.map +1 -1
  233. package/lib-es/staking/operations/sei.js +1 -1
  234. package/lib-es/staking/operations/sei.js.map +1 -1
  235. package/lib-es/staking/prepareIntents.js +1 -1
  236. package/lib-es/staking/prepareIntents.js.map +1 -1
  237. package/lib-es/staking/rewards.js +1 -1
  238. package/lib-es/staking/rewards.js.map +1 -1
  239. package/lib-es/staking/transactionData.js +1 -1
  240. package/lib-es/staking/transactionData.js.map +1 -1
  241. package/lib-es/staking/utils.d.ts +45 -0
  242. package/lib-es/staking/utils.d.ts.map +1 -0
  243. package/lib-es/{utils.js → staking/utils.js} +1 -147
  244. package/lib-es/staking/utils.js.map +1 -0
  245. package/lib-es/staking/validators/sei.js +1 -1
  246. package/lib-es/staking/validators/sei.js.map +1 -1
  247. package/lib-es/types/staking.d.ts +2 -2
  248. package/package.json +72 -7
  249. package/src/adapters/blockOperations.ts +1 -1
  250. package/src/adapters/etherscan.ts +1 -1
  251. package/src/adapters/ledger.ts +1 -1
  252. package/src/api/{index.arc_testnet.integ.test.ts → index.arc.integ.test.ts} +15 -12
  253. package/src/api/index.monad_testnet.integ.test.ts +95 -4
  254. package/src/api/index.ts +2 -2
  255. package/src/config.ts +22 -34
  256. package/src/errors.ts +13 -0
  257. package/src/fixtures/context.fixtures.ts +6 -1
  258. package/src/logic/broadcast.ts +1 -1
  259. package/src/logic/common.ts +4 -2
  260. package/src/logic/craftTransaction.ts +2 -1
  261. package/src/logic/estimateFees.ts +20 -6
  262. package/src/logic/getBalance.ts +72 -26
  263. package/src/logic/getBlock.ts +26 -14
  264. package/src/logic/getBlockInfo.ts +1 -1
  265. package/src/logic/getNextSequence.ts +4 -1
  266. package/src/logic/index.ts +4 -0
  267. package/src/logic/lastBlock.ts +1 -1
  268. package/src/logic/listOperations.ts +14 -1
  269. package/src/logic/tests/broadcast.integ.test.ts +53 -0
  270. package/src/logic/{broadcast.test.ts → tests/broadcast.test.ts} +7 -7
  271. package/src/logic/{broadcastSource.test.ts → tests/broadcastSource.test.ts} +6 -6
  272. package/src/logic/{combine.test.ts → tests/combine.test.ts} +1 -1
  273. package/src/logic/{common.test.ts → tests/common.test.ts} +45 -21
  274. package/src/logic/{computeGasLimit.test.ts → tests/computeGasLimit.test.ts} +2 -2
  275. package/src/logic/{craftTransaction.test.ts → tests/craftTransaction.test.ts} +7 -7
  276. package/src/logic/{craftTransactionData.test.ts → tests/craftTransactionData.test.ts} +4 -4
  277. package/src/logic/{estimateFees.test.ts → tests/estimateFees.test.ts} +12 -12
  278. package/src/logic/tests/getBalance.test.ts +602 -0
  279. package/src/logic/{getBlock.test.ts → tests/getBlock.test.ts} +182 -89
  280. package/src/logic/{getBlockInfo.test.ts → tests/getBlockInfo.test.ts} +8 -8
  281. package/src/logic/{getErc20Data.test.ts → tests/getErc20Data.test.ts} +1 -1
  282. package/src/logic/{getNextSequence.test.ts → tests/getNextSequence.test.ts} +7 -7
  283. package/src/logic/{getStakes.test.ts → tests/getStakes.test.ts} +13 -13
  284. package/src/logic/{internalTransactionsFetcher.test.ts → tests/internalTransactionsFetcher.test.ts} +8 -8
  285. package/src/logic/{lastBlock.test.ts → tests/lastBlock.test.ts} +7 -7
  286. package/src/logic/{listOperations.test.ts → tests/listOperations.test.ts} +125 -6
  287. package/src/logic/{validateAddress.test.ts → tests/validateAddress.test.ts} +1 -1
  288. package/src/logic/{validateIntent.test.ts → tests/validateIntent.test.ts} +80 -78
  289. package/src/logic/validateIntent.ts +7 -4
  290. package/src/logic-public/index.ts +18 -0
  291. package/src/{utils.test.ts → logic-public/tests/utils.test.ts} +1 -27
  292. package/src/logic-public/utils.ts +184 -0
  293. package/src/logic.test.ts +5 -59
  294. package/src/logic.ts +5 -3
  295. package/src/network/explorer/etherscan.test.ts +403 -195
  296. package/src/network/explorer/etherscan.ts +99 -10
  297. package/src/network/explorer/index.test.ts +27 -0
  298. package/src/network/explorer/ledger.test.ts +791 -62
  299. package/src/network/explorer/ledger.ts +426 -54
  300. package/src/network/explorer/none.ts +3 -0
  301. package/src/network/explorer/types.ts +29 -5
  302. package/src/network/index.ts +7 -0
  303. package/src/network/node/explorerProxy.test.ts +673 -0
  304. package/src/network/node/explorerProxy.ts +308 -0
  305. package/src/network/node/index.memoization.test.ts +22 -10
  306. package/src/network/node/index.test.ts +6 -3
  307. package/src/network/node/index.ts +11 -7
  308. package/src/network/node/ledger.ts +1 -1
  309. package/src/network/node/rpc.common.ts +3 -3
  310. package/src/network/node/rpc.test.ts +66 -105
  311. package/src/network/node/withNodeSources.test.ts +240 -0
  312. package/src/network/node/withNodeSources.ts +95 -0
  313. package/src/nodeSources.ts +38 -0
  314. package/src/staking/contracts.ts +1 -1
  315. package/src/staking/encoder.test.ts +1 -1
  316. package/src/staking/fetchers.ts +1 -1
  317. package/src/staking/operations/sei.ts +1 -1
  318. package/src/staking/prepareIntents.ts +1 -1
  319. package/src/staking/redelegations.test.ts +1 -1
  320. package/src/staking/rewards.test.ts +1 -1
  321. package/src/staking/rewards.ts +1 -1
  322. package/src/staking/transactionData.ts +1 -1
  323. package/src/staking/unbondings.test.ts +1 -1
  324. package/src/staking/utils.test.ts +25 -0
  325. package/src/{utils.ts → staking/utils.ts} +2 -182
  326. package/src/staking/validators/sei.ts +1 -1
  327. package/src/types/staking.ts +2 -2
  328. package/lib/constants.d.ts +0 -2
  329. package/lib/constants.d.ts.map +0 -1
  330. package/lib/constants.js +0 -11
  331. package/lib/constants.js.map +0 -1
  332. package/lib/utils.d.ts.map +0 -1
  333. package/lib/utils.js.map +0 -1
  334. package/lib-es/constants.d.ts +0 -2
  335. package/lib-es/constants.d.ts.map +0 -1
  336. package/lib-es/constants.js +0 -7
  337. package/lib-es/constants.js.map +0 -1
  338. package/lib-es/utils.d.ts.map +0 -1
  339. package/lib-es/utils.js.map +0 -1
  340. package/src/constants.ts +0 -9
  341. package/src/logic/broadcast.integ.test.ts +0 -46
  342. package/src/logic/getBalance.test.ts +0 -362
@@ -1,14 +1,14 @@
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, mkExternalNode, mkLedgerNode } from '../fixtures/context.fixtures'
6
- import { getNodeApi } from '../network/node'
7
- import { mockNodeApi } from '../network/node/node.fixtures'
8
- import { getBlockInfo } from './getBlockInfo'
9
-
10
- jest.mock('../network/node', () => ({
11
- ...jest.requireActual('../network/node'),
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
6
+ import { getNodeApi } from '../../network/node'
7
+ import { mockNodeApi } from '../../network/node/node.fixtures'
8
+ import { getBlockInfo } from '../getBlockInfo'
9
+
10
+ jest.mock('../../network/node', () => ({
11
+ ...jest.requireActual('../../network/node'),
12
12
  getNodeApi: jest.fn(),
13
13
  }))
14
14
 
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { getErc20Data } from './getErc20Data'
4
+ import { getErc20Data } from '../getErc20Data'
5
5
 
6
6
  describe('getErc20Data', () => {
7
7
  it.each([
@@ -1,14 +1,14 @@
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, mkExternalNode, mkLedgerNode } from '../fixtures/context.fixtures'
6
- import { getNodeApi } from '../network/node'
7
- import { mockNodeApi } from '../network/node/node.fixtures'
8
- import { getNextSequence } from './getNextSequence'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
6
+ import { getNodeApi } from '../../network/node'
7
+ import { mockNodeApi } from '../../network/node/node.fixtures'
8
+ import { getNextSequence } from '../getNextSequence'
9
9
 
10
- jest.mock('../network/node', () => ({
11
- ...jest.requireActual('../network/node'),
10
+ jest.mock('../../network/node', () => ({
11
+ ...jest.requireActual('../../network/node'),
12
12
  getNodeApi: jest.fn(),
13
13
  }))
14
14
 
@@ -1,29 +1,29 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { createMockEvmContext } from '../fixtures/context.fixtures'
5
- import { mkJsonRpcProvider, mkResult } from '../fixtures/ethers.fixtures'
6
- import { withApi } from '../network/node/rpc.common'
7
- import { encodeStakingData, decodeStakingResult } from '../staking/encoder'
8
- import { fetchUnbondings } from '../staking/unbondings'
9
- import { getValidators } from '../staking/validators'
10
- import { getStakes } from './getStakes'
11
-
12
- jest.mock('../network/node/rpc.common', () => ({
13
- ...jest.requireActual('../network/node/rpc.common'),
4
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
5
+ import { mkJsonRpcProvider, mkResult } from '../../fixtures/ethers.fixtures'
6
+ import { withApi } from '../../network/node/rpc.common'
7
+ import { encodeStakingData, decodeStakingResult } from '../../staking/encoder'
8
+ import { fetchUnbondings } from '../../staking/unbondings'
9
+ import { getValidators } from '../../staking/validators'
10
+ import { getStakes } from '../getStakes'
11
+
12
+ jest.mock('../../network/node/rpc.common', () => ({
13
+ ...jest.requireActual('../../network/node/rpc.common'),
14
14
  withApi: jest.fn(),
15
15
  }))
16
16
 
17
- jest.mock('../staking/encoder', () => ({
17
+ jest.mock('../../staking/encoder', () => ({
18
18
  encodeStakingData: jest.fn(),
19
19
  decodeStakingResult: jest.fn(),
20
20
  }))
21
21
 
22
- jest.mock('../staking/validators', () => ({
22
+ jest.mock('../../staking/validators', () => ({
23
23
  getValidators: jest.fn(),
24
24
  }))
25
25
 
26
- jest.mock('../staking/unbondings', () => ({
26
+ jest.mock('../../staking/unbondings', () => ({
27
27
  fetchUnbondings: jest.fn(),
28
28
  }))
29
29
 
@@ -1,21 +1,21 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { SourceFetcher } from './internalTransactionsFetcher'
4
+ import type { SourceFetcher } from '../internalTransactionsFetcher'
5
5
  import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
6
- import { internalTxSourcesFromList } from '../config'
7
- import { SourceUnavailableError } from '../errors'
6
+ import { internalTxSourcesFromList } from '../../config'
7
+ import { SourceUnavailableError } from '../../errors'
8
8
  import {
9
9
  createMockEvmConfigInfo,
10
10
  mkEtherscanExplorer,
11
11
  mkExternalNode,
12
12
  mkLedgerExplorer,
13
- } from '../fixtures/context.fixtures'
14
- import { getInternalTransactionsByBlock } from '../network/explorer/etherscan'
15
- import { mockNodeApi } from '../network/node/node.fixtures'
16
- import { composeInternalTxsFetcher, makeSourceFetchers } from './internalTransactionsFetcher'
13
+ } from '../../fixtures/context.fixtures'
14
+ import { getInternalTransactionsByBlock } from '../../network/explorer/etherscan'
15
+ import { mockNodeApi } from '../../network/node/node.fixtures'
16
+ import { composeInternalTxsFetcher, makeSourceFetchers } from '../internalTransactionsFetcher'
17
17
 
18
- jest.mock('../network/explorer/etherscan', () => ({
18
+ jest.mock('../../network/explorer/etherscan', () => ({
19
19
  getInternalTransactionsByBlock: jest.fn().mockResolvedValue([]),
20
20
  }))
21
21
 
@@ -6,14 +6,14 @@ import type {
6
6
  EvmConfigInfo,
7
7
  ExternalNodeConfig,
8
8
  LedgerNodeConfig,
9
- } from '../config'
10
- import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../fixtures/context.fixtures'
11
- import { getNodeApi } from '../network/node'
12
- import { mockNodeApi } from '../network/node/node.fixtures'
13
- import { lastBlock } from './lastBlock'
9
+ } from '../../config'
10
+ import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
11
+ import { getNodeApi } from '../../network/node'
12
+ import { mockNodeApi } from '../../network/node/node.fixtures'
13
+ import { lastBlock } from '../lastBlock'
14
14
 
15
- jest.mock('../network/node', () => ({
16
- ...jest.requireActual('../network/node'),
15
+ jest.mock('../../network/node', () => ({
16
+ ...jest.requireActual('../../network/node'),
17
17
  getNodeApi: jest.fn(),
18
18
  }))
19
19
 
@@ -1,23 +1,53 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfig, EvmContext } from '../config'
5
- import type { ExplorerApi } from '../network/explorer/types'
4
+ import type { EvmConfig, EvmContext } from '../../config'
5
+ import type { ExplorerApi } from '../../network/explorer/types'
6
+ import type { LedgerExplorerOperation } from '../../types'
6
7
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
8
+ import type { AxiosRequestConfig } from 'axios'
9
+ import { InvalidParameterError } from '@ledgerhq/coin-module-framework/errors'
10
+ import axios from 'axios'
7
11
  import BigNumber from 'bignumber.js'
8
12
  import {
9
13
  createMockEvmContext,
10
14
  mkEtherscanExplorer,
11
15
  mkLedgerExplorer,
12
- } from '../fixtures/context.fixtures'
13
- import etherscanExplorer from '../network/explorer/etherscan'
14
- import ledgerExplorer from '../network/explorer/ledger'
15
- import { listOperations } from './listOperations'
16
+ } from '../../fixtures/context.fixtures'
17
+ import etherscanExplorer from '../../network/explorer/etherscan'
18
+ import ledgerExplorer from '../../network/explorer/ledger'
19
+ import { listOperations } from '../listOperations'
16
20
 
17
21
  describe('listOperations', () => {
18
22
  const currency = ''
19
23
  const address = 'address'
20
24
 
25
+ describe('limit validation', () => {
26
+ it.each([[0], [-1]])(
27
+ 'rejects the non-positive limit %i instead of walking on it',
28
+ async (limit) => {
29
+ const request = jest
30
+ .spyOn(axios, 'request')
31
+ .mockResolvedValue({ data: { data: [], token: '' } })
32
+
33
+ await expect(
34
+ listOperations(
35
+ ctxWithExplorer(mkLedgerExplorer({ explorerId: 'eth' })),
36
+ currency,
37
+ address,
38
+ {
39
+ minHeight: 0,
40
+ limit,
41
+ }
42
+ )
43
+ ).rejects.toBeInstanceOf(InvalidParameterError)
44
+ // Nothing reaches the explorer: a zero page size used to make the paged walk double a
45
+ // zero forever, so this has to be caught before the first request.
46
+ expect(request).not.toHaveBeenCalled()
47
+ }
48
+ )
49
+ })
50
+
21
51
  // The logic layer resolves config from the threaded context, so tests carry their explorer
22
52
  // config on the context instead of seeding the module-level singleton.
23
53
  const ctxWithExplorer = (explorer: EvmConfig['explorer']): EvmContext =>
@@ -545,6 +575,7 @@ describe('listOperations', () => {
545
575
  // defaults to "desc" without limit
546
576
  undefinedLimit,
547
577
  'desc',
578
+ testContext.logger,
548
579
  ],
549
580
  ],
550
581
  })
@@ -1193,6 +1224,94 @@ describe('listOperations', () => {
1193
1224
  }
1194
1225
  )
1195
1226
 
1227
+ describe('ledger explorer pagination parameters reach the real arm', () => {
1228
+ const address = '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d'
1229
+
1230
+ // Minimal record: `from` is the requested address so it maps to exactly one operation.
1231
+ const record = (height: number, hash: string): LedgerExplorerOperation => ({
1232
+ hash,
1233
+ transaction_type: 2,
1234
+ nonce: '0x0',
1235
+ nonce_value: 0,
1236
+ value: '0',
1237
+ gas: '0',
1238
+ gas_price: '0',
1239
+ max_fee_per_gas: null,
1240
+ max_priority_fee_per_gas: null,
1241
+ from: address,
1242
+ to: '0x0000000000000000000000000000000000000009',
1243
+ transfer_events: [],
1244
+ erc721_transfer_events: [],
1245
+ erc1155_transfer_events: [],
1246
+ approval_events: [],
1247
+ actions: [],
1248
+ confirmations: 1,
1249
+ input: null,
1250
+ gas_used: '0',
1251
+ cumulative_gas_used: '0',
1252
+ status: 1,
1253
+ received_at: '2023-01-01T00:00:00Z',
1254
+ block: { hash: '0xblock', height, time: '2023-01-01T00:00:00Z' },
1255
+ })
1256
+
1257
+ // A prior test in this file may have left `ledgerExplorer.getOperations` spied with
1258
+ // `mockResolvedValue` (the outer `afterEach` only clears call state, it does not restore the
1259
+ // original implementation) — restore it so this suite drives the real arm.
1260
+ beforeEach(() => {
1261
+ jest.restoreAllMocks()
1262
+ })
1263
+
1264
+ afterEach(() => {
1265
+ jest.restoreAllMocks()
1266
+ })
1267
+
1268
+ it.each([['asc'], ['desc']] as const)(
1269
+ 'forwards options.limit/cursor/order to the ledger explorer request and returns its cursor as `next` (%s)',
1270
+ async (order) => {
1271
+ // The boundary record (height 11) stands for one already delivered by a previous page;
1272
+ // the explorer is expected to hand it back again (skip-through-hash territory), followed
1273
+ // by the two genuinely new records.
1274
+ const allRecords = [record(11, '0xh11'), record(10, '0xh10'), record(9, '0xh9')]
1275
+ const testContext = ctxWithExplorer({ type: 'ledger', explorerId: 'eth' })
1276
+ const request = jest
1277
+ .spyOn(axios, 'request')
1278
+ .mockImplementation(async ({ params }: AxiosRequestConfig) => {
1279
+ if (params.token !== undefined) {
1280
+ throw new Error('the paged path must not use the explorer continuation token')
1281
+ }
1282
+ return { data: { data: allRecords.slice(0, params.batch_size), token: '' } }
1283
+ })
1284
+
1285
+ const { next } = await listOperations(testContext, '', address, {
1286
+ minHeight: 0,
1287
+ limit: 3,
1288
+ cursor: '11:0xh11',
1289
+ order,
1290
+ })
1291
+
1292
+ expect(request).toHaveBeenCalledWith(
1293
+ expect.objectContaining({
1294
+ params: expect.objectContaining({
1295
+ batch_size: 3,
1296
+ order: order === 'asc' ? 'ascending' : 'descending',
1297
+ }),
1298
+ })
1299
+ )
1300
+ // The cursor forwarded by `listOperations` reached the explorer as the resumed window's
1301
+ // bound: descending caps at to_height, ascending floors at from_height.
1302
+ expect(request).toHaveBeenCalledWith(
1303
+ expect.objectContaining({
1304
+ params: expect.objectContaining(
1305
+ order === 'asc' ? { from_height: 11 } : { to_height: 11 }
1306
+ ),
1307
+ })
1308
+ )
1309
+ // The arm's own cursor (height:hash of the last record), not the explorer's token.
1310
+ expect(next).toBe('9:0xh9')
1311
+ }
1312
+ )
1313
+ })
1314
+
1196
1315
  it('should not enrich feePayer with ambiguous sender', async () => {
1197
1316
  const address = 'address'
1198
1317
  const parentTx = {
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { getAddress } from 'ethers'
5
- import { validateAddress } from './validateAddress'
5
+ import { validateAddress } from '../validateAddress'
6
6
 
7
7
  jest.mock('ethers')
8
8