@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,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
  BufferTxData,
7
7
  MemoNotSupported,
@@ -10,6 +10,7 @@ import type {
10
10
  import type { Logger } from '@ledgerhq/coin-module-framework/config'
11
11
  import { ethers } from 'ethers'
12
12
  import { toInterfaceAbi } from '../abis'
13
+ import { CHAIN_ID } from '../config'
13
14
  import { isStakingIntent } from '../logic-public'
14
15
  import { withApi } from '../network/node/rpc.common'
15
16
  import { isExternalNodeConfig } from '../network/node/types'
@@ -41,12 +42,11 @@ function isWithdrawalFeeInGweiResult(value: unknown): value is WithdrawalFeeInGw
41
42
  */
42
43
  type IntentPreparer = (
43
44
  config: EvmConfigInfo,
44
- currencyId: string,
45
45
  intent: StakingIntent,
46
46
  logger: Logger
47
47
  ) => Promise<StakingIntent>
48
48
 
49
- const prepareMonadIntent: IntentPreparer = async (config, _currencyId, intent, logger) => {
49
+ const prepareMonadIntent: IntentPreparer = async (config, intent, logger) => {
50
50
  if (!isStakingIntent(intent)) return intent
51
51
  if (intent.mode !== 'undelegate' || intent.withdrawId !== undefined || !intent.valId) {
52
52
  return intent
@@ -54,7 +54,6 @@ const prepareMonadIntent: IntentPreparer = async (config, _currencyId, intent, l
54
54
 
55
55
  const withdrawId = await findFirstFreeWithdrawId(
56
56
  config,
57
- 'monad',
58
57
  BigInt(intent.valId),
59
58
  intent.sender,
60
59
  logger
@@ -72,14 +71,14 @@ const prepareMonadIntent: IntentPreparer = async (config, _currencyId, intent, l
72
71
  return enriched
73
72
  }
74
73
 
75
- const prepareZeroGravityIntent: IntentPreparer = async (config, currencyId, intent) => {
74
+ const prepareZeroGravityIntent: IntentPreparer = async (config, intent) => {
76
75
  if (!isStakingIntent(intent)) return intent
77
76
  if (intent.mode !== 'undelegate' || intent.shares !== undefined || !intent.valAddress) {
78
77
  return intent
79
78
  }
80
79
  if (!intent.useAllAmount && intent.amount <= 0n) return intent
81
80
 
82
- const abi = getStakingABI(currencyId)
81
+ const abi = getStakingABI(config.chainId)
83
82
  if (!abi) return intent
84
83
 
85
84
  const node = config.node
@@ -91,7 +90,6 @@ const prepareZeroGravityIntent: IntentPreparer = async (config, currencyId, inte
91
90
 
92
91
  const { shares, txValue } = await withApi(
93
92
  config,
94
- currencyId,
95
93
  async (provider) => {
96
94
  const rawDelegation = await provider.call({
97
95
  to: valAddress,
@@ -144,9 +142,9 @@ const prepareZeroGravityIntent: IntentPreparer = async (config, currencyId, inte
144
142
  return enriched
145
143
  }
146
144
 
147
- const STAKING_INTENT_PREPARERS: Record<string, IntentPreparer> = {
148
- monad: prepareMonadIntent,
149
- zero_gravity: prepareZeroGravityIntent,
145
+ const STAKING_INTENT_PREPARERS: Partial<Record<ChainId, IntentPreparer>> = {
146
+ [CHAIN_ID.MONAD]: prepareMonadIntent,
147
+ [CHAIN_ID.ZERO_GRAVITY]: prepareZeroGravityIntent,
150
148
  }
151
149
 
152
150
  /**
@@ -156,10 +154,9 @@ const STAKING_INTENT_PREPARERS: Record<string, IntentPreparer> = {
156
154
  */
157
155
  export const prepareStakingIntent = async (
158
156
  config: EvmConfigInfo,
159
- currencyId: string,
160
157
  intent: StakingIntent,
161
158
  logger: Logger
162
159
  ): Promise<StakingIntent> => {
163
- const prepare = STAKING_INTENT_PREPARERS[currencyId]
164
- return prepare ? prepare(config, currencyId, intent, logger) : intent
160
+ const prepare = STAKING_INTENT_PREPARERS[config.chainId]
161
+ return prepare ? prepare(config, intent, logger) : intent
165
162
  }
@@ -6,9 +6,10 @@ import type { OperationLike } from './redelegations'
6
6
  import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
7
7
  import { BigNumber } from 'bignumber.js'
8
8
  import { ethers } from 'ethers'
9
+ import { CHAIN_ID } from '../config'
9
10
  import { testLogger } from '../fixtures/context.fixtures'
11
+ import { requireStakingContract } from '../fixtures/staking.fixtures'
10
12
  import { getStakingABI } from './abis'
11
- import { STAKING_CONTRACTS } from './contracts'
12
13
  import {
13
14
  fetchRedelegations,
14
15
  resolveRedelegationValidators,
@@ -39,27 +40,29 @@ const mockIsExternalNodeConfig = jest.mocked(require('../network/node/types').is
39
40
  const mockNode: EvmConfigInfo['node'] = { type: 'external', uri: 'https://sei-evm.coin.ledger.com' }
40
41
  const mockConfig: EvmConfigInfo = {
41
42
  status: { type: 'active' },
42
- chainId: 1,
43
+ chainId: CHAIN_ID.SEI_EVM,
43
44
  name: 'Test EVM',
44
45
  unit: { name: 'test', code: 'TEST', magnitude: 18 },
45
46
  node: mockNode,
46
47
  explorer: { type: 'none' },
47
48
  }
48
-
49
- const SEI_CURRENCY = 'sei_evm'
49
+ const ethereumConfig: EvmConfigInfo = { ...mockConfig, chainId: CHAIN_ID.ETHEREUM }
50
+ const celoConfig: EvmConfigInfo = { ...mockConfig, chainId: CHAIN_ID.CELO }
51
+ const monadConfig: EvmConfigInfo = { ...mockConfig, chainId: CHAIN_ID.MONAD }
52
+ const zeroGravityConfig: EvmConfigInfo = { ...mockConfig, chainId: CHAIN_ID.ZERO_GRAVITY }
50
53
 
51
54
  function encodeDelegateCalldata(validatorAddress: string): string {
52
- const abi = getStakingABI('sei_evm')!
55
+ const abi = getStakingABI(CHAIN_ID.SEI_EVM)!
53
56
  return new ethers.Interface(abi).encodeFunctionData('delegate', [validatorAddress])
54
57
  }
55
58
 
56
59
  function encodeUndelegateCalldata(validatorAddress: string, amountUsei: bigint): string {
57
- const abi = getStakingABI('sei_evm')!
60
+ const abi = getStakingABI(CHAIN_ID.SEI_EVM)!
58
61
  return new ethers.Interface(abi).encodeFunctionData('undelegate', [validatorAddress, amountUsei])
59
62
  }
60
63
 
61
64
  function encodeRedelegateCalldata(src: string, dst: string, amountUsei: bigint): string {
62
- const abi = getStakingABI('sei_evm')!
65
+ const abi = getStakingABI(CHAIN_ID.SEI_EVM)!
63
66
  return new ethers.Interface(abi).encodeFunctionData('redelegate', [src, dst, amountUsei])
64
67
  }
65
68
 
@@ -93,12 +96,12 @@ describe('redelegations', () => {
93
96
  mockIsExternalNodeConfig.mockImplementation((node: unknown) => node === mockNode)
94
97
  })
95
98
 
96
- it('should return [] for an unknown currencyId', async () => {
97
- expect(await fetchRedelegations(mockConfig, 'unknown_chain', '0xabc', testLogger)).toEqual([])
99
+ it('should return [] for a chain without staking', async () => {
100
+ expect(await fetchRedelegations(ethereumConfig, '0xabc', testLogger)).toEqual([])
98
101
  })
99
102
 
100
103
  it("should return [] when the strategy type is 'none'", async () => {
101
- expect(await fetchRedelegations(mockConfig, 'celo', '0xabc', testLogger)).toEqual([])
104
+ expect(await fetchRedelegations(celoConfig, '0xabc', testLogger)).toEqual([])
102
105
  })
103
106
 
104
107
  it('should return [] when the network call fails', async () => {
@@ -106,7 +109,6 @@ describe('redelegations', () => {
106
109
  expect(
107
110
  await fetchRedelegations(
108
111
  mockConfig,
109
- 'sei_evm',
110
112
  '0x1234567890abcdef1234567890abcdef12345678',
111
113
  testLogger
112
114
  )
@@ -118,7 +120,6 @@ describe('redelegations', () => {
118
120
  expect(
119
121
  await fetchRedelegations(
120
122
  mockConfig,
121
- 'sei_evm',
122
123
  '0x1234567890abcdef1234567890abcdef12345678',
123
124
  testLogger
124
125
  )
@@ -151,7 +152,6 @@ describe('redelegations', () => {
151
152
  expect(
152
153
  await fetchRedelegations(
153
154
  mockConfig,
154
- 'sei_evm',
155
155
  '0x1234567890abcdef1234567890abcdef12345678',
156
156
  testLogger
157
157
  )
@@ -183,7 +183,6 @@ describe('redelegations', () => {
183
183
 
184
184
  const result = await fetchRedelegations(
185
185
  mockConfig,
186
- 'sei_evm',
187
186
  '0x1234567890abcdef1234567890abcdef12345678',
188
187
  testLogger
189
188
  )
@@ -206,7 +205,7 @@ describe('redelegations', () => {
206
205
  mockGetSeiAddr.mockResolvedValueOnce(canonicalCosmosAddress)
207
206
  mockNetwork.mockResolvedValueOnce({ data: { redelegation_responses: [] } })
208
207
 
209
- await fetchRedelegations(mockConfig, 'sei_evm', evmAddress, testLogger)
208
+ await fetchRedelegations(mockConfig, evmAddress, testLogger)
210
209
 
211
210
  expect(mockNetwork).toHaveBeenCalledTimes(1)
212
211
  expect(mockNetwork).toHaveBeenCalledWith(
@@ -224,7 +223,6 @@ describe('redelegations', () => {
224
223
  expect(
225
224
  await fetchRedelegations(
226
225
  mockConfig,
227
- 'sei_evm',
228
226
  '0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3',
229
227
  testLogger
230
228
  )
@@ -245,7 +243,7 @@ describe('redelegations', () => {
245
243
  const calldata = encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI)
246
244
  const op = makeOperation({ type: 'REDELEGATE', extra: { contractPayload: calldata } })
247
245
 
248
- const result = await resolveRedelegationValidators(mockConfig, SEI_CURRENCY, op, testLogger)
246
+ const result = await resolveRedelegationValidators(mockConfig, op, testLogger)
249
247
 
250
248
  expect(result).toMatchObject({
251
249
  srcValidatorAddress: SRC,
@@ -257,14 +255,12 @@ describe('redelegations', () => {
257
255
  it('should fall back to RPC when contractPayload is absent', async () => {
258
256
  const calldata = encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI)
259
257
  mockIsExternalNodeConfig.mockReturnValue(true)
260
- mockWithApi.mockImplementation(
261
- (_config: unknown, _currencyId: unknown, fn: (p: unknown) => unknown) =>
262
- fn({ getTransaction: async () => ({ data: calldata }) })
258
+ mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
259
+ fn({ getTransaction: async () => ({ data: calldata }) })
263
260
  )
264
261
 
265
262
  const result = await resolveRedelegationValidators(
266
263
  mockConfig,
267
- SEI_CURRENCY,
268
264
  makeOperation({ type: 'REDELEGATE', extra: {} }),
269
265
  testLogger
270
266
  )
@@ -281,7 +277,6 @@ describe('redelegations', () => {
281
277
 
282
278
  const result = await resolveRedelegationValidators(
283
279
  mockConfig,
284
- SEI_CURRENCY,
285
280
  makeOperation({ type: 'REDELEGATE', extra: {} }),
286
281
  testLogger
287
282
  )
@@ -293,16 +288,12 @@ describe('redelegations', () => {
293
288
  type: 'REDELEGATE',
294
289
  extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
295
290
  })
296
- expect(
297
- await resolveRedelegationValidators(mockConfig, 'unsupported', op, testLogger)
298
- ).toBeNull()
291
+ expect(await resolveRedelegationValidators(ethereumConfig, op, testLogger)).toBeNull()
299
292
  })
300
293
 
301
294
  it('should return null for malformed calldata', async () => {
302
295
  const op = makeOperation({ type: 'REDELEGATE', extra: { contractPayload: '0xdeadbeef' } })
303
- expect(
304
- await resolveRedelegationValidators(mockConfig, SEI_CURRENCY, op, testLogger)
305
- ).toBeNull()
296
+ expect(await resolveRedelegationValidators(mockConfig, op, testLogger)).toBeNull()
306
297
  })
307
298
  })
308
299
 
@@ -318,48 +309,39 @@ describe('redelegations', () => {
318
309
  type: 'DELEGATE',
319
310
  extra: { contractPayload: encodeDelegateCalldata(VALIDATOR) },
320
311
  })
321
- expect(
322
- await resolveStakingValidator(mockConfig, 'unsupported', op, 'delegate', testLogger)
323
- ).toBeNull()
312
+ expect(await resolveStakingValidator(ethereumConfig, op, 'delegate', testLogger)).toBeNull()
324
313
  })
325
314
 
326
315
  describe('delegate (Monad, id-keyed validatorId)', () => {
327
316
  it('resolves the validator address from the uint64 validatorId via getValidator', async () => {
328
- const monadIface = new ethers.Interface(getStakingABI('monad')!)
317
+ const monadIface = new ethers.Interface(getStakingABI(CHAIN_ID.MONAD)!)
329
318
  const op = makeOperation({
330
319
  type: 'DELEGATE',
331
320
  extra: { contractPayload: monadIface.encodeFunctionData('delegate', [110n]) },
332
321
  })
333
322
 
334
323
  mockIsExternalNodeConfig.mockReturnValue(true)
335
- mockWithApi.mockImplementation(
336
- (_config: unknown, _currencyId: unknown, fn: (p: unknown) => unknown) =>
337
- fn({
338
- call: async () =>
339
- monadIface.encodeFunctionResult('getValidator', [
340
- '0x0000000000000000000000000000000000000000',
341
- 0n,
342
- 0n,
343
- 0n,
344
- 0n,
345
- 0n,
346
- 0n,
347
- 0n,
348
- 0n,
349
- 0n,
350
- '0x036e44a092493800e427b2b08d3427d804348b1368ecd0a6af6510ae40ce507187',
351
- '0x',
352
- ]),
353
- })
324
+ mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
325
+ fn({
326
+ call: async () =>
327
+ monadIface.encodeFunctionResult('getValidator', [
328
+ '0x0000000000000000000000000000000000000000',
329
+ 0n,
330
+ 0n,
331
+ 0n,
332
+ 0n,
333
+ 0n,
334
+ 0n,
335
+ 0n,
336
+ 0n,
337
+ 0n,
338
+ '0x036e44a092493800e427b2b08d3427d804348b1368ecd0a6af6510ae40ce507187',
339
+ '0x',
340
+ ]),
341
+ })
354
342
  )
355
343
 
356
- const result = await resolveStakingValidator(
357
- mockConfig,
358
- 'monad',
359
- op,
360
- 'delegate',
361
- testLogger
362
- )
344
+ const result = await resolveStakingValidator(monadConfig, op, 'delegate', testLogger)
363
345
 
364
346
  expect(result).toMatchObject({
365
347
  validatorAddress: ethers.computeAddress(
@@ -376,18 +358,12 @@ describe('redelegations', () => {
376
358
  recipients: ['0x2222222222222222222222222222222222222222'],
377
359
  extra: {
378
360
  contractPayload: new ethers.Interface(
379
- getStakingABI('zero_gravity')!
361
+ getStakingABI(CHAIN_ID.ZERO_GRAVITY)!
380
362
  ).encodeFunctionData('delegate', ['0x1111111111111111111111111111111111111111']),
381
363
  },
382
364
  })
383
365
 
384
- const result = await resolveStakingValidator(
385
- mockConfig,
386
- 'zero_gravity',
387
- op,
388
- 'delegate',
389
- testLogger
390
- )
366
+ const result = await resolveStakingValidator(zeroGravityConfig, op, 'delegate', testLogger)
391
367
 
392
368
  expect(result).toMatchObject({
393
369
  validatorAddress: '0x2222222222222222222222222222222222222222',
@@ -397,7 +373,7 @@ describe('redelegations', () => {
397
373
 
398
374
  describe('undelegate (0G, convertToTokens)', () => {
399
375
  it('calls convertToTokens on the validator contract to resolve the display amount', async () => {
400
- const zgIface = new ethers.Interface(getStakingABI('zero_gravity')!)
376
+ const zgIface = new ethers.Interface(getStakingABI(CHAIN_ID.ZERO_GRAVITY)!)
401
377
  const convertIface = new ethers.Interface([
402
378
  'function convertToTokens(uint256 shares) view returns (uint256)',
403
379
  ])
@@ -415,28 +391,21 @@ describe('redelegations', () => {
415
391
  const zgNode: EvmConfigInfo['node'] = { type: 'external', uri: 'https://0g.rpc' }
416
392
  const zgConfig: EvmConfigInfo = {
417
393
  status: { type: 'active' },
418
- chainId: 1,
394
+ chainId: CHAIN_ID.ZERO_GRAVITY,
419
395
  name: 'Test EVM',
420
396
  unit: { name: 'test', code: 'TEST', magnitude: 18 },
421
397
  node: zgNode,
422
398
  explorer: { type: 'none' },
423
399
  }
424
400
  mockIsExternalNodeConfig.mockImplementation((node: unknown) => node === zgNode)
425
- mockWithApi.mockImplementation(
426
- (_config: unknown, _currencyId: unknown, fn: (p: unknown) => unknown) =>
427
- fn({
428
- call: async () =>
429
- convertIface.encodeFunctionResult('convertToTokens', [13_000_000_000_000_000n]),
430
- })
401
+ mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
402
+ fn({
403
+ call: async () =>
404
+ convertIface.encodeFunctionResult('convertToTokens', [13_000_000_000_000_000n]),
405
+ })
431
406
  )
432
407
 
433
- const result = await resolveStakingValidator(
434
- zgConfig,
435
- 'zero_gravity',
436
- op,
437
- 'undelegate',
438
- testLogger
439
- )
408
+ const result = await resolveStakingValidator(zgConfig, op, 'undelegate', testLogger)
440
409
 
441
410
  expect(result).toEqual({
442
411
  validatorAddress: '0x3333333333333333333333333333333333333333',
@@ -452,27 +421,19 @@ describe('redelegations', () => {
452
421
  extra: { contractPayload: encodeDelegateCalldata(VALIDATOR) },
453
422
  })
454
423
 
455
- const result = await resolveStakingValidator(
456
- mockConfig,
457
- SEI_CURRENCY,
458
- op,
459
- 'delegate',
460
- testLogger
461
- )
424
+ const result = await resolveStakingValidator(mockConfig, op, 'delegate', testLogger)
462
425
 
463
426
  expect(result).toMatchObject({ validatorAddress: VALIDATOR })
464
427
  })
465
428
 
466
429
  it('should fall back to RPC when contractPayload is absent', async () => {
467
430
  mockIsExternalNodeConfig.mockReturnValue(true)
468
- mockWithApi.mockImplementation(
469
- (_config: unknown, _currencyId: unknown, fn: (p: unknown) => unknown) =>
470
- fn({ getTransaction: async () => ({ data: encodeDelegateCalldata(VALIDATOR) }) })
431
+ mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
432
+ fn({ getTransaction: async () => ({ data: encodeDelegateCalldata(VALIDATOR) }) })
471
433
  )
472
434
 
473
435
  const result = await resolveStakingValidator(
474
436
  mockConfig,
475
- SEI_CURRENCY,
476
437
  makeOperation({ type: 'DELEGATE', extra: {} }),
477
438
  'delegate',
478
439
  testLogger
@@ -487,7 +448,6 @@ describe('redelegations', () => {
487
448
  expect(
488
449
  await resolveStakingValidator(
489
450
  mockConfig,
490
- SEI_CURRENCY,
491
451
  makeOperation({ type: 'DELEGATE', extra: {} }),
492
452
  'delegate',
493
453
  testLogger
@@ -503,13 +463,7 @@ describe('redelegations', () => {
503
463
  extra: { contractPayload: encodeUndelegateCalldata(VALIDATOR, AMOUNT_USEI) },
504
464
  })
505
465
 
506
- const result = await resolveStakingValidator(
507
- mockConfig,
508
- SEI_CURRENCY,
509
- op,
510
- 'undelegate',
511
- testLogger
512
- )
466
+ const result = await resolveStakingValidator(mockConfig, op, 'undelegate', testLogger)
513
467
 
514
468
  expect(result).toMatchObject({ validatorAddress: VALIDATOR })
515
469
  expect(result!.amount?.isEqualTo(EXPECTED_WEI.toString())).toBe(true)
@@ -517,18 +471,16 @@ describe('redelegations', () => {
517
471
 
518
472
  it('should fall back to RPC when contractPayload is absent', async () => {
519
473
  mockIsExternalNodeConfig.mockReturnValue(true)
520
- mockWithApi.mockImplementation(
521
- (_config: unknown, _currencyId: unknown, fn: (p: unknown) => unknown) =>
522
- fn({
523
- getTransaction: async () => ({
524
- data: encodeUndelegateCalldata(VALIDATOR, AMOUNT_USEI),
525
- }),
526
- })
474
+ mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
475
+ fn({
476
+ getTransaction: async () => ({
477
+ data: encodeUndelegateCalldata(VALIDATOR, AMOUNT_USEI),
478
+ }),
479
+ })
527
480
  )
528
481
 
529
482
  const result = await resolveStakingValidator(
530
483
  mockConfig,
531
- SEI_CURRENCY,
532
484
  makeOperation({ type: 'UNDELEGATE', extra: {} }),
533
485
  'undelegate',
534
486
  testLogger
@@ -542,9 +494,7 @@ describe('redelegations', () => {
542
494
  type: 'UNDELEGATE',
543
495
  extra: { contractPayload: '0xdeadbeef' },
544
496
  })
545
- expect(
546
- await resolveStakingValidator(mockConfig, SEI_CURRENCY, op, 'undelegate', testLogger)
547
- ).toBeNull()
497
+ expect(await resolveStakingValidator(mockConfig, op, 'undelegate', testLogger)).toBeNull()
548
498
  })
549
499
  })
550
500
  })
@@ -554,19 +504,19 @@ describe('redelegations', () => {
554
504
  const DST = 'seivaloper1dst000000000000000000000000000000000'
555
505
  const AMOUNT_USEI = 1_000_000n
556
506
  const EXPECTED_WEI = AMOUNT_USEI * USEI_TO_EVM_SCALE
557
- const unbondingMs = STAKING_CONTRACTS['sei_evm'].unbondingPeriodDays! * 24 * 60 * 60 * 1000
507
+ const unbondingMs =
508
+ requireStakingContract(CHAIN_ID.SEI_EVM).unbondingPeriodDays! * 24 * 60 * 60 * 1000
558
509
 
559
510
  beforeEach(() => jest.clearAllMocks())
560
511
 
561
512
  it('should return [] for an unsupported currencyId', async () => {
562
- expect(await buildRedelegationsFromOps(mockConfig, 'unsupported', [], testLogger)).toEqual([])
513
+ expect(await buildRedelegationsFromOps(ethereumConfig, [], testLogger)).toEqual([])
563
514
  })
564
515
 
565
516
  it('should ignore non-REDELEGATE operations', async () => {
566
517
  expect(
567
518
  await buildRedelegationsFromOps(
568
519
  mockConfig,
569
- SEI_CURRENCY,
570
520
  [makeOperation({ type: 'DELEGATE' })],
571
521
  testLogger
572
522
  )
@@ -580,9 +530,7 @@ describe('redelegations', () => {
580
530
  extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
581
531
  date: new Date(),
582
532
  })
583
- expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op], testLogger)).toEqual(
584
- []
585
- )
533
+ expect(await buildRedelegationsFromOps(mockConfig, [op], testLogger)).toEqual([])
586
534
  })
587
535
 
588
536
  it('should ignore operations whose unbonding period has already elapsed', async () => {
@@ -591,9 +539,7 @@ describe('redelegations', () => {
591
539
  extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
592
540
  date: new Date(Date.now() - unbondingMs - 1000),
593
541
  })
594
- expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op], testLogger)).toEqual(
595
- []
596
- )
542
+ expect(await buildRedelegationsFromOps(mockConfig, [op], testLogger)).toEqual([])
597
543
  })
598
544
 
599
545
  it('should build a redelegation from a recent REDELEGATE op with cached calldata', async () => {
@@ -603,7 +549,7 @@ describe('redelegations', () => {
603
549
  date: new Date(),
604
550
  })
605
551
 
606
- const result = await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op], testLogger)
552
+ const result = await buildRedelegationsFromOps(mockConfig, [op], testLogger)
607
553
 
608
554
  expect(result).toHaveLength(1)
609
555
  expect(result[0]).toMatchObject({
@@ -617,16 +563,14 @@ describe('redelegations', () => {
617
563
 
618
564
  it('should fetch calldata from RPC when contractPayload is absent', async () => {
619
565
  mockIsExternalNodeConfig.mockReturnValue(true)
620
- mockWithApi.mockImplementation(
621
- (_config: unknown, _currencyId: unknown, fn: (p: unknown) => unknown) =>
622
- fn({
623
- getTransaction: async () => ({ data: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) }),
624
- })
566
+ mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
567
+ fn({
568
+ getTransaction: async () => ({ data: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) }),
569
+ })
625
570
  )
626
571
 
627
572
  const result = await buildRedelegationsFromOps(
628
573
  mockConfig,
629
- SEI_CURRENCY,
630
574
  [makeOperation({ type: 'REDELEGATE', extra: {}, date: new Date() })],
631
575
  testLogger
632
576
  )
@@ -641,9 +585,7 @@ describe('redelegations', () => {
641
585
  extra: { contractPayload: '0xdeadbeef' },
642
586
  date: new Date(),
643
587
  })
644
- expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op], testLogger)).toEqual(
645
- []
646
- )
588
+ expect(await buildRedelegationsFromOps(mockConfig, [op], testLogger)).toEqual([])
647
589
  })
648
590
 
649
591
  it('should process multiple operations correctly', async () => {
@@ -660,7 +602,7 @@ describe('redelegations', () => {
660
602
  }),
661
603
  ]
662
604
 
663
- const result = await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, ops, testLogger)
605
+ const result = await buildRedelegationsFromOps(mockConfig, ops, testLogger)
664
606
  expect(result).toHaveLength(2)
665
607
  expect(result[0].validatorSrcAddress).toBe(SRC)
666
608
  expect(result[1].validatorSrcAddress).toBe(DST)