@ledgerhq/coin-evm 10.0.0 → 15.0.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 (505) hide show
  1. package/.oxlintrc.json +2 -6
  2. package/CHANGELOG.md +54 -0
  3. package/docs/getBlock-internal-txs-schema.md +2 -2
  4. package/docs/network/node/index.md +1 -1
  5. package/lib/abis/index.d.ts +8 -0
  6. package/lib/abis/index.d.ts.map +1 -1
  7. package/lib/abis/index.js +30 -0
  8. package/lib/abis/index.js.map +1 -1
  9. package/lib/adapters/blockOperations.js +2 -2
  10. package/lib/adapters/blockOperations.js.map +1 -1
  11. package/lib/adapters/etherscan.d.ts +2 -1
  12. package/lib/adapters/etherscan.d.ts.map +1 -1
  13. package/lib/adapters/etherscan.js +2 -2
  14. package/lib/adapters/etherscan.js.map +1 -1
  15. package/lib/adapters/ledger.d.ts +2 -1
  16. package/lib/adapters/ledger.d.ts.map +1 -1
  17. package/lib/adapters/ledger.js +2 -2
  18. package/lib/adapters/ledger.js.map +1 -1
  19. package/lib/api/index.d.ts.map +1 -1
  20. package/lib/api/index.js +3 -2
  21. package/lib/api/index.js.map +1 -1
  22. package/lib/chains.d.ts +94 -0
  23. package/lib/chains.d.ts.map +1 -0
  24. package/lib/chains.js +98 -0
  25. package/lib/chains.js.map +1 -0
  26. package/lib/config.d.ts +4 -1
  27. package/lib/config.d.ts.map +1 -1
  28. package/lib/config.js +3 -1
  29. package/lib/config.js.map +1 -1
  30. package/lib/internalTxSources.d.ts.map +1 -1
  31. package/lib/internalTxSources.js +21 -3
  32. package/lib/internalTxSources.js.map +1 -1
  33. package/lib/logic/broadcast.js +2 -2
  34. package/lib/logic/broadcast.js.map +1 -1
  35. package/lib/logic/common.d.ts +1 -1
  36. package/lib/logic/common.d.ts.map +1 -1
  37. package/lib/logic/common.js +22 -14
  38. package/lib/logic/common.js.map +1 -1
  39. package/lib/logic/craftTransaction.d.ts.map +1 -1
  40. package/lib/logic/craftTransaction.js +7 -4
  41. package/lib/logic/craftTransaction.js.map +1 -1
  42. package/lib/logic/estimateFees.d.ts.map +1 -1
  43. package/lib/logic/estimateFees.js +11 -8
  44. package/lib/logic/estimateFees.js.map +1 -1
  45. package/lib/logic/getBalance.d.ts.map +1 -1
  46. package/lib/logic/getBalance.js +9 -9
  47. package/lib/logic/getBalance.js.map +1 -1
  48. package/lib/logic/getBlock.d.ts.map +1 -1
  49. package/lib/logic/getBlock.js +17 -17
  50. package/lib/logic/getBlock.js.map +1 -1
  51. package/lib/logic/getBlockInfo.js +2 -2
  52. package/lib/logic/getBlockInfo.js.map +1 -1
  53. package/lib/logic/getNextSequence.d.ts.map +1 -1
  54. package/lib/logic/getNextSequence.js +1 -1
  55. package/lib/logic/getNextSequence.js.map +1 -1
  56. package/lib/logic/getStakes.d.ts.map +1 -1
  57. package/lib/logic/getStakes.js +10 -10
  58. package/lib/logic/getStakes.js.map +1 -1
  59. package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
  60. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  61. package/lib/logic/internalTransactionsFetcher.js +9 -9
  62. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  63. package/lib/logic/lastBlock.js +2 -2
  64. package/lib/logic/lastBlock.js.map +1 -1
  65. package/lib/logic/listOperations.d.ts.map +1 -1
  66. package/lib/logic/listOperations.js +1 -1
  67. package/lib/logic/listOperations.js.map +1 -1
  68. package/lib/logic/predicates.d.ts +17 -0
  69. package/lib/logic/predicates.d.ts.map +1 -0
  70. package/lib/logic/predicates.js +126 -0
  71. package/lib/logic/predicates.js.map +1 -0
  72. package/lib/logic/validateIntent.d.ts.map +1 -1
  73. package/lib/logic/validateIntent.js +9 -9
  74. package/lib/logic/validateIntent.js.map +1 -1
  75. package/lib/logic.d.ts +1 -1
  76. package/lib/logic.d.ts.map +1 -1
  77. package/lib/logic.js +14 -13
  78. package/lib/logic.js.map +1 -1
  79. package/lib/network/explorer/etherscan.d.ts +2 -3
  80. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  81. package/lib/network/explorer/etherscan.js +6 -8
  82. package/lib/network/explorer/etherscan.js.map +1 -1
  83. package/lib/network/explorer/ledger.d.ts.map +1 -1
  84. package/lib/network/explorer/ledger.js +5 -5
  85. package/lib/network/explorer/ledger.js.map +1 -1
  86. package/lib/network/explorer/types.d.ts +2 -2
  87. package/lib/network/explorer/types.d.ts.map +1 -1
  88. package/lib/network/explorer/types.js +11 -1
  89. package/lib/network/explorer/types.js.map +1 -1
  90. package/lib/network/gasTracker/ledger.d.ts.map +1 -1
  91. package/lib/network/gasTracker/ledger.js +1 -3
  92. package/lib/network/gasTracker/ledger.js.map +1 -1
  93. package/lib/network/node/explorerProxy.d.ts.map +1 -1
  94. package/lib/network/node/explorerProxy.js +22 -17
  95. package/lib/network/node/explorerProxy.js.map +1 -1
  96. package/lib/network/node/gethCallTracerToTraceBlockItems.d.ts.map +1 -1
  97. package/lib/network/node/gethCallTracerToTraceBlockItems.js +10 -12
  98. package/lib/network/node/gethCallTracerToTraceBlockItems.js.map +1 -1
  99. package/lib/network/node/index.d.ts +1 -1
  100. package/lib/network/node/index.d.ts.map +1 -1
  101. package/lib/network/node/index.js +7 -7
  102. package/lib/network/node/index.js.map +1 -1
  103. package/lib/network/node/ledger.d.ts +3 -1
  104. package/lib/network/node/ledger.d.ts.map +1 -1
  105. package/lib/network/node/ledger.js +38 -24
  106. package/lib/network/node/ledger.js.map +1 -1
  107. package/lib/network/node/rpc.common.d.ts +1 -1
  108. package/lib/network/node/rpc.common.d.ts.map +1 -1
  109. package/lib/network/node/rpc.common.js +104 -103
  110. package/lib/network/node/rpc.common.js.map +1 -1
  111. package/lib/network/node/types.d.ts +21 -22
  112. package/lib/network/node/types.d.ts.map +1 -1
  113. package/lib/network/node/types.js +0 -27
  114. package/lib/network/node/types.js.map +1 -1
  115. package/lib/network/node/withNodeSources.d.ts.map +1 -1
  116. package/lib/network/node/withNodeSources.js +15 -15
  117. package/lib/network/node/withNodeSources.js.map +1 -1
  118. package/lib/nodeSources.d.ts.map +1 -1
  119. package/lib/nodeSources.js +11 -3
  120. package/lib/nodeSources.js.map +1 -1
  121. package/lib/staking/abis.d.ts +3 -2
  122. package/lib/staking/abis.d.ts.map +1 -1
  123. package/lib/staking/abis.js +10 -9
  124. package/lib/staking/abis.js.map +1 -1
  125. package/lib/staking/contracts.d.ts +3 -2
  126. package/lib/staking/contracts.d.ts.map +1 -1
  127. package/lib/staking/contracts.js +12 -13
  128. package/lib/staking/contracts.js.map +1 -1
  129. package/lib/staking/detectOperationType.d.ts +2 -4
  130. package/lib/staking/detectOperationType.d.ts.map +1 -1
  131. package/lib/staking/detectOperationType.js +22 -21
  132. package/lib/staking/detectOperationType.js.map +1 -1
  133. package/lib/staking/encoder.d.ts +2 -1
  134. package/lib/staking/encoder.d.ts.map +1 -1
  135. package/lib/staking/encoder.js +8 -8
  136. package/lib/staking/encoder.js.map +1 -1
  137. package/lib/staking/fetchers.d.ts +2 -1
  138. package/lib/staking/fetchers.d.ts.map +1 -1
  139. package/lib/staking/fetchers.js +27 -27
  140. package/lib/staking/fetchers.js.map +1 -1
  141. package/lib/staking/logic.d.ts +6 -6
  142. package/lib/staking/logic.d.ts.map +1 -1
  143. package/lib/staking/logic.js +14 -13
  144. package/lib/staking/logic.js.map +1 -1
  145. package/lib/staking/operations/index.d.ts +2 -1
  146. package/lib/staking/operations/index.d.ts.map +1 -1
  147. package/lib/staking/operations/index.js +39 -20
  148. package/lib/staking/operations/index.js.map +1 -1
  149. package/lib/staking/prepareIntents.d.ts +1 -1
  150. package/lib/staking/prepareIntents.d.ts.map +1 -1
  151. package/lib/staking/prepareIntents.js +14 -12
  152. package/lib/staking/prepareIntents.js.map +1 -1
  153. package/lib/staking/redelegations.d.ts +4 -4
  154. package/lib/staking/redelegations.d.ts.map +1 -1
  155. package/lib/staking/redelegations.js +22 -27
  156. package/lib/staking/redelegations.js.map +1 -1
  157. package/lib/staking/rewards.d.ts +1 -1
  158. package/lib/staking/rewards.d.ts.map +1 -1
  159. package/lib/staking/rewards.js +2 -2
  160. package/lib/staking/rewards.js.map +1 -1
  161. package/lib/staking/rewardsFromReceipt.d.ts +2 -1
  162. package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
  163. package/lib/staking/rewardsFromReceipt.js +2 -2
  164. package/lib/staking/rewardsFromReceipt.js.map +1 -1
  165. package/lib/staking/transactionData.d.ts +2 -1
  166. package/lib/staking/transactionData.d.ts.map +1 -1
  167. package/lib/staking/transactionData.js +6 -6
  168. package/lib/staking/transactionData.js.map +1 -1
  169. package/lib/staking/unbondings.d.ts +1 -1
  170. package/lib/staking/unbondings.d.ts.map +1 -1
  171. package/lib/staking/unbondings.js +2 -2
  172. package/lib/staking/unbondings.js.map +1 -1
  173. package/lib/staking/utils.d.ts.map +1 -1
  174. package/lib/staking/utils.js +22 -27
  175. package/lib/staking/utils.js.map +1 -1
  176. package/lib/staking/validators/index.d.ts +14 -14
  177. package/lib/staking/validators/index.d.ts.map +1 -1
  178. package/lib/staking/validators/index.js +39 -38
  179. package/lib/staking/validators/index.js.map +1 -1
  180. package/lib/staking/validators/monad.d.ts +5 -5
  181. package/lib/staking/validators/monad.d.ts.map +1 -1
  182. package/lib/staking/validators/monad.js +44 -37
  183. package/lib/staking/validators/monad.js.map +1 -1
  184. package/lib/staking/validators/monadResolver.d.ts +1 -1
  185. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  186. package/lib/staking/validators/monadResolver.js +7 -6
  187. package/lib/staking/validators/monadResolver.js.map +1 -1
  188. package/lib/staking/validators/sei.js +2 -2
  189. package/lib/staking/validators/sei.js.map +1 -1
  190. package/lib/staking/validators/somnia.d.ts +4 -4
  191. package/lib/staking/validators/somnia.d.ts.map +1 -1
  192. package/lib/staking/validators/somnia.js +25 -24
  193. package/lib/staking/validators/somnia.js.map +1 -1
  194. package/lib/staking/validators/types.d.ts +1 -1
  195. package/lib/staking/validators/types.d.ts.map +1 -1
  196. package/lib/staking/validators/zero_gravity.d.ts +1 -1
  197. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  198. package/lib/staking/validators/zero_gravity.js +10 -9
  199. package/lib/staking/validators/zero_gravity.js.map +1 -1
  200. package/lib/types/staking.d.ts +5 -6
  201. package/lib/types/staking.d.ts.map +1 -1
  202. package/lib-es/abis/index.d.ts +8 -0
  203. package/lib-es/abis/index.d.ts.map +1 -1
  204. package/lib-es/abis/index.js +29 -0
  205. package/lib-es/abis/index.js.map +1 -1
  206. package/lib-es/adapters/blockOperations.js +1 -1
  207. package/lib-es/adapters/blockOperations.js.map +1 -1
  208. package/lib-es/adapters/etherscan.d.ts +2 -1
  209. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  210. package/lib-es/adapters/etherscan.js +2 -2
  211. package/lib-es/adapters/etherscan.js.map +1 -1
  212. package/lib-es/adapters/ledger.d.ts +2 -1
  213. package/lib-es/adapters/ledger.d.ts.map +1 -1
  214. package/lib-es/adapters/ledger.js +2 -2
  215. package/lib-es/adapters/ledger.js.map +1 -1
  216. package/lib-es/api/index.d.ts.map +1 -1
  217. package/lib-es/api/index.js +3 -2
  218. package/lib-es/api/index.js.map +1 -1
  219. package/lib-es/chains.d.ts +94 -0
  220. package/lib-es/chains.d.ts.map +1 -0
  221. package/lib-es/chains.js +95 -0
  222. package/lib-es/chains.js.map +1 -0
  223. package/lib-es/config.d.ts +4 -1
  224. package/lib-es/config.d.ts.map +1 -1
  225. package/lib-es/config.js +1 -0
  226. package/lib-es/config.js.map +1 -1
  227. package/lib-es/internalTxSources.d.ts.map +1 -1
  228. package/lib-es/internalTxSources.js +21 -3
  229. package/lib-es/internalTxSources.js.map +1 -1
  230. package/lib-es/logic/broadcast.js +2 -2
  231. package/lib-es/logic/broadcast.js.map +1 -1
  232. package/lib-es/logic/common.d.ts +1 -1
  233. package/lib-es/logic/common.d.ts.map +1 -1
  234. package/lib-es/logic/common.js +22 -14
  235. package/lib-es/logic/common.js.map +1 -1
  236. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  237. package/lib-es/logic/craftTransaction.js +7 -4
  238. package/lib-es/logic/craftTransaction.js.map +1 -1
  239. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  240. package/lib-es/logic/estimateFees.js +11 -8
  241. package/lib-es/logic/estimateFees.js.map +1 -1
  242. package/lib-es/logic/getBalance.d.ts.map +1 -1
  243. package/lib-es/logic/getBalance.js +9 -9
  244. package/lib-es/logic/getBalance.js.map +1 -1
  245. package/lib-es/logic/getBlock.d.ts.map +1 -1
  246. package/lib-es/logic/getBlock.js +18 -18
  247. package/lib-es/logic/getBlock.js.map +1 -1
  248. package/lib-es/logic/getBlockInfo.js +2 -2
  249. package/lib-es/logic/getBlockInfo.js.map +1 -1
  250. package/lib-es/logic/getNextSequence.d.ts.map +1 -1
  251. package/lib-es/logic/getNextSequence.js +1 -1
  252. package/lib-es/logic/getNextSequence.js.map +1 -1
  253. package/lib-es/logic/getStakes.d.ts.map +1 -1
  254. package/lib-es/logic/getStakes.js +10 -10
  255. package/lib-es/logic/getStakes.js.map +1 -1
  256. package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
  257. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  258. package/lib-es/logic/internalTransactionsFetcher.js +9 -9
  259. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  260. package/lib-es/logic/lastBlock.js +2 -2
  261. package/lib-es/logic/lastBlock.js.map +1 -1
  262. package/lib-es/logic/listOperations.d.ts.map +1 -1
  263. package/lib-es/logic/listOperations.js +1 -1
  264. package/lib-es/logic/listOperations.js.map +1 -1
  265. package/lib-es/logic/predicates.d.ts +17 -0
  266. package/lib-es/logic/predicates.d.ts.map +1 -0
  267. package/lib-es/logic/predicates.js +114 -0
  268. package/lib-es/logic/predicates.js.map +1 -0
  269. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  270. package/lib-es/logic/validateIntent.js +9 -9
  271. package/lib-es/logic/validateIntent.js.map +1 -1
  272. package/lib-es/logic.d.ts +1 -1
  273. package/lib-es/logic.d.ts.map +1 -1
  274. package/lib-es/logic.js +14 -13
  275. package/lib-es/logic.js.map +1 -1
  276. package/lib-es/network/explorer/etherscan.d.ts +2 -3
  277. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  278. package/lib-es/network/explorer/etherscan.js +6 -8
  279. package/lib-es/network/explorer/etherscan.js.map +1 -1
  280. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  281. package/lib-es/network/explorer/ledger.js +5 -5
  282. package/lib-es/network/explorer/ledger.js.map +1 -1
  283. package/lib-es/network/explorer/types.d.ts +2 -2
  284. package/lib-es/network/explorer/types.d.ts.map +1 -1
  285. package/lib-es/network/explorer/types.js +11 -1
  286. package/lib-es/network/explorer/types.js.map +1 -1
  287. package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
  288. package/lib-es/network/gasTracker/ledger.js +1 -3
  289. package/lib-es/network/gasTracker/ledger.js.map +1 -1
  290. package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
  291. package/lib-es/network/node/explorerProxy.js +22 -17
  292. package/lib-es/network/node/explorerProxy.js.map +1 -1
  293. package/lib-es/network/node/gethCallTracerToTraceBlockItems.d.ts.map +1 -1
  294. package/lib-es/network/node/gethCallTracerToTraceBlockItems.js +4 -6
  295. package/lib-es/network/node/gethCallTracerToTraceBlockItems.js.map +1 -1
  296. package/lib-es/network/node/index.d.ts +1 -1
  297. package/lib-es/network/node/index.d.ts.map +1 -1
  298. package/lib-es/network/node/index.js +7 -7
  299. package/lib-es/network/node/index.js.map +1 -1
  300. package/lib-es/network/node/ledger.d.ts +3 -1
  301. package/lib-es/network/node/ledger.d.ts.map +1 -1
  302. package/lib-es/network/node/ledger.js +38 -24
  303. package/lib-es/network/node/ledger.js.map +1 -1
  304. package/lib-es/network/node/rpc.common.d.ts +1 -1
  305. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  306. package/lib-es/network/node/rpc.common.js +102 -101
  307. package/lib-es/network/node/rpc.common.js.map +1 -1
  308. package/lib-es/network/node/types.d.ts +21 -22
  309. package/lib-es/network/node/types.d.ts.map +1 -1
  310. package/lib-es/network/node/types.js +0 -25
  311. package/lib-es/network/node/types.js.map +1 -1
  312. package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
  313. package/lib-es/network/node/withNodeSources.js +15 -15
  314. package/lib-es/network/node/withNodeSources.js.map +1 -1
  315. package/lib-es/nodeSources.d.ts.map +1 -1
  316. package/lib-es/nodeSources.js +11 -3
  317. package/lib-es/nodeSources.js.map +1 -1
  318. package/lib-es/staking/abis.d.ts +3 -2
  319. package/lib-es/staking/abis.d.ts.map +1 -1
  320. package/lib-es/staking/abis.js +10 -9
  321. package/lib-es/staking/abis.js.map +1 -1
  322. package/lib-es/staking/contracts.d.ts +3 -2
  323. package/lib-es/staking/contracts.d.ts.map +1 -1
  324. package/lib-es/staking/contracts.js +12 -13
  325. package/lib-es/staking/contracts.js.map +1 -1
  326. package/lib-es/staking/detectOperationType.d.ts +2 -4
  327. package/lib-es/staking/detectOperationType.d.ts.map +1 -1
  328. package/lib-es/staking/detectOperationType.js +22 -21
  329. package/lib-es/staking/detectOperationType.js.map +1 -1
  330. package/lib-es/staking/encoder.d.ts +2 -1
  331. package/lib-es/staking/encoder.d.ts.map +1 -1
  332. package/lib-es/staking/encoder.js +8 -8
  333. package/lib-es/staking/encoder.js.map +1 -1
  334. package/lib-es/staking/fetchers.d.ts +2 -1
  335. package/lib-es/staking/fetchers.d.ts.map +1 -1
  336. package/lib-es/staking/fetchers.js +27 -27
  337. package/lib-es/staking/fetchers.js.map +1 -1
  338. package/lib-es/staking/logic.d.ts +6 -6
  339. package/lib-es/staking/logic.d.ts.map +1 -1
  340. package/lib-es/staking/logic.js +14 -13
  341. package/lib-es/staking/logic.js.map +1 -1
  342. package/lib-es/staking/operations/index.d.ts +2 -1
  343. package/lib-es/staking/operations/index.d.ts.map +1 -1
  344. package/lib-es/staking/operations/index.js +39 -20
  345. package/lib-es/staking/operations/index.js.map +1 -1
  346. package/lib-es/staking/prepareIntents.d.ts +1 -1
  347. package/lib-es/staking/prepareIntents.d.ts.map +1 -1
  348. package/lib-es/staking/prepareIntents.js +13 -11
  349. package/lib-es/staking/prepareIntents.js.map +1 -1
  350. package/lib-es/staking/redelegations.d.ts +4 -4
  351. package/lib-es/staking/redelegations.d.ts.map +1 -1
  352. package/lib-es/staking/redelegations.js +19 -24
  353. package/lib-es/staking/redelegations.js.map +1 -1
  354. package/lib-es/staking/rewards.d.ts +1 -1
  355. package/lib-es/staking/rewards.d.ts.map +1 -1
  356. package/lib-es/staking/rewards.js +2 -2
  357. package/lib-es/staking/rewards.js.map +1 -1
  358. package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
  359. package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
  360. package/lib-es/staking/rewardsFromReceipt.js +2 -2
  361. package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
  362. package/lib-es/staking/transactionData.d.ts +2 -1
  363. package/lib-es/staking/transactionData.d.ts.map +1 -1
  364. package/lib-es/staking/transactionData.js +6 -6
  365. package/lib-es/staking/transactionData.js.map +1 -1
  366. package/lib-es/staking/unbondings.d.ts +1 -1
  367. package/lib-es/staking/unbondings.d.ts.map +1 -1
  368. package/lib-es/staking/unbondings.js +2 -2
  369. package/lib-es/staking/unbondings.js.map +1 -1
  370. package/lib-es/staking/utils.d.ts.map +1 -1
  371. package/lib-es/staking/utils.js +20 -25
  372. package/lib-es/staking/utils.js.map +1 -1
  373. package/lib-es/staking/validators/index.d.ts +14 -14
  374. package/lib-es/staking/validators/index.d.ts.map +1 -1
  375. package/lib-es/staking/validators/index.js +39 -38
  376. package/lib-es/staking/validators/index.js.map +1 -1
  377. package/lib-es/staking/validators/monad.d.ts +5 -5
  378. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  379. package/lib-es/staking/validators/monad.js +43 -36
  380. package/lib-es/staking/validators/monad.js.map +1 -1
  381. package/lib-es/staking/validators/monadResolver.d.ts +1 -1
  382. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  383. package/lib-es/staking/validators/monadResolver.js +6 -5
  384. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  385. package/lib-es/staking/validators/sei.js +2 -2
  386. package/lib-es/staking/validators/sei.js.map +1 -1
  387. package/lib-es/staking/validators/somnia.d.ts +4 -4
  388. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  389. package/lib-es/staking/validators/somnia.js +24 -23
  390. package/lib-es/staking/validators/somnia.js.map +1 -1
  391. package/lib-es/staking/validators/types.d.ts +1 -1
  392. package/lib-es/staking/validators/types.d.ts.map +1 -1
  393. package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
  394. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  395. package/lib-es/staking/validators/zero_gravity.js +9 -8
  396. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  397. package/lib-es/types/staking.d.ts +5 -6
  398. package/lib-es/types/staking.d.ts.map +1 -1
  399. package/package.json +2 -2
  400. package/src/abis/index.test.ts +36 -0
  401. package/src/abis/index.ts +30 -0
  402. package/src/adapters/blockOperations.ts +1 -1
  403. package/src/adapters/etherscan.test.ts +34 -38
  404. package/src/adapters/etherscan.ts +3 -2
  405. package/src/adapters/ledger.test.ts +49 -22
  406. package/src/adapters/ledger.ts +3 -2
  407. package/src/api/getBlock.integ.test.ts +2 -1
  408. package/src/api/index.monad_testnet.integ.test.ts +2 -2
  409. package/src/api/index.ts +4 -3
  410. package/src/chains.test.ts +12 -0
  411. package/src/chains.ts +97 -0
  412. package/src/config.ts +5 -1
  413. package/src/fixtures/staking.fixtures.ts +13 -0
  414. package/src/internalTxSources.ts +20 -3
  415. package/src/logic/broadcast.ts +2 -2
  416. package/src/logic/common.ts +23 -14
  417. package/src/logic/craftTransaction.ts +6 -5
  418. package/src/logic/estimateFees.ts +10 -25
  419. package/src/logic/getBalance.ts +7 -13
  420. package/src/logic/getBlock.ts +22 -19
  421. package/src/logic/getBlockInfo.ts +2 -2
  422. package/src/logic/getNextSequence.ts +1 -4
  423. package/src/logic/getStakes.ts +11 -12
  424. package/src/logic/internalTransactionsFetcher.ts +7 -9
  425. package/src/logic/lastBlock.ts +2 -2
  426. package/src/logic/listOperations.ts +0 -1
  427. package/src/logic/predicates.ts +124 -0
  428. package/src/logic/tests/broadcast.test.ts +4 -4
  429. package/src/logic/tests/broadcastSource.test.ts +0 -3
  430. package/src/logic/tests/common.test.ts +17 -33
  431. package/src/logic/tests/craftTransaction.test.ts +13 -6
  432. package/src/logic/tests/estimateFees.test.ts +16 -7
  433. package/src/logic/tests/getBalance.test.ts +17 -33
  434. package/src/logic/tests/getBlock.test.ts +69 -75
  435. package/src/logic/tests/getBlockInfo.test.ts +1 -1
  436. package/src/logic/tests/getNextSequence.test.ts +1 -1
  437. package/src/logic/tests/getStakes.test.ts +28 -16
  438. package/src/logic/tests/internalTransactionsFetcher.test.ts +5 -5
  439. package/src/logic/tests/lastBlock.test.ts +3 -6
  440. package/src/logic/tests/listOperations.test.ts +3 -4
  441. package/src/logic/tests/validateIntent.test.ts +16 -3
  442. package/src/logic/validateIntent.ts +8 -10
  443. package/src/logic.test.ts +12 -4
  444. package/src/logic.ts +13 -13
  445. package/src/network/explorer/etherscan.test.ts +9 -58
  446. package/src/network/explorer/etherscan.ts +8 -24
  447. package/src/network/explorer/index.test.ts +1 -1
  448. package/src/network/explorer/ledger.test.ts +44 -146
  449. package/src/network/explorer/ledger.ts +2 -5
  450. package/src/network/explorer/types.ts +12 -5
  451. package/src/network/gasTracker/ledger.ts +1 -4
  452. package/src/network/node/explorerProxy.test.ts +17 -22
  453. package/src/network/node/explorerProxy.ts +23 -20
  454. package/src/network/node/gethCallTracerToTraceBlockItems.test.ts +1 -1
  455. package/src/network/node/gethCallTracerToTraceBlockItems.ts +6 -9
  456. package/src/network/node/index.memoization.test.ts +29 -22
  457. package/src/network/node/index.test.ts +1 -3
  458. package/src/network/node/index.ts +11 -8
  459. package/src/network/node/ledger.test.ts +63 -69
  460. package/src/network/node/ledger.ts +39 -38
  461. package/src/network/node/rpc.common.ts +134 -158
  462. package/src/network/node/rpc.test.ts +201 -110
  463. package/src/network/node/types.ts +17 -64
  464. package/src/network/node/withNodeSources.test.ts +7 -9
  465. package/src/network/node/withNodeSources.ts +23 -26
  466. package/src/nodeSources.ts +11 -3
  467. package/src/staking/abis.test.ts +24 -28
  468. package/src/staking/abis.ts +12 -10
  469. package/src/staking/contracts.test.ts +20 -8
  470. package/src/staking/contracts.ts +13 -14
  471. package/src/staking/detectOperationType.test.ts +16 -13
  472. package/src/staking/detectOperationType.ts +24 -22
  473. package/src/staking/encoder.test.ts +38 -27
  474. package/src/staking/encoder.ts +9 -8
  475. package/src/staking/fetchers.ts +28 -39
  476. package/src/staking/logic.test.ts +34 -32
  477. package/src/staking/logic.ts +14 -14
  478. package/src/staking/operations/index.test.ts +48 -39
  479. package/src/staking/operations/index.ts +43 -21
  480. package/src/staking/prepareIntents.test.ts +14 -34
  481. package/src/staking/prepareIntents.ts +12 -14
  482. package/src/staking/redelegations.test.ts +73 -131
  483. package/src/staking/redelegations.ts +13 -31
  484. package/src/staking/rewards.test.ts +19 -21
  485. package/src/staking/rewards.ts +1 -2
  486. package/src/staking/rewardsFromReceipt.test.ts +9 -8
  487. package/src/staking/rewardsFromReceipt.ts +3 -2
  488. package/src/staking/transactionData.test.ts +35 -25
  489. package/src/staking/transactionData.ts +7 -6
  490. package/src/staking/unbondings.test.ts +26 -20
  491. package/src/staking/unbondings.ts +1 -2
  492. package/src/staking/utils.ts +19 -26
  493. package/src/staking/validators/index.ts +45 -51
  494. package/src/staking/validators/monad.test.ts +52 -54
  495. package/src/staking/validators/monad.ts +42 -40
  496. package/src/staking/validators/monadResolver.ts +4 -5
  497. package/src/staking/validators/sei.ts +2 -2
  498. package/src/staking/validators/somnia.test.ts +22 -19
  499. package/src/staking/validators/somnia.ts +23 -29
  500. package/src/staking/validators/types.ts +0 -1
  501. package/src/staking/validators/zero_gravity.test.ts +34 -49
  502. package/src/staking/validators/zero_gravity.ts +7 -12
  503. package/src/staking/validators.integ.test.ts +3 -5
  504. package/src/staking/validators.test.ts +56 -53
  505. package/src/types/staking.ts +3 -6
