@ledgerhq/coin-evm 10.1.0 → 15.2.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 (463) hide show
  1. package/CHANGELOG.md +58 -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 +16 -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 +4 -2
  11. package/lib/adapters/ledger.js.map +1 -1
  12. package/lib/api/index.d.ts.map +1 -1
  13. package/lib/api/index.js +1 -2
  14. package/lib/api/index.js.map +1 -1
  15. package/lib/chains.d.ts +95 -0
  16. package/lib/chains.d.ts.map +1 -0
  17. package/lib/chains.js +99 -0
  18. package/lib/chains.js.map +1 -0
  19. package/lib/config.d.ts +4 -1
  20. package/lib/config.d.ts.map +1 -1
  21. package/lib/config.js +3 -1
  22. package/lib/config.js.map +1 -1
  23. package/lib/logic/broadcast.js +2 -2
  24. package/lib/logic/broadcast.js.map +1 -1
  25. package/lib/logic/common.d.ts +1 -1
  26. package/lib/logic/common.d.ts.map +1 -1
  27. package/lib/logic/common.js +11 -11
  28. package/lib/logic/common.js.map +1 -1
  29. package/lib/logic/craftTransaction.d.ts.map +1 -1
  30. package/lib/logic/craftTransaction.js +3 -3
  31. package/lib/logic/craftTransaction.js.map +1 -1
  32. package/lib/logic/estimateFees.d.ts.map +1 -1
  33. package/lib/logic/estimateFees.js +7 -7
  34. package/lib/logic/estimateFees.js.map +1 -1
  35. package/lib/logic/getBalance.d.ts.map +1 -1
  36. package/lib/logic/getBalance.js +9 -9
  37. package/lib/logic/getBalance.js.map +1 -1
  38. package/lib/logic/getBlock.d.ts.map +1 -1
  39. package/lib/logic/getBlock.js +38 -21
  40. package/lib/logic/getBlock.js.map +1 -1
  41. package/lib/logic/getBlockInfo.js +2 -2
  42. package/lib/logic/getBlockInfo.js.map +1 -1
  43. package/lib/logic/getNextSequence.d.ts.map +1 -1
  44. package/lib/logic/getNextSequence.js +1 -1
  45. package/lib/logic/getNextSequence.js.map +1 -1
  46. package/lib/logic/getStakes.d.ts.map +1 -1
  47. package/lib/logic/getStakes.js +10 -10
  48. package/lib/logic/getStakes.js.map +1 -1
  49. package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
  50. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  51. package/lib/logic/internalTransactionsFetcher.js +8 -8
  52. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  53. package/lib/logic/lastBlock.js +2 -2
  54. package/lib/logic/lastBlock.js.map +1 -1
  55. package/lib/logic/listOperations.d.ts.map +1 -1
  56. package/lib/logic/listOperations.js +3 -1
  57. package/lib/logic/listOperations.js.map +1 -1
  58. package/lib/logic/validateIntent.d.ts.map +1 -1
  59. package/lib/logic/validateIntent.js +9 -9
  60. package/lib/logic/validateIntent.js.map +1 -1
  61. package/lib/logic.d.ts +1 -1
  62. package/lib/logic.d.ts.map +1 -1
  63. package/lib/logic.js +14 -13
  64. package/lib/logic.js.map +1 -1
  65. package/lib/network/explorer/etherscan.d.ts +2 -3
  66. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  67. package/lib/network/explorer/etherscan.js +6 -8
  68. package/lib/network/explorer/etherscan.js.map +1 -1
  69. package/lib/network/explorer/ledger.d.ts.map +1 -1
  70. package/lib/network/explorer/ledger.js +5 -5
  71. package/lib/network/explorer/ledger.js.map +1 -1
  72. package/lib/network/explorer/types.d.ts +2 -2
  73. package/lib/network/explorer/types.d.ts.map +1 -1
  74. package/lib/network/explorer/types.js.map +1 -1
  75. package/lib/network/node/explorerProxy.d.ts.map +1 -1
  76. package/lib/network/node/explorerProxy.js +14 -12
  77. package/lib/network/node/explorerProxy.js.map +1 -1
  78. package/lib/network/node/index.d.ts +1 -1
  79. package/lib/network/node/index.d.ts.map +1 -1
  80. package/lib/network/node/index.js +7 -7
  81. package/lib/network/node/index.js.map +1 -1
  82. package/lib/network/node/ledger.d.ts +3 -1
  83. package/lib/network/node/ledger.d.ts.map +1 -1
  84. package/lib/network/node/ledger.js +32 -22
  85. package/lib/network/node/ledger.js.map +1 -1
  86. package/lib/network/node/rpc.common.d.ts +1 -1
  87. package/lib/network/node/rpc.common.d.ts.map +1 -1
  88. package/lib/network/node/rpc.common.js +67 -39
  89. package/lib/network/node/rpc.common.js.map +1 -1
  90. package/lib/network/node/types.d.ts +18 -16
  91. package/lib/network/node/types.d.ts.map +1 -1
  92. package/lib/network/node/types.js.map +1 -1
  93. package/lib/network/node/withNodeSources.d.ts.map +1 -1
  94. package/lib/network/node/withNodeSources.js +15 -15
  95. package/lib/network/node/withNodeSources.js.map +1 -1
  96. package/lib/staking/abis.d.ts +3 -2
  97. package/lib/staking/abis.d.ts.map +1 -1
  98. package/lib/staking/abis.js +10 -9
  99. package/lib/staking/abis.js.map +1 -1
  100. package/lib/staking/contracts.d.ts +3 -2
  101. package/lib/staking/contracts.d.ts.map +1 -1
  102. package/lib/staking/contracts.js +11 -10
  103. package/lib/staking/contracts.js.map +1 -1
  104. package/lib/staking/detectOperationType.d.ts +2 -1
  105. package/lib/staking/detectOperationType.d.ts.map +1 -1
  106. package/lib/staking/detectOperationType.js +7 -7
  107. package/lib/staking/detectOperationType.js.map +1 -1
  108. package/lib/staking/encoder.d.ts +2 -1
  109. package/lib/staking/encoder.d.ts.map +1 -1
  110. package/lib/staking/encoder.js +8 -8
  111. package/lib/staking/encoder.js.map +1 -1
  112. package/lib/staking/fetchers.d.ts +2 -1
  113. package/lib/staking/fetchers.d.ts.map +1 -1
  114. package/lib/staking/fetchers.js +27 -27
  115. package/lib/staking/fetchers.js.map +1 -1
  116. package/lib/staking/logic.d.ts +6 -6
  117. package/lib/staking/logic.d.ts.map +1 -1
  118. package/lib/staking/logic.js +14 -13
  119. package/lib/staking/logic.js.map +1 -1
  120. package/lib/staking/operations/index.d.ts +2 -1
  121. package/lib/staking/operations/index.d.ts.map +1 -1
  122. package/lib/staking/operations/index.js +30 -28
  123. package/lib/staking/operations/index.js.map +1 -1
  124. package/lib/staking/prepareIntents.d.ts +1 -1
  125. package/lib/staking/prepareIntents.d.ts.map +1 -1
  126. package/lib/staking/prepareIntents.js +11 -10
  127. package/lib/staking/prepareIntents.js.map +1 -1
  128. package/lib/staking/redelegations.d.ts +4 -4
  129. package/lib/staking/redelegations.d.ts.map +1 -1
  130. package/lib/staking/redelegations.js +18 -20
  131. package/lib/staking/redelegations.js.map +1 -1
  132. package/lib/staking/rewards.d.ts +1 -1
  133. package/lib/staking/rewards.d.ts.map +1 -1
  134. package/lib/staking/rewards.js +2 -2
  135. package/lib/staking/rewards.js.map +1 -1
  136. package/lib/staking/rewardsFromReceipt.d.ts +2 -1
  137. package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
  138. package/lib/staking/rewardsFromReceipt.js +2 -2
  139. package/lib/staking/rewardsFromReceipt.js.map +1 -1
  140. package/lib/staking/transactionData.d.ts +2 -1
  141. package/lib/staking/transactionData.d.ts.map +1 -1
  142. package/lib/staking/transactionData.js +6 -6
  143. package/lib/staking/transactionData.js.map +1 -1
  144. package/lib/staking/unbondings.d.ts +1 -1
  145. package/lib/staking/unbondings.d.ts.map +1 -1
  146. package/lib/staking/unbondings.js +2 -2
  147. package/lib/staking/unbondings.js.map +1 -1
  148. package/lib/staking/validators/index.d.ts +14 -14
  149. package/lib/staking/validators/index.d.ts.map +1 -1
  150. package/lib/staking/validators/index.js +39 -38
  151. package/lib/staking/validators/index.js.map +1 -1
  152. package/lib/staking/validators/monad.d.ts +5 -5
  153. package/lib/staking/validators/monad.d.ts.map +1 -1
  154. package/lib/staking/validators/monad.js +31 -33
  155. package/lib/staking/validators/monad.js.map +1 -1
  156. package/lib/staking/validators/monadResolver.d.ts +1 -1
  157. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  158. package/lib/staking/validators/monadResolver.js +4 -4
  159. package/lib/staking/validators/monadResolver.js.map +1 -1
  160. package/lib/staking/validators/sei.js +2 -2
  161. package/lib/staking/validators/sei.js.map +1 -1
  162. package/lib/staking/validators/somnia.d.ts +4 -4
  163. package/lib/staking/validators/somnia.d.ts.map +1 -1
  164. package/lib/staking/validators/somnia.js +22 -22
  165. package/lib/staking/validators/somnia.js.map +1 -1
  166. package/lib/staking/validators/types.d.ts +1 -1
  167. package/lib/staking/validators/types.d.ts.map +1 -1
  168. package/lib/staking/validators/zero_gravity.d.ts +1 -1
  169. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  170. package/lib/staking/validators/zero_gravity.js +7 -7
  171. package/lib/staking/validators/zero_gravity.js.map +1 -1
  172. package/lib/types/staking.d.ts +5 -6
  173. package/lib/types/staking.d.ts.map +1 -1
  174. package/lib-es/adapters/etherscan.d.ts +2 -1
  175. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  176. package/lib-es/adapters/etherscan.js +16 -2
  177. package/lib-es/adapters/etherscan.js.map +1 -1
  178. package/lib-es/adapters/ledger.d.ts +2 -1
  179. package/lib-es/adapters/ledger.d.ts.map +1 -1
  180. package/lib-es/adapters/ledger.js +4 -2
  181. package/lib-es/adapters/ledger.js.map +1 -1
  182. package/lib-es/api/index.d.ts.map +1 -1
  183. package/lib-es/api/index.js +1 -2
  184. package/lib-es/api/index.js.map +1 -1
  185. package/lib-es/chains.d.ts +95 -0
  186. package/lib-es/chains.d.ts.map +1 -0
  187. package/lib-es/chains.js +96 -0
  188. package/lib-es/chains.js.map +1 -0
  189. package/lib-es/config.d.ts +4 -1
  190. package/lib-es/config.d.ts.map +1 -1
  191. package/lib-es/config.js +1 -0
  192. package/lib-es/config.js.map +1 -1
  193. package/lib-es/logic/broadcast.js +2 -2
  194. package/lib-es/logic/broadcast.js.map +1 -1
  195. package/lib-es/logic/common.d.ts +1 -1
  196. package/lib-es/logic/common.d.ts.map +1 -1
  197. package/lib-es/logic/common.js +11 -11
  198. package/lib-es/logic/common.js.map +1 -1
  199. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  200. package/lib-es/logic/craftTransaction.js +3 -3
  201. package/lib-es/logic/craftTransaction.js.map +1 -1
  202. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  203. package/lib-es/logic/estimateFees.js +7 -7
  204. package/lib-es/logic/estimateFees.js.map +1 -1
  205. package/lib-es/logic/getBalance.d.ts.map +1 -1
  206. package/lib-es/logic/getBalance.js +9 -9
  207. package/lib-es/logic/getBalance.js.map +1 -1
  208. package/lib-es/logic/getBlock.d.ts.map +1 -1
  209. package/lib-es/logic/getBlock.js +39 -22
  210. package/lib-es/logic/getBlock.js.map +1 -1
  211. package/lib-es/logic/getBlockInfo.js +2 -2
  212. package/lib-es/logic/getBlockInfo.js.map +1 -1
  213. package/lib-es/logic/getNextSequence.d.ts.map +1 -1
  214. package/lib-es/logic/getNextSequence.js +1 -1
  215. package/lib-es/logic/getNextSequence.js.map +1 -1
  216. package/lib-es/logic/getStakes.d.ts.map +1 -1
  217. package/lib-es/logic/getStakes.js +10 -10
  218. package/lib-es/logic/getStakes.js.map +1 -1
  219. package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
  220. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  221. package/lib-es/logic/internalTransactionsFetcher.js +8 -8
  222. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  223. package/lib-es/logic/lastBlock.js +2 -2
  224. package/lib-es/logic/lastBlock.js.map +1 -1
  225. package/lib-es/logic/listOperations.d.ts.map +1 -1
  226. package/lib-es/logic/listOperations.js +3 -1
  227. package/lib-es/logic/listOperations.js.map +1 -1
  228. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  229. package/lib-es/logic/validateIntent.js +9 -9
  230. package/lib-es/logic/validateIntent.js.map +1 -1
  231. package/lib-es/logic.d.ts +1 -1
  232. package/lib-es/logic.d.ts.map +1 -1
  233. package/lib-es/logic.js +14 -13
  234. package/lib-es/logic.js.map +1 -1
  235. package/lib-es/network/explorer/etherscan.d.ts +2 -3
  236. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  237. package/lib-es/network/explorer/etherscan.js +6 -8
  238. package/lib-es/network/explorer/etherscan.js.map +1 -1
  239. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  240. package/lib-es/network/explorer/ledger.js +5 -5
  241. package/lib-es/network/explorer/ledger.js.map +1 -1
  242. package/lib-es/network/explorer/types.d.ts +2 -2
  243. package/lib-es/network/explorer/types.d.ts.map +1 -1
  244. package/lib-es/network/explorer/types.js.map +1 -1
  245. package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
  246. package/lib-es/network/node/explorerProxy.js +14 -12
  247. package/lib-es/network/node/explorerProxy.js.map +1 -1
  248. package/lib-es/network/node/index.d.ts +1 -1
  249. package/lib-es/network/node/index.d.ts.map +1 -1
  250. package/lib-es/network/node/index.js +7 -7
  251. package/lib-es/network/node/index.js.map +1 -1
  252. package/lib-es/network/node/ledger.d.ts +3 -1
  253. package/lib-es/network/node/ledger.d.ts.map +1 -1
  254. package/lib-es/network/node/ledger.js +32 -22
  255. package/lib-es/network/node/ledger.js.map +1 -1
  256. package/lib-es/network/node/rpc.common.d.ts +1 -1
  257. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  258. package/lib-es/network/node/rpc.common.js +67 -39
  259. package/lib-es/network/node/rpc.common.js.map +1 -1
  260. package/lib-es/network/node/types.d.ts +18 -16
  261. package/lib-es/network/node/types.d.ts.map +1 -1
  262. package/lib-es/network/node/types.js.map +1 -1
  263. package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
  264. package/lib-es/network/node/withNodeSources.js +15 -15
  265. package/lib-es/network/node/withNodeSources.js.map +1 -1
  266. package/lib-es/staking/abis.d.ts +3 -2
  267. package/lib-es/staking/abis.d.ts.map +1 -1
  268. package/lib-es/staking/abis.js +10 -9
  269. package/lib-es/staking/abis.js.map +1 -1
  270. package/lib-es/staking/contracts.d.ts +3 -2
  271. package/lib-es/staking/contracts.d.ts.map +1 -1
  272. package/lib-es/staking/contracts.js +11 -10
  273. package/lib-es/staking/contracts.js.map +1 -1
  274. package/lib-es/staking/detectOperationType.d.ts +2 -1
  275. package/lib-es/staking/detectOperationType.d.ts.map +1 -1
  276. package/lib-es/staking/detectOperationType.js +7 -7
  277. package/lib-es/staking/detectOperationType.js.map +1 -1
  278. package/lib-es/staking/encoder.d.ts +2 -1
  279. package/lib-es/staking/encoder.d.ts.map +1 -1
  280. package/lib-es/staking/encoder.js +8 -8
  281. package/lib-es/staking/encoder.js.map +1 -1
  282. package/lib-es/staking/fetchers.d.ts +2 -1
  283. package/lib-es/staking/fetchers.d.ts.map +1 -1
  284. package/lib-es/staking/fetchers.js +27 -27
  285. package/lib-es/staking/fetchers.js.map +1 -1
  286. package/lib-es/staking/logic.d.ts +6 -6
  287. package/lib-es/staking/logic.d.ts.map +1 -1
  288. package/lib-es/staking/logic.js +14 -13
  289. package/lib-es/staking/logic.js.map +1 -1
  290. package/lib-es/staking/operations/index.d.ts +2 -1
  291. package/lib-es/staking/operations/index.d.ts.map +1 -1
  292. package/lib-es/staking/operations/index.js +30 -28
  293. package/lib-es/staking/operations/index.js.map +1 -1
  294. package/lib-es/staking/prepareIntents.d.ts +1 -1
  295. package/lib-es/staking/prepareIntents.d.ts.map +1 -1
  296. package/lib-es/staking/prepareIntents.js +11 -10
  297. package/lib-es/staking/prepareIntents.js.map +1 -1
  298. package/lib-es/staking/redelegations.d.ts +4 -4
  299. package/lib-es/staking/redelegations.d.ts.map +1 -1
  300. package/lib-es/staking/redelegations.js +18 -20
  301. package/lib-es/staking/redelegations.js.map +1 -1
  302. package/lib-es/staking/rewards.d.ts +1 -1
  303. package/lib-es/staking/rewards.d.ts.map +1 -1
  304. package/lib-es/staking/rewards.js +2 -2
  305. package/lib-es/staking/rewards.js.map +1 -1
  306. package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
  307. package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
  308. package/lib-es/staking/rewardsFromReceipt.js +2 -2
  309. package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
  310. package/lib-es/staking/transactionData.d.ts +2 -1
  311. package/lib-es/staking/transactionData.d.ts.map +1 -1
  312. package/lib-es/staking/transactionData.js +6 -6
  313. package/lib-es/staking/transactionData.js.map +1 -1
  314. package/lib-es/staking/unbondings.d.ts +1 -1
  315. package/lib-es/staking/unbondings.d.ts.map +1 -1
  316. package/lib-es/staking/unbondings.js +2 -2
  317. package/lib-es/staking/unbondings.js.map +1 -1
  318. package/lib-es/staking/validators/index.d.ts +14 -14
  319. package/lib-es/staking/validators/index.d.ts.map +1 -1
  320. package/lib-es/staking/validators/index.js +39 -38
  321. package/lib-es/staking/validators/index.js.map +1 -1
  322. package/lib-es/staking/validators/monad.d.ts +5 -5
  323. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  324. package/lib-es/staking/validators/monad.js +31 -33
  325. package/lib-es/staking/validators/monad.js.map +1 -1
  326. package/lib-es/staking/validators/monadResolver.d.ts +1 -1
  327. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  328. package/lib-es/staking/validators/monadResolver.js +4 -4
  329. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  330. package/lib-es/staking/validators/sei.js +2 -2
  331. package/lib-es/staking/validators/sei.js.map +1 -1
  332. package/lib-es/staking/validators/somnia.d.ts +4 -4
  333. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  334. package/lib-es/staking/validators/somnia.js +22 -22
  335. package/lib-es/staking/validators/somnia.js.map +1 -1
  336. package/lib-es/staking/validators/types.d.ts +1 -1
  337. package/lib-es/staking/validators/types.d.ts.map +1 -1
  338. package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
  339. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  340. package/lib-es/staking/validators/zero_gravity.js +7 -7
  341. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  342. package/lib-es/types/staking.d.ts +5 -6
  343. package/lib-es/types/staking.d.ts.map +1 -1
  344. package/package.json +2 -2
  345. package/src/adapters/etherscan.test.ts +91 -43
  346. package/src/adapters/etherscan.ts +18 -2
  347. package/src/adapters/ledger.test.ts +106 -31
  348. package/src/adapters/ledger.ts +5 -2
  349. package/src/api/index.ts +1 -2
  350. package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +5 -4
  351. package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +3 -3
  352. package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +3 -3
  353. package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +3 -3
  354. package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +3 -3
  355. package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +3 -3
  356. package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +3 -3
  357. package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +3 -3
  358. package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +6 -6
  359. package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +3 -3
  360. package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +3 -3
  361. package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +3 -3
  362. package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +3 -3
  363. package/src/api/{index.test.ts → tests/index.test.ts} +4 -4
  364. package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +2 -2
  365. package/src/chains.test.ts +12 -0
  366. package/src/chains.ts +98 -0
  367. package/src/config.ts +5 -1
  368. package/src/fixtures/staking.fixtures.ts +13 -0
  369. package/src/logic/broadcast.ts +2 -2
  370. package/src/logic/common.ts +10 -11
  371. package/src/logic/craftTransaction.ts +2 -3
  372. package/src/logic/estimateFees.ts +6 -23
  373. package/src/logic/getBalance.ts +7 -13
  374. package/src/logic/getBlock.ts +59 -23
  375. package/src/logic/getBlockInfo.ts +2 -2
  376. package/src/logic/getNextSequence.ts +1 -4
  377. package/src/logic/getStakes.ts +11 -12
  378. package/src/logic/internalTransactionsFetcher.ts +6 -8
  379. package/src/logic/lastBlock.ts +2 -2
  380. package/src/logic/listOperations.ts +2 -1
  381. package/src/logic/tests/broadcast.test.ts +5 -5
  382. package/src/logic/tests/broadcastSource.test.ts +1 -4
  383. package/src/logic/tests/common.test.ts +18 -34
  384. package/src/logic/tests/craftTransaction.test.ts +14 -7
  385. package/src/logic/tests/estimateFees.test.ts +17 -8
  386. package/src/logic/tests/getBalance.test.ts +18 -34
  387. package/src/logic/tests/getBlock.test.ts +195 -80
  388. package/src/logic/tests/getBlockInfo.test.ts +2 -2
  389. package/src/logic/tests/getNextSequence.test.ts +2 -2
  390. package/src/logic/tests/getStakes.test.ts +28 -16
  391. package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -6
  392. package/src/logic/tests/lastBlock.test.ts +4 -7
  393. package/src/logic/tests/listOperations.test.ts +8 -7
  394. package/src/logic/tests/validateIntent.test.ts +49 -3
  395. package/src/logic/validateIntent.ts +8 -10
  396. package/src/logic.test.ts +13 -5
  397. package/src/logic.ts +13 -13
  398. package/src/network/explorer/etherscan.ts +8 -24
  399. package/src/network/explorer/ledger.ts +2 -5
  400. package/src/network/explorer/types.ts +0 -2
  401. package/src/network/node/explorerProxy.ts +14 -12
  402. package/src/network/node/index.ts +11 -8
  403. package/src/network/node/ledger.ts +32 -34
  404. package/src/network/node/rpc.common.ts +79 -86
  405. package/src/network/node/types.ts +16 -31
  406. package/src/network/node/withNodeSources.ts +23 -26
  407. package/src/network/{explorer → tests/explorer}/etherscan.test.ts +16 -65
  408. package/src/network/{explorer → tests/explorer}/index.test.ts +8 -8
  409. package/src/network/{explorer → tests/explorer}/ledger.test.ts +34 -142
  410. package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
  411. package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
  412. package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
  413. package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
  414. package/src/network/{node → tests/node}/explorerProxy.test.ts +22 -24
  415. package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
  416. package/src/network/tests/node/index.memoization.test.ts +70 -0
  417. package/src/network/{node → tests/node}/index.test.ts +4 -6
  418. package/src/network/{node → tests/node}/ledger.test.ts +69 -74
  419. package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
  420. package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
  421. package/src/network/{node → tests/node}/rpc.test.ts +100 -119
  422. package/src/network/{node → tests/node}/types.test.ts +1 -1
  423. package/src/network/{node → tests/node}/withNodeSources.test.ts +10 -12
  424. package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
  425. package/src/staking/abis.test.ts +24 -28
  426. package/src/staking/abis.ts +12 -10
  427. package/src/staking/contracts.test.ts +20 -8
  428. package/src/staking/contracts.ts +12 -11
  429. package/src/staking/detectOperationType.test.ts +16 -13
  430. package/src/staking/detectOperationType.ts +9 -8
  431. package/src/staking/encoder.test.ts +38 -27
  432. package/src/staking/encoder.ts +9 -8
  433. package/src/staking/fetchers.ts +28 -39
  434. package/src/staking/logic.test.ts +34 -32
  435. package/src/staking/logic.ts +14 -14
  436. package/src/staking/operations/index.test.ts +48 -39
  437. package/src/staking/operations/index.ts +31 -28
  438. package/src/staking/prepareIntents.test.ts +14 -34
  439. package/src/staking/prepareIntents.ts +10 -13
  440. package/src/staking/redelegations.test.ts +73 -131
  441. package/src/staking/redelegations.ts +12 -26
  442. package/src/staking/rewards.test.ts +19 -21
  443. package/src/staking/rewards.ts +1 -2
  444. package/src/staking/rewardsFromReceipt.test.ts +9 -8
  445. package/src/staking/rewardsFromReceipt.ts +3 -2
  446. package/src/staking/transactionData.test.ts +35 -25
  447. package/src/staking/transactionData.ts +7 -6
  448. package/src/staking/unbondings.test.ts +26 -20
  449. package/src/staking/unbondings.ts +1 -2
  450. package/src/staking/validators/index.ts +45 -51
  451. package/src/staking/validators/monad.test.ts +52 -54
  452. package/src/staking/validators/monad.ts +31 -37
  453. package/src/staking/validators/monadResolver.ts +2 -4
  454. package/src/staking/validators/sei.ts +2 -2
  455. package/src/staking/validators/somnia.test.ts +22 -19
  456. package/src/staking/validators/somnia.ts +20 -27
  457. package/src/staking/validators/types.ts +0 -1
  458. package/src/staking/validators/zero_gravity.test.ts +34 -49
  459. package/src/staking/validators/zero_gravity.ts +5 -11
  460. package/src/staking/validators.integ.test.ts +3 -5
  461. package/src/staking/validators.test.ts +56 -53
  462. package/src/types/staking.ts +3 -6
  463. package/src/network/node/index.memoization.test.ts +0 -63
