@ledgerhq/coin-evm 10.1.0 → 15.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 (436) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/docs/getBlock-internal-txs-schema.md +2 -2
  3. package/docs/network/node/index.md +1 -1
  4. package/lib/adapters/etherscan.d.ts +2 -1
  5. package/lib/adapters/etherscan.d.ts.map +1 -1
  6. package/lib/adapters/etherscan.js +2 -2
  7. package/lib/adapters/etherscan.js.map +1 -1
  8. package/lib/adapters/ledger.d.ts +2 -1
  9. package/lib/adapters/ledger.d.ts.map +1 -1
  10. package/lib/adapters/ledger.js +2 -2
  11. package/lib/adapters/ledger.js.map +1 -1
  12. package/lib/api/index.js +1 -1
  13. package/lib/api/index.js.map +1 -1
  14. package/lib/chains.d.ts +94 -0
  15. package/lib/chains.d.ts.map +1 -0
  16. package/lib/chains.js +98 -0
  17. package/lib/chains.js.map +1 -0
  18. package/lib/config.d.ts +4 -1
  19. package/lib/config.d.ts.map +1 -1
  20. package/lib/config.js +3 -1
  21. package/lib/config.js.map +1 -1
  22. package/lib/logic/broadcast.js +2 -2
  23. package/lib/logic/broadcast.js.map +1 -1
  24. package/lib/logic/common.d.ts +1 -1
  25. package/lib/logic/common.d.ts.map +1 -1
  26. package/lib/logic/common.js +11 -11
  27. package/lib/logic/common.js.map +1 -1
  28. package/lib/logic/craftTransaction.d.ts.map +1 -1
  29. package/lib/logic/craftTransaction.js +3 -3
  30. package/lib/logic/craftTransaction.js.map +1 -1
  31. package/lib/logic/estimateFees.d.ts.map +1 -1
  32. package/lib/logic/estimateFees.js +7 -7
  33. package/lib/logic/estimateFees.js.map +1 -1
  34. package/lib/logic/getBalance.d.ts.map +1 -1
  35. package/lib/logic/getBalance.js +9 -9
  36. package/lib/logic/getBalance.js.map +1 -1
  37. package/lib/logic/getBlock.d.ts.map +1 -1
  38. package/lib/logic/getBlock.js +17 -17
  39. package/lib/logic/getBlock.js.map +1 -1
  40. package/lib/logic/getBlockInfo.js +2 -2
  41. package/lib/logic/getBlockInfo.js.map +1 -1
  42. package/lib/logic/getNextSequence.d.ts.map +1 -1
  43. package/lib/logic/getNextSequence.js +1 -1
  44. package/lib/logic/getNextSequence.js.map +1 -1
  45. package/lib/logic/getStakes.d.ts.map +1 -1
  46. package/lib/logic/getStakes.js +10 -10
  47. package/lib/logic/getStakes.js.map +1 -1
  48. package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
  49. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  50. package/lib/logic/internalTransactionsFetcher.js +8 -8
  51. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  52. package/lib/logic/lastBlock.js +2 -2
  53. package/lib/logic/lastBlock.js.map +1 -1
  54. package/lib/logic/listOperations.d.ts.map +1 -1
  55. package/lib/logic/listOperations.js +1 -1
  56. package/lib/logic/listOperations.js.map +1 -1
  57. package/lib/logic/validateIntent.d.ts.map +1 -1
  58. package/lib/logic/validateIntent.js +9 -9
  59. package/lib/logic/validateIntent.js.map +1 -1
  60. package/lib/logic.d.ts +1 -1
  61. package/lib/logic.d.ts.map +1 -1
  62. package/lib/logic.js +14 -13
  63. package/lib/logic.js.map +1 -1
  64. package/lib/network/explorer/etherscan.d.ts +2 -3
  65. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  66. package/lib/network/explorer/etherscan.js +6 -8
  67. package/lib/network/explorer/etherscan.js.map +1 -1
  68. package/lib/network/explorer/ledger.d.ts.map +1 -1
  69. package/lib/network/explorer/ledger.js +5 -5
  70. package/lib/network/explorer/ledger.js.map +1 -1
  71. package/lib/network/explorer/types.d.ts +2 -2
  72. package/lib/network/explorer/types.d.ts.map +1 -1
  73. package/lib/network/explorer/types.js.map +1 -1
  74. package/lib/network/node/explorerProxy.js +12 -12
  75. package/lib/network/node/explorerProxy.js.map +1 -1
  76. package/lib/network/node/index.d.ts +1 -1
  77. package/lib/network/node/index.d.ts.map +1 -1
  78. package/lib/network/node/index.js +7 -7
  79. package/lib/network/node/index.js.map +1 -1
  80. package/lib/network/node/ledger.d.ts +3 -1
  81. package/lib/network/node/ledger.d.ts.map +1 -1
  82. package/lib/network/node/ledger.js +31 -22
  83. package/lib/network/node/ledger.js.map +1 -1
  84. package/lib/network/node/rpc.common.d.ts +1 -1
  85. package/lib/network/node/rpc.common.d.ts.map +1 -1
  86. package/lib/network/node/rpc.common.js +50 -39
  87. package/lib/network/node/rpc.common.js.map +1 -1
  88. package/lib/network/node/types.d.ts +15 -15
  89. package/lib/network/node/types.d.ts.map +1 -1
  90. package/lib/network/node/types.js.map +1 -1
  91. package/lib/network/node/withNodeSources.d.ts.map +1 -1
  92. package/lib/network/node/withNodeSources.js +15 -15
  93. package/lib/network/node/withNodeSources.js.map +1 -1
  94. package/lib/staking/abis.d.ts +3 -2
  95. package/lib/staking/abis.d.ts.map +1 -1
  96. package/lib/staking/abis.js +10 -9
  97. package/lib/staking/abis.js.map +1 -1
  98. package/lib/staking/contracts.d.ts +3 -2
  99. package/lib/staking/contracts.d.ts.map +1 -1
  100. package/lib/staking/contracts.js +11 -10
  101. package/lib/staking/contracts.js.map +1 -1
  102. package/lib/staking/detectOperationType.d.ts +2 -1
  103. package/lib/staking/detectOperationType.d.ts.map +1 -1
  104. package/lib/staking/detectOperationType.js +7 -7
  105. package/lib/staking/detectOperationType.js.map +1 -1
  106. package/lib/staking/encoder.d.ts +2 -1
  107. package/lib/staking/encoder.d.ts.map +1 -1
  108. package/lib/staking/encoder.js +8 -8
  109. package/lib/staking/encoder.js.map +1 -1
  110. package/lib/staking/fetchers.d.ts +2 -1
  111. package/lib/staking/fetchers.d.ts.map +1 -1
  112. package/lib/staking/fetchers.js +27 -27
  113. package/lib/staking/fetchers.js.map +1 -1
  114. package/lib/staking/logic.d.ts +6 -6
  115. package/lib/staking/logic.d.ts.map +1 -1
  116. package/lib/staking/logic.js +14 -13
  117. package/lib/staking/logic.js.map +1 -1
  118. package/lib/staking/operations/index.d.ts +2 -1
  119. package/lib/staking/operations/index.d.ts.map +1 -1
  120. package/lib/staking/operations/index.js +30 -28
  121. package/lib/staking/operations/index.js.map +1 -1
  122. package/lib/staking/prepareIntents.d.ts +1 -1
  123. package/lib/staking/prepareIntents.d.ts.map +1 -1
  124. package/lib/staking/prepareIntents.js +11 -10
  125. package/lib/staking/prepareIntents.js.map +1 -1
  126. package/lib/staking/redelegations.d.ts +4 -4
  127. package/lib/staking/redelegations.d.ts.map +1 -1
  128. package/lib/staking/redelegations.js +18 -20
  129. package/lib/staking/redelegations.js.map +1 -1
  130. package/lib/staking/rewards.d.ts +1 -1
  131. package/lib/staking/rewards.d.ts.map +1 -1
  132. package/lib/staking/rewards.js +2 -2
  133. package/lib/staking/rewards.js.map +1 -1
  134. package/lib/staking/rewardsFromReceipt.d.ts +2 -1
  135. package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
  136. package/lib/staking/rewardsFromReceipt.js +2 -2
  137. package/lib/staking/rewardsFromReceipt.js.map +1 -1
  138. package/lib/staking/transactionData.d.ts +2 -1
  139. package/lib/staking/transactionData.d.ts.map +1 -1
  140. package/lib/staking/transactionData.js +6 -6
  141. package/lib/staking/transactionData.js.map +1 -1
  142. package/lib/staking/unbondings.d.ts +1 -1
  143. package/lib/staking/unbondings.d.ts.map +1 -1
  144. package/lib/staking/unbondings.js +2 -2
  145. package/lib/staking/unbondings.js.map +1 -1
  146. package/lib/staking/validators/index.d.ts +14 -14
  147. package/lib/staking/validators/index.d.ts.map +1 -1
  148. package/lib/staking/validators/index.js +39 -38
  149. package/lib/staking/validators/index.js.map +1 -1
  150. package/lib/staking/validators/monad.d.ts +5 -5
  151. package/lib/staking/validators/monad.d.ts.map +1 -1
  152. package/lib/staking/validators/monad.js +31 -33
  153. package/lib/staking/validators/monad.js.map +1 -1
  154. package/lib/staking/validators/monadResolver.d.ts +1 -1
  155. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  156. package/lib/staking/validators/monadResolver.js +4 -4
  157. package/lib/staking/validators/monadResolver.js.map +1 -1
  158. package/lib/staking/validators/sei.js +2 -2
  159. package/lib/staking/validators/sei.js.map +1 -1
  160. package/lib/staking/validators/somnia.d.ts +4 -4
  161. package/lib/staking/validators/somnia.d.ts.map +1 -1
  162. package/lib/staking/validators/somnia.js +22 -22
  163. package/lib/staking/validators/somnia.js.map +1 -1
  164. package/lib/staking/validators/types.d.ts +1 -1
  165. package/lib/staking/validators/types.d.ts.map +1 -1
  166. package/lib/staking/validators/zero_gravity.d.ts +1 -1
  167. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  168. package/lib/staking/validators/zero_gravity.js +7 -7
  169. package/lib/staking/validators/zero_gravity.js.map +1 -1
  170. package/lib/types/staking.d.ts +5 -6
  171. package/lib/types/staking.d.ts.map +1 -1
  172. package/lib-es/adapters/etherscan.d.ts +2 -1
  173. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  174. package/lib-es/adapters/etherscan.js +2 -2
  175. package/lib-es/adapters/etherscan.js.map +1 -1
  176. package/lib-es/adapters/ledger.d.ts +2 -1
  177. package/lib-es/adapters/ledger.d.ts.map +1 -1
  178. package/lib-es/adapters/ledger.js +2 -2
  179. package/lib-es/adapters/ledger.js.map +1 -1
  180. package/lib-es/api/index.js +1 -1
  181. package/lib-es/api/index.js.map +1 -1
  182. package/lib-es/chains.d.ts +94 -0
  183. package/lib-es/chains.d.ts.map +1 -0
  184. package/lib-es/chains.js +95 -0
  185. package/lib-es/chains.js.map +1 -0
  186. package/lib-es/config.d.ts +4 -1
  187. package/lib-es/config.d.ts.map +1 -1
  188. package/lib-es/config.js +1 -0
  189. package/lib-es/config.js.map +1 -1
  190. package/lib-es/logic/broadcast.js +2 -2
  191. package/lib-es/logic/broadcast.js.map +1 -1
  192. package/lib-es/logic/common.d.ts +1 -1
  193. package/lib-es/logic/common.d.ts.map +1 -1
  194. package/lib-es/logic/common.js +11 -11
  195. package/lib-es/logic/common.js.map +1 -1
  196. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  197. package/lib-es/logic/craftTransaction.js +3 -3
  198. package/lib-es/logic/craftTransaction.js.map +1 -1
  199. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  200. package/lib-es/logic/estimateFees.js +7 -7
  201. package/lib-es/logic/estimateFees.js.map +1 -1
  202. package/lib-es/logic/getBalance.d.ts.map +1 -1
  203. package/lib-es/logic/getBalance.js +9 -9
  204. package/lib-es/logic/getBalance.js.map +1 -1
  205. package/lib-es/logic/getBlock.d.ts.map +1 -1
  206. package/lib-es/logic/getBlock.js +18 -18
  207. package/lib-es/logic/getBlock.js.map +1 -1
  208. package/lib-es/logic/getBlockInfo.js +2 -2
  209. package/lib-es/logic/getBlockInfo.js.map +1 -1
  210. package/lib-es/logic/getNextSequence.d.ts.map +1 -1
  211. package/lib-es/logic/getNextSequence.js +1 -1
  212. package/lib-es/logic/getNextSequence.js.map +1 -1
  213. package/lib-es/logic/getStakes.d.ts.map +1 -1
  214. package/lib-es/logic/getStakes.js +10 -10
  215. package/lib-es/logic/getStakes.js.map +1 -1
  216. package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
  217. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  218. package/lib-es/logic/internalTransactionsFetcher.js +8 -8
  219. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  220. package/lib-es/logic/lastBlock.js +2 -2
  221. package/lib-es/logic/lastBlock.js.map +1 -1
  222. package/lib-es/logic/listOperations.d.ts.map +1 -1
  223. package/lib-es/logic/listOperations.js +1 -1
  224. package/lib-es/logic/listOperations.js.map +1 -1
  225. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  226. package/lib-es/logic/validateIntent.js +9 -9
  227. package/lib-es/logic/validateIntent.js.map +1 -1
  228. package/lib-es/logic.d.ts +1 -1
  229. package/lib-es/logic.d.ts.map +1 -1
  230. package/lib-es/logic.js +14 -13
  231. package/lib-es/logic.js.map +1 -1
  232. package/lib-es/network/explorer/etherscan.d.ts +2 -3
  233. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  234. package/lib-es/network/explorer/etherscan.js +6 -8
  235. package/lib-es/network/explorer/etherscan.js.map +1 -1
  236. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  237. package/lib-es/network/explorer/ledger.js +5 -5
  238. package/lib-es/network/explorer/ledger.js.map +1 -1
  239. package/lib-es/network/explorer/types.d.ts +2 -2
  240. package/lib-es/network/explorer/types.d.ts.map +1 -1
  241. package/lib-es/network/explorer/types.js.map +1 -1
  242. package/lib-es/network/node/explorerProxy.js +12 -12
  243. package/lib-es/network/node/explorerProxy.js.map +1 -1
  244. package/lib-es/network/node/index.d.ts +1 -1
  245. package/lib-es/network/node/index.d.ts.map +1 -1
  246. package/lib-es/network/node/index.js +7 -7
  247. package/lib-es/network/node/index.js.map +1 -1
  248. package/lib-es/network/node/ledger.d.ts +3 -1
  249. package/lib-es/network/node/ledger.d.ts.map +1 -1
  250. package/lib-es/network/node/ledger.js +31 -22
  251. package/lib-es/network/node/ledger.js.map +1 -1
  252. package/lib-es/network/node/rpc.common.d.ts +1 -1
  253. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  254. package/lib-es/network/node/rpc.common.js +50 -39
  255. package/lib-es/network/node/rpc.common.js.map +1 -1
  256. package/lib-es/network/node/types.d.ts +15 -15
  257. package/lib-es/network/node/types.d.ts.map +1 -1
  258. package/lib-es/network/node/types.js.map +1 -1
  259. package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
  260. package/lib-es/network/node/withNodeSources.js +15 -15
  261. package/lib-es/network/node/withNodeSources.js.map +1 -1
  262. package/lib-es/staking/abis.d.ts +3 -2
  263. package/lib-es/staking/abis.d.ts.map +1 -1
  264. package/lib-es/staking/abis.js +10 -9
  265. package/lib-es/staking/abis.js.map +1 -1
  266. package/lib-es/staking/contracts.d.ts +3 -2
  267. package/lib-es/staking/contracts.d.ts.map +1 -1
  268. package/lib-es/staking/contracts.js +11 -10
  269. package/lib-es/staking/contracts.js.map +1 -1
  270. package/lib-es/staking/detectOperationType.d.ts +2 -1
  271. package/lib-es/staking/detectOperationType.d.ts.map +1 -1
  272. package/lib-es/staking/detectOperationType.js +7 -7
  273. package/lib-es/staking/detectOperationType.js.map +1 -1
  274. package/lib-es/staking/encoder.d.ts +2 -1
  275. package/lib-es/staking/encoder.d.ts.map +1 -1
  276. package/lib-es/staking/encoder.js +8 -8
  277. package/lib-es/staking/encoder.js.map +1 -1
  278. package/lib-es/staking/fetchers.d.ts +2 -1
  279. package/lib-es/staking/fetchers.d.ts.map +1 -1
  280. package/lib-es/staking/fetchers.js +27 -27
  281. package/lib-es/staking/fetchers.js.map +1 -1
  282. package/lib-es/staking/logic.d.ts +6 -6
  283. package/lib-es/staking/logic.d.ts.map +1 -1
  284. package/lib-es/staking/logic.js +14 -13
  285. package/lib-es/staking/logic.js.map +1 -1
  286. package/lib-es/staking/operations/index.d.ts +2 -1
  287. package/lib-es/staking/operations/index.d.ts.map +1 -1
  288. package/lib-es/staking/operations/index.js +30 -28
  289. package/lib-es/staking/operations/index.js.map +1 -1
  290. package/lib-es/staking/prepareIntents.d.ts +1 -1
  291. package/lib-es/staking/prepareIntents.d.ts.map +1 -1
  292. package/lib-es/staking/prepareIntents.js +11 -10
  293. package/lib-es/staking/prepareIntents.js.map +1 -1
  294. package/lib-es/staking/redelegations.d.ts +4 -4
  295. package/lib-es/staking/redelegations.d.ts.map +1 -1
  296. package/lib-es/staking/redelegations.js +18 -20
  297. package/lib-es/staking/redelegations.js.map +1 -1
  298. package/lib-es/staking/rewards.d.ts +1 -1
  299. package/lib-es/staking/rewards.d.ts.map +1 -1
  300. package/lib-es/staking/rewards.js +2 -2
  301. package/lib-es/staking/rewards.js.map +1 -1
  302. package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
  303. package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
  304. package/lib-es/staking/rewardsFromReceipt.js +2 -2
  305. package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
  306. package/lib-es/staking/transactionData.d.ts +2 -1
  307. package/lib-es/staking/transactionData.d.ts.map +1 -1
  308. package/lib-es/staking/transactionData.js +6 -6
  309. package/lib-es/staking/transactionData.js.map +1 -1
  310. package/lib-es/staking/unbondings.d.ts +1 -1
  311. package/lib-es/staking/unbondings.d.ts.map +1 -1
  312. package/lib-es/staking/unbondings.js +2 -2
  313. package/lib-es/staking/unbondings.js.map +1 -1
  314. package/lib-es/staking/validators/index.d.ts +14 -14
  315. package/lib-es/staking/validators/index.d.ts.map +1 -1
  316. package/lib-es/staking/validators/index.js +39 -38
  317. package/lib-es/staking/validators/index.js.map +1 -1
  318. package/lib-es/staking/validators/monad.d.ts +5 -5
  319. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  320. package/lib-es/staking/validators/monad.js +31 -33
  321. package/lib-es/staking/validators/monad.js.map +1 -1
  322. package/lib-es/staking/validators/monadResolver.d.ts +1 -1
  323. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  324. package/lib-es/staking/validators/monadResolver.js +4 -4
  325. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  326. package/lib-es/staking/validators/sei.js +2 -2
  327. package/lib-es/staking/validators/sei.js.map +1 -1
  328. package/lib-es/staking/validators/somnia.d.ts +4 -4
  329. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  330. package/lib-es/staking/validators/somnia.js +22 -22
  331. package/lib-es/staking/validators/somnia.js.map +1 -1
  332. package/lib-es/staking/validators/types.d.ts +1 -1
  333. package/lib-es/staking/validators/types.d.ts.map +1 -1
  334. package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
  335. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  336. package/lib-es/staking/validators/zero_gravity.js +7 -7
  337. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  338. package/lib-es/types/staking.d.ts +5 -6
  339. package/lib-es/types/staking.d.ts.map +1 -1
  340. package/package.json +1 -1
  341. package/src/adapters/etherscan.test.ts +34 -38
  342. package/src/adapters/etherscan.ts +3 -2
  343. package/src/adapters/ledger.test.ts +49 -22
  344. package/src/adapters/ledger.ts +3 -2
  345. package/src/api/getBlock.integ.test.ts +2 -1
  346. package/src/api/index.monad_testnet.integ.test.ts +2 -2
  347. package/src/api/index.ts +1 -1
  348. package/src/chains.test.ts +12 -0
  349. package/src/chains.ts +97 -0
  350. package/src/config.ts +5 -1
  351. package/src/fixtures/staking.fixtures.ts +13 -0
  352. package/src/logic/broadcast.ts +2 -2
  353. package/src/logic/common.ts +10 -11
  354. package/src/logic/craftTransaction.ts +2 -3
  355. package/src/logic/estimateFees.ts +6 -23
  356. package/src/logic/getBalance.ts +7 -13
  357. package/src/logic/getBlock.ts +22 -19
  358. package/src/logic/getBlockInfo.ts +2 -2
  359. package/src/logic/getNextSequence.ts +1 -4
  360. package/src/logic/getStakes.ts +11 -12
  361. package/src/logic/internalTransactionsFetcher.ts +6 -8
  362. package/src/logic/lastBlock.ts +2 -2
  363. package/src/logic/listOperations.ts +0 -1
  364. package/src/logic/tests/broadcast.test.ts +4 -4
  365. package/src/logic/tests/broadcastSource.test.ts +0 -3
  366. package/src/logic/tests/common.test.ts +17 -33
  367. package/src/logic/tests/craftTransaction.test.ts +13 -6
  368. package/src/logic/tests/estimateFees.test.ts +16 -7
  369. package/src/logic/tests/getBalance.test.ts +17 -33
  370. package/src/logic/tests/getBlock.test.ts +69 -75
  371. package/src/logic/tests/getBlockInfo.test.ts +1 -1
  372. package/src/logic/tests/getNextSequence.test.ts +1 -1
  373. package/src/logic/tests/getStakes.test.ts +28 -16
  374. package/src/logic/tests/internalTransactionsFetcher.test.ts +5 -5
  375. package/src/logic/tests/lastBlock.test.ts +3 -6
  376. package/src/logic/tests/listOperations.test.ts +3 -4
  377. package/src/logic/tests/validateIntent.test.ts +12 -2
  378. package/src/logic/validateIntent.ts +8 -10
  379. package/src/logic.test.ts +12 -4
  380. package/src/logic.ts +13 -13
  381. package/src/network/explorer/etherscan.test.ts +9 -58
  382. package/src/network/explorer/etherscan.ts +8 -24
  383. package/src/network/explorer/index.test.ts +1 -1
  384. package/src/network/explorer/ledger.test.ts +23 -131
  385. package/src/network/explorer/ledger.ts +2 -5
  386. package/src/network/explorer/types.ts +0 -2
  387. package/src/network/node/explorerProxy.test.ts +17 -22
  388. package/src/network/node/explorerProxy.ts +12 -12
  389. package/src/network/node/index.memoization.test.ts +29 -22
  390. package/src/network/node/index.test.ts +1 -3
  391. package/src/network/node/index.ts +11 -8
  392. package/src/network/node/ledger.test.ts +63 -69
  393. package/src/network/node/ledger.ts +31 -34
  394. package/src/network/node/rpc.common.ts +58 -86
  395. package/src/network/node/rpc.test.ts +86 -114
  396. package/src/network/node/types.ts +11 -29
  397. package/src/network/node/withNodeSources.test.ts +7 -9
  398. package/src/network/node/withNodeSources.ts +23 -26
  399. package/src/staking/abis.test.ts +24 -28
  400. package/src/staking/abis.ts +12 -10
  401. package/src/staking/contracts.test.ts +20 -8
  402. package/src/staking/contracts.ts +12 -11
  403. package/src/staking/detectOperationType.test.ts +16 -13
  404. package/src/staking/detectOperationType.ts +9 -8
  405. package/src/staking/encoder.test.ts +38 -27
  406. package/src/staking/encoder.ts +9 -8
  407. package/src/staking/fetchers.ts +28 -39
  408. package/src/staking/logic.test.ts +34 -32
  409. package/src/staking/logic.ts +14 -14
  410. package/src/staking/operations/index.test.ts +48 -39
  411. package/src/staking/operations/index.ts +31 -28
  412. package/src/staking/prepareIntents.test.ts +14 -34
  413. package/src/staking/prepareIntents.ts +10 -13
  414. package/src/staking/redelegations.test.ts +73 -131
  415. package/src/staking/redelegations.ts +12 -26
  416. package/src/staking/rewards.test.ts +19 -21
  417. package/src/staking/rewards.ts +1 -2
  418. package/src/staking/rewardsFromReceipt.test.ts +9 -8
  419. package/src/staking/rewardsFromReceipt.ts +3 -2
  420. package/src/staking/transactionData.test.ts +35 -25
  421. package/src/staking/transactionData.ts +7 -6
  422. package/src/staking/unbondings.test.ts +26 -20
  423. package/src/staking/unbondings.ts +1 -2
  424. package/src/staking/validators/index.ts +45 -51
  425. package/src/staking/validators/monad.test.ts +52 -54
  426. package/src/staking/validators/monad.ts +31 -37
  427. package/src/staking/validators/monadResolver.ts +2 -4
  428. package/src/staking/validators/sei.ts +2 -2
  429. package/src/staking/validators/somnia.test.ts +22 -19
  430. package/src/staking/validators/somnia.ts +20 -27
  431. package/src/staking/validators/types.ts +0 -1
  432. package/src/staking/validators/zero_gravity.test.ts +34 -49
  433. package/src/staking/validators/zero_gravity.ts +5 -11
  434. package/src/staking/validators.integ.test.ts +3 -5
  435. package/src/staking/validators.test.ts +56 -53
  436. package/src/types/staking.ts +3 -6
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmContext } from '../../config'
4
+ import type { ChainId, EvmContext } from '../../config'
5
5
  import type {
6
6
  BlockByHeightResult,
7
7
  BlockReceiptInfo,
@@ -13,7 +13,7 @@ import type {
13
13
  } from '../../network/node/types'
14
14
  import type { EtherscanInternalTransaction } from '../../types'
15
15
  import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
16
- import { internalTxSourcesFromList } from '../../config'
16
+ import { CHAIN_ID, internalTxSourcesFromList } from '../../config'
17
17
  import { UnsupportedRpcMethodError } from '../../errors'
18
18
  import {
19
19
  createMockEvmConfigInfo,
@@ -30,9 +30,6 @@ import { mockNodeApi } from '../../network/node/node.fixtures'
30
30
  import { getBlock } from '../getBlock'
31
31
  import { dropRootTraceDuplicates } from '../rootTraceDedup'
32
32
 
33
- // fixme refactor this test
34
- // use builder function to build the mocked return values
35
-
36
33
  jest.mock('../../network/node')
37
34
  jest.mock('../../network/explorer/etherscan', () => ({
38
35
  getInternalTransactionsByBlock: jest.fn().mockResolvedValue([]),
@@ -43,6 +40,10 @@ describe('getBlock', () => {
43
40
  jest.clearAllMocks()
44
41
  })
45
42
 
43
+ function mockGetBlockNodeApi(nodeApi: ReturnType<typeof mockNodeApi>): void {
44
+ jest.mocked(getNodeApi).mockReturnValue(nodeApi)
45
+ }
46
+
46
47
  const address1 = '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d'
47
48
  const address2 = '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619'
48
49
  const erc20Address = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
@@ -148,13 +149,12 @@ describe('getBlock', () => {
148
149
  })
149
150
  )
150
151
 
151
- const mockGetNodeApi = jest.mocked(getNodeApi)
152
152
  const mockGetBlockByHeight = jest
153
153
  .fn()
154
154
  .mockResolvedValueOnce(makeNodeBlock({ transactions: [] }))
155
155
  const mockTraceBlockErigon = jest.fn()
156
156
 
157
- mockGetNodeApi.mockReturnValue(
157
+ mockGetBlockNodeApi(
158
158
  mockNodeApi({
159
159
  getBlockByHeight: mockGetBlockByHeight,
160
160
  getBlockReceipts: jest.fn(),
@@ -179,12 +179,11 @@ describe('getBlock', () => {
179
179
  })
180
180
  )
181
181
 
182
- const mockGetNodeApi = jest.mocked(getNodeApi)
183
182
  const mockGetBlockByHeight = jest
184
183
  .fn()
185
184
  .mockResolvedValueOnce(makeNodeBlock({ transactions: [makeNodeBlockTx({ hash: '0xtx1' })] }))
186
185
 
187
- mockGetNodeApi.mockReturnValue(
186
+ mockGetBlockNodeApi(
188
187
  mockNodeApi({
189
188
  getBlockByHeight: mockGetBlockByHeight,
190
189
  getBlockReceipts: jest.fn().mockResolvedValue([makeNodeBlockReceipt({ hash: '0xtx1' })]),
@@ -205,7 +204,6 @@ describe('getBlock', () => {
205
204
  createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
206
205
  )
207
206
 
208
- const mockGetNodeApi = jest.mocked(getNodeApi)
209
207
  const mockGetBlockByHeight = jest.fn()
210
208
  mockGetBlockByHeight.mockResolvedValueOnce(
211
209
  makeNodeBlock({
@@ -226,7 +224,7 @@ describe('getBlock', () => {
226
224
  }),
227
225
  ])
228
226
 
229
- mockGetNodeApi.mockReturnValue(
227
+ mockGetBlockNodeApi(
230
228
  mockNodeApi({
231
229
  getBlockByHeight: mockGetBlockByHeight,
232
230
  getBlockReceipts: mockGetBlockReceipts,
@@ -297,8 +295,8 @@ describe('getBlock', () => {
297
295
  )
298
296
 
299
297
  const calldata = '0xa9059cbb00000000'
300
- const mockGetNodeApi = jest.mocked(getNodeApi)
301
- mockGetNodeApi.mockReturnValue(
298
+
299
+ mockGetBlockNodeApi(
302
300
  mockNodeApi({
303
301
  getBlockByHeight: jest.fn().mockResolvedValueOnce(
304
302
  makeNodeBlock({
@@ -338,8 +336,8 @@ describe('getBlock', () => {
338
336
  )
339
337
 
340
338
  const initCode = '0x6001600055'
341
- const mockGetNodeApi = jest.mocked(getNodeApi)
342
- mockGetNodeApi.mockReturnValue(
339
+
340
+ mockGetBlockNodeApi(
343
341
  mockNodeApi({
344
342
  getBlockByHeight: jest.fn().mockResolvedValueOnce(
345
343
  makeNodeBlock({
@@ -382,8 +380,7 @@ describe('getBlock', () => {
382
380
  createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
383
381
  )
384
382
 
385
- const mockGetNodeApi = jest.mocked(getNodeApi)
386
- mockGetNodeApi.mockReturnValue(
383
+ mockGetBlockNodeApi(
387
384
  mockNodeApi({
388
385
  getBlockByHeight: jest.fn().mockResolvedValueOnce(
389
386
  makeNodeBlock({
@@ -416,7 +413,7 @@ describe('getBlock', () => {
416
413
  )
417
414
 
418
415
  const calldata = '0xdeadbeef'
419
- const mockGetNodeApi = jest.mocked(getNodeApi)
416
+
420
417
  const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
421
418
  makeNodeBlock({
422
419
  transactions: [makeNodeBlockTx({ hash: '0xtx1' })],
@@ -437,7 +434,7 @@ describe('getBlock', () => {
437
434
  })
438
435
  )
439
436
 
440
- mockGetNodeApi.mockReturnValue(
437
+ mockGetBlockNodeApi(
441
438
  mockNodeApi({
442
439
  getBlockByHeight: mockGetBlockByHeight,
443
440
  getBlockReceipts: mockGetBlockReceipts,
@@ -462,7 +459,6 @@ describe('getBlock', () => {
462
459
  createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
463
460
  )
464
461
 
465
- const mockGetNodeApi = jest.mocked(getNodeApi)
466
462
  const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
467
463
  makeNodeBlock({
468
464
  hash: '0xabc123',
@@ -479,7 +475,7 @@ describe('getBlock', () => {
479
475
  .fn()
480
476
  .mockResolvedValueOnce(makeNodeTxInfo({ hash: '0xtx1', value: '1000' }))
481
477
 
482
- mockGetNodeApi.mockReturnValue(
478
+ mockGetBlockNodeApi(
483
479
  mockNodeApi({
484
480
  getBlockByHeight: mockGetBlockByHeight,
485
481
  getBlockReceipts: mockGetBlockReceipts,
@@ -499,8 +495,8 @@ describe('getBlock', () => {
499
495
  }),
500
496
  ]),
501
497
  })
502
- expect(mockGetBlockReceipts).toHaveBeenCalledWith(expect.anything(), 12345)
503
- expect(mockGetTransaction).toHaveBeenCalledWith(expect.anything(), '0xtx1')
498
+ expect(mockGetBlockReceipts).toHaveBeenCalledWith(12345)
499
+ expect(mockGetTransaction).toHaveBeenCalledWith('0xtx1')
504
500
  })
505
501
 
506
502
  it('falls back to per-transaction calls when prefetchTxs is not supported', async () => {
@@ -508,14 +504,13 @@ describe('getBlock', () => {
508
504
  createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
509
505
  )
510
506
 
511
- const mockGetNodeApi = jest.mocked(getNodeApi)
512
507
  const mockGetBlockByHeight = jest
513
508
  .fn()
514
509
  .mockResolvedValueOnce(makeNodeBlock({ hash: '0xabc123', transactionHashes: ['0xtx1'] }))
515
510
  const mockGetBlockReceipts = jest.fn()
516
511
  const mockGetTransaction = jest.fn().mockResolvedValueOnce(makeNodeTxInfo({ hash: '0xtx1' }))
517
512
 
518
- mockGetNodeApi.mockReturnValue(
513
+ mockGetBlockNodeApi(
519
514
  mockNodeApi({
520
515
  getBlockByHeight: mockGetBlockByHeight,
521
516
  getBlockReceipts: mockGetBlockReceipts,
@@ -535,9 +530,9 @@ describe('getBlock', () => {
535
530
  }),
536
531
  ]),
537
532
  })
538
- expect(mockGetBlockByHeight).toHaveBeenCalledWith(expect.anything(), 12345, true)
533
+ expect(mockGetBlockByHeight).toHaveBeenCalledWith(12345, true)
539
534
  expect(mockGetBlockReceipts).not.toHaveBeenCalled()
540
- expect(mockGetTransaction).toHaveBeenCalledWith(expect.anything(), '0xtx1')
535
+ expect(mockGetTransaction).toHaveBeenCalledWith('0xtx1')
541
536
  })
542
537
 
543
538
  it('does not fallback when getBlockReceipts fails for another reason', async () => {
@@ -545,7 +540,6 @@ describe('getBlock', () => {
545
540
  createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
546
541
  )
547
542
 
548
- const mockGetNodeApi = jest.mocked(getNodeApi)
549
543
  const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
550
544
  makeNodeBlock({
551
545
  height: 12345,
@@ -556,7 +550,7 @@ describe('getBlock', () => {
556
550
  const mockGetBlockReceipts = jest.fn().mockRejectedValueOnce(serverError)
557
551
  const mockGetTransaction = jest.fn()
558
552
 
559
- mockGetNodeApi.mockReturnValue(
553
+ mockGetBlockNodeApi(
560
554
  mockNodeApi({
561
555
  getBlockByHeight: mockGetBlockByHeight,
562
556
  getBlockReceipts: mockGetBlockReceipts,
@@ -599,7 +593,6 @@ describe('getBlock', () => {
599
593
  })
600
594
  )
601
595
 
602
- const mockGetNodeApi = jest.mocked(getNodeApi)
603
596
  const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
604
597
  makeNodeBlock({
605
598
  transactions: [makeNodeBlockTx({ hash: '0xtx1', value: '0' })],
@@ -609,7 +602,7 @@ describe('getBlock', () => {
609
602
  .fn()
610
603
  .mockResolvedValue([makeNodeBlockReceipt({ hash: '0xtx1', erc20Transfers: [] })])
611
604
 
612
- mockGetNodeApi.mockReturnValue(
605
+ mockGetBlockNodeApi(
613
606
  mockNodeApi({
614
607
  getBlockByHeight: mockGetBlockByHeight,
615
608
  getBlockReceipts: mockGetBlockReceipts,
@@ -674,8 +667,8 @@ describe('getBlock', () => {
674
667
  )
675
668
 
676
669
  const amount = 200000000000000000n
677
- const mockGetNodeApi = jest.mocked(getNodeApi)
678
- mockGetNodeApi.mockReturnValue(
670
+
671
+ mockGetBlockNodeApi(
679
672
  mockNodeApi({
680
673
  getBlockByHeight: jest.fn().mockResolvedValueOnce(
681
674
  makeNodeBlock({
@@ -725,8 +718,8 @@ describe('getBlock', () => {
725
718
  const coinAmount = 200000000000000000n
726
719
  const nestedAmount = 200000000000000000n
727
720
  const nestedRecipient = '0x330E16622F947CBBfA15aB2fdf83014EAa27eCd1'
728
- const mockGetNodeApi = jest.mocked(getNodeApi)
729
- mockGetNodeApi.mockReturnValue(
721
+
722
+ mockGetBlockNodeApi(
730
723
  mockNodeApi({
731
724
  getBlockByHeight: jest.fn().mockResolvedValueOnce(
732
725
  makeNodeBlock({
@@ -793,8 +786,8 @@ describe('getBlock', () => {
793
786
  action: makeNodeTraceAction({ from: address1, to: address2, value: amount.toString() }),
794
787
  }),
795
788
  ])
796
- const mockGetNodeApi = jest.mocked(getNodeApi)
797
- mockGetNodeApi.mockReturnValue(
789
+
790
+ mockGetBlockNodeApi(
798
791
  mockNodeApi({
799
792
  getBlockByHeight: jest.fn().mockResolvedValue(
800
793
  makeNodeBlock({
@@ -813,7 +806,7 @@ describe('getBlock', () => {
813
806
  const result = await getBlock(context, '', 12345)
814
807
 
815
808
  expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
816
- expect(mockTraceBlock).toHaveBeenCalledWith(expect.anything(), 12345)
809
+ expect(mockTraceBlock).toHaveBeenCalledWith(12345)
817
810
 
818
811
  const encodedFrom = safeEncodeEIP55(address1, testLogger)
819
812
  const encodedTo = safeEncodeEIP55(address2, testLogger)
@@ -855,8 +848,8 @@ describe('getBlock', () => {
855
848
  }
856
849
  )
857
850
  const mockTraceBlock = jest.fn().mockRejectedValue(error)
858
- const mockGetNodeApi = jest.mocked(getNodeApi)
859
- mockGetNodeApi.mockReturnValue(
851
+
852
+ mockGetBlockNodeApi(
860
853
  mockNodeApi({
861
854
  getBlockByHeight: jest.fn().mockResolvedValue(
862
855
  makeNodeBlock({
@@ -874,7 +867,7 @@ describe('getBlock', () => {
874
867
  await expect(getBlock(context, '', 12345)).rejects.toThrow(error)
875
868
 
876
869
  expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
877
- expect(mockTraceBlock).toHaveBeenCalledWith(expect.anything(), 12345)
870
+ expect(mockTraceBlock).toHaveBeenCalledWith(12345)
878
871
  })
879
872
 
880
873
  it('when explorer.getInternalTransactionsByBlock fails and node trace methods are undefined, returns block with no internal transactions', async () => {
@@ -886,8 +879,7 @@ describe('getBlock', () => {
886
879
  })
887
880
  )
888
881
 
889
- const mockGetNodeApi = jest.mocked(getNodeApi)
890
- mockGetNodeApi.mockReturnValue(
882
+ mockGetBlockNodeApi(
891
883
  mockNodeApi({
892
884
  getBlockByHeight: jest.fn().mockResolvedValue(
893
885
  makeNodeBlock({
@@ -934,8 +926,8 @@ describe('getBlock', () => {
934
926
  })
935
927
 
936
928
  const mockTraceBlock = jest.fn().mockResolvedValue([traceBlockItem])
937
- const mockGetNodeApi = jest.mocked(getNodeApi)
938
- mockGetNodeApi.mockReturnValue(
929
+
930
+ mockGetBlockNodeApi(
939
931
  mockNodeApi({
940
932
  getBlockByHeight: jest.fn().mockResolvedValue(
941
933
  makeNodeBlock({
@@ -955,7 +947,7 @@ describe('getBlock', () => {
955
947
 
956
948
  const result = await getBlock(context, '', 12345)
957
949
 
958
- expect(mockTraceBlock).toHaveBeenCalledWith(expect.anything(), 12345)
950
+ expect(mockTraceBlock).toHaveBeenCalledWith(12345)
959
951
  const encodedFrom = safeEncodeEIP55(address1, testLogger)
960
952
  const encodedTo = safeEncodeEIP55(address2, testLogger)
961
953
  expect(result).toMatchObject({
@@ -1004,8 +996,8 @@ describe('getBlock', () => {
1004
996
  }
1005
997
  )
1006
998
  const mockTraceBlock = jest.fn().mockRejectedValue(error)
1007
- const mockGetNodeApi = jest.mocked(getNodeApi)
1008
- mockGetNodeApi.mockReturnValue(
999
+
1000
+ mockGetBlockNodeApi(
1009
1001
  mockNodeApi({
1010
1002
  getBlockByHeight: jest.fn().mockResolvedValue(
1011
1003
  makeNodeBlock({
@@ -1026,7 +1018,7 @@ describe('getBlock', () => {
1026
1018
  await expect(getBlock(context, '', 12345)).rejects.toThrow(error)
1027
1019
 
1028
1020
  expect(mockGetInternalTransactionsByBlock).toHaveBeenCalledWith(expect.anything(), 12345)
1029
- expect(mockTraceBlock).toHaveBeenCalledWith(expect.anything(), 12345)
1021
+ expect(mockTraceBlock).toHaveBeenCalledWith(12345)
1030
1022
  })
1031
1023
 
1032
1024
  it('with default source list, propagates trace errors when explorer and both trace methods fail at runtime', async () => {
@@ -1048,8 +1040,8 @@ describe('getBlock', () => {
1048
1040
  )
1049
1041
  const mockTraceBlockErigon = jest.fn().mockRejectedValue(erigonError)
1050
1042
  const mockTraceBlockGeth = jest.fn().mockRejectedValue(gethError)
1051
- const mockGetNodeApi = jest.mocked(getNodeApi)
1052
- mockGetNodeApi.mockReturnValue(
1043
+
1044
+ mockGetBlockNodeApi(
1053
1045
  mockNodeApi({
1054
1046
  getBlockByHeight: jest.fn().mockResolvedValue(
1055
1047
  makeNodeBlock({
@@ -1071,8 +1063,8 @@ describe('getBlock', () => {
1071
1063
  await expect(getBlock(context, '', 12345)).rejects.toMatchObject({
1072
1064
  errors: [erigonError, gethError],
1073
1065
  })
1074
- expect(mockTraceBlockErigon).toHaveBeenCalledWith(expect.anything(), 12345)
1075
- expect(mockTraceBlockGeth).toHaveBeenCalledWith(expect.anything(), 12345)
1066
+ expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
1067
+ expect(mockTraceBlockGeth).toHaveBeenCalledWith(12345)
1076
1068
  })
1077
1069
 
1078
1070
  it('with default source list, falls back from traceBlockErigon to traceBlockGeth when explorer fails', async () => {
@@ -1091,8 +1083,8 @@ describe('getBlock', () => {
1091
1083
  action: makeNodeTraceAction({ from: address1, to: address2, value: amount.toString() }),
1092
1084
  }),
1093
1085
  ])
1094
- const mockGetNodeApi = jest.mocked(getNodeApi)
1095
- mockGetNodeApi.mockReturnValue(
1086
+
1087
+ mockGetBlockNodeApi(
1096
1088
  mockNodeApi({
1097
1089
  getBlockByHeight: jest.fn().mockResolvedValue(
1098
1090
  makeNodeBlock({
@@ -1112,8 +1104,8 @@ describe('getBlock', () => {
1112
1104
 
1113
1105
  const result = await getBlock(context, '', 12345)
1114
1106
 
1115
- expect(mockTraceBlockErigon).toHaveBeenCalledWith(expect.anything(), 12345)
1116
- expect(mockTraceBlockGeth).toHaveBeenCalledWith(expect.anything(), 12345)
1107
+ expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
1108
+ expect(mockTraceBlockGeth).toHaveBeenCalledWith(12345)
1117
1109
  const encodedFrom = safeEncodeEIP55(address1, testLogger)
1118
1110
  const encodedTo = safeEncodeEIP55(address2, testLogger)
1119
1111
  expect(result.transactions[0].operations).toEqual(
@@ -1150,8 +1142,8 @@ describe('getBlock', () => {
1150
1142
  { method: 'trace_block', rawError: { code: -32601 } }
1151
1143
  )
1152
1144
  const mockTraceBlockErigon = jest.fn().mockRejectedValue(erigonError)
1153
- const mockGetNodeApi = jest.mocked(getNodeApi)
1154
- mockGetNodeApi.mockReturnValue(
1145
+
1146
+ mockGetBlockNodeApi(
1155
1147
  mockNodeApi({
1156
1148
  getBlockByHeight: jest.fn().mockResolvedValue(
1157
1149
  makeNodeBlock({
@@ -1170,7 +1162,7 @@ describe('getBlock', () => {
1170
1162
  mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
1171
1163
 
1172
1164
  await expect(getBlock(context, '', 12345)).rejects.toThrow(erigonError)
1173
- expect(mockTraceBlockErigon).toHaveBeenCalledWith(expect.anything(), 12345)
1165
+ expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
1174
1166
  })
1175
1167
 
1176
1168
  it('uses prefetched tx gasPrice as fallback when Cronos receipt omits effectiveGasPrice and gasPrice', async () => {
@@ -1179,8 +1171,8 @@ describe('getBlock', () => {
1179
1171
  )
1180
1172
  const gasUsed = 21000n
1181
1173
  const txGasPrice = '568125000000'
1182
- const mockGetNodeApi = jest.mocked(getNodeApi)
1183
- mockGetNodeApi.mockReturnValue(
1174
+
1175
+ mockGetBlockNodeApi(
1184
1176
  mockNodeApi({
1185
1177
  getBlockByHeight: jest.fn().mockResolvedValueOnce(
1186
1178
  makeNodeBlock({
@@ -1209,8 +1201,8 @@ describe('getBlock', () => {
1209
1201
  const gasUsed = 21000n
1210
1202
  const receiptEffectiveGasPrice = '1000000000' // 1 Gwei — resolved from effectiveGasPrice by getBlockReceipts
1211
1203
  const txGasPrice = '568125000000' // higher value in the prefetched tx — must NOT win
1212
- const mockGetNodeApi = jest.mocked(getNodeApi)
1213
- mockGetNodeApi.mockReturnValue(
1204
+
1205
+ mockGetBlockNodeApi(
1214
1206
  mockNodeApi({
1215
1207
  getBlockByHeight: jest.fn().mockResolvedValueOnce(
1216
1208
  makeNodeBlock({
@@ -1239,8 +1231,8 @@ describe('getBlock', () => {
1239
1231
  const gasUsed = 21000n
1240
1232
  const gasPrice = '1000000000'
1241
1233
  const l1Fee = '95394812830580'
1242
- const mockGetNodeApi = jest.mocked(getNodeApi)
1243
- mockGetNodeApi.mockReturnValue(
1234
+
1235
+ mockGetBlockNodeApi(
1244
1236
  mockNodeApi({
1245
1237
  getBlockByHeight: jest.fn().mockResolvedValueOnce(
1246
1238
  makeNodeBlock({
@@ -1270,8 +1262,8 @@ describe('getBlock', () => {
1270
1262
  const gasUsed = '21000'
1271
1263
  const gasPrice = '1000000000'
1272
1264
  const l1Fee = '95394812830580'
1273
- const mockGetNodeApi = jest.mocked(getNodeApi)
1274
- mockGetNodeApi.mockReturnValue(
1265
+
1266
+ mockGetBlockNodeApi(
1275
1267
  mockNodeApi({
1276
1268
  getBlockByHeight: jest
1277
1269
  .fn()
@@ -1293,13 +1285,14 @@ describe('getBlock', () => {
1293
1285
 
1294
1286
  function buildZksyncMocks(
1295
1287
  txOverrides: Partial<PrefetchedBlockTransaction>,
1296
- receiptOverrides: Partial<BlockReceiptInfo>
1288
+ receiptOverrides: Partial<BlockReceiptInfo>,
1289
+ chainId: ChainId = CHAIN_ID.ZKSYNC
1297
1290
  ): EvmContext {
1298
1291
  const context = createMockEvmContext(
1299
- createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
1292
+ createMockEvmConfigInfo({ chainId, node: mkExternalNode() })
1300
1293
  )
1301
- const mockGetNodeApi = jest.mocked(getNodeApi)
1302
- mockGetNodeApi.mockReturnValue(
1294
+
1295
+ mockGetBlockNodeApi(
1303
1296
  mockNodeApi({
1304
1297
  getBlockByHeight: jest
1305
1298
  .fn()
@@ -1561,7 +1554,7 @@ describe('getBlock', () => {
1561
1554
  ])
1562
1555
  })
1563
1556
 
1564
- it('does not apply zkSync corrections to other currencies (e.g. ethereum) even when receipt type is 0xff', async () => {
1557
+ it('does not apply zkSync corrections to other chains (e.g. ethereum) even when the currency id is zksync and receipt type is 0xff', async () => {
1565
1558
  const context = buildZksyncMocks(
1566
1559
  { from: USER, to: USER, value: '270000000000000000' },
1567
1560
  {
@@ -1574,9 +1567,10 @@ describe('getBlock', () => {
1574
1567
  value: '270000000000000000',
1575
1568
  },
1576
1569
  ],
1577
- }
1570
+ },
1571
+ CHAIN_ID.ETHEREUM
1578
1572
  )
1579
- const result = await getBlock(context, 'ethereum', 12345)
1573
+ const result = await getBlock(context, 'zksync', 12345)
1580
1574
  expect(result.transactions[0].operations).toEqual([
1581
1575
  {
1582
1576
  type: 'transfer',
@@ -20,7 +20,7 @@ describe('getBlockInfo', () => {
20
20
 
21
21
  beforeEach(() => {
22
22
  jest.clearAllMocks()
23
- mockGetNodeApi.mockImplementation((config: EvmConfigInfo, _currencyId: string) => {
23
+ mockGetNodeApi.mockImplementation((config: EvmConfigInfo) => {
24
24
  return config?.node?.type === 'ledger' ? ledgerMocks : externalMocks
25
25
  })
26
26
  })
@@ -20,7 +20,7 @@ describe('getNextSequence', () => {
20
20
 
21
21
  beforeEach(() => {
22
22
  jest.clearAllMocks()
23
- mockGetNodeApi.mockImplementation((config: EvmConfigInfo, _currencyId: string) => {
23
+ mockGetNodeApi.mockImplementation((config: EvmConfigInfo) => {
24
24
  return config?.node?.type === 'ledger' ? ledgerMocks : externalMocks
25
25
  })
26
26
  })
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { CHAIN_ID } from '../../config'
4
5
  import { createMockEvmContext } from '../../fixtures/context.fixtures'
5
6
  import { mkJsonRpcProvider, mkResult } from '../../fixtures/ethers.fixtures'
6
7
  import { withApi } from '../../network/node/rpc.common'
@@ -35,10 +36,21 @@ const mockFetchUnbondings = jest.mocked(fetchUnbondings)
35
36
 
36
37
  const externalNodeConfig = { type: 'external' as const, uri: 'https://test' }
37
38
  const context = createMockEvmContext({
39
+ chainId: CHAIN_ID.CELO,
38
40
  node: externalNodeConfig,
39
41
  name: 'Celo',
40
42
  unit: { name: 'CELO', code: 'CELO', magnitude: 18 },
41
43
  })
44
+ const seiContext = createMockEvmContext({
45
+ chainId: CHAIN_ID.SEI_EVM,
46
+ node: externalNodeConfig,
47
+ name: 'Sei',
48
+ unit: { name: 'SEI', code: 'SEI', magnitude: 18 },
49
+ })
50
+ const ethereumContext = createMockEvmContext({
51
+ chainId: CHAIN_ID.ETHEREUM,
52
+ node: externalNodeConfig,
53
+ })
42
54
  const makeValidator = (validatorAddress: string) => ({
43
55
  id: validatorAddress,
44
56
  address: validatorAddress,
@@ -55,7 +67,7 @@ describe('EVM Staking - getStakes', () => {
55
67
  })
56
68
 
57
69
  it('should return stake objects with positive amounts for supported currencies', async () => {
58
- mockWithApi.mockImplementation(async (_cur, _currencyId, fn) => {
70
+ mockWithApi.mockImplementation(async (_cur, fn) => {
59
71
  const api = mkJsonRpcProvider()
60
72
  jest.spyOn(api, 'call').mockResolvedValue('0x')
61
73
  return fn(api)
@@ -88,7 +100,7 @@ describe('EVM Staking - getStakes', () => {
88
100
  })
89
101
 
90
102
  it('should filter out stakes with zero amounts', async () => {
91
- mockWithApi.mockImplementation(async (_cur, _currencyId, fn) => {
103
+ mockWithApi.mockImplementation(async (_cur, fn) => {
92
104
  const api = mkJsonRpcProvider()
93
105
  jest.spyOn(api, 'call').mockResolvedValue('0x')
94
106
  return fn(api)
@@ -109,7 +121,7 @@ describe('EVM Staking - getStakes', () => {
109
121
  next: undefined,
110
122
  })
111
123
 
112
- mockWithApi.mockImplementation(async (_cur, _currencyId, fn) => {
124
+ mockWithApi.mockImplementation(async (_cur, fn) => {
113
125
  const api = mkJsonRpcProvider()
114
126
  jest.spyOn(api, 'call').mockResolvedValue('0x')
115
127
  return fn(api)
@@ -130,7 +142,7 @@ describe('EVM Staking - getStakes', () => {
130
142
  })
131
143
  )
132
144
 
133
- const result = await getStakes(context, 'sei_evm', address)
145
+ const result = await getStakes(seiContext, 'sei_evm', address)
134
146
 
135
147
  expect(result).toEqual({
136
148
  items: [
@@ -149,7 +161,7 @@ describe('EVM Staking - getStakes', () => {
149
161
  })
150
162
 
151
163
  it('should return empty list for currencies not configured for staking', async () => {
152
- const result = await getStakes(context, 'ethereum', address)
164
+ const result = await getStakes(ethereumContext, 'ethereum', address)
153
165
 
154
166
  expect(result).toEqual({
155
167
  items: [],
@@ -157,7 +169,7 @@ describe('EVM Staking - getStakes', () => {
157
169
  })
158
170
 
159
171
  it('should handle RPC call failures gracefully without crashing', async () => {
160
- mockWithApi.mockImplementation(async (_cur, _currencyId, fn) => {
172
+ mockWithApi.mockImplementation(async (_cur, fn) => {
161
173
  const api = mkJsonRpcProvider()
162
174
  jest.spyOn(api, 'call').mockRejectedValue(new Error('rpc error'))
163
175
  return fn(api)
@@ -176,7 +188,7 @@ describe('EVM Staking - getStakes', () => {
176
188
  items: [makeValidator('seivaloper1abc')],
177
189
  next: undefined,
178
190
  })
179
- mockWithApi.mockImplementation(async (_cur, _currencyId, fn) => {
191
+ mockWithApi.mockImplementation(async (_cur, fn) => {
180
192
  const api = mkJsonRpcProvider()
181
193
  jest.spyOn(api, 'call').mockRejectedValue(
182
194
  Object.assign(new Error('missing revert data'), {
@@ -191,7 +203,7 @@ describe('EVM Staking - getStakes', () => {
191
203
  })
192
204
  mockEncodeStakingData.mockReturnValue('0xdeadbeef')
193
205
 
194
- const result = await getStakes(context, 'sei_evm', address)
206
+ const result = await getStakes(seiContext, 'sei_evm', address)
195
207
 
196
208
  expect(result).toEqual({
197
209
  items: [],
@@ -202,7 +214,7 @@ describe('EVM Staking - getStakes', () => {
202
214
  it('should handle SEI when no validators are available', async () => {
203
215
  mockGetValidators.mockResolvedValue({ items: [], next: undefined })
204
216
 
205
- const result = await getStakes(context, 'sei_evm', address)
217
+ const result = await getStakes(seiContext, 'sei_evm', address)
206
218
 
207
219
  expect(result).toEqual({
208
220
  items: [],
@@ -212,7 +224,7 @@ describe('EVM Staking - getStakes', () => {
212
224
  it('should survive network failures during validator fetching', async () => {
213
225
  mockGetValidators.mockRejectedValue(new Error('Network unreachable'))
214
226
 
215
- const result = await getStakes(context, 'sei_evm', address)
227
+ const result = await getStakes(seiContext, 'sei_evm', address)
216
228
 
217
229
  expect(result).toEqual({
218
230
  items: [],
@@ -220,7 +232,7 @@ describe('EVM Staking - getStakes', () => {
220
232
  })
221
233
 
222
234
  it('should handle completely unsupported currencies', async () => {
223
- const result = await getStakes(context, 'unsupported_currency', address)
235
+ const result = await getStakes(ethereumContext, 'unsupported_currency', address)
224
236
 
225
237
  expect(result).toEqual({
226
238
  items: [],
@@ -260,7 +272,7 @@ describe('EVM Staking - getStakes', () => {
260
272
  items: [makeValidator('seivaloper1abc')],
261
273
  next: undefined,
262
274
  })
263
- mockWithApi.mockImplementation(async (_cur, _currencyId, fn) => {
275
+ mockWithApi.mockImplementation(async (_cur, fn) => {
264
276
  const api = mkJsonRpcProvider()
265
277
  jest.spyOn(api, 'call').mockResolvedValue('0x')
266
278
  return fn(api)
@@ -278,7 +290,7 @@ describe('EVM Staking - getStakes', () => {
278
290
  mockOneDelegation()
279
291
  mockFetchUnbondings.mockResolvedValue([unbondingStake])
280
292
 
281
- const result = await getStakes(context, 'sei_evm', address)
293
+ const result = await getStakes(seiContext, 'sei_evm', address)
282
294
 
283
295
  expect(result.items.map((i) => i.state)).toEqual(['active', 'deactivating'])
284
296
  })
@@ -287,7 +299,7 @@ describe('EVM Staking - getStakes', () => {
287
299
  mockGetValidators.mockResolvedValue({ items: [], next: undefined })
288
300
  mockFetchUnbondings.mockResolvedValue([unbondingStake])
289
301
 
290
- const result = await getStakes(context, 'sei_evm', address)
302
+ const result = await getStakes(seiContext, 'sei_evm', address)
291
303
 
292
304
  expect(result.items).toEqual([unbondingStake])
293
305
  })
@@ -296,13 +308,13 @@ describe('EVM Staking - getStakes', () => {
296
308
  mockOneDelegation()
297
309
  mockFetchUnbondings.mockRejectedValue(new Error('REST down'))
298
310
 
299
- const result = await getStakes(context, 'sei_evm', address)
311
+ const result = await getStakes(seiContext, 'sei_evm', address)
300
312
 
301
313
  expect(result.items.map((i) => i.state)).toEqual(['active'])
302
314
  })
303
315
 
304
316
  it('should not be attempted for a chain without an unbonding strategy', async () => {
305
- mockWithApi.mockImplementation(async (_cur, _currencyId, fn) => {
317
+ mockWithApi.mockImplementation(async (_cur, fn) => {
306
318
  const api = mkJsonRpcProvider()
307
319
  jest.spyOn(api, 'call').mockResolvedValue('0x')
308
320
  return fn(api)