@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
@@ -1,9 +1,10 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
4
+ import type { ChainId, EvmConfigInfo } from '../config'
5
5
  import type { Stake } from '@ledgerhq/coin-module-framework/api/types'
6
6
  import { ethers } from 'ethers'
7
+ import { CHAIN_ID } from '../config'
7
8
  import { isExternalNodeConfig } from '../network/node/types'
8
9
  import { getStakingABI } from './abis'
9
10
  import { STAKING_CONTRACTS } from './contracts'
@@ -11,10 +12,10 @@ import { getCosmosAddr } from './redelegations'
11
12
 
12
13
  type RedelegationLike = { validatorDstAddress: string; completionDate: Date }
13
14
 
14
- export function canUndelegate(stake: Stake, currencyId: string): boolean {
15
+ export function canUndelegate(stake: Stake, chainId: ChainId): boolean {
15
16
  // An activating stake is not yet in the active set, so it cannot be undelegated.
16
17
  if (stake.state === 'activating') return false
17
- const chainCanUndelegate = STAKING_CONTRACTS[currencyId]?.canUndelegate
18
+ const chainCanUndelegate = STAKING_CONTRACTS[chainId]?.canUndelegate
18
19
  if (chainCanUndelegate) return chainCanUndelegate(stake)
19
20
  return true
20
21
  }
@@ -38,13 +39,13 @@ export function canDelegate(spendableBalance: bigint): boolean {
38
39
  export function canRedelegate(
39
40
  stake: Stake,
40
41
  activeRedelegations: RedelegationLike[],
41
- currencyId: string
42
+ chainId: ChainId
42
43
  ): boolean {
43
44
  // The chain must expose a redelegate precompile function; without it the
44
45
  // transaction will always fail, so the UI action should be hidden entirely.
45
- if (!STAKING_CONTRACTS[currencyId]?.functions.redelegate) return false
46
+ if (!STAKING_CONTRACTS[chainId]?.functions.redelegate) return false
46
47
 
47
- const maxRedelegations = STAKING_CONTRACTS[currencyId]?.maxRedelegations
48
+ const maxRedelegations = STAKING_CONTRACTS[chainId]?.maxRedelegations
48
49
  if (maxRedelegations !== undefined && activeRedelegations.length >= maxRedelegations) return false
49
50
 
50
51
  // Cannot redelegate FROM a validator that currently holds an active incoming
@@ -53,10 +54,10 @@ export function canRedelegate(
53
54
  return !activeRedelegations.some((rd) => rd.validatorDstAddress === stake.delegate)
54
55
  }
55
56
 
56
- export function canCompound(stake: Stake, currencyId: string): boolean {
57
+ export function canCompound(stake: Stake, chainId: ChainId): boolean {
57
58
  // The chain must expose a compound precompile function; without it the
58
59
  // transaction will always fail, so the UI option should be hidden entirely.
59
- if (!STAKING_CONTRACTS[currencyId]?.functions.compoundReward) return false
60
+ if (!STAKING_CONTRACTS[chainId]?.functions.compoundReward) return false
60
61
 
61
62
  // Compounding restakes accrued rewards, so it only makes sense when there is
62
63
  // something to restake.
@@ -84,12 +85,11 @@ export function parseAmountStringToNumber(amountString: string, unitCode: string
84
85
  */
85
86
  export async function isSeiAccountUnassociated(
86
87
  config: EvmConfigInfo,
87
- currencyId: string,
88
88
  freshAddress: string
89
89
  ): Promise<boolean> {
90
- if (currencyId !== 'sei_evm') return false
90
+ if (config.chainId !== CHAIN_ID.SEI_EVM) return false
91
91
 
92
- const precompile = STAKING_CONTRACTS[currencyId]?.apiConfig?.precompileAddress
92
+ const precompile = STAKING_CONTRACTS[config.chainId]?.apiConfig?.precompileAddress
93
93
  if (!precompile) return false
94
94
 
95
95
  // Resolve the RPC endpoint. A missing/non-external config means we cannot
@@ -116,12 +116,12 @@ export async function isSeiAccountUnassociated(
116
116
  * absent or malformed so callers can fall back gracefully.
117
117
  */
118
118
  export function decodeRedelegatePayload(
119
- currencyId: string,
119
+ chainId: ChainId,
120
120
  contractPayload: string
121
121
  ): { srcValidatorAddress: string; dstValidatorAddress: string } | null {
122
- const config = STAKING_CONTRACTS[currencyId]
122
+ const config = STAKING_CONTRACTS[chainId]
123
123
  const functionName = config?.functions.redelegate
124
- const abi = getStakingABI(currencyId)
124
+ const abi = getStakingABI(chainId)
125
125
  if (!abi || !functionName) return null
126
126
  try {
127
127
  const iface = new ethers.Interface(abi)
@@ -1,9 +1,15 @@
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 { StakingOperation } from '../../types/staking'
6
+ import { CHAIN_ID } from '../../config'
7
+ import { createMockEvmConfigInfo, mkExternalNode } from '../../fixtures/context.fixtures'
5
8
  import { buildTransactionParams } from '.'
6
9
 
10
+ const mkConfig = (chainId: ChainId, name: string) =>
11
+ createMockEvmConfigInfo({ chainId, name, node: mkExternalNode() })
12
+
7
13
  describe('buildTransactionParams', () => {
8
14
  const validatorAddress = 'seivaloper1abc123'
9
15
  // 1 SEI expressed in the EVM-native unit (18 decimals). The precompile
@@ -15,10 +21,10 @@ describe('buildTransactionParams', () => {
15
21
  const delegatorAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
16
22
 
17
23
  describe('SEI Network', () => {
18
- const currencyId = 'sei_evm'
24
+ const evmConfig = mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm')
19
25
 
20
26
  it('should build params for delegate operation', () => {
21
- const params = buildTransactionParams(currencyId, 'delegate', {
27
+ const params = buildTransactionParams(evmConfig, 'delegate', {
22
28
  valAddress: validatorAddress,
23
29
  amount,
24
30
  })
@@ -27,7 +33,7 @@ describe('buildTransactionParams', () => {
27
33
  })
28
34
 
29
35
  it('should build params for undelegate operation (amount converted from 18-dec EVM to 6-dec usei)', () => {
30
- const params = buildTransactionParams(currencyId, 'undelegate', {
36
+ const params = buildTransactionParams(evmConfig, 'undelegate', {
31
37
  valAddress: validatorAddress,
32
38
  amount,
33
39
  })
@@ -36,7 +42,7 @@ describe('buildTransactionParams', () => {
36
42
  })
37
43
 
38
44
  it('should build params for redelegate operation (amount converted from 18-dec EVM to 6-dec usei)', () => {
39
- const params = buildTransactionParams(currencyId, 'redelegate', {
45
+ const params = buildTransactionParams(evmConfig, 'redelegate', {
40
46
  valAddress: validatorAddress,
41
47
  amount,
42
48
  dstValAddress: dstValidatorAddress,
@@ -47,7 +53,7 @@ describe('buildTransactionParams', () => {
47
53
 
48
54
  it('should truncate sub-usei precision on undelegate (precompile has 6-decimal precision)', () => {
49
55
  // 1.234567891 SEI -> truncated to 1.234567 uSEI (9th and later decimals dropped)
50
- const params = buildTransactionParams(currencyId, 'undelegate', {
56
+ const params = buildTransactionParams(evmConfig, 'undelegate', {
51
57
  valAddress: validatorAddress,
52
58
  amount: 1234567891000000000n,
53
59
  })
@@ -57,7 +63,7 @@ describe('buildTransactionParams', () => {
57
63
 
58
64
  it('should throw error for redelegate without dstValAddress', () => {
59
65
  expect(() => {
60
- buildTransactionParams(currencyId, 'redelegate', {
66
+ buildTransactionParams(evmConfig, 'redelegate', {
61
67
  valAddress: validatorAddress,
62
68
  amount,
63
69
  })
@@ -65,7 +71,7 @@ describe('buildTransactionParams', () => {
65
71
  })
66
72
 
67
73
  it('should build params for getStakedBalance operation', () => {
68
- const params = buildTransactionParams(currencyId, 'getStakedBalance', {
74
+ const params = buildTransactionParams(evmConfig, 'getStakedBalance', {
69
75
  valAddress: validatorAddress,
70
76
  amount,
71
77
  dstValAddress: validatorAddress,
@@ -77,7 +83,7 @@ describe('buildTransactionParams', () => {
77
83
 
78
84
  it('should throw error for getStakedBalance without required params', () => {
79
85
  expect(() => {
80
- buildTransactionParams(currencyId, 'getStakedBalance', {
86
+ buildTransactionParams(evmConfig, 'getStakedBalance', {
81
87
  valAddress: validatorAddress,
82
88
  amount,
83
89
  })
@@ -86,7 +92,7 @@ describe('buildTransactionParams', () => {
86
92
 
87
93
  it('should return the correct params for a claim rewards', () => {
88
94
  const transactionType: StakingOperation = 'claimReward'
89
- const params = buildTransactionParams(currencyId, transactionType, {
95
+ const params = buildTransactionParams(evmConfig, transactionType, {
90
96
  valAddress: validatorAddress,
91
97
  amount,
92
98
  })
@@ -96,8 +102,10 @@ describe('buildTransactionParams', () => {
96
102
  })
97
103
 
98
104
  describe('Monad', () => {
105
+ const evmConfig = mkConfig(CHAIN_ID.MONAD, 'monad')
106
+
99
107
  it('builds params for delegate operation (valId as bigint, amount carried by msg.value)', () => {
100
- const params = buildTransactionParams('monad', 'delegate', {
108
+ const params = buildTransactionParams(evmConfig, 'delegate', {
101
109
  valId: '42',
102
110
  amount: 1000000000000000000n,
103
111
  })
@@ -106,7 +114,7 @@ describe('buildTransactionParams', () => {
106
114
  })
107
115
 
108
116
  it('builds params for claimReward operation (valId as bigint)', () => {
109
- const params = buildTransactionParams('monad', 'claimReward', {
117
+ const params = buildTransactionParams(evmConfig, 'claimReward', {
110
118
  valId: '42',
111
119
  amount: 0n,
112
120
  })
@@ -115,7 +123,7 @@ describe('buildTransactionParams', () => {
115
123
  })
116
124
 
117
125
  it('builds params for compoundReward operation (valId as bigint)', () => {
118
- const params = buildTransactionParams('monad', 'compoundReward', {
126
+ const params = buildTransactionParams(evmConfig, 'compoundReward', {
119
127
  valId: '42',
120
128
  amount: 0n,
121
129
  })
@@ -125,14 +133,14 @@ describe('buildTransactionParams', () => {
125
133
 
126
134
  it('throws when monad staking is missing valId', () => {
127
135
  expect(() => {
128
- buildTransactionParams('monad', 'delegate', {
136
+ buildTransactionParams(evmConfig, 'delegate', {
129
137
  amount: 1000000000000000000n,
130
138
  })
131
139
  }).toThrow('monad staking requires valId')
132
140
  })
133
141
 
134
142
  it('builds params for undelegate operation (valId, amount, withdrawId as bigints)', () => {
135
- const params = buildTransactionParams('monad', 'undelegate', {
143
+ const params = buildTransactionParams(evmConfig, 'undelegate', {
136
144
  valId: '42',
137
145
  amount: 1000000000000000000n,
138
146
  withdrawId: '7',
@@ -143,7 +151,7 @@ describe('buildTransactionParams', () => {
143
151
 
144
152
  it('throws when monad undelegate is missing withdrawId', () => {
145
153
  expect(() => {
146
- buildTransactionParams('monad', 'undelegate', {
154
+ buildTransactionParams(evmConfig, 'undelegate', {
147
155
  valId: '42',
148
156
  amount: 1000000000000000000n,
149
157
  })
@@ -151,7 +159,7 @@ describe('buildTransactionParams', () => {
151
159
  })
152
160
 
153
161
  it('builds params for withdraw operation (valId, withdrawId as bigints)', () => {
154
- const params = buildTransactionParams('monad', 'withdraw', {
162
+ const params = buildTransactionParams(evmConfig, 'withdraw', {
155
163
  valId: '42',
156
164
  amount: 0n,
157
165
  withdrawId: '7',
@@ -162,7 +170,7 @@ describe('buildTransactionParams', () => {
162
170
 
163
171
  it('throws when monad withdraw is missing withdrawId', () => {
164
172
  expect(() => {
165
- buildTransactionParams('monad', 'withdraw', {
173
+ buildTransactionParams(evmConfig, 'withdraw', {
166
174
  valId: '42',
167
175
  amount: 0n,
168
176
  })
@@ -171,11 +179,11 @@ describe('buildTransactionParams', () => {
171
179
  })
172
180
 
173
181
  describe('CELO', () => {
174
- const currencyId = 'celo'
182
+ const evmConfig = mkConfig(CHAIN_ID.CELO, 'celo')
175
183
  const celoValidatorAddress = '0x123456789abcdef'
176
184
 
177
185
  it('should build params for delegate operation', () => {
178
- const params = buildTransactionParams(currencyId, 'delegate', {
186
+ const params = buildTransactionParams(evmConfig, 'delegate', {
179
187
  valAddress: celoValidatorAddress,
180
188
  amount,
181
189
  })
@@ -184,7 +192,7 @@ describe('buildTransactionParams', () => {
184
192
  })
185
193
 
186
194
  it('should build params for undelegate operation', () => {
187
- const params = buildTransactionParams(currencyId, 'undelegate', {
195
+ const params = buildTransactionParams(evmConfig, 'undelegate', {
188
196
  valAddress: celoValidatorAddress,
189
197
  amount,
190
198
  })
@@ -194,7 +202,7 @@ describe('buildTransactionParams', () => {
194
202
 
195
203
  it('should throw error for redelegate operation (not supported)', () => {
196
204
  expect(() => {
197
- buildTransactionParams(currencyId, 'redelegate', {
205
+ buildTransactionParams(evmConfig, 'redelegate', {
198
206
  valAddress: celoValidatorAddress,
199
207
  amount,
200
208
  })
@@ -202,7 +210,7 @@ describe('buildTransactionParams', () => {
202
210
  })
203
211
 
204
212
  it('should build params for getStakedBalance operation', () => {
205
- const params = buildTransactionParams(currencyId, 'getStakedBalance', {
213
+ const params = buildTransactionParams(evmConfig, 'getStakedBalance', {
206
214
  valAddress: celoValidatorAddress,
207
215
  amount,
208
216
  })
@@ -211,7 +219,7 @@ describe('buildTransactionParams', () => {
211
219
  })
212
220
 
213
221
  it('should build params for getUnstakedBalance operation', () => {
214
- const params = buildTransactionParams(currencyId, 'getUnstakedBalance', {
222
+ const params = buildTransactionParams(evmConfig, 'getUnstakedBalance', {
215
223
  valAddress: celoValidatorAddress,
216
224
  amount,
217
225
  })
@@ -221,11 +229,11 @@ describe('buildTransactionParams', () => {
221
229
  })
222
230
 
223
231
  describe('Somnia', () => {
224
- const currencyId = 'somnia'
232
+ const evmConfig = mkConfig(CHAIN_ID.SOMNIA, 'somnia')
225
233
  const somniaValidatorAddress = '0x1234567890abcdef1234567890abcdef12345678'
226
234
 
227
235
  it('builds params for delegate operation', () => {
228
- const params = buildTransactionParams(currencyId, 'delegate', {
236
+ const params = buildTransactionParams(evmConfig, 'delegate', {
229
237
  valAddress: somniaValidatorAddress,
230
238
  amount,
231
239
  })
@@ -234,7 +242,7 @@ describe('buildTransactionParams', () => {
234
242
  })
235
243
 
236
244
  it('builds params for undelegate operation', () => {
237
- const params = buildTransactionParams(currencyId, 'undelegate', {
245
+ const params = buildTransactionParams(evmConfig, 'undelegate', {
238
246
  valAddress: somniaValidatorAddress,
239
247
  amount,
240
248
  })
@@ -243,7 +251,7 @@ describe('buildTransactionParams', () => {
243
251
  })
244
252
 
245
253
  it('builds params for claimReward operation', () => {
246
- const params = buildTransactionParams(currencyId, 'claimReward', {
254
+ const params = buildTransactionParams(evmConfig, 'claimReward', {
247
255
  valAddress: somniaValidatorAddress,
248
256
  amount: 0n,
249
257
  })
@@ -252,7 +260,7 @@ describe('buildTransactionParams', () => {
252
260
  })
253
261
 
254
262
  it('builds params for getStakedBalance operation', () => {
255
- const params = buildTransactionParams(currencyId, 'getStakedBalance', {
263
+ const params = buildTransactionParams(evmConfig, 'getStakedBalance', {
256
264
  valAddress: somniaValidatorAddress,
257
265
  amount: 0n,
258
266
  delegator: delegatorAddress,
@@ -263,7 +271,7 @@ describe('buildTransactionParams', () => {
263
271
 
264
272
  it('throws when getStakedBalance is missing delegator', () => {
265
273
  expect(() => {
266
- buildTransactionParams(currencyId, 'getStakedBalance', {
274
+ buildTransactionParams(evmConfig, 'getStakedBalance', {
267
275
  valAddress: somniaValidatorAddress,
268
276
  amount: 0n,
269
277
  })
@@ -274,7 +282,7 @@ describe('buildTransactionParams', () => {
274
282
  describe('Error handling', () => {
275
283
  it('should throw error for unsupported currency', () => {
276
284
  expect(() => {
277
- buildTransactionParams('unsupported_currency', 'delegate', {
285
+ buildTransactionParams(mkConfig(CHAIN_ID.ETHEREUM, 'unsupported_currency'), 'delegate', {
278
286
  valAddress: validatorAddress,
279
287
  amount,
280
288
  })
@@ -284,20 +292,21 @@ describe('buildTransactionParams', () => {
284
292
  it('should throw error for unsupported operation type', () => {
285
293
  expect(() => {
286
294
  // @ts-expect-error invalid operation
287
- buildTransactionParams('sei_evm', 'invalidOperation', {
295
+ buildTransactionParams(mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm'), 'invalidOperation', {
288
296
  valAddress: validatorAddress,
289
297
  amount,
290
298
  })
291
299
  }).toThrow('Unsupported transaction type for sei_evm: invalidOperation')
292
300
  })
293
301
 
294
- it.each(['sei_evm', 'celo', 'somnia'])(
295
- 'throws when %s staking is missing valAddress',
296
- (currencyId) => {
297
- expect(() => {
298
- buildTransactionParams(currencyId, 'delegate', { amount })
299
- }).toThrow(`${currencyId} staking requires valAddress`)
300
- }
301
- )
302
+ it.each([
303
+ ['sei_evm', CHAIN_ID.SEI_EVM],
304
+ ['celo', CHAIN_ID.CELO],
305
+ ['somnia', CHAIN_ID.SOMNIA],
306
+ ])('throws when %s staking is missing valAddress', (name, chainId) => {
307
+ expect(() => {
308
+ buildTransactionParams(mkConfig(chainId, name), 'delegate', { amount })
309
+ }).toThrow(`${name} staking requires valAddress`)
310
+ })
302
311
  })
303
312
  })
@@ -1,8 +1,10 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { ChainId, EvmConfigInfo } from '../../config'
4
5
  import type { StakingOperation } from '../../types/staking'
5
6
  import type { OperationParams, StakingProtocol } from './types'
7
+ import { CHAIN_ID } from '../../config'
6
8
  import celoProtocol from './celo'
7
9
  import monadProtocol from './monad'
8
10
  import seiProtocol from './sei'
@@ -10,25 +12,25 @@ import somniaProtocol from './somnia'
10
12
  import zeroGravityProtocol from './zero_gravity'
11
13
 
12
14
  const STAKING_PROTOCOLS = {
13
- sei_evm: seiProtocol,
14
- celo: celoProtocol,
15
- monad: monadProtocol,
16
- zero_gravity: zeroGravityProtocol,
17
- somnia: somniaProtocol,
15
+ [CHAIN_ID.SEI_EVM]: seiProtocol,
16
+ [CHAIN_ID.CELO]: celoProtocol,
17
+ [CHAIN_ID.MONAD]: monadProtocol,
18
+ [CHAIN_ID.ZERO_GRAVITY]: zeroGravityProtocol,
19
+ [CHAIN_ID.SOMNIA]: somniaProtocol,
18
20
  }
19
21
 
20
22
  function isStakingProtocol(value: object): value is StakingProtocol {
21
23
  return Object.values(value).every((entry) => typeof entry === 'function')
22
24
  }
23
25
 
24
- function stakingProtocolFor(currencyId: string): StakingProtocol | undefined {
25
- switch (currencyId) {
26
- case 'sei_evm':
27
- case 'celo':
28
- case 'monad':
29
- case 'zero_gravity':
30
- case 'somnia': {
31
- const protocol = STAKING_PROTOCOLS[currencyId]
26
+ function stakingProtocolFor(chainId: ChainId): StakingProtocol | undefined {
27
+ switch (chainId) {
28
+ case CHAIN_ID.SEI_EVM:
29
+ case CHAIN_ID.CELO:
30
+ case CHAIN_ID.MONAD:
31
+ case CHAIN_ID.ZERO_GRAVITY:
32
+ case CHAIN_ID.SOMNIA: {
33
+ const protocol = STAKING_PROTOCOLS[chainId]
32
34
  return isStakingProtocol(protocol) ? protocol : undefined
33
35
  }
34
36
  default:
@@ -36,47 +38,48 @@ function stakingProtocolFor(currencyId: string): StakingProtocol | undefined {
36
38
  }
37
39
  }
38
40
 
39
- const REQUIRES_VAL_ADDRESS = new Set(['celo', 'sei_evm', 'somnia'])
41
+ const REQUIRES_VAL_ADDRESS = new Set<ChainId>([CHAIN_ID.CELO, CHAIN_ID.SEI_EVM, CHAIN_ID.SOMNIA])
40
42
 
41
43
  export const buildTransactionParams = (
42
- currencyId: string,
44
+ evmConfig: EvmConfigInfo,
43
45
  transactionType: StakingOperation,
44
46
  params: OperationParams
45
47
  ): Array<string | bigint> => {
46
- const protocol = stakingProtocolFor(currencyId)
48
+ const { chainId, name } = evmConfig
49
+ const protocol = stakingProtocolFor(chainId)
47
50
  if (!protocol) {
48
- throw new Error(`Unsupported staking currency: ${currencyId}`)
51
+ throw new Error(`Unsupported staking currency: ${name}`)
49
52
  }
50
53
 
51
54
  const operation = protocol[transactionType]
52
55
  if (!operation) {
53
- throw new Error(`Unsupported transaction type for ${currencyId}: ${transactionType}`)
56
+ throw new Error(`Unsupported transaction type for ${name}: ${transactionType}`)
54
57
  }
55
58
 
56
- if (!params.valAddress && REQUIRES_VAL_ADDRESS.has(currencyId)) {
57
- throw new Error(`${currencyId} staking requires valAddress`)
59
+ if (!params.valAddress && REQUIRES_VAL_ADDRESS.has(chainId)) {
60
+ throw new Error(`${name} staking requires valAddress`)
58
61
  }
59
62
 
60
- if (!params.valId && currencyId === 'monad') {
61
- throw new Error(`${currencyId} staking requires valId`)
63
+ if (!params.valId && chainId === CHAIN_ID.MONAD) {
64
+ throw new Error(`${name} staking requires valId`)
62
65
  }
63
66
 
64
- if (!params.delegator && currencyId === 'zero_gravity') {
65
- throw new Error(`${currencyId} staking requires delegator`)
67
+ if (!params.delegator && chainId === CHAIN_ID.ZERO_GRAVITY) {
68
+ throw new Error(`${name} staking requires delegator`)
66
69
  }
67
70
 
68
- if (currencyId === 'zero_gravity' && transactionType === 'undelegate') {
71
+ if (chainId === CHAIN_ID.ZERO_GRAVITY && transactionType === 'undelegate') {
69
72
  if (params.shares === undefined || params.shares < 1_000_000_000n) {
70
- throw new Error(`${currencyId} undelegate requires shares`)
73
+ throw new Error(`${name} undelegate requires shares`)
71
74
  }
72
75
  }
73
76
 
74
77
  if (
75
78
  params.withdrawId === undefined &&
76
- currencyId === 'monad' &&
79
+ chainId === CHAIN_ID.MONAD &&
77
80
  (transactionType === 'undelegate' || transactionType === 'withdraw')
78
81
  ) {
79
- throw new Error(`${currencyId} ${transactionType} requires withdrawId`)
82
+ throw new Error(`${name} ${transactionType} requires withdrawId`)
80
83
  }
81
84
 
82
85
  return operation(params)
@@ -7,6 +7,7 @@ import type { TransactionRequest } from 'ethers'
7
7
  import { createStakingTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
8
8
  import { ethers } from 'ethers'
9
9
  import zeroGravityAbi from '../abis/zero_gravity-validator.abi.json'
10
+ import { CHAIN_ID } from '../config'
10
11
  import { createMockEvmConfigInfo, mkExternalNode, testLogger } from '../fixtures/context.fixtures'
11
12
  import { withApi } from '../network/node/rpc.common'
12
13
  import { isExternalNodeConfig } from '../network/node/types'
@@ -20,7 +21,7 @@ const mockedWithApi = jest.mocked(withApi)
20
21
  const mockedIsExternalNodeConfig = jest.mocked(isExternalNodeConfig)
21
22
 
22
23
  const mockConfig = createMockEvmConfigInfo({
23
- chainId: 1,
24
+ chainId: CHAIN_ID.ZERO_GRAVITY,
24
25
  node: mkExternalNode({ uri: 'https://zero-gravity.coin.ledger.com' }),
25
26
  })
26
27
 
@@ -65,7 +66,7 @@ function makeCallHandler(options: {
65
66
  }
66
67
 
67
68
  function setupProvider(callHandler: ReturnType<typeof jest.fn>) {
68
- mockedWithApi.mockImplementation(async (_config, _currencyId, fn) =>
69
+ mockedWithApi.mockImplementation(async (_config, fn) =>
69
70
  fn(Object.assign(Object.create(null), { call: callHandler }))
70
71
  )
71
72
  }
@@ -87,7 +88,6 @@ describe('prepareStakingIntent / zero_gravity', () => {
87
88
 
88
89
  const result = await prepareStakingIntent(
89
90
  mockConfig,
90
- 'zero_gravity',
91
91
  makeIntent({ useAllAmount: false }),
92
92
  testLogger
93
93
  )
@@ -99,12 +99,7 @@ describe('prepareStakingIntent / zero_gravity', () => {
99
99
  setupProvider(makeCallHandler({ getDelegationShares: 0n }))
100
100
 
101
101
  await expect(
102
- prepareStakingIntent(
103
- mockConfig,
104
- 'zero_gravity',
105
- makeIntent({ useAllAmount: false }),
106
- testLogger
107
- )
102
+ prepareStakingIntent(mockConfig, makeIntent({ useAllAmount: false }), testLogger)
108
103
  ).rejects.toThrow('no shares to undelegate from this validator')
109
104
  })
110
105
 
@@ -119,7 +114,6 @@ describe('prepareStakingIntent / zero_gravity', () => {
119
114
 
120
115
  const result = await prepareStakingIntent(
121
116
  mockConfig,
122
- 'zero_gravity',
123
117
  makeIntent({ useAllAmount: false }),
124
118
  testLogger
125
119
  )
@@ -138,7 +132,6 @@ describe('prepareStakingIntent / zero_gravity', () => {
138
132
 
139
133
  const result = await prepareStakingIntent(
140
134
  mockConfig,
141
- 'zero_gravity',
142
135
  makeIntent({ useAllAmount: false }),
143
136
  testLogger
144
137
  )
@@ -156,12 +149,7 @@ describe('prepareStakingIntent / zero_gravity', () => {
156
149
  )
157
150
 
158
151
  await expect(
159
- prepareStakingIntent(
160
- mockConfig,
161
- 'zero_gravity',
162
- makeIntent({ useAllAmount: false }),
163
- testLogger
164
- )
152
+ prepareStakingIntent(mockConfig, makeIntent({ useAllAmount: false }), testLogger)
165
153
  ).rejects.toThrow('requested amount exceeds delegated shares')
166
154
  })
167
155
 
@@ -175,12 +163,7 @@ describe('prepareStakingIntent / zero_gravity', () => {
175
163
  )
176
164
 
177
165
  await expect(
178
- prepareStakingIntent(
179
- mockConfig,
180
- 'zero_gravity',
181
- makeIntent({ useAllAmount: false }),
182
- testLogger
183
- )
166
+ prepareStakingIntent(mockConfig, makeIntent({ useAllAmount: false }), testLogger)
184
167
  ).rejects.toThrow('shares below 0G contract minimum')
185
168
  })
186
169
 
@@ -189,7 +172,6 @@ describe('prepareStakingIntent / zero_gravity', () => {
189
172
 
190
173
  const result = await prepareStakingIntent(
191
174
  mockConfig,
192
- 'zero_gravity',
193
175
  makeIntent({ useAllAmount: true }),
194
176
  testLogger
195
177
  )
@@ -198,12 +180,7 @@ describe('prepareStakingIntent / zero_gravity', () => {
198
180
  })
199
181
 
200
182
  it('is a no-op when shares is already set', async () => {
201
- const result = await prepareStakingIntent(
202
- mockConfig,
203
- 'zero_gravity',
204
- makeIntent({ shares: 42n }),
205
- testLogger
206
- )
183
+ const result = await prepareStakingIntent(mockConfig, makeIntent({ shares: 42n }), testLogger)
207
184
 
208
185
  expect(result).toMatchObject({
209
186
  mode: 'undelegate',
@@ -216,7 +193,6 @@ describe('prepareStakingIntent / zero_gravity', () => {
216
193
  it('is a no-op when mode is not undelegate', async () => {
217
194
  const result = await prepareStakingIntent(
218
195
  mockConfig,
219
- 'zero_gravity',
220
196
  makeIntent({ mode: 'delegate' }),
221
197
  testLogger
222
198
  )
@@ -231,7 +207,7 @@ describe('prepareStakingIntent / zero_gravity', () => {
231
207
  it('is a no-op when node is not external', async () => {
232
208
  mockedIsExternalNodeConfig.mockReturnValue(false)
233
209
 
234
- const result = await prepareStakingIntent(mockConfig, 'zero_gravity', makeIntent(), testLogger)
210
+ const result = await prepareStakingIntent(mockConfig, makeIntent(), testLogger)
235
211
 
236
212
  expect(result).toMatchObject({
237
213
  mode: 'undelegate',
@@ -240,8 +216,12 @@ describe('prepareStakingIntent / zero_gravity', () => {
240
216
  expect(mockedWithApi).not.toHaveBeenCalled()
241
217
  })
242
218
 
243
- it('is a no-op for unknown currencies', async () => {
244
- const result = await prepareStakingIntent(mockConfig, 'unknown_chain', makeIntent(), testLogger)
219
+ it('is a no-op for chains without an intent preparer', async () => {
220
+ const result = await prepareStakingIntent(
221
+ { ...mockConfig, chainId: CHAIN_ID.ETHEREUM },
222
+ makeIntent(),
223
+ testLogger
224
+ )
245
225
 
246
226
  expect(result).toMatchObject({
247
227
  mode: 'undelegate',