@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 { EvmConfigInfo } from '../../config'
4
+ import type { ChainId, EvmConfigInfo } from '../../config'
5
5
  import type { StakingContractConfig } from '../../types/staking'
6
6
  import type { ValidatorApi } from './types'
7
7
  import type { Cursor, Page } from '@ledgerhq/coin-module-framework/api/index'
@@ -63,11 +63,11 @@ function responseStatus(error: unknown): number | undefined {
63
63
  }
64
64
 
65
65
  const fetchValidatorName = async (
66
- currencyId: string,
66
+ chainId: ChainId,
67
67
  secp: string,
68
68
  logger: Logger
69
69
  ): Promise<string | null> => {
70
- const baseUrl = STAKING_CONTRACTS[currencyId]?.validatorNameSource?.baseUrl
70
+ const baseUrl = STAKING_CONTRACTS[chainId]?.validatorNameSource?.baseUrl
71
71
  if (!baseUrl) return null
72
72
 
73
73
  try {
@@ -81,7 +81,7 @@ const fetchValidatorName = async (
81
81
  if (status === 404) return null
82
82
  // Anything else is transient: log and rethrow so the cache doesn't pin a miss.
83
83
  logger('coin-evm/staking', 'fetchValidatorName: validator-info lookup failed', {
84
- currencyId,
84
+ chainId,
85
85
  secp,
86
86
  error: error instanceof Error ? error.message : String(error),
87
87
  })
@@ -89,11 +89,11 @@ const fetchValidatorName = async (
89
89
  }
90
90
  }
91
91
 
92
- // Concurrent calls for the same (currencyId, secp) share one in-flight request.
92
+ // Concurrent calls for the same (chainId, secp) share one in-flight request.
93
93
  const validatorNameCache = makeLRUCache(
94
94
  fetchValidatorName,
95
95
  // logger is a side-channel arg, excluded from the cache key.
96
- (currencyId: string, secp: string, _logger: Logger) => `${currencyId}-${secp}`,
96
+ (chainId: ChainId, secp: string, _logger: Logger) => `${chainId}-${secp}`,
97
97
  { max: 1000, ttl: NAME_CACHE_MAX_AGE_MS }
98
98
  )
99
99
 
@@ -137,14 +137,11 @@ type ResolvedContext = {
137
137
  contractAddress: string
138
138
  }
139
139
 
140
- const resolveContext = (
141
- evmConfig: EvmConfigInfo,
142
- currencyId: string
143
- ): ResolvedContext | undefined => {
144
- const config = STAKING_CONTRACTS[currencyId]
140
+ const resolveContext = (evmConfig: EvmConfigInfo): ResolvedContext | undefined => {
141
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
145
142
  if (!config) return undefined
146
143
 
147
- const abi = getStakingABI(currencyId)
144
+ const abi = getStakingABI(evmConfig.chainId)
148
145
  if (!abi) return undefined
149
146
 
150
147
  const node = evmConfig.node
@@ -162,7 +159,7 @@ const resolveContext = (
162
159
  }
163
160
 
164
161
  const fetchValidatorDetails = async (
165
- currencyId: string,
162
+ chainId: ChainId,
166
163
  provider: JsonRpcProvider,
167
164
  iface: ethers.Interface,
168
165
  contractAddress: string,
@@ -181,9 +178,7 @@ const fetchValidatorDetails = async (
181
178
  const [, , stake, , commission, , , , , , secpPubkey] = decoded
182
179
  const secp = secpPubkey.toLowerCase().replace(/^0x/, '')
183
180
  const name =
184
- secp.length > 0
185
- ? await validatorNameCache(currencyId, secp, logger).catch(() => null)
186
- : null
181
+ secp.length > 0 ? await validatorNameCache(chainId, secp, logger).catch(() => null) : null
187
182
 
188
183
  return {
189
184
  id: valId.toString(),
@@ -215,7 +210,7 @@ const fetchValidatorDetails = async (
215
210
  }
216
211
 
217
212
  const fetchPage = async (
218
- currencyId: string,
213
+ chainId: ChainId,
219
214
  provider: JsonRpcProvider,
220
215
  iface: ethers.Interface,
221
216
  contractAddress: string,
@@ -232,7 +227,7 @@ const fetchPage = async (
232
227
  const items =
233
228
  pageIds.length === 0
234
229
  ? []
235
- : await fetchValidatorDetails(currencyId, provider, iface, contractAddress, pageIds, logger)
230
+ : await fetchValidatorDetails(chainId, provider, iface, contractAddress, pageIds, logger)
236
231
 
237
232
  const exhausted = isDone || pageIds.length === 0 || nextIndex <= startIndex
238
233
  return { items, next: exhausted ? undefined : nextIndex.toString() }
@@ -240,11 +235,10 @@ const fetchPage = async (
240
235
 
241
236
  const fetchValidators = async (
242
237
  evmConfig: EvmConfigInfo,
243
- currencyId: string,
244
238
  logger: Logger,
245
239
  cursor?: Cursor
246
240
  ): Promise<Page<Validator>> => {
247
- const ctx = resolveContext(evmConfig, currencyId)
241
+ const ctx = resolveContext(evmConfig)
248
242
  if (!ctx) return { items: [], next: undefined }
249
243
 
250
244
  try {
@@ -252,17 +246,23 @@ const fetchValidators = async (
252
246
 
253
247
  return await withApi(
254
248
  evmConfig,
255
- currencyId,
256
249
  async (provider) => {
257
250
  const iface = new ethers.Interface(ctx.abi)
258
- return fetchPage(currencyId, provider, iface, ctx.contractAddress, startIndex, logger)
251
+ return fetchPage(
252
+ evmConfig.chainId,
253
+ provider,
254
+ iface,
255
+ ctx.contractAddress,
256
+ startIndex,
257
+ logger
258
+ )
259
259
  },
260
260
  ctx.node
261
261
  )
262
262
  } catch (error) {
263
263
  logger('coin-evm/staking', 'fetchValidators: Monad validators page fetch failed', {
264
264
  error: error instanceof Error ? error.message : String(error),
265
- currencyId,
265
+ currency: evmConfig.name,
266
266
  cursor,
267
267
  })
268
268
  return { items: [], next: undefined }
@@ -298,7 +298,6 @@ const fetchDelegatedValIds = async (
298
298
 
299
299
  const fetchStakeForValId = async (
300
300
  evmConfig: EvmConfigInfo,
301
- currencyId: string,
302
301
  provider: JsonRpcProvider,
303
302
  iface: ethers.Interface,
304
303
  contractAddress: string,
@@ -343,7 +342,7 @@ const fetchStakeForValId = async (
343
342
  const secp = secpPubkey.toLowerCase().replace(/^0x/, '')
344
343
  if (secp.length > 0) {
345
344
  validatorName =
346
- (await validatorNameCache(currencyId, secp, logger).catch(() => null)) ?? undefined
345
+ (await validatorNameCache(evmConfig.chainId, secp, logger).catch(() => null)) ?? undefined
347
346
  }
348
347
  }
349
348
 
@@ -397,7 +396,7 @@ const fetchStakeForValId = async (
397
396
  }
398
397
 
399
398
  export const extractMonadKnownValIds = (
400
- currencyId: string,
399
+ chainId: ChainId,
401
400
  ops: Array<Operation<MemoNotSupported>>,
402
401
  logger: Logger
403
402
  ): string[] => {
@@ -407,7 +406,7 @@ export const extractMonadKnownValIds = (
407
406
  WITHDRAW_UNBONDED: 'withdraw',
408
407
  }
409
408
 
410
- const abi = getStakingABI(currencyId)
409
+ const abi = getStakingABI(chainId)
411
410
  if (!abi) return []
412
411
 
413
412
  const iface = new ethers.Interface(toInterfaceAbi(abi))
@@ -436,17 +435,15 @@ export const fetchMonadStakes = async (
436
435
  evmConfig: EvmConfigInfo,
437
436
  address: string,
438
437
  _config: StakingContractConfig,
439
- currencyId: string,
440
438
  logger: Logger,
441
439
  knownValIds?: string[]
442
440
  ): Promise<Stake[]> => {
443
- const ctx = resolveContext(evmConfig, currencyId)
441
+ const ctx = resolveContext(evmConfig)
444
442
  if (!ctx) return []
445
443
 
446
444
  try {
447
445
  return await withApi(
448
446
  evmConfig,
449
- currencyId,
450
447
  async (provider) => {
451
448
  const iface = new ethers.Interface(ctx.abi)
452
449
  const fromDelegations = await fetchDelegatedValIds(
@@ -471,7 +468,6 @@ export const fetchMonadStakes = async (
471
468
  chunk.map((valId) =>
472
469
  fetchStakeForValId(
473
470
  evmConfig,
474
- currencyId,
475
471
  provider,
476
472
  iface,
477
473
  ctx.contractAddress,
@@ -501,7 +497,7 @@ export const fetchMonadStakes = async (
501
497
  )
502
498
  } catch (error) {
503
499
  logger('coin-evm/staking', 'fetchMonadStakes: delegations fetch failed', {
504
- currencyId,
500
+ currency: evmConfig.name,
505
501
  error: error instanceof Error ? error.message : String(error),
506
502
  })
507
503
  return []
@@ -588,18 +584,16 @@ const fetchWithdrawalRequests = async (
588
584
 
589
585
  export const findFirstFreeWithdrawId = async (
590
586
  evmConfig: EvmConfigInfo,
591
- currencyId: string,
592
587
  valId: bigint,
593
588
  delegator: string,
594
589
  logger: Logger
595
590
  ): Promise<number | null> => {
596
- const ctx = resolveContext(evmConfig, currencyId)
591
+ const ctx = resolveContext(evmConfig)
597
592
  if (!ctx) return null
598
593
 
599
594
  try {
600
595
  return await withApi(
601
596
  evmConfig,
602
- currencyId,
603
597
  async (provider) => {
604
598
  const iface = new ethers.Interface(ctx.abi)
605
599
 
@@ -627,7 +621,7 @@ export const findFirstFreeWithdrawId = async (
627
621
  'coin-evm/staking',
628
622
  'findFirstFreeWithdrawId: getWithdrawalRequest call failed',
629
623
  {
630
- currencyId,
624
+ currency: evmConfig.name,
631
625
  valId: valId.toString(),
632
626
  withdrawId: ids[i],
633
627
  error: res.reason instanceof Error ? res.reason.message : String(res.reason),
@@ -645,7 +639,7 @@ export const findFirstFreeWithdrawId = async (
645
639
  )
646
640
  } catch (error) {
647
641
  logger('coin-evm/staking', 'findFirstFreeWithdrawId: lookup failed', {
648
- currencyId,
642
+ currency: evmConfig.name,
649
643
  valId: valId.toString(),
650
644
  error: error instanceof Error ? error.message : String(error),
651
645
  })
@@ -54,11 +54,10 @@ export const callGetValidator = async (
54
54
 
55
55
  export const getValidatorAddressById = async (
56
56
  config: EvmConfigInfo,
57
- currencyId: string,
58
57
  valId: bigint,
59
58
  logger: Logger
60
59
  ): Promise<string | null> => {
61
- const abi = getStakingABI(currencyId)
60
+ const abi = getStakingABI(config.chainId)
62
61
  if (!abi) return null
63
62
 
64
63
  const node = config.node
@@ -67,7 +66,6 @@ export const getValidatorAddressById = async (
67
66
  try {
68
67
  return await withApi(
69
68
  config,
70
- currencyId,
71
69
  async (provider) => {
72
70
  const iface = new ethers.Interface(toInterfaceAbi(abi))
73
71
  const decoded = await callGetValidator(provider, iface, MONAD_PRECOMPILE, valId)
@@ -79,7 +77,7 @@ export const getValidatorAddressById = async (
79
77
  )
80
78
  } catch (error) {
81
79
  logger('coin-evm/staking', 'getValidatorAddressById: getValidator call failed', {
82
- currencyId,
80
+ currency: config.name,
83
81
  valId: valId.toString(),
84
82
  error: error instanceof Error ? error.message : String(error),
85
83
  })
@@ -30,8 +30,8 @@ type CosmosValidatorsResponse = { validators: CosmosValidator[] }
30
30
  // Sei's REST endpoint returns the whole validator set in one response, so it
31
31
  // ignores the cursor and always reports `next: undefined` (single page).
32
32
  const seiValidatorApi: ValidatorApi = {
33
- fetchValidators: async (_config, currencyId): Promise<Page<Validator>> => {
34
- const apiConfig = STAKING_CONTRACTS[currencyId]?.apiConfig
33
+ fetchValidators: async (config): Promise<Page<Validator>> => {
34
+ const apiConfig = STAKING_CONTRACTS[config.chainId]?.apiConfig
35
35
  if (!apiConfig?.baseUrl) return { items: [], next: undefined }
36
36
 
37
37
  const { baseUrl, validatorsEndpoint } = apiConfig
@@ -7,14 +7,15 @@ import type { TransactionRequest } from 'ethers'
7
7
  import network from '@ledgerhq/live-network'
8
8
  import { ethers } from 'ethers'
9
9
  import somniaAbi from '../../abis/somnia.abi.json'
10
+ import { CHAIN_ID } from '../../config'
10
11
  import {
11
12
  createMockEvmConfigInfo,
12
13
  mkExternalNode,
13
14
  mkLedgerNode,
14
15
  testLogger,
15
16
  } from '../../fixtures/context.fixtures'
17
+ import { requireStakingContract } from '../../fixtures/staking.fixtures'
16
18
  import { withApi } from '../../network/node/rpc.common'
17
- import { STAKING_CONTRACTS } from '../contracts'
18
19
  import { clearValidatorNamesCache, fetchSomniaStakes, fetchValidatorNames } from './somnia'
19
20
  import { clearValidatorsCache, getValidators } from './index'
20
21
 
@@ -25,12 +26,14 @@ const mockedWithApi = jest.mocked(withApi)
25
26
  const mockedNetwork = jest.mocked<DeepPartialReturn<typeof network>>(network)
26
27
 
27
28
  const mockConfig = createMockEvmConfigInfo({
28
- chainId: 5031,
29
+ chainId: CHAIN_ID.SOMNIA,
29
30
  node: mkExternalNode({ uri: 'https://somnia-rpc.publicnode.com' }),
30
31
  name: 'Somnia',
31
32
  unit: { name: 'SOMI', code: 'SOMI', magnitude: 18 },
32
33
  })
33
- const ledgerConfig = createMockEvmConfigInfo({ chainId: 5031, node: mkLedgerNode() })
34
+ const ledgerConfig = createMockEvmConfigInfo({ chainId: CHAIN_ID.SOMNIA, node: mkLedgerNode() })
35
+
36
+ const somniaContract = requireStakingContract(CHAIN_ID.SOMNIA)
34
37
 
35
38
  const somniaIface = new ethers.Interface(somniaAbi)
36
39
  const CONTRACT = '0xBe367d410D96E1cAeF68C0632251072CDf1b8250'
@@ -42,7 +45,7 @@ type CallHandler = (request: TransactionRequest) => Promise<string>
42
45
 
43
46
  const setupRpc = (handler: CallHandler) => {
44
47
  const callMock = jest.fn(handler)
45
- mockedWithApi.mockImplementation(async (_config, _currencyId, fn) =>
48
+ mockedWithApi.mockImplementation(async (_config, fn) =>
46
49
  fn(Object.assign(Object.create(null), { call: callMock }))
47
50
  )
48
51
  return callMock
@@ -120,8 +123,8 @@ const routeByName = (responses: {
120
123
  describe('staking/validators/somnia', () => {
121
124
  beforeEach(() => {
122
125
  jest.clearAllMocks()
123
- clearValidatorsCache('somnia')
124
- clearValidatorNamesCache('somnia')
126
+ clearValidatorsCache(CHAIN_ID.SOMNIA)
127
+ clearValidatorNamesCache(CHAIN_ID.SOMNIA)
125
128
  })
126
129
 
127
130
  describe('fetchValidators', () => {
@@ -139,7 +142,7 @@ describe('staking/validators/somnia', () => {
139
142
  })
140
143
  )
141
144
 
142
- const page = await getValidators(mockConfig, 'somnia', testLogger)
145
+ const page = await getValidators(mockConfig, testLogger)
143
146
 
144
147
  expect(page.next).toBeUndefined()
145
148
  expect(page.items).toHaveLength(2)
@@ -172,7 +175,7 @@ describe('staking/validators/somnia', () => {
172
175
  })
173
176
  )
174
177
 
175
- const page = await getValidators(mockConfig, 'somnia', testLogger)
178
+ const page = await getValidators(mockConfig, testLogger)
176
179
 
177
180
  expect(page.items).toHaveLength(1)
178
181
  expect(page.items[0].address).toBe(VALIDATOR_B)
@@ -185,14 +188,14 @@ describe('staking/validators/somnia', () => {
185
188
  })
186
189
  )
187
190
 
188
- const page = await getValidators(mockConfig, 'somnia', testLogger)
191
+ const page = await getValidators(mockConfig, testLogger)
189
192
 
190
193
  expect(page.items).toStrictEqual([])
191
194
  expect(page.next).toBeUndefined()
192
195
  })
193
196
 
194
197
  it('returns empty when the node config is not external', async () => {
195
- const page = await getValidators(ledgerConfig, 'somnia', testLogger)
198
+ const page = await getValidators(ledgerConfig, testLogger)
196
199
 
197
200
  expect(page.items).toStrictEqual([])
198
201
  expect(mockedWithApi).not.toHaveBeenCalled()
@@ -201,7 +204,7 @@ describe('staking/validators/somnia', () => {
201
204
  it('returns empty on getCommitteeValidators failure', async () => {
202
205
  setupRpc(routeByName({ getCommitteeValidators: () => new Error('network error') }))
203
206
 
204
- const page = await getValidators(mockConfig, 'somnia', testLogger)
207
+ const page = await getValidators(mockConfig, testLogger)
205
208
 
206
209
  expect(page.items).toStrictEqual([])
207
210
  })
@@ -216,7 +219,7 @@ describe('staking/validators/somnia', () => {
216
219
  [VALIDATOR_B.toLowerCase()]: 'Kiln',
217
220
  })
218
221
 
219
- const names = await fetchValidatorNames('somnia', testLogger)
222
+ const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
220
223
 
221
224
  expect(names).toStrictEqual({
222
225
  [VALIDATOR_A.toLowerCase()]: 'BitGo',
@@ -231,7 +234,7 @@ describe('staking/validators/somnia', () => {
231
234
  '0x1234': 'Too short',
232
235
  })
233
236
 
234
- const names = await fetchValidatorNames('somnia', testLogger)
237
+ const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
235
238
 
236
239
  expect(names).toStrictEqual({ [VALIDATOR_A.toLowerCase()]: 'Everstake' })
237
240
  })
@@ -245,7 +248,7 @@ describe('staking/validators/somnia', () => {
245
248
  '0x4444444444444444444444444444444444444444': null,
246
249
  })
247
250
 
248
- const names = await fetchValidatorNames('somnia', testLogger)
251
+ const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
249
252
 
250
253
  expect(names).toStrictEqual({ [VALIDATOR_A.toLowerCase()]: 'Everstake' })
251
254
  })
@@ -257,7 +260,7 @@ describe('staking/validators/somnia', () => {
257
260
  error: { code: -32600, message: 'invalid request' },
258
261
  })
259
262
 
260
- const names = await fetchValidatorNames('somnia', testLogger)
263
+ const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
261
264
 
262
265
  expect(names).toStrictEqual({})
263
266
  })
@@ -265,7 +268,7 @@ describe('staking/validators/somnia', () => {
265
268
  it('returns {} when the payload is an array', async () => {
266
269
  mockNamesResponse([{ addr: VALIDATOR_A, name: 'BitGo' }])
267
270
 
268
- const names = await fetchValidatorNames('somnia', testLogger)
271
+ const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
269
272
 
270
273
  expect(names).toStrictEqual({})
271
274
  })
@@ -273,7 +276,7 @@ describe('staking/validators/somnia', () => {
273
276
  it('returns {} when the payload is null', async () => {
274
277
  mockNamesResponse(null)
275
278
 
276
- const names = await fetchValidatorNames('somnia', testLogger)
279
+ const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
277
280
 
278
281
  expect(names).toStrictEqual({})
279
282
  })
@@ -281,13 +284,13 @@ describe('staking/validators/somnia', () => {
281
284
  it('rethrows on network error so makeLRUCache evicts (callers stay best-effort)', async () => {
282
285
  mockedNetwork.mockRejectedValue(new Error('network down'))
283
286
 
284
- await expect(fetchValidatorNames('somnia', testLogger)).rejects.toThrow('network down')
287
+ await expect(fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)).rejects.toThrow('network down')
285
288
  })
286
289
  })
287
290
 
288
291
  describe('fetchSomniaStakes', () => {
289
292
  const fetchStakes = (config: EvmConfigInfo = mockConfig) =>
290
- fetchSomniaStakes(config, DELEGATOR, STAKING_CONTRACTS['somnia'], 'somnia', testLogger)
293
+ fetchSomniaStakes(config, DELEGATOR, somniaContract, testLogger)
291
294
 
292
295
  const defaultStakeHandlers = (
293
296
  overrides: {
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../../config'
4
+ import type { ChainId, EvmConfigInfo } from '../../config'
5
5
  import type { StakingContractConfig } from '../../types/staking'
6
6
  import type { ValidatorApi } from './types'
7
7
  import type { Cursor, Page } from '@ledgerhq/coin-module-framework/api/index'
@@ -65,14 +65,11 @@ type ResolvedContext = {
65
65
  contractAddress: string
66
66
  }
67
67
 
68
- const resolveContext = (
69
- evmConfig: EvmConfigInfo,
70
- currencyId: string
71
- ): ResolvedContext | undefined => {
72
- const config = STAKING_CONTRACTS[currencyId]
68
+ const resolveContext = (evmConfig: EvmConfigInfo): ResolvedContext | undefined => {
69
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
73
70
  if (!config) return undefined
74
71
 
75
- const abi = getStakingABI(currencyId)
72
+ const abi = getStakingABI(evmConfig.chainId)
76
73
  if (!abi) return undefined
77
74
 
78
75
  const node = evmConfig.node
@@ -95,10 +92,10 @@ const resolveContext = (
95
92
  * Callers should treat it as best-effort and fall back to the on-chain address as the display name.
96
93
  */
97
94
  export const fetchValidatorNames = async (
98
- currencyId: string,
95
+ chainId: ChainId,
99
96
  logger: Logger
100
97
  ): Promise<ValidatorNamesMap> => {
101
- const baseUrl = STAKING_CONTRACTS[currencyId]?.validatorNameSource?.baseUrl
98
+ const baseUrl = STAKING_CONTRACTS[chainId]?.validatorNameSource?.baseUrl
102
99
  if (!baseUrl) return {}
103
100
 
104
101
  try {
@@ -116,7 +113,7 @@ export const fetchValidatorNames = async (
116
113
  return out
117
114
  } catch (error) {
118
115
  logger('coin-evm/staking', 'fetchValidatorNames: validator-names lookup failed', {
119
- currencyId,
116
+ chainId,
120
117
  error: error instanceof Error ? error.message : String(error),
121
118
  })
122
119
  throw error
@@ -126,27 +123,27 @@ export const fetchValidatorNames = async (
126
123
  const validatorNamesCache = makeLRUCache(
127
124
  fetchValidatorNames,
128
125
  // logger is a side-channel arg, excluded from the cache key.
129
- (currencyId: string, _logger: Logger) => currencyId,
126
+ (chainId: ChainId, _logger: Logger) => String(chainId),
130
127
  {
131
128
  max: 10,
132
129
  ttl: NAME_CACHE_MAX_AGE_MS,
133
130
  }
134
131
  )
135
132
 
136
- // Drop the cached validator-names overlay for a currency (primarily to keep tests deterministic,
137
- // since the cache is module-level and keyed only by currencyId).
138
- export const clearValidatorNamesCache = (currencyId: string): void =>
139
- validatorNamesCache.clear(currencyId)
133
+ // Drop the cached validator-names overlay for a chain (primarily to keep tests deterministic,
134
+ // since the cache is module-level and keyed only by chainId).
135
+ export const clearValidatorNamesCache = (chainId: ChainId): void =>
136
+ validatorNamesCache.clear(String(chainId))
140
137
 
141
138
  const fetchValidatorDetails = async (
142
- currencyId: string,
139
+ chainId: ChainId,
143
140
  provider: JsonRpcProvider,
144
141
  iface: ethers.Interface,
145
142
  contractAddress: string,
146
143
  addresses: string[],
147
144
  logger: Logger
148
145
  ): Promise<Validator[]> => {
149
- const names = await validatorNamesCache(currencyId, logger).catch((): ValidatorNamesMap => ({}))
146
+ const names = await validatorNamesCache(chainId, logger).catch((): ValidatorNamesMap => ({}))
150
147
 
151
148
  const items: Validator[] = []
152
149
 
@@ -195,17 +192,15 @@ const fetchValidatorDetails = async (
195
192
 
196
193
  const fetchValidators = async (
197
194
  evmConfig: EvmConfigInfo,
198
- currencyId: string,
199
195
  logger: Logger,
200
196
  _cursor?: Cursor
201
197
  ): Promise<Page<Validator>> => {
202
- const ctx = resolveContext(evmConfig, currencyId)
198
+ const ctx = resolveContext(evmConfig)
203
199
  if (!ctx) return { items: [], next: undefined }
204
200
 
205
201
  try {
206
202
  return await withApi(
207
203
  evmConfig,
208
- currencyId,
209
204
  async (provider) => {
210
205
  const iface = new ethers.Interface(ctx.abi)
211
206
  const data = iface.encodeFunctionData('getCommitteeValidators', [])
@@ -218,7 +213,7 @@ const fetchValidators = async (
218
213
  if (addresses.length === 0) return { items: [], next: undefined }
219
214
 
220
215
  const items = await fetchValidatorDetails(
221
- currencyId,
216
+ evmConfig.chainId,
222
217
  provider,
223
218
  iface,
224
219
  ctx.contractAddress,
@@ -231,7 +226,7 @@ const fetchValidators = async (
231
226
  )
232
227
  } catch (error) {
233
228
  logger('coin-evm/staking', 'fetchSomniaValidators: fetch failed', {
234
- currencyId,
229
+ currency: evmConfig.name,
235
230
  error: error instanceof Error ? error.message : String(error),
236
231
  })
237
232
  return { items: [], next: undefined }
@@ -300,17 +295,15 @@ export const fetchSomniaStakes = async (
300
295
  evmConfig: EvmConfigInfo,
301
296
  address: string,
302
297
  _config: StakingContractConfig,
303
- currencyId: string,
304
298
  logger: Logger,
305
299
  _knownValIds?: string[]
306
300
  ): Promise<Stake[]> => {
307
- const ctx = resolveContext(evmConfig, currencyId)
301
+ const ctx = resolveContext(evmConfig)
308
302
  if (!ctx) return []
309
303
 
310
304
  try {
311
305
  return await withApi(
312
306
  evmConfig,
313
- currencyId,
314
307
  async (provider) => {
315
308
  const iface = new ethers.Interface(ctx.abi)
316
309
 
@@ -327,7 +320,7 @@ export const fetchSomniaStakes = async (
327
320
 
328
321
  // Display-name overlay, keyed by lowercased operator address. Best-effort: on failure
329
322
  // the delegation still shows, falling back to the raw address as its name.
330
- const names = await validatorNamesCache(currencyId, logger).catch(
323
+ const names = await validatorNamesCache(evmConfig.chainId, logger).catch(
331
324
  (): ValidatorNamesMap => ({})
332
325
  )
333
326
 
@@ -387,7 +380,7 @@ export const fetchSomniaStakes = async (
387
380
  )
388
381
  } catch (error) {
389
382
  logger('coin-evm/staking', 'fetchSomniaStakes: delegations fetch failed', {
390
- currencyId,
383
+ currency: evmConfig.name,
391
384
  error: error instanceof Error ? error.message : String(error),
392
385
  })
393
386
  return []
@@ -9,7 +9,6 @@ import type { Logger } from '@ledgerhq/coin-module-framework/config'
9
9
  export type ValidatorApi = {
10
10
  fetchValidators: (
11
11
  config: EvmConfigInfo,
12
- currencyId: string,
13
12
  logger: Logger,
14
13
  cursor?: Cursor
15
14
  ) => Promise<Page<Validator>>