@@ -4,8 +4,9 @@
4
4
  import type { EvmConfigInfo } from '../config'
5
5
  import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
6
6
  import { ethers } from 'ethers'
7
+ import { CHAIN_ID } from '../config'
7
8
  import { testLogger } from '../fixtures/context.fixtures'
8
- import { STAKING_CONTRACTS } from './contracts'
9
+ import { requireStakingContract } from '../fixtures/staking.fixtures'
9
10
  import { fetchUnbondings } from './unbondings'
10
11
  import { USEI_TO_EVM_SCALE } from './utils'
11
12
 
@@ -29,14 +30,13 @@ const mockIsExternalNodeConfig = jest.mocked(require('../network/node/types').is
29
30
  const mockNode: EvmConfigInfo['node'] = { type: 'external', uri: 'https://sei-evm.coin.ledger.com' }
30
31
  const mockConfig: EvmConfigInfo = {
31
32
  status: { type: 'active' },
32
- chainId: 1329,
33
+ chainId: CHAIN_ID.SEI_EVM,
33
34
  name: 'Sei',
34
35
  unit: { name: 'sei', code: 'SEI', magnitude: 18 },
35
36
  node: mockNode,
36
37
  explorer: { type: 'none' },
37
38
  }
38
39
 
39
- const SEI_CURRENCY = 'sei_evm'
40
40
  const EVM_ADDRESS = '0x1111111111111111111111111111111111111111'
41
41
  const VALIDATOR = 'seivaloper1qe8uuf5x69c526h4nzxwv4ltftr73v7qnkypla'
42
42
  const OTHER_VALIDATOR = 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn'
@@ -79,38 +79,44 @@ describe('staking/unbondings', () => {
79
79
  mockIsExternalNodeConfig.mockImplementation((node: unknown) => node === mockNode)
80
80
  })
81
81
 
82
- it('should return [] for an unknown currencyId', async () => {
83
- expect(await fetchUnbondings(mockConfig, 'unknown_chain', EVM_ADDRESS, testLogger)).toEqual(
84
- []
85
- )
82
+ it('should return [] for a chain without staking', async () => {
83
+ expect(
84
+ await fetchUnbondings(
85
+ { ...mockConfig, chainId: CHAIN_ID.ETHEREUM },
86
+ EVM_ADDRESS,
87
+ testLogger
88
+ )
89
+ ).toEqual([])
86
90
  expect(mockNetwork).not.toHaveBeenCalled()
87
91
  })
88
92
 
89
- it('should return [] for a currency without an unbonding strategy', async () => {
90
- expect(await fetchUnbondings(mockConfig, 'celo', EVM_ADDRESS, testLogger)).toEqual([])
93
+ it('should return [] for a chain without an unbonding strategy', async () => {
94
+ expect(
95
+ await fetchUnbondings({ ...mockConfig, chainId: CHAIN_ID.CELO }, EVM_ADDRESS, testLogger)
96
+ ).toEqual([])
91
97
  expect(mockNetwork).not.toHaveBeenCalled()
92
98
  })
93
99
 
94
100
  it('should return [] when the address is not associated on-chain yet', async () => {
95
101
  mockGetSeiAddr.mockResolvedValue(null)
96
- expect(await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)).toEqual([])
102
+ expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
97
103
  expect(mockNetwork).not.toHaveBeenCalled()
98
104
  })
99
105
 
100
106
  it('should return [] when the REST call fails', async () => {
101
107
  mockNetwork.mockRejectedValue(new Error('network error'))
102
- expect(await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)).toEqual([])
108
+ expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
103
109
  })
104
110
 
105
111
  it('should return [] when the response has no unbonding_responses array', async () => {
106
112
  mockNetwork.mockResolvedValue({ data: {} })
107
- expect(await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)).toEqual([])
113
+ expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
108
114
  })
109
115
 
110
116
  it('should query the delegator endpoint with the resolved Cosmos address', async () => {
111
117
  mockNetwork.mockResolvedValue({ data: { unbonding_responses: [] } })
112
118
 
113
- await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)
119
+ await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
114
120
 
115
121
  expect(mockNetwork).toHaveBeenCalledWith({
116
122
  url: 'https://rest.sei-apis.com/cosmos/staking/v1beta1/delegators/sei1defaultcosmosaddressfortest/unbonding_delegations',
@@ -130,7 +136,7 @@ describe('staking/unbondings', () => {
130
136
  },
131
137
  })
132
138
 
133
- const stakes = await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)
139
+ const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
134
140
 
135
141
  expect(stakes).toHaveLength(1)
136
142
  expect(stakes[0]).toMatchObject({
@@ -153,7 +159,7 @@ describe('staking/unbondings', () => {
153
159
  },
154
160
  })
155
161
 
156
- const [stake] = await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)
162
+ const [stake] = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
157
163
 
158
164
  // Sei credits the funds back automatically: no withdraw transaction exists.
159
165
  expect(stake.actions).toEqual([])
@@ -172,7 +178,7 @@ describe('staking/unbondings', () => {
172
178
  },
173
179
  })
174
180
 
175
- const stakes = await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)
181
+ const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
176
182
 
177
183
  expect(stakes).toHaveLength(2)
178
184
  expect(new Set(stakes.map((s) => s.uid)).size).toBe(2)
@@ -194,7 +200,7 @@ describe('staking/unbondings', () => {
194
200
  },
195
201
  })
