@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
@@ -168,11 +168,10 @@ async function fetchCosmosRestRedelegations(
168
168
  */
169
169
  export async function fetchRedelegations(
170
170
  evmConfig: EvmConfigInfo,
171
- currencyId: string,
172
171
  evmAddress: string,
173
172
  logger: Logger
174
173
  ): Promise<EvmRedelegation[]> {
175
- const config = STAKING_CONTRACTS[currencyId]
174
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
176
175
  const strategy = config?.redelegationStrategy
177
176
  if (!strategy || strategy.type === 'none') return []
178
177
 
@@ -205,7 +204,6 @@ export async function fetchRedelegations(
205
204
  */
206
205
  async function fetchTxDataFromRpc(
207
206
  config: EvmConfigInfo,
208
- currencyId: string,
209
207
  txHash: string,
210
208
  logger: Logger
211
209
  ): Promise<string | undefined> {
@@ -214,7 +212,6 @@ async function fetchTxDataFromRpc(
214
212
  if (!isExternalNodeConfig(node)) return undefined
215
213
  const data = await withApi(
216
214
  config,
217
- currencyId,
218
215
  async (api) => {
219
216
  const tx = await api.getTransaction(txHash)
220
217
  return tx?.data ?? null
@@ -224,7 +221,7 @@ async function fetchTxDataFromRpc(
224
221
  return data && data !== '0x' ? data : undefined
225
222
  } catch (e) {
226
223
  logger('coin-evm/staking', 'fetchTxDataFromRpc: getTransaction failed', {
227
- currencyId,
224
+ currency: config.name,
228
225
  txHash,
229
226
  error: e instanceof Error ? e.message : String(e),
230
227
  })
@@ -243,7 +240,6 @@ async function fetchTxDataFromRpc(
243
240
  */
244
241
  export async function resolveRedelegationValidators(
245
242
  evmConfig: EvmConfigInfo,
246
- currencyId: string,
247
243
  operation: OperationLike,
248
244
  logger: Logger
249
245
  ): Promise<{
@@ -256,13 +252,13 @@ export async function resolveRedelegationValidators(
256
252
  const payload =
257
253
  typeof cached === 'string'
258
254
  ? cached
259
- : await fetchTxDataFromRpc(evmConfig, currencyId, operation.hash, logger)
255
+ : await fetchTxDataFromRpc(evmConfig, operation.hash, logger)
260
256
 
261
257
  if (!payload) return null
262
258
 
263
- const config = STAKING_CONTRACTS[currencyId]
259
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
264
260
  const functionName = config?.functions.redelegate
265
- const abi = getStakingABI(currencyId)
261
+ const abi = getStakingABI(evmConfig.chainId)
266
262
  if (!abi || !functionName) return null
267
263
  try {
268
264
  const iface = new ethers.Interface(abi)
@@ -295,7 +291,6 @@ export async function resolveRedelegationValidators(
295
291
  */
296
292
  export async function resolveStakingValidator(
297
293
  evmConfig: EvmConfigInfo,
298
- currencyId: string,
299
294
  operation: OperationLike,
300
295
  operationType: 'delegate' | 'undelegate' | 'withdraw',
301
296
  logger: Logger
@@ -305,13 +300,13 @@ export async function resolveStakingValidator(
305
300
  const payload =
306
301
  typeof cached === 'string'
307
302
  ? cached
308
- : await fetchTxDataFromRpc(evmConfig, currencyId, operation.hash, logger)
303
+ : await fetchTxDataFromRpc(evmConfig, operation.hash, logger)
309
304
 
310
305
  if (!payload) return null
311
306
 
312
- const config = STAKING_CONTRACTS[currencyId]
307
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
313
308
  const functionName = config?.functions[operationType]
314
- const abi = getStakingABI(currencyId)
309
+ const abi = getStakingABI(evmConfig.chainId)
315
310
  if (!abi || !functionName) return null
316
311
  try {
317
312
  const iface = new ethers.Interface(abi)
@@ -326,13 +321,7 @@ export async function resolveStakingValidator(
326
321
  if (!validatorAddress) return null
327
322
 
328
323
  const contractAddress = operation.recipients[0] ?? validatorAddress
329
- const amount = await config.resolveOperationAmount(
330
- evmConfig,
331
- d,
332
- operationType,
333
- currencyId,
334
- contractAddress
335
- )
324
+ const amount = await config.resolveOperationAmount(evmConfig, d, operationType, contractAddress)
336
325
  return { validatorAddress, amount }
337
326
  } catch {
338
327
  return null
@@ -341,14 +330,13 @@ export async function resolveStakingValidator(
341
330
 
342
331
  export async function buildRedelegationsFromOps(
343
332
  evmConfig: EvmConfigInfo,
344
- currencyId: string,
345
333
  operations: OperationLike[],
346
334
  logger: Logger
347
335
  ): Promise<EvmRedelegation[]> {
348
- const config = STAKING_CONTRACTS[currencyId]
336
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
349
337
  if (!config?.functions.redelegate) return []
350
338
 
351
- const abi = getStakingABI(currencyId)
339
+ const abi = getStakingABI(evmConfig.chainId)
352
340
  if (!abi) return []
353
341
 
354
342
  const functionName = config.functions.redelegate
@@ -369,9 +357,7 @@ export async function buildRedelegationsFromOps(
369
357
  const extra = isRecord(op.extra) ? op.extra : undefined
370
358
  const cached = extra?.contractPayload
371
359
  const payload =
372
- typeof cached === 'string'
373
- ? cached
374
- : await fetchTxDataFromRpc(evmConfig, currencyId, op.hash, logger)
360
+ typeof cached === 'string' ? cached : await fetchTxDataFromRpc(evmConfig, op.hash, logger)
375
361
  if (!payload) return null
376
362
  try {
377
363
  const d = iface.decodeFunctionData(functionName, payload)
@@ -3,6 +3,7 @@
3
3
 
4
4
  import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
5
5
  import { ethers } from 'ethers'
6
+ import { CHAIN_ID } from '../config'
6
7
  import { createMockEvmConfigInfo, mkExternalNode, testLogger } from '../fixtures/context.fixtures'
7
8
  import { fetchRewards } from './rewards'
8
9
  import { USEI_TO_EVM_SCALE } from './utils'
@@ -28,7 +29,7 @@ const EVM_ADDRESS = '0x1234567890abcdef1234567890abcdef12345678'
28
29
  const COSMOS_ADDRESS = 'sei1defaultcosmosaddressfortest'
29
30
 
30
31
  const mockNode = mkExternalNode({ uri: 'https://sei-evm.coin.ledger.com' })
31
- const mockConfig = createMockEvmConfigInfo({ chainId: 1, node: mockNode })
32
+ const mockConfig = createMockEvmConfigInfo({ chainId: CHAIN_ID.SEI_EVM, node: mockNode })
32
33
 
33
34
  type RewardCoin = { denom: string; amount: string }
34
35
  const restResponse = (rewards: Array<{ validator_address: string; reward: RewardCoin[] }>) => ({
@@ -51,30 +52,32 @@ describe('fetchRewards', () => {
51
52
  })
52
53
 
53
54
  it.each([
54
- { case: 'unknown currencyId', currencyId: 'unknown_chain', setup: () => undefined },
55
+ { case: 'chain without staking', chainId: CHAIN_ID.ETHEREUM, setup: () => undefined },
55
56
  {
56
57
  case: 'chain has no rewardsStrategy (e.g. Celo)',
57
- currencyId: 'celo',
58
+ chainId: CHAIN_ID.CELO,
58
59
  setup: () => undefined,
59
60
  },
60
61
  {
61
62
  case: 'REST call fails',
62
- currencyId: 'sei_evm',
63
+ chainId: CHAIN_ID.SEI_EVM,
63
64
  setup: () => mockNetwork.mockRejectedValue(new Error('network error')),
64
65
  },
65
66
  {
66
67
  case: 'API response has no rewards array',
67
- currencyId: 'sei_evm',
68
+ chainId: CHAIN_ID.SEI_EVM,
68
69
  setup: () => mockNetwork.mockResolvedValue({ data: {} }),
69
70
  },
70
71
  {
71
72
  case: 'address precompile call fails',
72
- currencyId: 'sei_evm',
73
+ chainId: CHAIN_ID.SEI_EVM,
73
74
  setup: () => mockGetSeiAddr.mockRejectedValueOnce(new Error('not associated')),
74
75
  },
75
- ])('returns an empty map when $case', async ({ currencyId, setup }) => {
76
+ ])('returns an empty map when $case', async ({ chainId, setup }) => {
76
77
  setup()
77
- expect(await fetchRewards(mockConfig, currencyId, EVM_ADDRESS, testLogger)).toEqual(new Map())
78
+ expect(await fetchRewards({ ...mockConfig, chainId }, EVM_ADDRESS, testLogger)).toEqual(
79
+ new Map()
80
+ )
78
81
  })
79
82
 
80
83
  it('resolves the EVM address to its canonical Cosmos bech32 via the precompile', async () => {
@@ -82,12 +85,7 @@ describe('fetchRewards', () => {
82
85
  mockGetSeiAddr.mockResolvedValueOnce(canonicalCosmosAddress)
83
86
  mockNetwork.mockResolvedValueOnce(restResponse([]))
84
87
 
85
- await fetchRewards(
86
- mockConfig,
87
- 'sei_evm',
88
- '0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3',
89
- testLogger
90
- )
88
+ await fetchRewards(mockConfig, '0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3', testLogger)
91
89
 
92
90
  expect(mockNetwork.mock.calls[0][0]).toMatchObject({
93
91
  url: expect.stringContaining(canonicalCosmosAddress),
@@ -105,7 +103,7 @@ describe('fetchRewards', () => {
105
103
  ])
106
104
  )
107
105
 
108
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
106
+ const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
109
107
 
110
108
  expect(result.size).toBe(1)
111
109
  expect(result.get('seivaloper1one')).toBe(569n * USEI_TO_EVM_SCALE)
@@ -124,7 +122,7 @@ describe('fetchRewards', () => {
124
122
  ])
125
123
  )
126
124
 
127
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
125
+ const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
128
126
 
129
127
  expect(result.get('seivaloper1one')).toBe(123n * USEI_TO_EVM_SCALE)
130
128
  })
@@ -142,7 +140,7 @@ describe('fetchRewards', () => {
142
140
  ])
143
141
  )
144
142
 
145
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
143
+ const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
146
144
 
147
145
  expect(result.get('seivaloper1one')).toBe(500n * USEI_TO_EVM_SCALE)
148
146
  })
@@ -158,7 +156,7 @@ describe('fetchRewards', () => {
158
156
  ])
159
157
  )
160
158
 
161
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
159
+ const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
162
160
 
163
161
  expect(result.has('seivaloper1dust')).toBe(false)
164
162
  expect(result.get('seivaloper1real')).toBe(42n * USEI_TO_EVM_SCALE)
@@ -173,7 +171,7 @@ describe('fetchRewards', () => {
173
171
  ])
174
172
  )
175
173
 
176
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
174
+ const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
177
175
 
178
176
  expect(result.size).toBe(3)
179
177
  expect(result.get('seivaloper1a')).toBe(10n * USEI_TO_EVM_SCALE)
@@ -191,7 +189,7 @@ describe('fetchRewards', () => {
191
189
  ])
192
190
  )
193
191
 
194
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
192
+ const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
195
193
 
196
194
  expect(result.has('seivaloper1bad')).toBe(false)
197
195
  })
@@ -209,7 +207,7 @@ describe('fetchRewards', () => {
209
207
  ])
210
208
  )
211
209
 
212
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
210
+ const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
213
211
 
214
212
  expect(result.get('seivaloper1mixed')).toBe(100n * USEI_TO_EVM_SCALE)
215
213
  })
@@ -59,12 +59,11 @@ async function fetchCosmosRestRewards(
59
59
  // back to zero without blocking the staking sync.
60
60
  export async function fetchRewards(
61
61
  evmConfig: EvmConfigInfo,
62
- currencyId: string,
63
62
  evmAddress: string,
64
63
  logger: Logger
65
64
  ): Promise<Map<string, bigint>> {
66
65
  try {
67
- const config = STAKING_CONTRACTS[currencyId]
66
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
68
67
  const strategy = config?.rewardsStrategy
69
68
  if (!strategy || strategy.type === 'none') return new Map()
70
69
 
@@ -3,12 +3,13 @@
3
3
 
4
4
  import type { LogWithAddress } from '../network/node/types'
5
5
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
6
+ import { CHAIN_ID } from '../config'
6
7
  import { testLogger } from '../fixtures/context.fixtures'
7
- import { STAKING_CONTRACTS } from './contracts'
8
+ import { requireStakingContract } from '../fixtures/staking.fixtures'
8
9
  import { enrichRewardOperationsValue, sumRewardFromReceiptLogs } from './rewardsFromReceipt'
9
10
 
10
- const MONAD_DECODER = STAKING_CONTRACTS.monad.rewardsEventDecoder!
11
- const SEI_DECODER = STAKING_CONTRACTS.sei_evm.rewardsEventDecoder!
11
+ const MONAD_DECODER = requireStakingContract(CHAIN_ID.MONAD).rewardsEventDecoder!
12
+ const SEI_DECODER = requireStakingContract(CHAIN_ID.SEI_EVM).rewardsEventDecoder!
12
13
 
13
14
  const MONAD_STAKING = '0x0000000000000000000000000000000000001000'
14
15
  const SEI_DISTRIBUTION = '0x0000000000000000000000000000000000001007'
@@ -108,17 +109,17 @@ describe('enrichRewardOperationsValue', () => {
108
109
  .fn()
109
110
  .mockResolvedValue({ logs: [monadClaimRewardsLog(MONAD_DELEGATOR_TOPIC, '030405ea888e')] })
110
111
 
111
- await enrichRewardOperationsValue('monad', [op], getReceipt, testLogger)
112
+ await enrichRewardOperationsValue(CHAIN_ID.MONAD, [op], getReceipt, testLogger)
112
113
 
113
114
  expect(getReceipt).toHaveBeenCalledWith('0xabc')
114
115
  expect(op.value).toStrictEqual(3315814008974n)
115
116
  })
116
117
 
117
- it('is a no-op for a currency without a rewardsEventDecoder', async () => {
118
+ it('is a no-op for a chain without a rewardsEventDecoder', async () => {
118
119
  const op = rewardOp('0xabc', MONAD_DELEGATOR)
119
120
  const getReceipt = jest.fn()
120
121
 
121
- await enrichRewardOperationsValue('ethereum', [op], getReceipt, testLogger)
122
+ await enrichRewardOperationsValue(CHAIN_ID.ETHEREUM, [op], getReceipt, testLogger)
122
123
 
123
124
  expect(getReceipt).not.toHaveBeenCalled()
124
125
  expect(op.value).toStrictEqual(0n)
@@ -135,7 +136,7 @@ describe('enrichRewardOperationsValue', () => {
135
136
  }
136
137
  const getReceipt = jest.fn().mockResolvedValue(null)
137
138
 
138
- await enrichRewardOperationsValue('monad', [out, nonZero], getReceipt, testLogger)
139
+ await enrichRewardOperationsValue(CHAIN_ID.MONAD, [out, nonZero], getReceipt, testLogger)
139
140
 
140
141
  expect(getReceipt).not.toHaveBeenCalled()
141
142
  })
@@ -144,7 +145,7 @@ describe('enrichRewardOperationsValue', () => {
144
145
  const op = rewardOp('0xabc', MONAD_DELEGATOR)
145
146
  const getReceipt = jest.fn().mockRejectedValue(new Error('rpc down'))
146
147
 
147
- await enrichRewardOperationsValue('monad', [op], getReceipt, testLogger)
148
+ await enrichRewardOperationsValue(CHAIN_ID.MONAD, [op], getReceipt, testLogger)
148
149
 
149
150
  expect(op.value).toStrictEqual(0n)
150
151
  })
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { ChainId } from '../config'
4
5
  import type { LogWithAddress } from '../network/node/types'
5
6
  import type { RewardsEventDecoder } from '../types/staking'
6
7
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
@@ -72,12 +73,12 @@ export function sumRewardFromReceiptLogs(
72
73
  * untouched (amount falls back to 0) rather than blocking sync.
73
74
  */
74
75
  export async function enrichRewardOperationsValue(
75
- currencyId: string,
76
+ chainId: ChainId,
76
77
  operations: Array<Operation<MemoNotSupported>>,
77
78
  getReceipt: ReceiptFetcher,
78
79
  logger: Logger
79
80
  ): Promise<void> {
80
- const decoder = STAKING_CONTRACTS[currencyId]?.rewardsEventDecoder
81
+ const decoder = STAKING_CONTRACTS[chainId]?.rewardsEventDecoder
81
82
  if (!decoder) {
82
83
  return
83
84
  }
@@ -1,14 +1,24 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { ChainId } from '../config'
4
5
  import type { MemoNotSupported } from '@ledgerhq/coin-module-framework/api/index'
5
6
  import type { BufferTxData } from '@ledgerhq/coin-module-framework/api/types'
6
7
  import { createStakingTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
7
8
  import { ethers } from 'ethers'
9
+ import { CHAIN_ID } from '../config'
10
+ import { createMockEvmConfigInfo, mkExternalNode } from '../fixtures/context.fixtures'
11
+ import { requireStakingContract } from '../fixtures/staking.fixtures'
8
12
  import { getStakingABI } from './abis'
9
- import { STAKING_CONTRACTS } from './contracts'
10
13
  import { buildStakingTransactionParams } from './transactionData'
11
14
 
15
+ const mkConfig = (chainId: ChainId, name: string) =>
16
+ createMockEvmConfigInfo({ chainId, name, node: mkExternalNode() })
17
+
18
+ const monadConfig = mkConfig(CHAIN_ID.MONAD, 'monad')
19
+ const seiConfig = mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm')
20
+ const zeroGravityConfig = mkConfig(CHAIN_ID.ZERO_GRAVITY, 'zero_gravity')
21
+
12
22
  const delegateIntent = (fields: Record<string, unknown>) =>
13
23
  Object.assign(
14
24
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
@@ -30,9 +40,9 @@ describe('buildStakingTransactionParams', () => {
30
40
  valAddress: '0xDisplayAddressIgnoredByEncoder',
31
41
  })
32
42
 
33
- const { to, data, value } = buildStakingTransactionParams('monad', intent)
43
+ const { to, data, value } = buildStakingTransactionParams(monadConfig, intent)
34
44
 
35
- const iface = new ethers.Interface(getStakingABI('monad') ?? [])
45
+ const iface = new ethers.Interface(getStakingABI(CHAIN_ID.MONAD) ?? [])
36
46
  expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('delegate', [42n]))
37
47
  expect(to).toEqual('0x0000000000000000000000000000000000001000')
38
48
  expect(value).toEqual(1000000000000000000n)
@@ -46,9 +56,9 @@ describe('buildStakingTransactionParams', () => {
46
56
  valAddress: '0xDisplayAddressIgnoredByEncoder',
47
57
  })
48
58
 
49
- const { to, data, value } = buildStakingTransactionParams('monad', intent)
59
+ const { to, data, value } = buildStakingTransactionParams(monadConfig, intent)
50
60
 
51
- const iface = new ethers.Interface(getStakingABI('monad') ?? [])
61
+ const iface = new ethers.Interface(getStakingABI(CHAIN_ID.MONAD) ?? [])
52
62
  expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('compound', [42n]))
53
63
  expect(to).toEqual('0x0000000000000000000000000000000000001000')
54
64
  expect(value).toEqual(0n)
@@ -56,7 +66,7 @@ describe('buildStakingTransactionParams', () => {
56
66
 
57
67
  it('throws when a Monad delegate intent has no valId', () => {
58
68
  expect(() => {
59
- buildStakingTransactionParams('monad', delegateIntent({}))
69
+ buildStakingTransactionParams(monadConfig, delegateIntent({}))
60
70
  }).toThrow('monad staking requires valId')
61
71
  })
62
72
 
@@ -68,9 +78,9 @@ describe('buildStakingTransactionParams', () => {
68
78
  valAddress: '0xDisplayAddressIgnoredByEncoder',
69
79
  })
70
80
 
71
- const { to, data, value } = buildStakingTransactionParams('monad', intent)
81
+ const { to, data, value } = buildStakingTransactionParams(monadConfig, intent)
72
82
 
73
- const iface = new ethers.Interface(getStakingABI('monad') ?? [])
83
+ const iface = new ethers.Interface(getStakingABI(CHAIN_ID.MONAD) ?? [])
74
84
  expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('withdraw', [42n, 7n]))
75
85
  expect(to).toEqual('0x0000000000000000000000000000000000001000')
76
86
  expect(value).toEqual(0n)
@@ -78,7 +88,7 @@ describe('buildStakingTransactionParams', () => {
78
88
 
79
89
  it('throws when a Monad withdraw intent has no withdrawId', () => {
80
90
  expect(() => {
81
- buildStakingTransactionParams('monad', delegateIntent({ mode: 'withdraw', valId: '42' }))
91
+ buildStakingTransactionParams(monadConfig, delegateIntent({ mode: 'withdraw', valId: '42' }))
82
92
  }).toThrow('monad withdraw requires withdrawId')
83
93
  })
84
94
 
@@ -86,9 +96,9 @@ describe('buildStakingTransactionParams', () => {
86
96
  const valAddress = 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn'
87
97
  const intent = delegateIntent({ valAddress })
88
98
 
89
- const { to, data, value } = buildStakingTransactionParams('sei_evm', intent)
99
+ const { to, data, value } = buildStakingTransactionParams(seiConfig, intent)
90
100
 
91
- const iface = new ethers.Interface(getStakingABI('sei_evm') ?? [])
101
+ const iface = new ethers.Interface(getStakingABI(CHAIN_ID.SEI_EVM) ?? [])
92
102
  expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('delegate', [valAddress]))
93
103
  expect(to).toEqual('0x0000000000000000000000000000000000001005')
94
104
  expect(value).toEqual(1000000000000000000n)
@@ -98,18 +108,18 @@ describe('buildStakingTransactionParams', () => {
98
108
  const valAddress = 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn'
99
109
  const intent = delegateIntent({ mode: 'claimReward', valAddress })
100
110
 
101
- const { to } = buildStakingTransactionParams('sei_evm', intent)
111
+ const { to } = buildStakingTransactionParams(seiConfig, intent)
102
112
 
103
113
  expect(to).toEqual('0x0000000000000000000000000000000000001007')
104
114
  })
105
115
 
106
116
  it.each([
107
- ['sei_evm', { valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn' }],
108
- ['monad', { valId: '42', valAddress: '0xDisplayAddressIgnoredByEncoder' }],
109
- ])("ignores txValue for '%s'", (currencyId, fields) => {
117
+ ['sei_evm', seiConfig, { valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn' }],
118
+ ['monad', monadConfig, { valId: '42', valAddress: '0xDisplayAddressIgnoredByEncoder' }],
119
+ ])("ignores txValue for '%s'", (_name, evmConfig, fields) => {
110
120
  const intent = delegateIntent({ ...fields, txValue: 999n })
111
121
 
112
- const { value } = buildStakingTransactionParams(currencyId, intent)
122
+ const { value } = buildStakingTransactionParams(evmConfig, intent)
113
123
 
114
124
  expect(value).toEqual(1000000000000000000n)
115
125
  })
@@ -122,9 +132,9 @@ describe('0G / zero_gravity delegate', () => {
122
132
  sender: '0x0000000000000000000000000000000000000002',
123
133
  })
124
134
 
125
- const { to, data, value } = buildStakingTransactionParams('zero_gravity', intent)
135
+ const { to, data, value } = buildStakingTransactionParams(zeroGravityConfig, intent)
126
136
 
127
- const iface = new ethers.Interface(getStakingABI('zero_gravity') ?? [])
137
+ const iface = new ethers.Interface(getStakingABI(CHAIN_ID.ZERO_GRAVITY) ?? [])
128
138
  expect('0x' + data.toString('hex')).toEqual(
129
139
  iface.encodeFunctionData('delegate', ['0x0000000000000000000000000000000000000002'])
130
140
  )
@@ -134,14 +144,14 @@ describe('0G / zero_gravity delegate', () => {
134
144
 
135
145
  it('throws when valAddress is missing', () => {
136
146
  expect(() => {
137
- buildStakingTransactionParams('zero_gravity', delegateIntent({ valAddress: '' }))
147
+ buildStakingTransactionParams(zeroGravityConfig, delegateIntent({ valAddress: '' }))
138
148
  }).toThrow('0G staking requires a validator address')
139
149
  })
140
150
 
141
151
  it('throws when delegator is missing', () => {
142
152
  expect(() => {
143
153
  buildStakingTransactionParams(
144
- 'zero_gravity',
154
+ zeroGravityConfig,
145
155
  delegateIntent({ valAddress: '0x0000000000000000000000000000000000000001', sender: '' })
146
156
  )
147
157
  }).toThrow('zero_gravity staking requires delegator')
@@ -162,9 +172,9 @@ describe('0G / zero_gravity undelegate', () => {
162
172
  txValue: 50_000_000_000n,
163
173
  })
164
174
 
165
- const { to, data, value } = buildStakingTransactionParams('zero_gravity', intent)
175
+ const { to, data, value } = buildStakingTransactionParams(zeroGravityConfig, intent)
166
176
 
167
- const iface = new ethers.Interface(getStakingABI('zero_gravity') ?? [])
177
+ const iface = new ethers.Interface(getStakingABI(CHAIN_ID.ZERO_GRAVITY) ?? [])
168
178
  expect('0x' + data.toString('hex')).toEqual(
169
179
  iface.encodeFunctionData('undelegate', [DELEGATOR, 1_500_000_000n])
170
180
  )
@@ -175,7 +185,7 @@ describe('0G / zero_gravity undelegate', () => {
175
185
  it('throws when shares is missing', () => {
176
186
  expect(() => {
177
187
  buildStakingTransactionParams(
178
- 'zero_gravity',
188
+ zeroGravityConfig,
179
189
  delegateIntent({ mode: 'undelegate', valAddress: VAL })
180
190
  )
181
191
  }).toThrow('zero_gravity undelegate requires shares')
@@ -183,7 +193,7 @@ describe('0G / zero_gravity undelegate', () => {
183
193
  })
184
194
 
185
195
  describe('0G / zero_gravity contractAddress resolver', () => {
186
- const config = STAKING_CONTRACTS['zero_gravity']
196
+ const config = requireStakingContract(CHAIN_ID.ZERO_GRAVITY)
187
197
 
188
198
  it('returns valAddress when provided', () => {
189
199
  expect(config.contractAddress({ mode: 'delegate', valAddress: '0xValidatorAddr' })).toEqual(
@@ -203,7 +213,7 @@ describe('0G / zero_gravity contractAddress resolver', () => {
203
213
  })
204
214
 
205
215
  describe('0G / zero_gravity value resolver', () => {
206
- const config = STAKING_CONTRACTS['zero_gravity']
216
+ const config = requireStakingContract(CHAIN_ID.ZERO_GRAVITY)
207
217
 
208
218
  it.each([
209
219
  [{ mode: 'delegate', amount: 1000n }, 1000n],
@@ -1,6 +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
5
  import type { TransactionIntent, MemoNotSupported } from '@ledgerhq/coin-module-framework/api/index'
5
6
  import { isStakingIntent } from '../logic-public'
6
7
  import { isPayable } from './abis'
@@ -13,7 +14,7 @@ import { buildTransactionParams } from './operations'
13
14
  * Builds transaction parameters for staking transactions
14
15
  */
15
16
  export function buildStakingTransactionParams(
16
- currencyId: string,
17
+ evmConfig: EvmConfigInfo,
17
18
  intent: TransactionIntent<MemoNotSupported>
18
19
  ): {
19
20
  to: string
@@ -27,16 +28,16 @@ export function buildStakingTransactionParams(
27
28
  const { amount, sender, mode, valAddress, valId, dstValAddress, withdrawId, txValue, shares } =
28
29
  intent
29
30
 
30
- const config = STAKING_CONTRACTS[currencyId]
31
+ const config = STAKING_CONTRACTS[evmConfig.chainId]
31
32
  if (!config) {
32
- throw new Error(`Unsupported staking currency: ${currencyId}`)
33
+ throw new Error(`Unsupported staking currency: ${evmConfig.name}`)
33
34
  }
34
35
 
35
36
  if (!mode || !isStakingOperation(mode)) {
36
37
  throw new Error(`Invalid staking operation: ${mode}`)
37
38
  }
38
39
 
39
- const stakingParams = buildTransactionParams(currencyId, mode, {
40
+ const stakingParams = buildTransactionParams(evmConfig, mode, {
40
41
  valAddress,
41
42
  valId,
42
43
  amount,
@@ -49,7 +50,7 @@ export function buildStakingTransactionParams(
49
50
  const to = config.contractAddress({ mode, valAddress })
50
51
  const data = Buffer.from(
51
52
  encodeStakingData({
52
- currencyId,
53
+ evmConfig,
53
54
  operation: mode,
54
55
  config,
55
56
  params: stakingParams,
@@ -62,7 +63,7 @@ export function buildStakingTransactionParams(
62
63
  throw new Error(`No function mapping found for the operation: ${mode}`)
63
64
  }
64
65
 
65
- const value = isPayable(currencyId, functionName)
66
+ const value = isPayable(evmConfig.chainId, functionName)
66
67
  ? config.value({ mode, amount, ...(typeof txValue === 'bigint' ? { txValue } : {}) })
67
68
  : 0n
68
69