@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
package/src/chains.ts ADDED
@@ -0,0 +1,98 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * The EVM networks coin-evm supports, valued by their EIP-155 chain id.
6
+ */
7
+ export const CHAIN_ID = {
8
+ ETHEREUM: 1,
9
+ EXPANSE: 2,
10
+ UBIQ: 8,
11
+ OPTIMISM: 10,
12
+ FLARE: 14,
13
+ SONGBIRD: 19,
14
+ CRONOS: 25,
15
+ RSK: 30,
16
+ TELOS_EVM: 40,
17
+ LUKSO: 42,
18
+ BSC: 56,
19
+ SYSCOIN: 57,
20
+ GOCHAIN: 60,
21
+ ETHEREUM_CLASSIC: 61,
22
+ ELLAISM: 64,
23
+ MIX: 76,
24
+ TOMO: 88,
25
+ POA: 99,
26
+ VELAS_EVM: 106,
27
+ THUNDERCORE: 108,
28
+ UNICHAIN: 130,
29
+ POLYGON: 137,
30
+ MONAD: 143,
31
+ SONIC: 146,
32
+ BITTORRENT: 199,
33
+ DEXON: 237,
34
+ ENERGY_WEB: 246,
35
+ FANTOM: 250,
36
+ HPB: 269,
37
+ BOBA: 288,
38
+ ZKSYNC_SEPOLIA: 300,
39
+ ZKSYNC: 324,
40
+ SHAPE: 360,
41
+ ASTAR: 592,
42
+ CALLISTO: 820,
43
+ WANCHAIN: 888,
44
+ HYPEREVM: 999,
45
+ KLAYTN_BAOBAB: 1001,
46
+ METIS: 1088,
47
+ POLYGON_ZK_EVM: 1101,
48
+ CORE: 1116,
49
+ MOONBEAM: 1284,
50
+ MOONRIVER: 1285,
51
+ UNICHAIN_SEPOLIA: 1301,
52
+ SEI_EVM: 1329,
53
+ POLYGON_ZK_EVM_TESTNET: 1442,
54
+ STORY: 1514,
55
+ ATHEIOS: 1620,
56
+ ETHERGEM: 1987,
57
+ REOSC: 2894,
58
+ ROBINHOOD: 4663,
59
+ MANTLE: 5000,
60
+ MANTLE_SEPOLIA: 5003,
61
+ SOMNIA: 5031,
62
+ ARC: 5042,
63
+ KLAYTN: 8217,
64
+ BASE: 8453,
65
+ MONAD_TESTNET: 10143,
66
+ ZERO_GRAVITY: 16661,
67
+ ALPEN_TESTNET: 20310,
68
+ ETHERSOCIAL: 31102,
69
+ ADI: 36900,
70
+ ARBITRUM: 42161,
71
+ CELO: 42220,
72
+ ETHERLINK: 42793,
73
+ AVALANCHE_C_CHAIN_FUJI: 43113,
74
+ AVALANCHE_C_CHAIN: 43114,
75
+ ROBINHOOD_TESTNET: 46630,
76
+ SONIC_BLAZE: 57054,
77
+ LINEA_SEPOLIA: 59141,
78
+ LINEA: 59144,
79
+ POLYGON_AMOY: 80002,
80
+ BERACHAIN: 80094,
81
+ BLAST: 81457,
82
+ BASE_SEPOLIA: 84532,
83
+ AKROMA: 200625,
84
+ BITLAYER: 200901,
85
+ ARBITRUM_SEPOLIA: 421614,
86
+ SCROLL: 534352,
87
+ ETHEREUM_HOODI: 560048,
88
+ ETHER1: 1313114,
89
+ ARC_TESTNET: 5042002,
90
+ MUSICOIN: 7762959,
91
+ ETHEREUM_SEPOLIA: 11155111,
92
+ OPTIMISM_SEPOLIA: 11155420,
93
+ BLAST_SEPOLIA: 168587773,
94
+ NEON_EVM: 245022934,
95
+ PIRL: 3125659152,
96
+ } as const
97
+
98
+ export type ChainId = (typeof CHAIN_ID)[keyof typeof CHAIN_ID]
package/src/config.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { ChainId } from './chains'
4
5
  import type { InternalTxSourceList } from './internalTxSources'