196
202
 
197
- const stakes = await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)
203
+ const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
198
204
 
199
205
  expect(stakes.map((s) => s.delegate)).toEqual([VALIDATOR, OTHER_VALIDATOR])
200
206
  })
@@ -211,7 +217,7 @@ describe('staking/unbondings', () => {
211
217
  },
212
218
  })
213
219
 
214
- const stakes = await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)
220
+ const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
215
221
 
216
222
  expect(stakes).toHaveLength(1)
217
223
  expect(stakes[0].amount).toBe(2000000n * USEI_TO_EVM_SCALE)
@@ -231,7 +237,7 @@ describe('staking/unbondings', () => {
231
237
  },
232
238
  })
233
239
 
234
- const stakes = await fetchUnbondings(mockConfig, SEI_CURRENCY, EVM_ADDRESS, testLogger)
240
+ const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
235
241
 
236
242
  expect(stakes).toHaveLength(1)
237
243
  expect(stakes[0].amount).toBe(3000000n * USEI_TO_EVM_SCALE)
@@ -240,7 +246,7 @@ describe('staking/unbondings', () => {
240
246
 
241
247
  describe('sei_evm unbonding strategy config', () => {
242
248
  it('should be configured to read the Cosmos unbonding_delegations endpoint', () => {
243
- expect(STAKING_CONTRACTS[SEI_CURRENCY]?.unbondingStrategy).toEqual({
249
+ expect(requireStakingContract(CHAIN_ID.SEI_EVM).unbondingStrategy).toEqual({
244
250
  type: 'cosmos-rest',
245
251
  endpoint: '/cosmos/staking/v1beta1/delegators/{address}/unbonding_delegations',
246
252
  })
@@ -120,11 +120,10 @@ async function fetchCosmosRestUnbondings(
120
120
  */
121
121
  export async function fetchUnbondings(
122
122
  evmConfig: EvmConfigInfo,
123
- currencyId: string,
124
123
  evmAddress: string,
125
124
  logger: Logger
126
125
  ): Promise<Stake[]> {
127
- const config = STAKING_CONTRACTS[currencyId]
126
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
128
127
  const strategy = config?.unbondingStrategy
129
128
  if (!config || !strategy || strategy.type === 'none') return []
130
129
 
@@ -1,11 +1,12 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo, EvmContext } from '../../config'
4
+ import type { ChainId, EvmConfigInfo, EvmContext } from '../../config'
5
5
  import type { ValidatorApi } from './types'
6
6
  import type { Cursor, Page, Validator } from '@ledgerhq/coin-module-framework/api/index'
7
7
  import type { Logger } from '@ledgerhq/coin-module-framework/config'
8
8
  import { makeLRUCache } from '@ledgerhq/live-network/cache'
9
+ import { CHAIN_ID } from '../../config'
9
10
  import { STAKING_CONTRACTS } from '../contracts'
10
11
  import monadValidatorApi from './monad'
11
12
  import seiValidatorApi from './sei'
@@ -18,15 +19,15 @@ import zeroGravityValidatorApi from './zero_gravity'
18
19
  */
19
20
  const CACHE_MAX_AGE_MS = 30 * 1000
20
21
 
21
- export const getValidatorApi = (currencyId: string): ValidatorApi | undefined => {
22
- switch (currencyId) {
23
- case 'sei_evm':
22
+ export const getValidatorApi = (chainId: ChainId): ValidatorApi | undefined => {
23
+ switch (chainId) {
24
+ case CHAIN_ID.SEI_EVM:
24
25
  return seiValidatorApi
25
- case 'monad':
26
+ case CHAIN_ID.MONAD:
26
27
  return monadValidatorApi
27
- case 'zero_gravity':
28
+ case CHAIN_ID.ZERO_GRAVITY:
28
29
  return zeroGravityValidatorApi
29
- case 'somnia':
30
+ case CHAIN_ID.SOMNIA:
30
31
  return somniaValidatorApi
31
32
  default:
32
33
  return undefined
@@ -35,46 +36,44 @@ export const getValidatorApi = (currencyId: string): ValidatorApi | undefined =>
35
36
 
36
37
  const resolveValidators = async (
37
38
  config: EvmConfigInfo,
38
- currencyId: string,
39
39
  logger: Logger,
40
40
  cursor?: Cursor
41
41
  ): Promise<Page<Validator>> => {
42
- const api = getValidatorApi(currencyId)
42
+ const api = getValidatorApi(config.chainId)
43
43
  if (!api) return { items: [], next: undefined }
44
- return api.fetchValidators(config, currencyId, logger, cursor)
44
+ return api.fetchValidators(config, logger, cursor)
45
45
  }
46
46
 
47
47
  // One cache key per page, so each page of a paginated chain (e.g. Monad) is
48
48
  // cached and deduplicated independently. Because makeLRUCache stores the pending
49
49
  // promise, concurrent callers (e.g. Info modal + Delegate modal opening in quick
50
50
  // succession) share one in-flight fetch — no separate request-deduplication map needed.
51
- const pageKey = (currencyId: string, cursor?: Cursor): string => `${currencyId}-${cursor ?? ''}`
51
+ const pageKey = (chainId: ChainId, cursor?: Cursor): string => `${chainId}-${cursor ?? ''}`
52
52
 
53
53
  const validatorsCache = makeLRUCache(
54
- (config: EvmConfigInfo, currencyId: string, logger: Logger, cursor?: Cursor) =>
55
- resolveValidators(config, currencyId, logger, cursor),
56
- // config and logger are deterministic/side-channel per currency, so they are intentionally
57
- // excluded from the cache key.
58
- (_config: EvmConfigInfo, currencyId: string, _logger: Logger, cursor?: Cursor) =>
59
- pageKey(currencyId, cursor),
54
+ (config: EvmConfigInfo, logger: Logger, cursor?: Cursor) =>
55
+ resolveValidators(config, logger, cursor),
56
+ // Only the chain id of config is part of the key: config and logger are otherwise
57
+ // deterministic/side-channel per chain, so they are intentionally excluded.
58
+ (config: EvmConfigInfo, _logger: Logger, cursor?: Cursor) => pageKey(config.chainId, cursor),
60
59
  { max: 50, ttl: CACHE_MAX_AGE_MS }
61
60
  )
62
61
 
63
62
  // makeLRUCache exposes no key enumeration, so we track the page keys we've issued
64
- // to support clearing every page of a single currency (keys are `currencyId-cursor`).
63
+ // to support clearing every page of a single chain (keys are `chainId-cursor`).
65
64
  const issuedKeys = new Set<string>()
66
65
 
67
- export const clearValidatorsCache = (currencyId?: string): void => {
68
- if (!currencyId) {
66
+ export const clearValidatorsCache = (chainId?: ChainId): void => {
67
+ if (chainId === undefined) {
69
68
  validatorsCache.reset()
70
69
  issuedKeys.clear()
71
70
  return
72
71
  }
73
72
 
74
- // Evict every cached page of this currency (the `-` delimiter keeps e.g.
75
- // "monad" from matching "monad2").
73
+ // Evict every cached page of this chain (the `-` delimiter keeps e.g.
74
+ // chain 1 from matching chain 10).
76
75
  for (const key of issuedKeys) {
77
- if (key.startsWith(`${currencyId}-`)) {
76
+ if (key.startsWith(`${chainId}-`)) {
78
77
  validatorsCache.clear(key)
79
78
  issuedKeys.delete(key)
80
79
  }
@@ -83,15 +82,14 @@ export const clearValidatorsCache = (currencyId?: string): void => {
83
82
 
84
83
  export const getValidators = async (
85
84
  config: EvmConfigInfo,
86
- currencyId: string,
87
85
  logger: Logger,
88
86
  cursor?: Cursor
89
87
  ): Promise<Page<Validator>> => {
90
- const key = pageKey(currencyId, cursor)
88
+ const key = pageKey(config.chainId, cursor)
91
89
  issuedKeys.add(key)
92
90
 
93
91
  try {
94
- const page = await validatorsCache(config, currencyId, logger, cursor)
92
+ const page = await validatorsCache(config, logger, cursor)
95
93
  // Never keep an empty page cached, so a transient empty response is retried next time.
96
94
  if (page.items.length === 0) {
97
95
  validatorsCache.clear(key)
@@ -111,49 +109,45 @@ export const getValidators = async (
111
109
  * cache entry already returns without a network call, so repeated calls are cheap.
112
110
  * Only the first page is warmed; subsequent pages are fetched lazily by the hook.
113
111
  */
114
- export const prefetchValidators = (
115
- config: EvmConfigInfo,
116
- currencyId: string,
117
- logger: Logger
118
- ): void => {
119
- void getValidators(config, currencyId, logger).catch(() => {
112
+ export const prefetchValidators = (config: EvmConfigInfo, logger: Logger): void => {
113
+ void getValidators(config, logger).catch(() => {
120
114
  /* swallow: the hook surfaces errors via its own flow */
121
115
  })
122
116
  }
123
117
 
124
- export const getValidatorExplorerUrl = (currencyId: string, address: string): string | undefined =>
125
- STAKING_CONTRACTS[currencyId]?.explorerConfig?.validatorUrl?.replace(
118
+ export const getValidatorExplorerUrl = (chainId: ChainId, address: string): string | undefined =>
119
+ STAKING_CONTRACTS[chainId]?.explorerConfig?.validatorUrl?.replace(
126
120
  '$address',
127
121
  address.toLowerCase()
128
122
  )
129
123
 
130
- export const getUnbondingPeriodDays = (currencyId: string): number | undefined =>
131
- STAKING_CONTRACTS[currencyId]?.unbondingPeriodDays
124
+ export const getUnbondingPeriodDays = (chainId: ChainId): number | undefined =>
125
+ STAKING_CONTRACTS[chainId]?.unbondingPeriodDays
132
126
 
133
- export const getMaxRedelegations = (currencyId: string): number | undefined =>
134
- STAKING_CONTRACTS[currencyId]?.maxRedelegations
127
+ export const getMaxRedelegations = (chainId: ChainId): number | undefined =>
128
+ STAKING_CONTRACTS[chainId]?.maxRedelegations
135
129
 
136
- export const getDelegationVisibilityDelayMinutes = (currencyId: string): number | undefined =>
137
- STAKING_CONTRACTS[currencyId]?.delegationVisibilityDelayMinutes
130
+ export const getDelegationVisibilityDelayMinutes = (chainId: ChainId): number | undefined =>
131
+ STAKING_CONTRACTS[chainId]?.delegationVisibilityDelayMinutes
138
132
 
139
- export const hasDelegationVisibilityDelay = (currencyId: string): boolean => {
140
- const minutes = getDelegationVisibilityDelayMinutes(currencyId)
133
+ export const hasDelegationVisibilityDelay = (chainId: ChainId): boolean => {
134
+ const minutes = getDelegationVisibilityDelayMinutes(chainId)
141
135
  return typeof minutes === 'number' && minutes > 0
142
136
  }
143
137
 
144
- export const hasUnbondingPeriod = (currencyId: string): boolean => {
145
- const days = getUnbondingPeriodDays(currencyId)
138
+ export const hasUnbondingPeriod = (chainId: ChainId): boolean => {
139
+ const days = getUnbondingPeriodDays(chainId)
146
140
  return typeof days === 'number' && days > 0
147
141
  }
148
142
 
149
- export const hasRedelegation = (currencyId: string): boolean =>
150
- typeof STAKING_CONTRACTS[currencyId]?.functions.redelegate === 'string'
143
+ export const hasRedelegation = (chainId: ChainId): boolean =>
144
+ typeof STAKING_CONTRACTS[chainId]?.functions.redelegate === 'string'
151
145
 
152
- export const hasCompound = (currencyId: string): boolean =>
153
- typeof STAKING_CONTRACTS[currencyId]?.functions.compoundReward === 'string'
146
+ export const hasCompound = (chainId: ChainId): boolean =>
147
+ typeof STAKING_CONTRACTS[chainId]?.functions.compoundReward === 'string'
154
148
 
155
- export const hasChainRewards = (currencyId: string): boolean => {
156
- const config = STAKING_CONTRACTS[currencyId]
149
+ export const hasChainRewards = (chainId: ChainId): boolean => {
150
+ const config = STAKING_CONTRACTS[chainId]
157
151
  return typeof config?.functions.claimReward === 'string'
158
152
  }
159
153
 
@@ -167,5 +161,5 @@ export const getValidatorsPage = async (
167
161
  cursor?: Cursor
168
162
  ): Promise<Page<Validator>> => {
169
163
  const config = await context.config(currencyId)
170
- return getValidators(config, currencyId, context.logger, cursor)
164
+ return getValidators(config, context.logger, cursor)
171
165
  }
@@ -7,6 +7,7 @@ import type { AddressLike } from 'ethers'
7
7
  import network from '@ledgerhq/live-network'
8
8
  import { ethers } from 'ethers'
9
9
  import monadAbi from '../../abis/monad.abi.json'
10
+ import { CHAIN_ID } from '../../config'
10
11
  import {
11
12
  createMockEvmConfigInfo,
12
13
  mkExternalNode,
@@ -32,12 +33,15 @@ const mockedWithApi = jest.mocked(withApi)
32
33
  const mockedNetwork = jest.mocked(network)
33
34
 
34
35
  const mockConfig = createMockEvmConfigInfo({
35
- chainId: 10143,
36
+ chainId: CHAIN_ID.MONAD,
36
37
  name: 'Monad',
37
38
  unit: { name: 'MON', code: 'MON', magnitude: 18 },
38
39
  node: mkExternalNode({ uri: 'https://monad.rpc/' }),
39
40
  })
40
- const ledgerConfig = createMockEvmConfigInfo({ chainId: 10143, node: mkLedgerNode() })
41
+ const ledgerConfig = createMockEvmConfigInfo({
42
+ chainId: CHAIN_ID.MONAD,
43
+ node: mkLedgerNode(),
44
+ })
41
45
 
42
46
  const monadIface = new ethers.Interface(monadAbi)
43
47
  const PRECOMPILE = '0x0000000000000000000000000000000000001000'
@@ -75,7 +79,7 @@ const parseCalldata = (data: string | Uint8Array) =>
75
79
 
76
80
  const setupRpc = (handler: CallHandler) => {
77
81
  const callMock = jest.fn(handler)
78
- mockedWithApi.mockImplementation(async (_config, _currencyId, fn) => {
82
+ mockedWithApi.mockImplementation(async (_config, fn) => {
79
83
  const api = mkJsonRpcProvider()
80
84
  jest.spyOn(api, 'call').mockImplementation(callMock)
81
85
  return fn(api)
@@ -175,7 +179,7 @@ describe('staking/validators/monad', () => {
175
179
  })
176
180
  )
177
181
 
178
- expect(await getValidators(mockConfig, 'monad', testLogger)).toStrictEqual({
182
+ expect(await getValidators(mockConfig, testLogger)).toStrictEqual({
179
183
  items: [
180
184
  {
181
185
  id: '1',
@@ -204,7 +208,7 @@ describe('staking/validators/monad', () => {
204
208
 
205
209
  // a non-empty page is cached: the second read makes no further RPC calls
206
210
  const callsAfterFirst = callMock.mock.calls.length
207
- await getValidators(mockConfig, 'monad', testLogger)
211
+ await getValidators(mockConfig, testLogger)
208
212
  expect(callMock.mock.calls.length).toBe(callsAfterFirst)
209
213
  })
210
214
 
@@ -226,7 +230,7 @@ describe('staking/validators/monad', () => {
226
230
  status: 200,
227
231
  })
228
232
 
229
- const page = await getValidators(mockConfig, 'monad', testLogger)
233
+ const page = await getValidators(mockConfig, testLogger)
230
234
 
231
235
  expect(page.items[0]).toMatchObject({
232
236
  address: ethers.computeAddress(
@@ -258,7 +262,7 @@ describe('staking/validators/monad', () => {
258
262
  })
259
263
  )
260
264
 
261
- const page = await getValidators(mockConfig, 'monad', testLogger)
265
+ const page = await getValidators(mockConfig, testLogger)
262
266
 
263
267
  expect(page.items).toHaveLength(1)
264
268
  expect(page.items[0]).toMatchObject({
@@ -277,19 +281,19 @@ describe('staking/validators/monad', () => {
277
281
  })
278
282
  )
279
283
 
280
- const page = await getValidators(mockConfig, 'monad', testLogger)
284
+ const page = await getValidators(mockConfig, testLogger)
281
285
 
282
286
  expect(page.items).toStrictEqual([])
283
287
  expect(page.next).toBeUndefined()
284
288
 
285
289
  // empty results are not cached, so the next read hits the precompile again
286
290
  const callsAfterFirst = callMock.mock.calls.length
287
- await getValidators(mockConfig, 'monad', testLogger)
291
+ await getValidators(mockConfig, testLogger)
288
292
  expect(callMock.mock.calls.length).toBeGreaterThan(callsAfterFirst)
289
293
  })
290
294
 
291
295
  it('returns an empty page when the node config is not external', async () => {
292
- const page = await getValidators(ledgerConfig, 'monad', testLogger)
296
+ const page = await getValidators(ledgerConfig, testLogger)
293
297
 
294
298
  expect(page.items).toStrictEqual([])
295
299
  expect(page.next).toBeUndefined()
@@ -305,7 +309,7 @@ describe('staking/validators/monad', () => {
305
309
  })
306
310
  )
307
311
 
308
- const page = await getValidators(mockConfig, 'monad', testLogger)
312
+ const page = await getValidators(mockConfig, testLogger)
309
313
 
310
314
  expect(page.items).toHaveLength(2)
311
315
  expect(page.next).toBe('100')
@@ -322,10 +326,10 @@ describe('staking/validators/monad', () => {
322
326
  })
323
327
  )
324
328
 
325
- const first = await getValidators(mockConfig, 'monad', testLogger)
329
+ const first = await getValidators(mockConfig, testLogger)
326
330
  expect(first.next).toBe('100')
327
331
 
328
- const second = await getValidators(mockConfig, 'monad', testLogger, first.next)
332
+ const second = await getValidators(mockConfig, testLogger, first.next)
329
333
  expect(second.items).toHaveLength(1)
330
334
  expect(second.next).toBeUndefined()
331
335
  })
@@ -342,7 +346,7 @@ describe('staking/validators/monad', () => {
342
346
  })
343
347
  )
344
348
 
345
- const page = await getValidators(mockConfig, 'monad', testLogger)
349
+ const page = await getValidators(mockConfig, testLogger)
346
350
 
347
351
  expect(page.next).toBeUndefined()
348
352
  })
@@ -357,10 +361,10 @@ describe('staking/validators/monad', () => {
357
361
  })
358
362
  )
359
363
 
360
- await getValidators(mockConfig, 'monad', testLogger)
364
+ await getValidators(mockConfig, testLogger)
361
365
  const callCountAfterFirst = callMock.mock.calls.length
362
366
 
363
- const second = await getValidators(mockConfig, 'monad', testLogger)
367
+ const second = await getValidators(mockConfig, testLogger)
364
368
  expect(second.items).toHaveLength(1)
365
369
  expect(callMock.mock.calls.length).toBe(callCountAfterFirst)
366
370
  })
@@ -376,8 +380,8 @@ describe('staking/validators/monad', () => {
376
380
  })
377
381
  )
378
382
 
379
- const firstPage = await getValidators(mockConfig, 'monad', testLogger)
380
- const secondPage = await getValidators(mockConfig, 'monad', testLogger, '100')
383
+ const firstPage = await getValidators(mockConfig, testLogger)
384
+ const secondPage = await getValidators(mockConfig, testLogger, '100')
381
385
  const callsAfterBoth = callMock.mock.calls.length
382
386
 
383
387
  expect(firstPage).toStrictEqual({
@@ -398,12 +402,12 @@ describe('staking/validators/monad', () => {
398
402
  expect(secondPage.next).toBeUndefined()
399
403
 
400
404
  // both cursors are now cached independently — no further RPC calls
401
- expect(await getValidators(mockConfig, 'monad', testLogger)).toStrictEqual(firstPage)
402
- expect(await getValidators(mockConfig, 'monad', testLogger, '100')).toStrictEqual(secondPage)
405
+ expect(await getValidators(mockConfig, testLogger)).toStrictEqual(firstPage)
406
+ expect(await getValidators(mockConfig, testLogger, '100')).toStrictEqual(secondPage)
403
407
  expect(callMock.mock.calls.length).toBe(callsAfterBoth)
404
408
  })
405
409
 
406
- it('clearValidatorsCache(currencyId) drops every cached cursor for that currency', async () => {
410
+ it('clearValidatorsCache(chainId) drops every cached cursor for that chain', async () => {
407
411
  const callMock = setupRpc(
408
412
  routeByName({
409
413
  getExecutionValidatorSet: (startIndex) =>
@@ -414,15 +418,15 @@ describe('staking/validators/monad', () => {
414
418
  })
415
419
  )
416
420
 
417
- await getValidators(mockConfig, 'monad', testLogger)
418
- await getValidators(mockConfig, 'monad', testLogger, '100')
421
+ await getValidators(mockConfig, testLogger)
422
+ await getValidators(mockConfig, testLogger, '100')
419
423
  const callsBeforeClear = callMock.mock.calls.length
420
424
 
421
- clearValidatorsCache('monad')
425
+ clearValidatorsCache(CHAIN_ID.MONAD)
422
426
 
423
427
  // every cursor was evicted, so both reads hit the precompile again
424
- await getValidators(mockConfig, 'monad', testLogger)
425
- await getValidators(mockConfig, 'monad', testLogger, '100')
428
+ await getValidators(mockConfig, testLogger)
429
+ await getValidators(mockConfig, testLogger, '100')
426
430
  expect(callMock.mock.calls.length).toBeGreaterThan(callsBeforeClear)
427
431
  })
428
432
  })
@@ -440,7 +444,7 @@ describe('staking/validators/monad', () => {
440
444
  })
441
445
  )
442
446
 
443
- expect(await getValidatorAddressById(mockConfig, 'monad', 7n, testLogger)).toEqual(
447
+ expect(await getValidatorAddressById(mockConfig, 7n, testLogger)).toEqual(
444
448
  ethers.computeAddress(
445
449
  '0x036e44a092493800e427b2b08d3427d804348b1368ecd0a6af6510ae40ce507187'
446
450
  )
@@ -448,13 +452,13 @@ describe('staking/validators/monad', () => {
448
452
  })
449
453
 
450
454
  it('returns null when the node config is not external', async () => {
451
- expect(await getValidatorAddressById(ledgerConfig, 'monad', 7n, testLogger)).toBeNull()
455
+ expect(await getValidatorAddressById(ledgerConfig, 7n, testLogger)).toBeNull()
452
456
  })
453
457
 
454
458
  it('returns null when the getValidator call fails', async () => {
455
459
  setupRpc(routeByName({ getValidator: () => new Error('boom') }))
456
460
 
457
- expect(await getValidatorAddressById(mockConfig, 'monad', 7n, testLogger)).toBeNull()
461
+ expect(await getValidatorAddressById(mockConfig, 7n, testLogger)).toBeNull()
458
462
  })
459
463
  })
460
464
 
@@ -470,7 +474,7 @@ describe('staking/validators/monad', () => {
470
474
  }
471
475
 
472
476
  const fetchStakes = (config: EvmConfigInfo = mockConfig) =>
473
- fetchMonadStakes(config, DELEGATOR, dummyStakingConfig, 'monad', testLogger)
477
+ fetchMonadStakes(config, DELEGATOR, dummyStakingConfig, testLogger)
474
478
 
475
479
  const encodeDelegator = (
476
480
  stake: bigint,
@@ -858,14 +862,9 @@ describe('staking/validators/monad', () => {
858
862
  })
859
863
  )
860
864
 
861
- const stakes = await fetchMonadStakes(
862
- mockConfig,
863
- DELEGATOR,
864
- dummyStakingConfig,
865
- 'monad',
866
- testLogger,
867
- ['92']
868
- )
865
+ const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, dummyStakingConfig, testLogger, [
866
+ '92',
867
+ ])
869
868
 
870
869
  const withdrawal = stakes.find((s) => s.details?.validatorId === '92')
871
870
  expect(withdrawal).toMatchObject({
@@ -888,14 +887,9 @@ describe('staking/validators/monad', () => {
888
887
  })
889
888
  )
890
889
 
891
- const stakes = await fetchMonadStakes(
892
- mockConfig,
893
- DELEGATOR,
894
- dummyStakingConfig,
895
- 'monad',
896
- testLogger,
897
- ['7']
898
- )
890
+ const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, dummyStakingConfig, testLogger, [
891
+ '7',
892
+ ])
899
893
 
900
894
  expect(stakes).toHaveLength(1)
901
895
  expect(delegatorCallCount).toBe(1)
@@ -926,21 +920,21 @@ describe('staking/validators/monad', () => {
926
920
  it('extracts a validator id from a DELEGATE op', () => {
927
921
  const payload = monadIface.encodeFunctionData('delegate', [42n])
928
922
  expect(
929
- extractMonadKnownValIds('monad', [makeOp('DELEGATE', payload)], testLogger)
923
+ extractMonadKnownValIds(CHAIN_ID.MONAD, [makeOp('DELEGATE', payload)], testLogger)
930
924
  ).toStrictEqual(['42'])
931
925
  })
932
926
 
933
927
  it('extracts a validator id from an UNDELEGATE op', () => {
934
928
  const payload = monadIface.encodeFunctionData('undelegate', [92n, 10_000_000_000n, 0n])
935
929
  expect(
936
- extractMonadKnownValIds('monad', [makeOp('UNDELEGATE', payload)], testLogger)
930
+ extractMonadKnownValIds(CHAIN_ID.MONAD, [makeOp('UNDELEGATE', payload)], testLogger)
937
931
  ).toStrictEqual(['92'])
938
932
  })
939
933
 
940
934
  it('extracts a validator id from a WITHDRAW_UNBONDED op', () => {
941
935
  const payload = monadIface.encodeFunctionData('withdraw', [7n, 3n])
942
936
  expect(
943
- extractMonadKnownValIds('monad', [makeOp('WITHDRAW_UNBONDED', payload)], testLogger)
937
+ extractMonadKnownValIds(CHAIN_ID.MONAD, [makeOp('WITHDRAW_UNBONDED', payload)], testLogger)
944
938
  ).toStrictEqual(['7'])
945
939
  })
946
940
 
@@ -948,7 +942,7 @@ describe('staking/validators/monad', () => {
948
942
  const p1 = monadIface.encodeFunctionData('undelegate', [92n, 5_000_000_000n, 0n])
949
943
  const p2 = monadIface.encodeFunctionData('undelegate', [92n, 5_000_000_000n, 1n])
950
944
  const result = extractMonadKnownValIds(
951
- 'monad',
945
+ CHAIN_ID.MONAD,
952
946
  [makeOp('UNDELEGATE', p1), makeOp('UNDELEGATE', p2)],
953
947
  testLogger
954
948
  )
@@ -956,19 +950,23 @@ describe('staking/validators/monad', () => {
956
950
  })
957
951
 
958
952
  it('ignores ops whose type is not a staking function', () => {
959
- const result = extractMonadKnownValIds('monad', [makeOp('OUT'), makeOp('IN')], testLogger)
953
+ const result = extractMonadKnownValIds(
954
+ CHAIN_ID.MONAD,
955
+ [makeOp('OUT'), makeOp('IN')],
956
+ testLogger
957
+ )
960
958
  expect(result).toStrictEqual([])
961
959
  })
962
960
 
963
961
  it('skips ops with no contractPayload without throwing', () => {
964
- const result = extractMonadKnownValIds('monad', [makeOp('UNDELEGATE')], testLogger)
962
+ const result = extractMonadKnownValIds(CHAIN_ID.MONAD, [makeOp('UNDELEGATE')], testLogger)
965
963
  expect(result).toStrictEqual([])
966
964
  })
967
965
 
968
- it('returns an empty array for an unknown currencyId (no ABI available)', () => {
966
+ it('returns an empty array for an unknown chainId (no ABI available)', () => {
969
967
  const payload = monadIface.encodeFunctionData('undelegate', [7n, 1n, 0n])
970
968
  expect(
971
- extractMonadKnownValIds('unknown_coin', [makeOp('UNDELEGATE', payload)], testLogger)
969
+ extractMonadKnownValIds(CHAIN_ID.ETHEREUM, [makeOp('UNDELEGATE', payload)], testLogger)
972
970
  ).toStrictEqual([])
973
971
  })
974
972
  })