@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,23 +1,29 @@
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'
5
6
  import { ethers } from 'ethers'
6
- import { STAKING_CONTRACTS } from './contracts'
7
+ import { CHAIN_ID } from '../config'
8
+ import { createMockEvmConfigInfo, mkExternalNode } from '../fixtures/context.fixtures'
9
+ import { requireStakingContract } from '../fixtures/staking.fixtures'
7
10
  import { encodeStakingData, decodeStakingResult } from './encoder'
8
11
  import { extractSeiDelegation, getSeiDelegationAmount } from './utils'
9
12
 
13
+ const mkConfig = (chainId: ChainId, name: string) =>
14
+ createMockEvmConfigInfo({ chainId, name, node: mkExternalNode() })
15
+
10
16
  describe('encodeStakingData', () => {
11
17
  describe('SEI Network', () => {
12
- const currencyId = 'sei_evm'
13
- const config = STAKING_CONTRACTS[currencyId]
18
+ const evmConfig = mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm')
19
+ const config = requireStakingContract(CHAIN_ID.SEI_EVM)
14
20
 
15
21
  it('should encode delegate operation', () => {
16
22
  const validatorAddress = 'seivaloper1abc123'
17
23
  const params = [validatorAddress]
18
24
 
19
25
  const encoded = encodeStakingData({
20
- currencyId,
26
+ evmConfig,
21
27
  operation: 'delegate',
22
28
  config,
23
29
  params,
@@ -32,7 +38,7 @@ describe('encodeStakingData', () => {
32
38
  const params = [validatorAddress, amount]
33
39
 
34
40
  const encoded = encodeStakingData({
35
- currencyId,
41
+ evmConfig,
36
42
  operation: 'undelegate',
37
43
  config,
38
44
  params,
@@ -48,7 +54,7 @@ describe('encodeStakingData', () => {
48
54
  const params = [srcAddress, dstAddress, amount]
49
55
 
50
56
  const encoded = encodeStakingData({
51
- currencyId,
57
+ evmConfig,
52
58
  operation: 'redelegate',
53
59
  config,
54
60
  params,
@@ -63,7 +69,7 @@ describe('encodeStakingData', () => {
63
69
  const params = [validatorAddress]
64
70
 
65
71
  const encoded = encodeStakingData({
66
- currencyId,
72
+ evmConfig,
67
73
  operation,
68
74
  config,
69
75
  params,
@@ -74,8 +80,8 @@ describe('encodeStakingData', () => {
74
80
  })
75
81
 
76
82
  describe('CELO', () => {
77
- const currencyId = 'celo'
78
- const config = STAKING_CONTRACTS[currencyId]
83
+ const evmConfig = mkConfig(CHAIN_ID.CELO, 'celo')
84
+ const config = requireStakingContract(CHAIN_ID.CELO)
79
85
 
80
86
  it('should encode delegate operation', () => {
81
87
  const account = '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d'
@@ -83,7 +89,7 @@ describe('encodeStakingData', () => {
83
89
  const params = [account, value]
84
90
 
85
91
  const encoded = encodeStakingData({
86
- currencyId,
92
+ evmConfig,
87
93
  operation: 'delegate',
88
94
  config,
89
95
  params,
@@ -98,7 +104,7 @@ describe('encodeStakingData', () => {
98
104
  const params = [account, value]
99
105
 
100
106
  const encoded = encodeStakingData({
101
- currencyId,
107
+ evmConfig,
102
108
  operation: 'undelegate',
103
109
  config,
104
110
  params,
@@ -109,12 +115,12 @@ describe('encodeStakingData', () => {
109
115
  })
110
116
 
111
117
  describe('Error handling', () => {
112
- const config = STAKING_CONTRACTS['sei_evm']
118
+ const config = requireStakingContract(CHAIN_ID.SEI_EVM)
113
119
 
114
120
  it('should throw error for unsupported currency', () => {
115
121
  expect(() => {
116
122
  encodeStakingData({
117
- currencyId: 'unsupported_currency',
123
+ evmConfig: mkConfig(CHAIN_ID.ETHEREUM, 'unsupported_currency'),
118
124
  operation: 'delegate',
119
125
  config,
120
126
  params: ['validator'],
@@ -125,7 +131,7 @@ describe('encodeStakingData', () => {
125
131
  it('should throw error for unsupported operation', () => {
126
132
  expect(() => {
127
133
  encodeStakingData({
128
- currencyId: 'sei_evm',
134
+ evmConfig: mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm'),
129
135
  // @ts-ignore — intentionally invalid operation to test error path
130
136
  operation: 'invalidOperation',
131
137
  config,
@@ -138,8 +144,8 @@ describe('encodeStakingData', () => {
138
144
 
139
145
  describe('decodeStakingResult', () => {
140
146
  describe('SEI Network', () => {
141
- const currencyId = 'sei_evm'
142
- const config = STAKING_CONTRACTS[currencyId]
147
+ const evmConfig = mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm')
148
+ const config = requireStakingContract(CHAIN_ID.SEI_EVM)
143
149
 
144
150
  it('should decode delegation result', () => {
145
151
  const mockBalance = {
@@ -198,7 +204,7 @@ describe('decodeStakingResult', () => {
198
204
  [mockBalance, mockDelegation],
199
205
  ])
200
206
 
201
- const decoded = decodeStakingResult(currencyId, 'getStakedBalance', config, encodedResult)
207
+ const decoded = decodeStakingResult(evmConfig, 'getStakedBalance', config, encodedResult)
202
208
 
203
209
  expect(decoded).toBeInstanceOf(Array)
204
210
  expect(decoded.length).toBeGreaterThan(0)
@@ -259,12 +265,7 @@ describe('decodeStakingResult', () => {
259
265
  ],
260
266
  ])
261
267
 
262
- const decoded = decodeStakingResult(
263
- 'sei_evm',
264
- 'getStakedBalance',
265
- STAKING_CONTRACTS['sei_evm'],
266
- encodedResult
267
- )
268
+ const decoded = decodeStakingResult(evmConfig, 'getStakedBalance', config, encodedResult)
268
269
 
269
270
  const delegation = extractSeiDelegation(decoded)
270
271
  expect(delegation?.balance.denom).toBe('usei')
@@ -275,18 +276,28 @@ describe('decodeStakingResult', () => {
275
276
  })
276
277
 
277
278
  describe('Error handling', () => {
278
- const config = STAKING_CONTRACTS['sei_evm']
279
+ const config = requireStakingContract(CHAIN_ID.SEI_EVM)
279
280
 
280
281
  it('should throw error for unsupported currency', () => {
281
282
  expect(() => {
282
- decodeStakingResult('unsupported_currency', 'getStakedBalance', config, '0x')
283
+ decodeStakingResult(
284
+ mkConfig(CHAIN_ID.ETHEREUM, 'unsupported_currency'),
285
+ 'getStakedBalance',
286
+ config,
287
+ '0x'
288
+ )
283
289
  }).toThrow('No ABI found for staking currency: unsupported_currency')
284
290
  })
285
291
 
286
292
  it('should throw error for unsupported operation', () => {
287
293
  expect(() => {
288
- // @ts-ignore — intentionally invalid operation to test error path
289
- decodeStakingResult('sei_evm', 'invalidOperation', config, '0x')
294
+ decodeStakingResult(
295
+ mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm'),
296
+ // @ts-ignore: intentionally invalid operation to test error path
297
+ 'invalidOperation',
298
+ config,
299
+ '0x'
300
+ )
290
301
  }).toThrow("Operation 'invalidOperation' not supported for currency: sei_evm")
291
302
  })
292
303
  })
@@ -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 {
5
6
  EncodeStakingDataParams,
6
7
  StakingContractConfig,
@@ -10,16 +11,16 @@ import { ethers } from 'ethers'
10
11
  import { getStakingABI } from './abis'
11
12
 
12
13
  export const encodeStakingData = (encodeParams: EncodeStakingDataParams): string => {
13
- const { currencyId, operation, config, params } = encodeParams
14
+ const { evmConfig, operation, config, params } = encodeParams
14
15
 
15
- const abi = getStakingABI(currencyId)
16
+ const abi = getStakingABI(evmConfig.chainId)
16
17
  if (!abi) {
17
- throw new Error(`No ABI found for staking currency: ${currencyId}`)
18
+ throw new Error(`No ABI found for staking currency: ${evmConfig.name}`)
18
19
  }
19
20
 
20
21
  const functionName = config.functions[operation]
21
22
  if (!functionName) {
22
- throw new Error(`Operation '${operation}' not supported for currency: ${currencyId}`)
23
+ throw new Error(`Operation '${operation}' not supported for currency: ${evmConfig.name}`)
23
24
  }
24
25
 
25
26
  const iface = new ethers.Interface(abi)
@@ -27,19 +28,19 @@ export const encodeStakingData = (encodeParams: EncodeStakingDataParams): string
27
28
  }
28
29
 
29
30
  export const decodeStakingResult = (
30
- currencyId: string,
31
+ evmConfig: EvmConfigInfo,
31
32
  operation: StakingOperation,
32
33
  config: StakingContractConfig,
33
34
  result: string
34
35
  ): ethers.Result => {
35
- const abi = getStakingABI(currencyId)
36
+ const abi = getStakingABI(evmConfig.chainId)
36
37
  if (!abi) {
37
- throw new Error(`No ABI found for staking currency: ${currencyId}`)
38
+ throw new Error(`No ABI found for staking currency: ${evmConfig.name}`)
38
39
  }
39
40
 
40
41
  const functionName = config.functions[operation]
41
42
  if (!functionName) {
42
- throw new Error(`Operation '${operation}' not supported for currency: ${currencyId}`)
43
+ throw new Error(`Operation '${operation}' not supported for currency: ${evmConfig.name}`)
43
44
  }
44
45
 
45
46
  const iface = new ethers.Interface(abi)
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
4
+ import type { ChainId, EvmConfigInfo } from '../config'
5
5
  import type {
6
6
  StakeCreate,
7
7
  StakingContractConfig,
@@ -11,6 +11,7 @@ import type {
11
11
  import type { Stake, Validator } from '@ledgerhq/coin-module-framework/api/types'
12
12
  import type { Logger } from '@ledgerhq/coin-module-framework/config'
13
13
  import { delay } from '@ledgerhq/coin-module-framework/promises'
14
+ import { CHAIN_ID } from '../config'
14
15
  import { withApi } from '../network/node/rpc.common'
15
16
  import { isExternalNodeConfig } from '../network/node/types'
16
17
  import { encodeStakingData, decodeStakingResult } from './encoder'
@@ -29,7 +30,6 @@ const createStakingFetcher = (
29
30
  getValidatorsFn: (
30
31
  evmConfig: EvmConfigInfo,
31
32
  config: StakingContractConfig,
32
- currencyId: string,
33
33
  logger: Logger
34
34
  ) => Promise<Validator[]>
35
35
  ) => {
@@ -37,60 +37,52 @@ const createStakingFetcher = (
37
37
  evmConfig: EvmConfigInfo,
38
38
  address: string,
39
39
  config: StakingContractConfig,
40
- currencyId: string,
41
40
  logger: Logger,
42
41
  _knownValIds?: string[]
43
42
  ): Promise<Stake[]> => {
44
- const validators = await getValidatorsFn(evmConfig, config, currencyId, logger)
43
+ const validators = await getValidatorsFn(evmConfig, config, logger)
45
44
  const validatorAddresses = validators.map((v) => v.address)
46
- return getStakesForValidators(
47
- evmConfig,
48
- address,
49
- config,
50
- currencyId,
51
- validatorAddresses,
52
- logger
53
- )
45
+ return getStakesForValidators(evmConfig, address, config, validatorAddresses, logger)
54
46
  }
55
47
  }
56
48
 
57
- export const STAKING_CONFIG: Record<string, StakingStrategy> = {
58
- sei_evm: {
49
+ export const STAKING_CONFIG: Partial<Record<ChainId, StakingStrategy>> = {
50
+ [CHAIN_ID.SEI_EVM]: {
59
51
  // Sei returns its whole validator set in a single page, so the first page's
60
52
  // items are the complete list.
61
- fetcher: createStakingFetcher(async (evmConfig, _config, currencyId, logger) => {
62
- const { items } = await getValidators(evmConfig, currencyId, logger)
53
+ fetcher: createStakingFetcher(async (evmConfig, _config, logger) => {
54
+ const { items } = await getValidators(evmConfig, logger)
63
55
  return items
64
56
  }),
65
57
  },
66
- celo: {
58
+ [CHAIN_ID.CELO]: {
67
59
  fetcher: createStakingFetcher(async (_evmConfig, config) => {
68
60
  const address = config.contractAddress()
69
61
  return [{ id: address, address, name: '' }]
70
62
  }),
71
63
  },
72
- monad: {
64
+ [CHAIN_ID.MONAD]: {
73
65
  fetcher: fetchMonadStakes,
74
66
  extractKnownValIds: extractMonadKnownValIds,
75
67
  },
76
- zero_gravity: {
68
+ [CHAIN_ID.ZERO_GRAVITY]: {
77
69
  fetcher: fetchZeroGravityStakes,
78
70
  },
79
- somnia: {
71
+ [CHAIN_ID.SOMNIA]: {
80
72
  fetcher: fetchSomniaStakes,
81
73
  },
82
74
  }
83
75
 
84
- const AMOUNT_EXTRACTORS: Record<string, StakingExtractor> = {
85
- sei_evm: (decoded: unknown): bigint => {
76
+ const AMOUNT_EXTRACTORS: Partial<Record<ChainId, StakingExtractor>> = {
77
+ [CHAIN_ID.SEI_EVM]: (decoded: unknown): bigint => {
86
78
  const delegation = extractSeiDelegation(decoded)
87
79
  return getSeiDelegationAmount(delegation)
88
80
  },
89
- celo: getCeloAmount,
81
+ [CHAIN_ID.CELO]: getCeloAmount,
90
82
  }
91
83
 
92
- const getAmountFromDecoded = (currencyId: string, decoded: unknown): bigint => {
93
- const extractor = AMOUNT_EXTRACTORS[currencyId]
84
+ const getAmountFromDecoded = (chainId: ChainId, decoded: unknown): bigint => {
85
+ const extractor = AMOUNT_EXTRACTORS[chainId]
94
86
  return extractor ? extractor(decoded) : 0n
95
87
  }
96
88
 
@@ -113,8 +105,8 @@ const isMissingRevertDataCallException = (error: unknown): boolean => {
113
105
  )
114
106
  }
115
107
 
116
- const isSeiMissingDelegationError = (currencyId: string, error: unknown): boolean =>
117
- currencyId === 'sei_evm' && isMissingRevertDataCallException(error)
108
+ const isSeiMissingDelegationError = (chainId: ChainId, error: unknown): boolean =>
109
+ chainId === CHAIN_ID.SEI_EVM && isMissingRevertDataCallException(error)
118
110
 
119
111
  // Short retry delay for staking calls. The staking precompile returns
120
112
  // CALL_EXCEPTION with "missing revert data" both for genuine no-delegation AND
@@ -127,7 +119,7 @@ const createStakeFromContract = async (
127
119
  evmConfig: EvmConfigInfo,
128
120
  stakingContract: StakeCreate
129
121
  ): Promise<Stake | null> => {
130
- const { config, address, currencyId, validatorAddress } = stakingContract
122
+ const { config, address, validatorAddress } = stakingContract
131
123
  const node = evmConfig.node
132
124
  if (!isExternalNodeConfig(node)) {
133
125
  throw new Error("Currency doesn't have an RPC node provided")
@@ -135,17 +127,16 @@ const createStakeFromContract = async (
135
127
 
136
128
  return withApi(
137
129
  evmConfig,
138
- currencyId,
139
130
  async (rpcProvider) => {
140
131
  const executeCall = async (): Promise<Stake | null> => {
141
- const params = buildTransactionParams(currencyId, 'getStakedBalance', {
132
+ const params = buildTransactionParams(evmConfig, 'getStakedBalance', {
142
133
  valAddress: address,
143
134
  amount: 0n,
144
135
  dstValAddress: validatorAddress,
145
136
  delegator: address,
146
137
  })
147
138
  const encodedData = encodeStakingData({
148
- currencyId,
139
+ evmConfig,
149
140
  operation: 'getStakedBalance',
150
141
  config,
151
142
  params,
@@ -159,8 +150,8 @@ const createStakeFromContract = async (
159
150
  to: contractAddress,
160
151
  data: encodedData,
161
152
  })
162
- const decoded = decodeStakingResult(currencyId, 'getStakedBalance', config, result)
163
- const amount = getAmountFromDecoded(currencyId, decoded)
153
+ const decoded = decodeStakingResult(evmConfig, 'getStakedBalance', config, result)
154
+ const amount = getAmountFromDecoded(evmConfig.chainId, decoded)
164
155
 
165
156
  if (amount === 0n) {
166
157
  return null
@@ -188,7 +179,7 @@ const createStakeFromContract = async (
188
179
  try {
189
180
  return await executeCall()
190
181
  } catch (error) {
191
- if (isSeiMissingDelegationError(currencyId, error)) {
182
+ if (isSeiMissingDelegationError(evmConfig.chainId, error)) {
192
183
  // The SEI staking precompile returns CALL_EXCEPTION with "missing revert
193
184
  // data" both when there is genuinely no delegation AND on transient RPC
194
185
  // failures. Retry once after a brief delay: a genuine no-delegation
@@ -198,7 +189,7 @@ const createStakeFromContract = async (
198
189
  try {
199
190
  return await executeCall()
200
191
  } catch (retryError) {
201
- if (isSeiMissingDelegationError(currencyId, retryError)) {
192
+ if (isSeiMissingDelegationError(evmConfig.chainId, retryError)) {
202
193
  return null // Consistent CALL_EXCEPTION — genuinely no delegation
203
194
  }
204
195
  throw new Error(
@@ -223,7 +214,6 @@ const getStakesForValidators = async (
223
214
  evmConfig: EvmConfigInfo,
224
215
  address: string,
225
216
  config: StakingContractConfig,
226
- currencyId: string,
227
217
  validators: string[],
228
218
  logger: Logger
229
219
  ): Promise<Stake[]> => {
@@ -235,7 +225,7 @@ const getStakesForValidators = async (
235
225
  // Fired here so its latency overlaps the precompile batch loop below;
236
226
  // awaited at the end. Any failure resolves to an empty map so the staking
237
227
  // sync never blocks on the off-chain rewards call.
238
- const rewardsPromise = fetchRewards(evmConfig, currencyId, address, logger).catch(
228
+ const rewardsPromise = fetchRewards(evmConfig, address, logger).catch(
239
229
  () => new Map<string, bigint>()
240
230
  )
241
231
 
@@ -251,12 +241,11 @@ const getStakesForValidators = async (
251
241
  createStakeFromContract(evmConfig, {
252
242
  address,
253
243
  config,
254
- currencyId,
255
244
  validatorAddress: validator,
256
245
  }).catch((error) => {
257
246
  console.error('Failed to fetch stake for validator', {
258
247
  validator,
259
- currencyId,
248
+ currency: evmConfig.name,
260
249
  address,
261
250
  error: error instanceof Error ? error.message : String(error),
262
251
  })
@@ -4,6 +4,7 @@
4
4
  import type { Stake } from '@ledgerhq/coin-module-framework/api/types'
5
5
  import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
6
6
  import { ethers } from 'ethers'
7
+ import { CHAIN_ID } from '../config'
7
8
  import { createMockEvmConfigInfo, mkExternalNode } from '../fixtures/context.fixtures'
8
9
  import {
9
10
  canCompound,
@@ -29,7 +30,8 @@ jest.mock('../network/node/types')
29
30
  const mockIsExternalNodeConfig = jest.mocked(require('../network/node/types').isExternalNodeConfig)
30
31
 
31
32
  const mockNode = mkExternalNode({ uri: 'https://sei-evm.coin.ledger.com' })
32
- const mockConfig = createMockEvmConfigInfo({ chainId: 1, node: mockNode })
33
+ const mockConfig = createMockEvmConfigInfo({ chainId: CHAIN_ID.ETHEREUM, node: mockNode })
34
+ const seiConfig = createMockEvmConfigInfo({ chainId: CHAIN_ID.SEI_EVM, node: mockNode })
33
35
 
34
36
  function makeStake(delegate: string, overrides: Partial<Stake> = {}): Stake {
35
37
  return {
@@ -49,20 +51,22 @@ describe('evm staking logic', () => {
49
51
  const FUTURE = new Date(Date.now() + 86_400_000)
50
52
 
51
53
  it('returns false for a chain without a redelegate precompile function (celo)', () => {
52
- expect(canRedelegate(makeStake('0xvalidator'), [], 'celo')).toBe(false)
54
+ expect(canRedelegate(makeStake('0xvalidator'), [], CHAIN_ID.CELO)).toBe(false)
53
55
  })
54
56
 
55
- it('returns false for an unknown currency id', () => {
56
- expect(canRedelegate(makeStake('0xvalidator'), [], 'unknown_chain')).toBe(false)
57
+ it('returns false for a chain without staking', () => {
58
+ expect(canRedelegate(makeStake('0xvalidator'), [], CHAIN_ID.ETHEREUM)).toBe(false)
57
59
  })
58
60
 
59
61
  it('returns true for sei_evm when no active redelegations exist', () => {
60
- expect(canRedelegate(makeStake('0xvalidator'), [], 'sei_evm')).toBe(true)
62
+ expect(canRedelegate(makeStake('0xvalidator'), [], CHAIN_ID.SEI_EVM)).toBe(true)
61
63
  })
62
64
 
63
65
  it('returns false when the delegation is the destination of an active redelegation (cooldown)', () => {
64
66
  const activeRedelegations = [{ validatorDstAddress: '0xvalidator', completionDate: FUTURE }]
65
- expect(canRedelegate(makeStake('0xvalidator'), activeRedelegations, 'sei_evm')).toBe(false)
67
+ expect(canRedelegate(makeStake('0xvalidator'), activeRedelegations, CHAIN_ID.SEI_EVM)).toBe(
68
+ false
69
+ )
66
70
  })
67
71
 
68
72
  it('returns false when the maxRedelegations cap is reached', () => {
@@ -70,36 +74,42 @@ describe('evm staking logic', () => {
70
74
  validatorDstAddress: `0xdst${i}`,
71
75
  completionDate: FUTURE,
72
76
  }))
73
- expect(canRedelegate(makeStake('0xother'), activeRedelegations, 'sei_evm')).toBe(false)
77
+ expect(canRedelegate(makeStake('0xother'), activeRedelegations, CHAIN_ID.SEI_EVM)).toBe(false)
74
78
  })
75
79
  })
76
80
 
77
81
  describe('canCompound', () => {
78
82
  it('returns false for a chain without a compound precompile function (sei_evm)', () => {
79
- expect(canCompound(makeStake('0xvalidator', { amountRewarded: 100n }), 'sei_evm')).toBe(false)
83
+ expect(
84
+ canCompound(makeStake('0xvalidator', { amountRewarded: 100n }), CHAIN_ID.SEI_EVM)
85
+ ).toBe(false)
80
86
  })
81
87
 
82
88
  it('returns false for monad when there are no pending rewards', () => {
83
- expect(canCompound(makeStake('0xvalidator'), 'monad')).toBe(false)
89
+ expect(canCompound(makeStake('0xvalidator'), CHAIN_ID.MONAD)).toBe(false)
84
90
  })
85
91
 
86
92
  it('returns true for monad when there are pending rewards', () => {
87
- expect(canCompound(makeStake('0xvalidator', { amountRewarded: 100n }), 'monad')).toBe(true)
93
+ expect(canCompound(makeStake('0xvalidator', { amountRewarded: 100n }), CHAIN_ID.MONAD)).toBe(
94
+ true
95
+ )
88
96
  })
89
97
  })
90
98
 
91
99
  describe('canUndelegate', () => {
92
100
  it('returns true for an active stake', () => {
93
- expect(canUndelegate(makeStake('0xvalidator'), 'monad')).toBe(true)
101
+ expect(canUndelegate(makeStake('0xvalidator'), CHAIN_ID.MONAD)).toBe(true)
94
102
  })
95
103
 
96
104
  it('returns false for an activating stake', () => {
97
- expect(canUndelegate(makeStake('0xvalidator', { state: 'activating' }), 'monad')).toBe(false)
105
+ expect(canUndelegate(makeStake('0xvalidator', { state: 'activating' }), CHAIN_ID.MONAD)).toBe(
106
+ false
107
+ )
98
108
  })
99
109
 
100
110
  it('returns false for 0G when shares is zero', () => {
101
111
  expect(
102
- canUndelegate(makeStake('0xvalidator', { details: { shares: 0n } }), 'zero_gravity')
112
+ canUndelegate(makeStake('0xvalidator', { details: { shares: 0n } }), CHAIN_ID.ZERO_GRAVITY)
103
113
  ).toBe(false)
104
114
  })
105
115
 
@@ -107,7 +117,7 @@ describe('evm staking logic', () => {
107
117
  expect(
108
118
  canUndelegate(
109
119
  makeStake('0xvalidator', { details: { shares: 999_999_999n } }),
110
- 'zero_gravity'
120
+ CHAIN_ID.ZERO_GRAVITY
111
121
  )
112
122
  ).toBe(false)
113
123
  })
@@ -116,13 +126,13 @@ describe('evm staking logic', () => {
116
126
  expect(
117
127
  canUndelegate(
118
128
  makeStake('0xvalidator', { details: { shares: 1_000_000_000n } }),
119
- 'zero_gravity'
129
+ CHAIN_ID.ZERO_GRAVITY
120
130
  )
121
131
  ).toBe(true)
122
132
  })
123
133
 
124
134
  it('returns true for 0G when shares is undefined (legacy pre-sync account)', () => {
125
- expect(canUndelegate(makeStake('0xvalidator'), 'zero_gravity')).toBe(true)
135
+ expect(canUndelegate(makeStake('0xvalidator'), CHAIN_ID.ZERO_GRAVITY)).toBe(true)
126
136
  })
127
137
  })
128
138
 
@@ -157,31 +167,25 @@ describe('evm staking logic', () => {
157
167
  })
158
168
 
159
169
  it('returns false for a non-sei_evm currency without querying the chain', async () => {
160
- await expect(isSeiAccountUnassociated(mockConfig, 'ethereum', SEI_ADDRESS)).resolves.toBe(
161
- false
162
- )
170
+ await expect(isSeiAccountUnassociated(mockConfig, SEI_ADDRESS)).resolves.toBe(false)
163
171
  expect(mockGetSeiAddr).not.toHaveBeenCalled()
164
172
  })
165
173
 
166
174
  it('returns false when the currency has no external RPC node configured', async () => {
167
175
  mockIsExternalNodeConfig.mockReturnValue(false)
168
- await expect(isSeiAccountUnassociated(mockConfig, 'sei_evm', SEI_ADDRESS)).resolves.toBe(
169
- false
170
- )
176
+ await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(false)
171
177
  expect(mockGetSeiAddr).not.toHaveBeenCalled()
172
178
  })
173
179
 
174
180
  it('returns true for sei_evm when the precompile resolves an empty string (unassociated)', async () => {
175
181
  mockGetSeiAddr.mockResolvedValue('')
176
- await expect(isSeiAccountUnassociated(mockConfig, 'sei_evm', SEI_ADDRESS)).resolves.toBe(true)
182
+ await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(true)
177
183
  expect(mockGetSeiAddr).toHaveBeenCalledWith(SEI_ADDRESS)
178
184
  })
179
185
 
180
186
  it('returns false for sei_evm when the precompile resolves a linked Cosmos address', async () => {
181
187
  mockGetSeiAddr.mockResolvedValue('sei1associatedcosmosaddress')
182
- await expect(isSeiAccountUnassociated(mockConfig, 'sei_evm', SEI_ADDRESS)).resolves.toBe(
183
- false
184
- )
188
+ await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(false)
185
189
  })
186
190
 
187
191
  it('returns true when the precompile reverts (unassociated address)', async () => {
@@ -192,23 +196,21 @@ describe('evm staking logic', () => {
192
196
  revert: null,
193
197
  })
194
198
  mockGetSeiAddr.mockRejectedValue(revert)
195
- await expect(isSeiAccountUnassociated(mockConfig, 'sei_evm', SEI_ADDRESS)).resolves.toBe(true)
199
+ await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(true)
196
200
  })
197
201
 
198
202
  it('returns true when the precompile call fails for any other reason', async () => {
199
203
  mockGetSeiAddr.mockRejectedValue(new Error('network error'))
200
- await expect(isSeiAccountUnassociated(mockConfig, 'sei_evm', SEI_ADDRESS)).resolves.toBe(true)
204
+ await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(true)
201
205
  })
202
206
 
203
207
  it('returns true when the precompile returns an unexpected non-string result', async () => {
204
208
  mockGetSeiAddr.mockResolvedValue(undefined)
205
- await expect(isSeiAccountUnassociated(mockConfig, 'sei_evm', SEI_ADDRESS)).resolves.toBe(true)
209
+ await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(true)
206
210
  })
207
211
 
208
212
  it('returns false when the config carries no external RPC node', async () => {
209
- await expect(isSeiAccountUnassociated(mockConfig, 'sei_evm', SEI_ADDRESS)).resolves.toBe(
210
- false
211
- )
213
+ await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(false)
212
214
  })
213
215
  })
214
216
  })