5
6
  import type { NodeSourceList } from './nodeSources'
6
7
  import type { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
7
8
 
9
+ export { CHAIN_ID } from './chains'
10
+ export type { ChainId } from './chains'
11
+
8
12
  export type { InternalTxSource, InternalTxSourceList, NonEmptySource } from './internalTxSources'
9
13
  export {
10
14
  DEFAULT_INTERNAL_TX_SOURCES,
@@ -27,7 +31,7 @@ export const DEFAULT_LEDGER_EXPLORER_URI = 'https://explorers.api.live.ledger.co
27
31
  export const DEFAULT_EIP1559_BASE_FEE_MULTIPLIER = 1.6
28
32
 
29
33
  export type EvmConfig = {
30
- chainId: number
34
+ chainId: ChainId
31
35
  node:
32
36
  | {
33
37
  type: 'external'
@@ -0,0 +1,13 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { ChainId } from '../config'
5
+ import type { StakingContractConfig } from '../types/staking'
6
+ import { STAKING_CONTRACTS } from '../staking/contracts'
7
+
8
+ /** The staking contract config of a chain that is expected to have one (registries are partial). */
9
+ export const requireStakingContract = (chainId: ChainId): StakingContractConfig => {
10
+ const config = STAKING_CONTRACTS[chainId]
11
+ if (!config) throw new Error(`No staking contract config for chain ${chainId}`)
12
+ return config
13
+ }
@@ -17,8 +17,8 @@ export async function broadcast(
17
17
  }
18
18
  ): Promise<string> {
19
19
  const config = await context.config(currencyId)
20
- const nodeApi = getNodeApi(config, currencyId, context.logger)
21
- return await nodeApi.broadcastTransaction(currencyId, signature, broadcastConfig)
20
+ const nodeApi = getNodeApi(config, context.logger)
21
+ return await nodeApi.broadcastTransaction(signature, broadcastConfig)
22
22
  }
23
23
 
24
24
  export default broadcast
@@ -125,7 +125,7 @@ function buildSendTxParams(intent: TransactionIntent<MemoNotSupported, BufferTxD
125
125
  }
126
126
 
127
127
  async function estimateGas(
128
- currencyId: string,
128
+ config: EvmConfigInfo,
129
129
  node: ReturnType<typeof getNodeApi>,
130
130
  sender: string,
131
131
  params: { to: string; data: Buffer; value: bigint },
@@ -136,7 +136,7 @@ async function estimateGas(
136
136
  // trying to send more token asset than available.
137
137
  // Fallback to an estimation of 0 to not break the UI.
138
138
  return node
139
- .getGasEstimation(currencyId, sender, {
139
+ .getGasEstimation(sender, {
140
140
  amount: BigNumber(params.value.toString()),
141
141
  recipient: params.to,
142
142
  data: params.data,
@@ -145,15 +145,15 @@ async function estimateGas(
145
145
  if (!isStakingTransactionIntent(transactionIntent)) return new BigNumber(0)
146
146
  // Retry staking gas estimation with the chain min calldata unit (LIVE-32750).
147
147
  // Rebuild calldata + value to keep `msg.value` consistent with calldata-encoded amounts (e.g. Somnia).
148
- const minUnit = STAKING_CONTRACTS[currencyId]?.calldataAmountScale ?? 1n
148
+ const minUnit = STAKING_CONTRACTS[config.chainId]?.calldataAmountScale ?? 1n
149
149
  // Reuse the already-prepared staking intent (enrichment done above) and only
150
150
  // override the amount, so we don't repeat the async on-chain lookups.
151
- const retry = buildStakingTransactionParams(currencyId, {
151
+ const retry = buildStakingTransactionParams(config, {
152
152
  ...(preparedStakingIntent ?? transactionIntent),
153
153
  amount: minUnit,
154
154
  })
155
155
  return node
156
- .getGasEstimation(currencyId, sender, {
156
+ .getGasEstimation(sender, {
157
157
  amount: new BigNumber(retry.value.toString()),
158
158
  recipient: retry.to,
159
159
  data: retry.data,
@@ -164,27 +164,26 @@ async function estimateGas(
164
164
 
165
165
  export async function prepareUnsignedTxParams(
166
166
  config: EvmConfigInfo,
167
- currencyId: string,
168
167
  transactionIntent: TransactionIntent<MemoNotSupported, BufferTxData>,
169
168
  logger: Logger,
170
169
  customFeesParameters?: FeeEstimation['parameters']
171
170
  ): Promise<TransactionLikeWithPreparedParams> {
172
171
  const { sender, type } = transactionIntent
173
172
  const transactionType = getTransactionType(type)
174
- const node = getNodeApi(config, currencyId, logger)
173
+ const node = getNodeApi(config, logger)
175
174
  const isSend = isSendTransactionIntent(transactionIntent)
176
175
 
177
176
  // Prepare staking intents once (can require async on-chain lookups). See: LIVE-32750
178
177
  const preparedStakingIntent = isSend
179
178
  ? undefined
180
- : await prepareStakingIntent(config, currencyId, transactionIntent, logger)
179
+ : await prepareStakingIntent(config, transactionIntent, logger)
181
180
 
182
181
  const { to, data, value } = isSend
183
182
  ? buildSendTxParams(transactionIntent)
184
- : buildStakingTransactionParams(currencyId, preparedStakingIntent ?? transactionIntent)
183
+ : buildStakingTransactionParams(config, preparedStakingIntent ?? transactionIntent)
185
184
 
186
185
  const stakingGasMultiplier = isStakingTransactionIntent(transactionIntent)
187
- ? (STAKING_CONTRACTS[currencyId]?.gasMultiplier?.({ mode: transactionIntent.mode }) ??
186
+ ? (STAKING_CONTRACTS[config.chainId]?.gasMultiplier?.({ mode: transactionIntent.mode }) ??
188
187
  new BigNumber(1))
189
188
  : new BigNumber(1)
190
189
 
@@ -198,7 +197,7 @@ export async function prepareUnsignedTxParams(
198
197
  ? BigNumber(customGasLimit.toString())
199
198
  : (
200
199
  await estimateGas(
201
- currencyId,
200
+ config,
202
201
  node,
203
202
  sender,
204
203
  { to, data, value },
@@ -32,7 +32,6 @@ export async function craftTransaction(
32
32
  const config = await context.config(currencyId)
33
33
  const { type, to, data, value, gasLimit } = await prepareUnsignedTxParams(
34
34
  config,
35
- currencyId,
36
35
  transactionIntent,
37
36
  context.logger,
38
37
  customFees?.parameters
@@ -80,8 +79,8 @@ export async function craftTransaction(
80
79
  }
81
80
 
82
81
  if (!hasFeeData) {
83
- const node = getNodeApi(config, currencyId, context.logger)
84
- const feeData = await node.getFeeData(config, currencyId, {
82
+ const node = getNodeApi(config, context.logger)
83
+ const feeData = await node.getFeeData(config, {
85
84
  type,
86
85
  feesStrategy: isFeesStrategy(customFees?.parameters?.feesStrategy)
87
86
  ? customFees.parameters.feesStrategy
@@ -28,7 +28,6 @@ const SEND_MAX_L1_FEE_BUFFER = new BigNumber(2)
28
28
 
29
29
  async function computeAdditionalFees(
30
30
  config: EvmConfigInfo,
31
- currencyId: string,
32
31
  unsignedTransaction: TransactionLike,
33
32
  logger: Logger
34
33
  ): Promise<BigNumber | undefined> {
@@ -43,12 +42,7 @@ async function computeAdditionalFees(
43
42
  }
44
43
 
45
44
  try {
46
- return await getAdditionalLayer2Fees(
47
- config,
48
- currencyId,
49
- Transaction.from(transaction).serialized,
50
- logger
51
- )
45
+ return await getAdditionalLayer2Fees(config, Transaction.from(transaction).serialized, logger)
52
46
  } catch {
53
47
  return new BigNumber(0)
54
48
  }
@@ -183,8 +177,8 @@ export async function estimateFees(
183
177
  return { finalFeeData: remoteGasOptions[feesStrategy], finalGasOptions: remoteGasOptions }
184
178
  }
185
179
 
186
- const node = getNodeApi(config, currencyId, context.logger)
187
- const feeData = await node.getFeeData(config, currencyId, {
180
+ const node = getNodeApi(config, context.logger)
181
+ const feeData = await node.getFeeData(config, {
188
182
  type: txType,
189
183
  feesStrategy,
190
184
  })
@@ -196,13 +190,7 @@ export async function estimateFees(
196
190
  // all independent network calls and sequencing them triples the latency.
197
191
  const [{ to, data, value, gasLimit }, nonce, { finalFeeData, finalGasOptions }] =
198
192
  await Promise.all([
199
- prepareUnsignedTxParams(
200
- config,
201
- currencyId,
202
- transactionIntent,
203
- context.logger,
204
- customFeesParameters
205
- ),
193
+ prepareUnsignedTxParams(config, transactionIntent, context.logger, customFeesParameters),
206
194
  noncePromise,
207
195
  feeDataPromise,
208
196
  ])
@@ -240,19 +228,14 @@ export async function estimateFees(
240
228
  value,
241
229
  chainId,
242
230
  }
243
- const rawAdditionalFees = await computeAdditionalFees(
244
- config,
245
- currencyId,
246
- unsignedTransaction,
247
- context.logger
248
- )
231
+ const rawAdditionalFees = await computeAdditionalFees(config, unsignedTransaction, context.logger)
249
232
  const additionalFees =
250
233
  transactionIntent.useAllAmount && rawAdditionalFees
251
234
  ? rawAdditionalFees.multipliedBy(SEND_MAX_L1_FEE_BUFFER).integerValue(BigNumber.ROUND_CEIL)
252
235
  : rawAdditionalFees
253
236
 
254
237
  // delegate send-max: expose reserve/scale so the bridge can compute the amount (it has the balance)
255
- const stakingConfig = STAKING_CONTRACTS[currencyId]
238
+ const stakingConfig = STAKING_CONTRACTS[config.chainId]
256
239
  const delegateMaxParams =
257
240
  transactionIntent.useAllAmount &&
258
241
  isStakingIntent(transactionIntent) &&
@@ -27,24 +27,20 @@ export async function getBalance(
27
27
  options?: BalanceOptions
28
28
  ): Promise<Balance[]> {
29
29
  const config = await context.config(currencyId)
30
- const nodeApi = getNodeApi(config, currencyId, context.logger)
30
+ const nodeApi = getNodeApi(config, context.logger)
31
31
  const explorerApi = getExplorerApi(config)
32
32
 
33
33
  const [nativeBalance, tokensBalances] = await Promise.all([
34
- getNativeBalance(currencyId, address, nodeApi),
34
+ getNativeBalance(address, nodeApi),
35
35
  getTokenBalances(context, currencyId, address, nodeApi, explorerApi, config, options),
36
36
  ])
37
37
 
38
38
  return [nativeBalance].concat(tokensBalances)
39
39
  }
40
40
 
41
- async function getNativeBalance(
42
- currencyId: string,
43
- address: string,
44
- nodeApi: NodeApi
45
- ): Promise<Balance> {
41
+ async function getNativeBalance(address: string, nodeApi: NodeApi): Promise<Balance> {
46
42
  // Get native balance for the first element array
47
- const nativeBalance = await nodeApi.getCoinBalance(currencyId, address)
43
+ const nativeBalance = await nodeApi.getCoinBalance(address)
48
44
 
49
45
  return {
50
46
  asset: { type: 'native' },
@@ -73,7 +69,7 @@ async function getTokenBalances(
73
69
  // list into `{ value: 0n }` for every already-known sub-account, which would silently display
74
70
  // a held token's balance as zero — so the explorer's own error is left to propagate, never
75
71
  // swallowed into an empty result.
76
- const extractKnownValIds = STAKING_CONFIG[currencyId]?.extractKnownValIds
72
+ const extractKnownValIds = STAKING_CONFIG[config.chainId]?.extractKnownValIds
77
73
 
78
74
  let discoveredAssets: AssetInfo[]
79
75
  let knownValidatorIds: string[] | undefined
@@ -82,7 +78,6 @@ async function getTokenBalances(
82
78
  const ops = await explorerApi.getOperations(
83
79
  config,
84
80
  context.logger,
85
- currencyId,
86
81
  address,
87
82
  0,
88
83
  undefined,
@@ -90,7 +85,7 @@ async function getTokenBalances(
90
85
  undefined,
91
86
  undefined
92
87
  )
93
- knownValidatorIds = extractKnownValIds(currencyId, ops.lastCoinOperations, context.logger)
88
+ knownValidatorIds = extractKnownValIds(config.chainId, ops.lastCoinOperations, context.logger)
94
89
 
95
90
  discoveredAssets = []
96
91
  for (const operation of ops.lastTokenOperations) {
@@ -106,7 +101,6 @@ async function getTokenBalances(
106
101
  discoveredAssets = await explorerApi.discoverTokenAssets(
107
102
  config,
108
103
  context.logger,
109
- currencyId,
110
104
  address,
111
105
  scanMinHeight
112
106
  )
@@ -163,7 +157,7 @@ async function getTokenBalances(
163
157
  chunk.map(async (contract) => {
164
158
  const asset = assets.get(contract)
165
159
  if (asset === undefined) throw new Error(`No asset defined for contract ${contract}`)
166
- const balance = await nodeApi.getTokenBalance(currencyId, address, contract)
160
+ const balance = await nodeApi.getTokenBalance(address, contract)
167
161
  return { asset, value: BigInt(balance.toFixed(0)) }
168
162
  })
169
163
  )
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmContext } from '../config'
4
+ import type { ChainId, EvmContext } from '../config'
5
5
  import type { BlockReceiptInfo, PrefetchedBlockTransaction } from '../network/node/types'
6
6
  import type { InternalTxsByHash } from './internalTransactionsFetcher'
7
7
  import type {
@@ -14,7 +14,7 @@ import type {
14
14
  import type { Logger } from '@ledgerhq/coin-module-framework/config'
15
15
  import { promiseAllBatched } from '@ledgerhq/coin-module-framework/promises'
16
16
  import { rpcTransactionToBlockOperations } from '../adapters/blockOperations'
17
- import { DEFAULT_INTERNAL_TX_SOURCES } from '../config'
17
+ import { CHAIN_ID, DEFAULT_INTERNAL_TX_SOURCES } from '../config'
18
18
  import { UnsupportedRpcMethodError } from '../errors'
19
19
  import { buildSmartContractDetails, safeEncodeEIP55 } from '../logic-public'
20
20
  import { getNodeApi } from '../network/node'
@@ -35,17 +35,16 @@ export async function getBlock(
35
35
  // per `getBlockInternalTxsSources`) in parallel with the receipts, and merge them into the
36
36
  // block transactions
37
37
  const config = await context.config(currencyId)
38
- const nodeApi = getNodeApi(config, currencyId, context.logger)
38
+ const nodeApi = getNodeApi(config, context.logger)
39
39
  const internalTxSources = config.getBlockInternalTxsSources ?? DEFAULT_INTERNAL_TX_SOURCES
40
40
  const fetchInternalTxs = createInternalTransactionsFetcher(
41
41
  config,
42
42
  nodeApi,
43
- currencyId,
44
43
  internalTxSources,
45
44
  context.logger
46
45
  )
47
46
 
48
- const result = await nodeApi.getBlockByHeight(currencyId, height, true)
47
+ const result = await nodeApi.getBlockByHeight(height, true)
49
48
 
50
49
  const info: BlockInfo = {
51
50
  height: result.height,
@@ -68,7 +67,8 @@ export async function getBlock(
68
67
  // source that is one metered `txlistinternal` call per empty block.
69
68
  const [transactions, internalTxs] = await Promise.all([
70
69
  getTransactionsFromNode(
71
- currencyId,
70
+ config.chainId,
71
+ config.name,
72
72
  transactionHashes,
73
73
  nodeApi,
74
74
  result.height,
@@ -125,7 +125,8 @@ function mergeInternalTransactions(
125
125
  }
126
126
 
127
127
  async function getTransactionsFromNode(
128
- currencyId: string,
128
+ chainId: ChainId,
129
+ chainName: string,
129
130
  transactionHashes: string[],
130
131
  nodeApi: ReturnType<typeof getNodeApi>,
131
132
  blockHeight: number,
@@ -135,7 +136,8 @@ async function getTransactionsFromNode(
135
136
  if (transactionHashes.length === 0) return []
136
137
 
137
138
  const bulkTransactions = await getTransactionsFromPrefetchedData(
138
- currencyId,
139
+ chainId,
140
+ chainName,
139
141
  blockHeight,
140
142
  prefetchedTransactions,
141
143
  nodeApi,
@@ -154,14 +156,15 @@ async function getTransactionsFromNode(
154
156
  const transactionResults = await promiseAllBatched(
155
157
  MAX_CONCURRENCY,
156
158
  transactionHashes,
157
- (txHash: string) => getTransactionFromHash(currencyId, txHash, nodeApi, logger)
159
+ (txHash: string) => getTransactionFromHash(chainId, txHash, nodeApi, logger)
158
160
  )
159
161
 
160
162
  return transactionResults.filter((tx): tx is BlockTransaction => tx !== null)
161
163
  }
162
164
 
163
165
  async function getTransactionsFromPrefetchedData(
164
- currencyId: string,
166
+ chainId: ChainId,
167
+ chainName: string,
165
168
  blockHeight: number,
166
169
  prefetchedTransactions: PrefetchedBlockTransaction[] | undefined,
167
170
  nodeApi: ReturnType<typeof getNodeApi>,
@@ -171,7 +174,7 @@ async function getTransactionsFromPrefetchedData(
171
174
  return null
172
175
 
173
176
  try {
174
- const receipts = await nodeApi.getBlockReceipts(currencyId, blockHeight)
177
+ const receipts = await nodeApi.getBlockReceipts(blockHeight)
175
178
  const receiptsByHash = new Map(receipts.map((receipt) => [receipt.hash, receipt]))
176
179
 
177
180
  const transactions: BlockTransaction[] = []
@@ -182,7 +185,7 @@ async function getTransactionsFromPrefetchedData(
182
185
  transactions.push({
183
186
  ...blockTx,
184
187
  operations: applyChainSpecificCorrections(
185
- currencyId,
188
+ chainId,
186
189
  blockTx.operations,
187
190
  receipt.type,
188
191
  logger
@@ -196,7 +199,7 @@ async function getTransactionsFromPrefetchedData(
196
199
  throw error
197
200
 
198
201
  logger('warn', 'EVM getBlock fallback: eth_getBlockReceipts unsupported', {
199
- currencyId,
202
+ currency: chainName,
200
203
  blockHeight,
201
204
  error: error.rawError,
202
205
  })
@@ -226,7 +229,12 @@ function prefetchedTransactionToBlockTransaction(
226
229
  logger
227
230
  )
228
231
 
229
- const details = buildSmartContractDetails(tx.to, tx.input, logger, receipt.contractAddress)
232
+ const details = buildTransactionDetails(
233
+ gasPrice,
234
+ tx.gasLimit,
235
+ tx.nonce,
236
+ buildSmartContractDetails(tx.to, tx.input, logger, receipt.contractAddress)
237
+ )
230
238
 
231
239
  return {
232
240
  hash: tx.hash,
@@ -234,26 +242,31 @@ function prefetchedTransactionToBlockTransaction(
234
242
  operations,
235
243
  fees,
236
244
  feesPayer: tx.from,
237
- ...(details ? { details } : {}),
245
+ details,
238
246
  }
239
247
  }
240
248
 
241
249
  async function getTransactionFromHash(
242
- currencyId: string,
250
+ chainId: ChainId,
243
251
  txHash: string,
244
252
  nodeApi: ReturnType<typeof getNodeApi>,
245
253
  logger: Logger
246
254
  ): Promise<BlockTransaction | null> {
247
- const txInfo = await nodeApi.getTransaction(currencyId, txHash)
255
+ const txInfo = await nodeApi.getTransaction(txHash)
248
256
 
249
257
  const failed = txInfo.status === 0
250
258
  const fees =
251
259
  BigInt(txInfo.gasUsed) * BigInt(txInfo.gasPrice) + (txInfo.l1Fee ? BigInt(txInfo.l1Fee) : 0n)
252
260
 
253
261
  const rawOperations = rpcTransactionToBlockOperations(txInfo, logger)
254
- const operations = applyChainSpecificCorrections(currencyId, rawOperations, txInfo.type, logger)
262
+ const operations = applyChainSpecificCorrections(chainId, rawOperations, txInfo.type, logger)
255
263
 
256
- const details = buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress)
264
+ const details = buildTransactionDetails(
265
+ BigInt(txInfo.gasPrice),
266
+ txInfo.gasLimit,
267
+ txInfo.nonce,
268
+ buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress)
269
+ )
257
270
 
258
271
  return {
259
272
  hash: txHash,
@@ -261,18 +274,41 @@ async function getTransactionFromHash(
261
274
  operations,
262
275
  fees,
263
276
  feesPayer: txInfo.from,
264
- ...(details ? { details } : {}),
277
+ details,
278
+ }
279
+ }
280
+
281
+ /**
282
+ * Builds the transaction details. The gas and nonce keys match the ones set by
283
+ * {@link listOperations}, so consumers get the same keys whichever sync wrote the transaction.
284
+ *
285
+ * @param gasPrice gas price actually paid, in wei
286
+ * @param gasLimit gas limit set by the sender (decimal), when known
287
+ * @param nonce nonce of the transaction, when known
288
+ * @param smartContractDetails details of the contract interaction or deployment, if any
289
+ */
290
+ function buildTransactionDetails(
291
+ gasPrice: bigint,
292
+ gasLimit: string | undefined,
293
+ nonce: number | undefined,
294
+ smartContractDetails: Record<string, unknown> | undefined
295
+ ): Record<string, unknown> {
296
+ return {
297
+ gasPrice: gasPrice.toString(),
298
+ ...(gasLimit !== undefined ? { gasLimit } : {}),
299
+ ...(nonce !== undefined ? { sequence: nonce } : {}),
300
+ ...(smartContractDetails ?? {}),
265
301
  }
266
302
  }
267
303
 
268
304
  function applyChainSpecificCorrections(
269
- currencyId: string,
305
+ chainId: ChainId,
270
306
  operations: BlockOperation[],
271
307
  receiptType: number | undefined,
272
308
  logger: Logger
273
309
  ): BlockOperation[] {
274
- switch (currencyId) {
275
- case 'zksync':
310
+ switch (chainId) {
311
+ case CHAIN_ID.ZKSYNC:
276
312
  return rewriteZkSyncL1ToL2DepositOps(operations, receiptType, logger)
277
313
  default:
278
314
  return operations
@@ -11,8 +11,8 @@ export async function getBlockInfo(
11
11
  height: number
12
12
  ): Promise<BlockInfo> {
13
13
  const config = await context.config(currencyId)
14
- const api = getNodeApi(config, currencyId, context.logger)
15
- const result = await api.getBlockByHeight(currencyId, height)
14
+ const api = getNodeApi(config, context.logger)
15
+ const result = await api.getBlockByHeight(height)
16
16
 
17
17
  const blockInfo: BlockInfo = {
18
18
  height: result.height,
@@ -10,9 +10,6 @@ export async function getNextSequence(
10
10
  address: string
11
11
  ): Promise<bigint> {
12
12
  const config = await context.config(currencyId)
13
- const txCount = await getNodeApi(config, currencyId, context.logger).getTransactionCount(
14
- currencyId,
15
- address
16
- )
13
+ const txCount = await getNodeApi(config, context.logger).getTransactionCount(address)
17
14
  return typeof txCount === 'number' ? BigInt(txCount) : txCount
18
15
  }
@@ -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 {