@@ -12,28 +12,27 @@ export const getStakes = async (
12
12
  address: string,
13
13
  options?: StakesOptions
14
14
  ): Promise<Page<Stake>> => {
15
- const contractConfig = STAKING_CONTRACTS[currencyId]
16
- if (!contractConfig) {
17
- return { items: [] }
18
- }
19
-
20
- const stakingStrategy = STAKING_CONFIG[currencyId]
21
- if (!stakingStrategy) {
22
- return { items: [] }
23
- }
24
-
25
15
  try {
26
16
  const config = await context.config(currencyId)
17
+ const contractConfig = STAKING_CONTRACTS[config.chainId]
18
+ if (!contractConfig) {
19
+ return { items: [] }
20
+ }
21
+
22
+ const stakingStrategy = STAKING_CONFIG[config.chainId]
23
+ if (!stakingStrategy) {
24
+ return { items: [] }
25
+ }
26
+
27
27
  const [stakes, unbondings] = await Promise.all([
28
28
  stakingStrategy.fetcher(
29
29
  config,
30
30
  address,
31
31
  contractConfig,
32
- currencyId,
33
32
  context.logger,
34
33
  options?.knownValidatorIds
35
34
  ),
36
- fetchUnbondings(config, currencyId, address, context.logger).catch(() => []),
35
+ fetchUnbondings(config, address, context.logger).catch(() => []),
37
36
  ])
38
37
  return { items: [...stakes, ...unbondings] }
39
38
  } catch {
@@ -42,7 +42,7 @@ async function runInternalTxSources(
42
42
  try {
43
43
  return await fetchers[source](height)
44
44
  } catch (error) {
45
- if ((error as { name?: string })?.name === 'SourceUnavailableError') {
45
+ if (error instanceof SourceUnavailableError) {
46
46
  hadUnavailableSource = true
47
47
  continue
48
48
  }
@@ -71,7 +71,6 @@ export function composeInternalTxsFetcher(
71
71
  export function makeSourceFetchers(
72
72
  config: EvmConfigInfo,
73
73
  nodeApi: NodeApi,
74
- currencyId: string,
75
74
  logger: Logger
76
75
  ): Record<InternalTxSource, SourceFetcher> {
77
76
  const { explorer } = config || {}
@@ -80,7 +79,7 @@ export function makeSourceFetchers(
80
79
  trace_block: (height: number) => {
81
80
  if (nodeApi.traceBlockErigon === undefined) {
82
81
  logger('coin-evm', 'debug: trace_block internal tx source unavailable', {
83
- currencyId,
82
+ currency: config.name,
84
83
  blockHeight: height,
85
84
  })
86
85
  return Promise.reject(
@@ -88,13 +87,13 @@ export function makeSourceFetchers(
88
87
  )
89
88
  }
90
89
  return nodeApi
91
- .traceBlockErigon(currencyId, height)
90
+ .traceBlockErigon(height)
92
91
  .then((items) => traceBlockItemsToOperationsByHash(items, logger))
93
92
  },
94
93
  debug_traceBlockByNumber: (height: number) => {
95
94
  if (nodeApi.traceBlockGeth === undefined) {
96
95
  logger('coin-evm', 'debug: debug_traceBlockByNumber internal tx source unavailable', {
97
- currencyId,
96
+ currency: config.name,
98
97
  blockHeight: height,
99
98
  })
100
99
  return Promise.reject(
@@ -104,7 +103,7 @@ export function makeSourceFetchers(
104
103
  )
105
104
  }
106
105
  return nodeApi
107
- .traceBlockGeth(currencyId, height)
106
+ .traceBlockGeth(height)
108
107
  .then((items) => traceBlockItemsToOperationsByHash(items, logger))
109
108
  },
110
109
  explorer: (height: number) => {
@@ -119,7 +118,7 @@ export function makeSourceFetchers(
119
118
  .then((txs) => internalTxsToOperationsByHash(txs, logger))
120
119
  .catch((error) => {
121
120
  logger('coin-evm', 'debug: explorer internal txs failed, falling through', {
122
- currencyId,
121
+ currency: config.name,
123
122
  blockHeight: height,
124
123
  error,
125
124
  })
@@ -133,9 +132,8 @@ export function makeSourceFetchers(
133
132
  export function createInternalTransactionsFetcher(
134
133
  config: EvmConfigInfo,
135
134
  nodeApi: NodeApi,
136
- currencyId: string,
137
135
  sources: readonly InternalTxSource[],
138
136
  logger: Logger
139
137
  ): SourceFetcher {
140
- return composeInternalTxsFetcher(sources, makeSourceFetchers(config, nodeApi, currencyId, logger))
138
+ return composeInternalTxsFetcher(sources, makeSourceFetchers(config, nodeApi, logger))
141
139
  }
@@ -7,9 +7,9 @@ import { getNodeApi } from '../network/node'
7
7
 
8
8
  export async function lastBlock(context: EvmContext, currencyId: string): Promise<BlockInfo> {
9
9
  const config = await context.config(currencyId)
10
- const api = getNodeApi(config, currencyId, context.logger)
10
+ const api = getNodeApi(config, context.logger)
11
11
  const { finalizationLevel = 'latest' } = config
12
- const result = await api.getBlockByHeight(currencyId, finalizationLevel)
12
+ const result = await api.getBlockByHeight(finalizationLevel)
13
13
 
14
14
  return {
15
15
  height: result.height,
@@ -71,7 +71,6 @@ export async function listOperations(
71
71
  } = await explorerApi.getOperations(
72
72
  config,
73
73
  context.logger,
74
- currencyId,
75
74
  address,
76
75
  options.minHeight,
77
76
  undefined,
@@ -0,0 +1,124 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type {
5
+ LogWithAddress,
6
+ TraceBlockCallAction,
7
+ TraceBlockItem,
8
+ TransactionReceipt,
9
+ } from '../network/node/types'
10
+ import type { FeesStrategy } from '@ledgerhq/coin-module-framework/api/index'
11
+
12
+ /** Plain object. Arrays are objects in JavaScript, so they are rejected here. */
13
+ export function isRecord(value: unknown): value is Record<string, unknown> {
14
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
15
+ }
16
+
17
+ export function isString(value: unknown): value is string {
18
+ return typeof value === 'string'
19
+ }
20
+
21
+ export function isBigInt(value: unknown): value is bigint {
22
+ return typeof value === 'bigint'
23
+ }
24
+
25
+ export function isOptionalString(value: unknown): value is string | null | undefined {
26
+ return value === undefined || value === null || isString(value)
27
+ }
28
+
29
+ /** A quantity already decoded by ethers (`bigint`) or still carried as a string. */
30
+ export function isQuantity(value: unknown): value is bigint | string {
31
+ return isBigInt(value) || isString(value)
32
+ }
33
+
34
+ /** {@link isQuantity}, or JSON null / a missing field. */
35
+ export function isOptionalQuantity(value: unknown): value is bigint | string | null | undefined {
36
+ return isOptionalString(value) || isBigInt(value)
37
+ }
38
+
39
+ /** Hex or decimal integer string that `BigInt` accepts. Rejects leading-zero decimals such as `"01"`. */
40
+ function isBigIntString(value: unknown): value is string {
41
+ if (!isString(value) || !/^(?:0x[0-9a-fA-F]+|[0-9]+)$/.test(value)) return false
42
+ try {
43
+ BigInt(value)
44
+ return true
45
+ } catch {
46
+ return false
47
+ }
48
+ }
49
+
50
+ function isOptionalBigIntString(value: unknown): value is string | null | undefined {
51
+ return value === undefined || value === null || isBigIntString(value)
52
+ }
53
+
54
+ /**
55
+ * Value `Number` can convert without producing `NaN` or dropping low bits.
56
+ * Accepts a safe integer, or a hex/decimal string equal to that integer.
57
+ */
58
+ function isNonNegativeSafeInteger(value: unknown): value is string | number {
59
+ if (typeof value === 'number') return Number.isSafeInteger(value) && value >= 0
60
+ if (!isBigIntString(value)) return false
61
+ const parsed = Number(value)
62
+ return Number.isSafeInteger(parsed) && parsed >= 0 && BigInt(parsed) === BigInt(value)
63
+ }
64
+
65
+ function isReceiptStatus(value: unknown): value is TransactionReceipt['status'] {
66
+ return value === null || isNonNegativeSafeInteger(value)
67
+ }
68
+
69
+ function isReceiptType(value: unknown): value is TransactionReceipt['type'] {
70
+ if (value === undefined || value === null) return true
71
+ return isString(value) && isNonNegativeSafeInteger(value)
72
+ }
73
+
74
+ function isLogWithAddress(value: unknown): value is LogWithAddress {
75
+ if (!isRecord(value)) return false
76
+ if (!isString(value.address)) return false
77
+ // `0x` is valid empty log data. Any longer value is passed to `BigInt` for ERC20 amounts.
78
+ if (!isString(value.data) || !/^0x[0-9a-fA-F]*$/.test(value.data)) return false
79
+ return Array.isArray(value.topics) && value.topics.every(isString)
80
+ }
81
+
82
+ export function isTransactionReceipt(value: unknown): value is TransactionReceipt {
83
+ if (!isRecord(value)) return false
84
+ if (!isString(value.transactionHash)) return false
85
+ if (!isBigIntString(value.gasUsed)) return false
86
+ if (!isOptionalBigIntString(value.effectiveGasPrice)) return false
87
+ if (!isOptionalBigIntString(value.gasPrice)) return false
88
+ if (!isReceiptStatus(value.status)) return false
89
+ if (!isReceiptType(value.type)) return false
90
+ // Non-standard OP-stack field. Only a string is later passed to `BigInt`.
91
+ if (isString(value.l1Fee) && !isBigIntString(value.l1Fee)) return false
92
+ return Array.isArray(value.logs) && value.logs.every(isLogWithAddress)
93
+ }
94
+
95
+ export function isTraceBlockCallAction(action: unknown): action is TraceBlockCallAction {
96
+ if (!isRecord(action)) return false
97
+ return (
98
+ isString(action.from) &&
99
+ isString(action.to) &&
100
+ isString(action.callType) &&
101
+ isString(action.value)
102
+ )
103
+ }
104
+
105
+ /** Type guard for {@link TraceBlockItem} (Erigon `trace_block` and Geth adapter output). */
106
+ export function isTraceBlockItem(value: unknown): value is TraceBlockItem {
107
+ if (!isRecord(value) || !isRecord(value.action)) return false
108
+ if (value.error !== undefined && !isString(value.error)) return false
109
+
110
+ const result = value.result
111
+ const resultOk =
112
+ result === undefined ||
113
+ result === null ||
114
+ (isRecord(result) && (result.error === undefined || isString(result.error)))
115
+ const validCall = isString(value.transactionHash) && resultOk
116
+
117
+ return !isTraceBlockCallAction(value.action) || validCall
118
+ }
119
+
120
+ const FEES_STRATEGIES = new Set<string>(['slow', 'medium', 'fast', 'custom'])
121
+
122
+ export function isFeesStrategy(value: unknown): value is FeesStrategy {
123
+ return isString(value) && FEES_STRATEGIES.has(value)
124
+ }
@@ -27,8 +27,8 @@ describe('broadcastLogic', () => {
27
27
  signature: '0xabcdef',
28
28
  broadcastConfig: { mevProtected: true },
29
29
  })
30
- expect(mockGetNodeApi).toHaveBeenCalledWith(expect.anything(), 'ethereum', expect.any(Function))
31
- expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('ethereum', '0xabcdef', {
30
+ expect(mockGetNodeApi).toHaveBeenCalledWith(expect.anything(), expect.any(Function))
31
+ expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('0xabcdef', {
32
32
  mevProtected: true,
33
33
  })
34
34
  expect(result).toBe('txid123')
@@ -50,7 +50,7 @@ describe('broadcastLogic', () => {
50
50
  signature: '0xabcdef',
51
51
  broadcastConfig: undefined,
52
52
  })
53
- expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('ethereum', '0xabcdef', undefined)
53
+ expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('0xabcdef', undefined)
54
54
  expect(result).toBe('txid456')
55
55
  })
56
56
 
@@ -60,7 +60,7 @@ describe('broadcastLogic', () => {
60
60
  signature: '0x123456',
61
61
  broadcastConfig: { mevProtected: true },
62
62
  })
63
- expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('ethereum', '0x123456', {
63
+ expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('0x123456', {
64
64
  mevProtected: true,
65
65
  })
66
66
  expect(result).toBe('txid789')
@@ -35,7 +35,6 @@ describe('EVM broadcast with source', () => {
35
35
  })
36
36
 
37
37
  expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith(
38
- 'ethereum',
39
38
  '0xsignature',
40
39
  expect.objectContaining({
41
40
  mevProtected: true,
@@ -62,7 +61,6 @@ describe('EVM broadcast with source', () => {
62
61
  })
63
62
 
64
63
  expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith(
65
- 'ethereum',
66
64
  '0xsignature',
67
65
  expect.objectContaining({
68
66
  source: {
@@ -83,7 +81,6 @@ describe('EVM broadcast with source', () => {
83
81
  })
84
82
 
85
83
  expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith(
86
- 'ethereum',
87
84
  '0xsignature',
88
85
  expect.objectContaining({
89
86
  mevProtected: false,
@@ -8,6 +8,7 @@ import {
8
8
  createStakingTransactionIntentMockData,
9
9
  } from '@ledgerhq/coin-module-framework/test-utils'
10
10
  import { BigNumber } from 'bignumber.js'
11
+ import { CHAIN_ID } from '../../config'
11
12
  import {
12
13
  createMockEvmConfigInfo,
13
14
  mkExternalNode,
@@ -37,7 +38,7 @@ jest.mock('../../network/node', () => ({
37
38
  jest.mock('../../staking', () => ({
38
39
  ...jest.requireActual('../../staking'),
39
40
  buildStakingTransactionParams: jest.fn(),
40
- prepareStakingIntent: jest.fn((_config, _currencyId, intent) => Promise.resolve(intent)),
41
+ prepareStakingIntent: jest.fn((_config, intent) => Promise.resolve(intent)),
41
42
  }))
42
43
 
43
44
  const mockGetNodeApi = jest.mocked(getNodeApi)
@@ -50,6 +51,9 @@ const testConfig = createMockEvmConfigInfo({
50
51
  node: mkExternalNode({ uri: 'https://test' }),
51
52
  })
52
53
 
54
+ const seiConfig = { ...testConfig, chainId: CHAIN_ID.SEI_EVM }
55
+ const zeroGravityConfig = { ...testConfig, chainId: CHAIN_ID.ZERO_GRAVITY }
56
+
53
57
  describe('common', () => {
54
58
  describe('getCallData', () => {
55
59
  beforeEach(() => {
@@ -200,21 +204,20 @@ describe('common', () => {
200
204
  .mockResolvedValueOnce(new BigNumber(70_000))
201
205
 
202
206
  const result = await prepareUnsignedTxParams(
203
- testConfig,
204
- 'sei_evm',
207
+ seiConfig,
205
208
  makeStakingIntent(spendableBalance),
206
209
  testLogger
207
210
  )
208
211
 
209
212
  expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
210
213
  // First call used the full balance
211
- expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(1, 'sei_evm', '0xSender', {
214
+ expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(1, '0xSender', {
212
215
  amount: new BigNumber(spendableBalance.toString()),
213
216
  recipient: stakingContractAddress,
214
217
  data: stakingData,
215
218
  })
216
219
  // Retry used the minimum calldata unit for the chain (calldataAmountScale)
217
- expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, 'sei_evm', '0xSender', {
220
+ expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '0xSender', {
218
221
  amount: new BigNumber(USEI_TO_EVM_SCALE.toString()),
219
222
  recipient: stakingContractAddress,
220
223
  data: stakingData,
@@ -234,15 +237,10 @@ describe('common', () => {
234
237
  .mockRejectedValueOnce(GAS_ESTIMATION_ERROR)
235
238
  .mockResolvedValueOnce(new BigNumber(70_000))
236
239
 
237
- const result = await prepareUnsignedTxParams(
238
- testConfig,
239
- 'sei_evm',
240
- makeStakingIntent(0n),
241
- testLogger
242
- )
240
+ const result = await prepareUnsignedTxParams(seiConfig, makeStakingIntent(0n), testLogger)
243
241
 
244
242
  expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
245
- expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, 'sei_evm', '0xSender', {
243
+ expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '0xSender', {
246
244
  amount: new BigNumber(USEI_TO_EVM_SCALE.toString()),
247
245
  recipient: stakingContractAddress,
248
246
  data: stakingData,
@@ -259,12 +257,7 @@ describe('common', () => {
259
257
 
260
258
  nodeApiMock.getGasEstimation.mockRejectedValue(GAS_ESTIMATION_ERROR)
261
259
 
262
- const result = await prepareUnsignedTxParams(
263
- testConfig,
264
- 'sei_evm',
265
- makeStakingIntent(0n),
266
- testLogger
267
- )
260
+ const result = await prepareUnsignedTxParams(seiConfig, makeStakingIntent(0n), testLogger)
268
261
 
269
262
  expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
270
263
  expect(result.gasLimit).toEqual(new BigNumber(0))
@@ -289,17 +282,12 @@ describe('common', () => {
289
282
  .mockRejectedValueOnce(GAS_ESTIMATION_ERROR)
290
283
  .mockResolvedValueOnce(new BigNumber(1_412_179))
291
284
 
292
- const result = await prepareUnsignedTxParams(
293
- testConfig,
294
- 'sei_evm',
295
- makeStakingIntent(0n),
296
- testLogger
297
- )
285
+ const result = await prepareUnsignedTxParams(seiConfig, makeStakingIntent(0n), testLogger)
298
286
 
299
287
  expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
300
288
  // Retry rebuilds BOTH calldata and value from the min unit (USEI_TO_EVM_SCALE), so the
301
289
  // calldata-encoded amount matches msg.value — otherwise the contract would revert.
302
- expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, 'sei_evm', '0xSender', {
290
+ expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '0xSender', {
303
291
  amount: new BigNumber(USEI_TO_EVM_SCALE.toString()),
304
292
  recipient: stakingContractAddress,
305
293
  data: Buffer.from(`delegate:${USEI_TO_EVM_SCALE.toString()}`),
@@ -318,8 +306,7 @@ describe('common', () => {
318
306
  nodeApiMock.getGasEstimation.mockResolvedValueOnce(new BigNumber(237_279))
319
307
 
320
308
  const result = await prepareUnsignedTxParams(
321
- testConfig,
322
- 'zero_gravity',
309
+ zeroGravityConfig,
323
310
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
324
311
  type: 'staking-eip1559',
325
312
  mode: 'delegate',
@@ -347,8 +334,7 @@ describe('common', () => {
347
334
  nodeApiMock.getGasEstimation.mockResolvedValueOnce(new BigNumber(237_279))
348
335
 
349
336
  const result = await prepareUnsignedTxParams(
350
- testConfig,
351
- 'zero_gravity',
337
+ zeroGravityConfig,
352
338
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
353
339
  type: 'staking-eip1559',
354
340
  mode: 'undelegate',
@@ -374,8 +360,7 @@ describe('common', () => {
374
360
  })
375
361
 
376
362
  const result = await prepareUnsignedTxParams(
377
- testConfig,
378
- 'zero_gravity',
363
+ zeroGravityConfig,
379
364
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
380
365
  type: 'staking-eip1559',
381
366
  mode: 'delegate',
@@ -399,8 +384,7 @@ describe('common', () => {
399
384
  nodeApiMock.getGasEstimation.mockRejectedValueOnce(GAS_ESTIMATION_ERROR)
400
385
 
401
386
  const result = await prepareUnsignedTxParams(
402
- testConfig,
403
- 'sei_evm',
387
+ seiConfig,
404
388
  createSendTransactionIntentMockData<MemoNotSupported, BufferTxData>({
405
389
  type: 'send-legacy',
406
390
  amount: 1n,
@@ -9,6 +9,7 @@ import {
9
9
  } from '@ledgerhq/coin-module-framework/test-utils'
10
10
  import BigNumber from 'bignumber.js'
11
11
  import { ethers } from 'ethers'
12
+ import { CHAIN_ID } from '../../config'
12
13
  import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
13
14
  import { getNodeApi } from '../../network/node'
14
15
  import { mockNodeApi } from '../../network/node/node.fixtures'
@@ -29,7 +30,7 @@ describe('craftTransaction', () => {
29
30
  const ledgerMocks = mockNodeApi()
30
31
  beforeEach(() => {
31
32
  jest.clearAllMocks()
32
- mockGetNodeApi.mockImplementation((config: EvmConfigInfo, _currencyId: string) => {
33
+ mockGetNodeApi.mockImplementation((config: EvmConfigInfo) => {
33
34
  return config?.node?.type === 'ledger' ? ledgerMocks : externalMocks
34
35
  })
35
36
  })
@@ -376,7 +377,10 @@ describe('craftTransaction', () => {
376
377
  ] as const)(
377
378
  'crafts a SEI staking delegate transaction using %s',
378
379
  async (_, type, mocks) => {
379
- const context = createMockEvmContext({ node: nodeFor(type), chainId: 42 })
380
+ const context = createMockEvmContext({
381
+ node: nodeFor(type),
382
+ chainId: CHAIN_ID.SEI_EVM,
383
+ })
380
384
  mocks.getTransactionCount.mockResolvedValue(25)
381
385
  mocks.getGasEstimation.mockResolvedValue(new BigNumber(45000))
382
386
  mocks.getFeeData.mockResolvedValue(feeData)
@@ -403,7 +407,7 @@ describe('craftTransaction', () => {
403
407
  nonce: 25,
404
408
  gasLimit: 45000n,
405
409
  value: 1000000000000000000n,
406
- chainId: 42n,
410
+ chainId: BigInt(CHAIN_ID.SEI_EVM),
407
411
  })
408
412
  expect(parsedTx.data).toMatch(/^0x[a-fA-F0-9]+$/) // encoded delegate function call
409
413
  }
@@ -415,7 +419,10 @@ describe('craftTransaction', () => {
415
419
  ] as const)(
416
420
  'crafts a SEI staking undelegate transaction using %s',
417
421
  async (_, type, mocks) => {
418
- const context = createMockEvmContext({ node: nodeFor(type), chainId: 42 })
422
+ const context = createMockEvmContext({
423
+ node: nodeFor(type),
424
+ chainId: CHAIN_ID.SEI_EVM,
425
+ })
419
426
  mocks.getTransactionCount.mockResolvedValue(26)
420
427
  mocks.getGasEstimation.mockResolvedValue(new BigNumber(50000))
421
428
  mocks.getFeeData.mockResolvedValue(feeData)
@@ -442,7 +449,7 @@ describe('craftTransaction', () => {
442
449
  nonce: 26,
443
450
  gasLimit: 50000n,
444
451
  value: 0n, // SEI undelegate is nonpayable
445
- chainId: 42n,
452
+ chainId: BigInt(CHAIN_ID.SEI_EVM),
446
453
  })
447
454
  expect(parsedTx.data).toMatch(/^0x[a-fA-F0-9]+$/) // encoded undelegate function call
448
455
  }
@@ -503,7 +510,7 @@ describe('craftTransaction', () => {
503
510
  })
504
511
 
505
512
  it('fails to craft staking transaction with unsupported operation', async () => {
506
- const context = createMockEvmContext({ node: mkExternalNode() })
513
+ const context = createMockEvmContext({ node: mkExternalNode(), chainId: CHAIN_ID.SEI_EVM })
507
514
 
508
515
  await expect(
509
516
  craftTransaction(context, 'sei_evm', {
@@ -10,6 +10,7 @@ import type {
10
10
  } from '@ledgerhq/coin-module-framework/api/index'
11
11
  import { createSendTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
12
12
  import BigNumber from 'bignumber.js'
13
+ import { CHAIN_ID } from '../../config'
13
14
  import { GasEstimationError } from '../../errors'
14
15
  import { createMockEvmContext } from '../../fixtures/context.fixtures'
15
16
  import { getGasTracker } from '../../network/gasTracker'
@@ -52,6 +53,14 @@ describe('estimateFees', () => {
52
53
  const context: EvmContext = createMockEvmContext({
53
54
  gasTracker: { type: 'ledger', explorerId: 'eth' },
54
55
  })
56
+ const optimismContext: EvmContext = createMockEvmContext({
57
+ chainId: CHAIN_ID.OPTIMISM,
58
+ gasTracker: { type: 'ledger', explorerId: 'eth' },
59
+ })
60
+ const seiContext: EvmContext = createMockEvmContext({
61
+ chainId: CHAIN_ID.SEI_EVM,
62
+ gasTracker: { type: 'ledger', explorerId: 'eth' },
63
+ })
55
64
 
56
65
  beforeEach(() => {
57
66
  jest.clearAllMocks()
@@ -389,7 +398,7 @@ describe('estimateFees', () => {
389
398
  mockGetGasTracker.mockReturnValue(null)
390
399
  nodeApiMock.getOptimismAdditionalFees.mockResolvedValue(new BigNumber(8000))
391
400
 
392
- const result = await estimateFees(context, 'optimism', {
401
+ const result = await estimateFees(optimismContext, 'optimism', {
393
402
  intentType: 'transaction',
394
403
  type: 'send-legacy',
395
404
  amount: BigInt('1000000000000000000'),
@@ -424,7 +433,7 @@ describe('estimateFees', () => {
424
433
  mockGetGasTracker.mockReturnValue(null)
425
434
  nodeApiMock.getOptimismAdditionalFees.mockResolvedValue(new BigNumber(8000))
426
435
 
427
- const result = await estimateFees(context, 'optimism', {
436
+ const result = await estimateFees(optimismContext, 'optimism', {
428
437
  intentType: 'transaction',
429
438
  type: 'send-legacy',
430
439
  amount: BigInt('1000000000000000000'),
@@ -450,7 +459,7 @@ describe('estimateFees', () => {
450
459
  mockGetGasTracker.mockReturnValue(null)
451
460
  nodeApiMock.getOptimismAdditionalFees.mockResolvedValue(new BigNumber(8000))
452
461
 
453
- const result = await estimateFees(context, 'optimism', {
462
+ const result = await estimateFees(optimismContext, 'optimism', {
454
463
  intentType: 'transaction',
455
464
  type: 'send-legacy',
456
465
  amount: BigInt('1000000000000000000'),
@@ -494,7 +503,7 @@ describe('estimateFees', () => {
494
503
  valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
495
504
  amount: 1000000n,
496
505
  }
497
- const result = await estimateFees(context, 'sei_evm', tokenIntent)
506
+ const result = await estimateFees(seiContext, 'sei_evm', tokenIntent)
498
507
  expect(result).toEqual({
499
508
  value: 420000000000000n,
500
509
  parameters: {
@@ -528,7 +537,7 @@ describe('estimateFees', () => {
528
537
  amount: 1000000n,
529
538
  useAllAmount: true,
530
539
  }
531
- const result = await estimateFees(context, 'sei_evm', delegateMaxIntent)
540
+ const result = await estimateFees(seiContext, 'sei_evm', delegateMaxIntent)
532
541
  expect(result.parameters).toMatchObject({
533
542
  reserve: 10n ** 17n, // 0.1 SEI reserve
534
543
  amountScale: 10n ** 12n, // usei -> wei scale
@@ -546,7 +555,7 @@ describe('estimateFees', () => {
546
555
  amount: 1000000n,
547
556
  }
548
557
 
549
- const result = await estimateFees(context, 'sei_evm', redelegateNoDst)
558
+ const result = await estimateFees(seiContext, 'sei_evm', redelegateNoDst)
550
559
 
551
560
  expect(result).toEqual({ value: 0n })
552
561
  expect(mockGetNodeApi).not.toHaveBeenCalled()
@@ -573,7 +582,7 @@ describe('estimateFees', () => {
573
582
  dstValAddress: 'selfvaloper1uvdqeduxvtchfphueyxraag9qkf8zfznzxs30y',
574
583
  amount: 1000000n,
575
584
  }
576
- const result = await estimateFees(context, 'sei_evm', tokenIntent)
585
+ const result = await estimateFees(seiContext, 'sei_evm', tokenIntent)
577
586
  expect(result).toEqual({
578
587
  value: 420000000000000n,
579
588
  parameters: {