@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
@@ -5,6 +5,7 @@ import type { BlockByHeightResult, NodeApi, TransactionInfo } from './types'
5
5
  import type { Logger } from '@ledgerhq/coin-module-framework/config'
6
6
  import axios from 'axios'
7
7
  import { isSmartContractInput, safeEncodeEIP55 } from '../../logic-public'
8
+ import { isRecord } from '../../logic/predicates'
8
9
  import { ETHERSCAN_TIMEOUT } from '../explorer/etherscan'
9
10
  import { withRetries } from '../withRetries'
10
11
  import { parseERC20TransfersFromLogs } from './rpc.common'
@@ -89,8 +90,8 @@ export async function getBlockFromExplorerProxy(
89
90
  explorerUri,
90
91
  { action: 'eth_getBlockByNumber', tag: hexHeight, boolean: 'false' },
91
92
  (result) => {
92
- const block = result as Record<string, unknown>
93
- if (!block || typeof block !== 'object') return null
93
+ if (!isRecord(result)) return null
94
+ const block = result
94
95
 
95
96
  const hash = block.hash
96
97
  if (typeof hash !== 'string' || !hash || /^0x0+$/.test(hash)) return null
@@ -142,8 +143,9 @@ export async function getTransactionFromExplorerProxy(
142
143
  explorerUri,
143
144
  { action: 'eth_getTransactionByHash', txhash: hash },
144
145
  (r) => {
145
- const t = r as Record<string, unknown>
146
- if (!t || typeof t.hash !== 'string') return null
146
+ if (!isRecord(r)) return null
147
+ const t = r
148
+ if (typeof t.hash !== 'string') return null
147
149
  if (t.hash.toLowerCase() !== hash.toLowerCase()) return null
148
150
  return t
149
151
  },
@@ -154,8 +156,9 @@ export async function getTransactionFromExplorerProxy(
154
156
  explorerUri,
155
157
  { action: 'eth_getTransactionReceipt', txhash: hash },
156
158
  (r) => {
157
- const rec = r as Record<string, unknown>
158
- if (!rec || typeof rec.transactionHash !== 'string') return null
159
+ if (!isRecord(r)) return null
160
+ const rec = r
161
+ if (typeof rec.transactionHash !== 'string') return null
159
162
  if (rec.transactionHash.toLowerCase() !== hash.toLowerCase()) return null
160
163
  return rec
161
164
  },
@@ -196,8 +199,8 @@ export async function getTransactionFromExplorerProxy(
196
199
  if (!Array.isArray(receipt.logs)) return null
197
200
  const logs: { address: string; topics: string[]; data: string }[] = []
198
201
  for (const l of receipt.logs) {
199
- if (!l || typeof l !== 'object') return null
200
- const entry = l as Record<string, unknown>
202
+ if (!isRecord(l)) return null
203
+ const entry = l
201
204
  if (typeof entry.address !== 'string') return null
202
205
  if (typeof entry.data !== 'string') return null
203
206
  if (
@@ -273,17 +276,17 @@ export function createExplorerProxyNodeApi(
273
276
  logger: Logger
274
277
  ): NodeApi {
275
278
  return {
276
- call: (_c, _p) => notSupported('call'),
277
- getCoinBalance: (_c, _a) => notSupported('getCoinBalance'),
278
- getTokenBalance: (_c, _a, _ca) => notSupported('getTokenBalance'),
279
- getTokenAllowance: (_c, _o, _ca, _s) => notSupported('getTokenAllowance'),
280
- getTransactionCount: (_c, _a) => notSupported('getTransactionCount'),
281
- getGasEstimation: (_c, _a, _t) => notSupported('getGasEstimation'),
282
- getFeeData: (_cfg, _c, _t) => notSupported('getFeeData'),
283
- broadcastTransaction: (_c, _tx) => notSupported('broadcastTransaction'),
284
- getOptimismAdditionalFees: (_c, _t) => notSupported('getOptimismAdditionalFees'),
285
- getScrollAdditionalFees: (_c, _t) => notSupported('getScrollAdditionalFees'),
286
- getBlockByHeight: async (_c, height) => {
279
+ call: (_p) => notSupported('call'),
280
+ getCoinBalance: (_a) => notSupported('getCoinBalance'),
281
+ getTokenBalance: (_a, _ca) => notSupported('getTokenBalance'),
282
+ getTokenAllowance: (_o, _ca, _s) => notSupported('getTokenAllowance'),
283
+ getTransactionCount: (_a) => notSupported('getTransactionCount'),
284
+ getGasEstimation: (_a, _t) => notSupported('getGasEstimation'),
285
+ getFeeData: (_cfg, _t) => notSupported('getFeeData'),
286
+ broadcastTransaction: (_tx) => notSupported('broadcastTransaction'),
287
+ getOptimismAdditionalFees: (_t) => notSupported('getOptimismAdditionalFees'),
288
+ getScrollAdditionalFees: (_t) => notSupported('getScrollAdditionalFees'),
289
+ getBlockByHeight: async (height) => {
287
290
  if (typeof height !== 'number')
288
291
  throw new Error('EVM getBlockByHeight: explorer proxy only supports numeric heights')
289
292
  const result = await getBlockFromExplorerProxy(explorerUri, height, explorerRetries, logger)
@@ -293,7 +296,7 @@ export function createExplorerProxyNodeApi(
293
296
  )
294
297
  return result
295
298
  },
296
- getTransaction: async (_c, hash) => {
299
+ getTransaction: async (hash) => {
297
300
  const result = await getTransactionFromExplorerProxy(
298
301
  explorerUri,
299
302
  hash,
@@ -2,9 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { TraceBlockItem } from './types'
5
+ import { isTraceBlockItem } from '../../logic/predicates'
5
6
  import { gethCallTracerToTraceBlockItems } from './gethCallTracerToTraceBlockItems'
6
7
  import flareBlock0x36ffc39CallTracerTrace from './resources/flare-0x36ffc39-debug-trace-block-call-tracer.json'
7
- import { isTraceBlockItem } from './types'
8
8
 
9
9
  describe('gethCallTracerToTraceBlockItems', () => {
10
10
  const blockNumber = 12345
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { TraceBlockItem, TraceBlockOtherAction, TraceBlockResult } from './types'
5
+ import { isRecord, isString } from '../../logic/predicates'
5
6
 
6
7
  /**
7
8
  * Geth `debug_traceBlockByNumber` with `callTracer` returns one entry per transaction (same order as
@@ -39,10 +40,6 @@ export function gethCallTracerToTraceBlockItems(
39
40
  .filter((item) => item !== null)
40
41
  }
41
42
 
42
- function isString(value: unknown): value is string {
43
- return typeof value === 'string'
44
- }
45
-
46
43
  function stringValue(value: unknown, orDefault: string): string {
47
44
  if (isString(value)) return value
48
45
  return orDefault
@@ -64,8 +61,8 @@ function parseDebugTraceBlockEntry(
64
61
  entry: unknown,
65
62
  index: number
66
63
  ): { txHash: string; root: Record<string, unknown> } | null {
67
- if (typeof entry !== 'object' || entry === null || entry === undefined) return null
68
- const o = entry as Record<string, unknown>
64
+ if (!isRecord(entry)) return null
65
+ const o = entry
69
66
  const txHash = extractTxHash(o)
70
67
 
71
68
  if (txHash !== null) {
@@ -80,13 +77,13 @@ function parseDebugTraceBlockEntry(
80
77
  `debug_traceBlockByNumber entry at index ${index} (tx ${txHash}) has null or undefined "result"`
81
78
  )
82
79
  }
83
- if (typeof inner !== 'object') {
80
+ if (!isRecord(inner)) {
84
81
  throw new TypeError(
85
82
  `debug_traceBlockByNumber entry at index ${index} (tx ${txHash}) has invalid "result" (expected object)`
86
83
  )
87
84
  }
88
85
 
89
- return { txHash, root: inner as Record<string, unknown> }
86
+ return { txHash, root: inner }
90
87
  }
91
88
 
92
89
  if ('type' in o || 'from' in o || 'calls' in o) {
@@ -121,7 +118,7 @@ function flattenCallFrame(
121
118
 
122
119
  for (let i = 0; i < calls.length; i++) {
123
120
  const child = calls[i]
124
- if (child && typeof child === 'object' && child !== null) {
121
+ if (isRecord(child)) {
125
122
  items.push(
126
123
  ...flattenCallFrame(
127
124
  child,
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { CHAIN_ID } from '../../config'
4
5
  import {
5
6
  createMockEvmConfigInfo,
6
7
  mkExternalNode,
@@ -9,30 +10,38 @@ import {
9
10
  import { getNodeApi } from './index'
10
11
 
11
12
  describe('getNodeApi memoization', () => {
12
- it('should return the same NodeApi instance for same currency and retries (memoization)', () => {
13
- const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
14
- expect(getNodeApi(config, 'ethereum', testLogger)).toBe(
15
- getNodeApi(config, 'ethereum', testLogger)
16
- )
13
+ it('should return the same NodeApi instance for same chain and retries (memoization)', () => {
14
+ const config = createMockEvmConfigInfo({
15
+ chainId: CHAIN_ID.ETHEREUM,
16
+ node: mkExternalNode(),
17
+ })
18
+ expect(getNodeApi(config, testLogger)).toBe(getNodeApi(config, testLogger))
17
19
  })
18
20
 
19
21
  it('should return cached NodeApi on subsequent calls (createNodeApi called once)', () => {
20
- const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
21
- const cachedInstance = getNodeApi(config, 'cached_value_test', testLogger)
22
+ const config = createMockEvmConfigInfo({
23
+ chainId: CHAIN_ID.ETHEREUM,
24
+ node: mkExternalNode(),
25
+ })
26
+ const cachedInstance = getNodeApi(config, testLogger)
22
27
 
23
- expect(getNodeApi(config, 'cached_value_test', testLogger)).toBe(cachedInstance)
24
- expect(getNodeApi(config, 'cached_value_test', testLogger)).toBe(cachedInstance)
28
+ expect(getNodeApi(config, testLogger)).toBe(cachedInstance)
29
+ expect(getNodeApi(config, testLogger)).toBe(cachedInstance)
25
30
  })
26
31
 
27
32
  it('should return different NodeApi instances for different retries', () => {
28
33
  const node1 = getNodeApi(
29
- createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u', retries: 2 }) }),
30
- 'ethereum',
34
+ createMockEvmConfigInfo({
35
+ chainId: CHAIN_ID.ETHEREUM,
36
+ node: mkExternalNode({ uri: 'u', retries: 2 }),
37
+ }),
31
38
  testLogger
32
39
  )
33
40
  const node2 = getNodeApi(
34
- createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u', retries: 5 }) }),
35
- 'ethereum',
41
+ createMockEvmConfigInfo({
42
+ chainId: CHAIN_ID.ETHEREUM,
43
+ node: mkExternalNode({ uri: 'u', retries: 5 }),
44
+ }),
36
45
  testLogger
37
46
  )
38
47
  expect(node1).not.toBe(node2)
@@ -40,24 +49,22 @@ describe('getNodeApi memoization', () => {
40
49
 
41
50
  it('should return different NodeApi instances for different uris', () => {
42
51
  const node1 = getNodeApi(
43
- createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u1' }) }),
44
- 'ethereum',
52
+ createMockEvmConfigInfo({ chainId: CHAIN_ID.ETHEREUM, node: mkExternalNode({ uri: 'u1' }) }),
45
53
  testLogger
46
54
  )
47
55
  const node2 = getNodeApi(
48
- createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u2' }) }),
49
- 'ethereum',
56
+ createMockEvmConfigInfo({ chainId: CHAIN_ID.ETHEREUM, node: mkExternalNode({ uri: 'u2' }) }),
50
57
  testLogger
51
58
  )
52
59
 
53
60
  expect(node1).not.toBe(node2)
54
61
  })
55
62
 
56
- it('should return different NodeApi instances for different currencies', () => {
57
- const conf = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u1' }) })
63
+ it('should return different NodeApi instances for different chains sharing a node', () => {
64
+ const node = mkExternalNode({ uri: 'u1' })
65
+ const ethereum = createMockEvmConfigInfo({ chainId: CHAIN_ID.ETHEREUM, node })
66
+ const bsc = createMockEvmConfigInfo({ chainId: CHAIN_ID.BSC, node })
58
67
 
59
- expect(getNodeApi(conf, 'ethereum1', testLogger)).not.toBe(
60
- getNodeApi(conf, 'ethereum2', testLogger)
61
- )
68
+ expect(getNodeApi(ethereum, testLogger)).not.toBe(getNodeApi(bsc, testLogger))
62
69
  })
63
70
  })
@@ -16,13 +16,12 @@ describe('EVM Family', () => {
16
16
  it('should throw when requesting a non existing node type', () => {
17
17
  const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
18
18
  Object.assign(config, { node: { type: 'anything', uri: 'notworking' } })
19
- expect(() => getNodeApi(config, 'not-existing', testLogger)).toThrow(UnknownNode)
19
+ expect(() => getNodeApi(config, testLogger)).toThrow(UnknownNode)
20
20
  })
21
21
 
22
22
  it('should return the rpc api', () => {
23
23
  const node = getNodeApi(
24
24
  createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'working' }) }),
25
- 'external',
26
25
  testLogger
27
26
  )
28
27
 
@@ -44,7 +43,6 @@ describe('EVM Family', () => {
44
43
  it('should return the ledger api', () => {
45
44
  const node = getNodeApi(
46
45
  createMockEvmConfigInfo({ chainId: 1, node: mkLedgerNode({ explorerId: 'eth' }) }),
47
- 'ledger-supported',
48
46
  testLogger
49
47
  )
50
48
 
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../../config'
4
+ import type { ChainId, EvmConfigInfo } from '../../config'
5
5
  import type { NodeApi } from './types'
6
6
  import type { Logger } from '@ledgerhq/coin-module-framework/config'
7
7
  import { DEFAULT_LEDGER_EXPLORER_URI } from '../../config'
@@ -13,23 +13,23 @@ import { withNodeSources } from './withNodeSources'
13
13
  /**
14
14
  * Memoized NodeApi instances for both ledger and external nodes.
15
15
  * Key includes all config dimensions that affect the API instance's behavior.
16
- * Unbounded growth is acceptable: the number of entries is at most (currencies × distinct
17
- * node configs). In practice there are few EVM chains and config is static per currency,
16
+ * Unbounded growth is acceptable: the number of entries is at most (chains × distinct
17
+ * node configs). In practice there are few EVM chains and config is static per chain,
18
18
  * so the cache stays small.
19
19
  */
20
20
  const nodeApiCache = new Map<string, NodeApi>()
21
21
 
22
22
  function cacheKey(
23
- currencyId: string,
23
+ chainId: ChainId,
24
24
  node: { type: string; [key: string]: unknown },
25
25
  explorerUri: string,
26
26
  clientVersion: string,
27
27
  nodeSources: string
28
28
  ): string {
29
- return `${currencyId}:${JSON.stringify(node)}:${explorerUri}:${clientVersion}:${nodeSources}`
29
+ return `${chainId}:${JSON.stringify(node)}:${explorerUri}:${clientVersion}:${nodeSources}`
30
30
  }
31
31
 
32
- export const getNodeApi = (config: EvmConfigInfo, currencyId: string, logger: Logger): NodeApi => {
32
+ export const getNodeApi = (config: EvmConfigInfo, logger: Logger): NodeApi => {
33
33
  const node = config?.node
34
34
  const type = node?.type
35
35
 
@@ -40,13 +40,16 @@ export const getNodeApi = (config: EvmConfigInfo, currencyId: string, logger: Lo
40
40
  const explorerUri = config.ledgerExplorerUri ?? DEFAULT_LEDGER_EXPLORER_URI
41
41
  const clientVersion = config.ledgerClientVersion ?? ''
42
42
  const nodeSources = JSON.stringify(config.nodeSources ?? ['node'])
43
- const key = cacheKey(currencyId, node, explorerUri, clientVersion, nodeSources)
43
+ const key = cacheKey(config.chainId, node, explorerUri, clientVersion, nodeSources)
44
44
 
45
45
  let api = nodeApiCache.get(key)
46
46
  if (api === undefined) {
47
47
  const raw =
48
48
  type === 'ledger'
49
- ? createLedgerNodeApi({ ...node, explorerUri, clientVersion }, logger)
49
+ ? createLedgerNodeApi(
50
+ { ...node, explorerUri, clientVersion, chainId: config.chainId },
51
+ logger
52
+ )
50
53
  : createNodeApi(config, node, logger)
51
54
  api = withNodeSources(raw, config, logger)
52
55
  nodeApiCache.set(key, api)
@@ -5,7 +5,7 @@ import { delay } from '@ledgerhq/coin-module-framework/promises'
5
5
  import axios from 'axios'
6
6
  import BigNumber from 'bignumber.js'
7
7
  import { Transaction } from 'ethers'
8
- import { DEFAULT_LEDGER_EXPLORER_URI } from '../../config'
8
+ import { CHAIN_ID, DEFAULT_LEDGER_EXPLORER_URI } from '../../config'
9
9
  import { GasEstimationError } from '../../errors'
10
10
  import { createMockEvmConfigInfo, testLogger } from '../../fixtures/context.fixtures'
11
11
  import { getGasOptions } from '../gasTracker/ledger'
@@ -25,10 +25,10 @@ jest.mocked(delay).mockImplementation(
25
25
  () => new Promise((resolve) => setTimeout(resolve, 1)) // mocking the delay supposed to happen after each try
26
26
  )
27
27
 
28
- const currencyId = 'ethereum'
29
28
  const address = '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d'
30
29
 
31
30
  const ledgerConfig = {
31
+ chainId: CHAIN_ID.ETHEREUM,
32
32
  type: 'ledger' as const,
33
33
  explorerId: 'eth' as const,
34
34
  retries: 2,
@@ -60,7 +60,7 @@ describe('EVM Family', () => {
60
60
  ],
61
61
  }))
62
62
 
63
- const result = await api.call(currencyId, { to: USDC, data: DECIMALS_SELECTOR })
63
+ const result = await api.call({ to: USDC, data: DECIMALS_SELECTOR })
64
64
 
65
65
  expect(result).toEqual(DECIMALS_RESPONSE)
66
66
  expect(spy).toHaveBeenCalledWith(
@@ -83,7 +83,7 @@ describe('EVM Family', () => {
83
83
  ],
84
84
  }))
85
85
 
86
- await api.call(currencyId, { to: USDC, data: DECIMALS_SELECTOR, block: 123 })
86
+ await api.call({ to: USDC, data: DECIMALS_SELECTOR, block: 123 })
87
87
 
88
88
  expect(spy).toHaveBeenCalledWith(
89
89
  expect.objectContaining({
@@ -103,7 +103,7 @@ describe('EVM Family', () => {
103
103
  ],
104
104
  }))
105
105
 
106
- await expect(api.call(currencyId, { to: USDC, data: DECIMALS_SELECTOR })).rejects.toThrow(
106
+ await expect(api.call({ to: USDC, data: DECIMALS_SELECTOR })).rejects.toThrow(
107
107
  'EVM call failed'
108
108
  )
109
109
  })
@@ -133,7 +133,7 @@ describe('EVM Family', () => {
133
133
  },
134
134
  }
135
135
  })
136
- const response = await api.getTransaction(currencyId, '0xHash')
136
+ const response = await api.getTransaction('0xHash')
137
137
  expect(response.hash).toEqual('0xabc')
138
138
  expect(spy).toHaveBeenCalledTimes(3)
139
139
  })
@@ -149,7 +149,7 @@ describe('EVM Family', () => {
149
149
  }
150
150
  return { data: {} }
151
151
  })
152
- await expect(api.getTransaction(currencyId, '0xHash')).rejects.toBeInstanceOf(SpyError)
152
+ await expect(api.getTransaction('0xHash')).rejects.toBeInstanceOf(SpyError)
153
153
  })
154
154
  })
155
155
 
@@ -201,7 +201,7 @@ describe('EVM Family', () => {
201
201
  },
202
202
  }))
203
203
 
204
- const response = await api.getTransaction(currencyId, '0xHash')
204
+ const response = await api.getTransaction('0xHash')
205
205
  expect(response).toEqual({
206
206
  gasPrice: '83953611012',
207
207
  gasUsed: '21000',
@@ -244,7 +244,7 @@ describe('EVM Family', () => {
244
244
  data: { balance: '6969' },
245
245
  }))
246
246
 
247
- expect(await api.getCoinBalance(currencyId, '0xkvn')).toEqual(new BigNumber('6969'))
247
+ expect(await api.getCoinBalance('0xkvn')).toEqual(new BigNumber('6969'))
248
248
  })
249
249
  })
250
250
 
@@ -258,9 +258,7 @@ describe('EVM Family', () => {
258
258
  ],
259
259
  }))
260
260
 
261
- expect(await api.getTokenBalance(currencyId, '0xusdc', '0xkvn')).toEqual(
262
- new BigNumber('6969')
263
- )
261
+ expect(await api.getTokenBalance('0xusdc', '0xkvn')).toEqual(new BigNumber('6969'))
264
262
  })
265
263
  })
266
264
 
@@ -271,7 +269,7 @@ describe('EVM Family', () => {
271
269
  data: { address: '0xkvn', nonce: 123 },
272
270
  }))
273
271
 
274
- expect(await api.getTransactionCount(currencyId, '0xkvn')).toEqual(123)
272
+ expect(await api.getTransactionCount('0xkvn')).toEqual(123)
275
273
  })
276
274
  })
277
275
 
@@ -283,7 +281,7 @@ describe('EVM Family', () => {
283
281
  })
284
282
 
285
283
  await expect(
286
- api.getGasEstimation(currencyId, address, { amount: new BigNumber(0), recipient: '0x0' })
284
+ api.getGasEstimation(address, { amount: new BigNumber(0), recipient: '0x0' })
287
285
  ).rejects.toBeInstanceOf(GasEstimationError)
288
286
  })
289
287
 
@@ -294,7 +292,7 @@ describe('EVM Family', () => {
294
292
  .mockImplementation(() => Promise.reject({ code: 'ECONNABORTED' }))
295
293
 
296
294
  await expect(
297
- api.getGasEstimation(currencyId, address, { amount: new BigNumber(0), recipient: '0x0' })
295
+ api.getGasEstimation(address, { amount: new BigNumber(0), recipient: '0x0' })
298
296
  ).rejects.toBeInstanceOf(GasEstimationError)
299
297
  })
300
298
 
@@ -321,10 +319,8 @@ describe('EVM Family', () => {
321
319
  data: Buffer.from('ffff', 'hex'),
322
320
  }
323
321
 
324
- expect(await api.getGasEstimation(currencyId, address, transaction)).toEqual(
325
- new BigNumber(789)
326
- )
327
- expect(await api.getGasEstimation(currencyId, address, transactionWithData)).toEqual(
322
+ expect(await api.getGasEstimation(address, transaction)).toEqual(new BigNumber(789))
323
+ expect(await api.getGasEstimation(address, transactionWithData)).toEqual(
328
324
  new BigNumber(1_000_000)
329
325
  )
330
326
  })
@@ -356,7 +352,6 @@ describe('EVM Family', () => {
356
352
 
357
353
  const slowFeeData = await api.getFeeData(
358
354
  createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
359
- currencyId,
360
355
  {
361
356
  type: 2,
362
357
  feesStrategy: 'slow',
@@ -364,7 +359,6 @@ describe('EVM Family', () => {
364
359
  )
365
360
  const mediumFeeData = await api.getFeeData(
366
361
  createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
367
- currencyId,
368
362
  {
369
363
  type: 2,
370
364
  feesStrategy: 'medium',
@@ -372,7 +366,6 @@ describe('EVM Family', () => {
372
366
  )
373
367
  const fastFeeData = await api.getFeeData(
374
368
  createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
375
- currencyId,
376
369
  {
377
370
  type: 2,
378
371
  feesStrategy: 'fast',
@@ -424,7 +417,6 @@ describe('EVM Family', () => {
424
417
 
425
418
  const feeData = await api.getFeeData(
426
419
  createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
427
- currencyId,
428
420
  { type: 2 }
429
421
  )
430
422
 
@@ -446,7 +438,7 @@ describe('EVM Family', () => {
446
438
  },
447
439
  }))
448
440
 
449
- expect(await api.broadcastTransaction(currencyId, '0xSigneTx')).toEqual('0xHash')
441
+ expect(await api.broadcastTransaction('0xSigneTx')).toEqual('0xHash')
450
442
  })
451
443
 
452
444
  it('should include mevProtected=true in the request parameters when specified', async () => {
@@ -457,7 +449,7 @@ describe('EVM Family', () => {
457
449
  },
458
450
  }))
459
451
 
460
- await api.broadcastTransaction(currencyId, '0xSignedTx', { mevProtected: true })
452
+ await api.broadcastTransaction('0xSignedTx', { mevProtected: true })
461
453
 
462
454
  expect(mockRequest).toHaveBeenCalledWith(
463
455
  expect.objectContaining({
@@ -478,7 +470,7 @@ describe('EVM Family', () => {
478
470
  },
479
471
  }))
480
472
 
481
- await api.broadcastTransaction(currencyId, '0xSignedTx', {
473
+ await api.broadcastTransaction('0xSignedTx', {
482
474
  mevProtected: false,
483
475
  source: { type: 'live-app', name: 'test-manifest-id' },
484
476
  })
@@ -503,7 +495,7 @@ describe('EVM Family', () => {
503
495
  },
504
496
  }))
505
497
 
506
- await api.broadcastTransaction(currencyId, '0xSignedTx', { mevProtected: false })
498
+ await api.broadcastTransaction('0xSignedTx', { mevProtected: false })
507
499
 
508
500
  // ledgerConfig sets no clientVersion, so `{}` proves no source header was added.
509
501
  expect(mockRequest).toHaveBeenCalledWith(
@@ -544,14 +536,14 @@ describe('EVM Family', () => {
544
536
  }
545
537
  })
546
538
 
547
- expect(await api.getBlockByHeight(currencyId, 12)).toEqual({
539
+ expect(await api.getBlockByHeight(12)).toEqual({
548
540
  hash: '0xhash',
549
541
  height: 123,
550
542
  timestamp: Date.now(),
551
543
  parentHash: '0xparentHash',
552
544
  transactionHashes: ['0xTx1', '0xTx2'],
553
545
  })
554
- expect(await api.getBlockByHeight(currencyId, 'latest')).toEqual({
546
+ expect(await api.getBlockByHeight('latest')).toEqual({
555
547
  hash: '0xhashLatest',
556
548
  height: 456,
557
549
  timestamp: Date.now(),
@@ -564,11 +556,11 @@ describe('EVM Family', () => {
564
556
  describe('getOptimismAdditionalFees', () => {
565
557
  it('should return 0 for an incompatible currency', async () => {
566
558
  const api = createLedgerNodeApi(ledgerConfig, testLogger)
567
- expect(await api.getOptimismAdditionalFees(currencyId, '')).toEqual(new BigNumber(0))
559
+ expect(await api.getOptimismAdditionalFees('')).toEqual(new BigNumber(0))
568
560
  })
569
561
 
570
562
  it('should return the expected payload', async () => {
571
- const api = createLedgerNodeApi(ledgerConfig, testLogger)
563
+ const api = createLedgerNodeApi({ ...ledgerConfig, chainId: CHAIN_ID.OPTIMISM }, testLogger)
572
564
  jest.spyOn(axios, 'request').mockImplementationOnce(async () => ({
573
565
  data: [
574
566
  {
@@ -597,58 +589,60 @@ describe('EVM Family', () => {
597
589
  },
598
590
  })
599
591
 
600
- expect(await api.getOptimismAdditionalFees('optimism', transaction.serialized)).toEqual(
592
+ expect(await api.getOptimismAdditionalFees(transaction.serialized)).toEqual(
601
593
  new BigNumber('100000000')
602
594
  )
603
595
  })
604
596
 
605
- it.each(['blast', 'blast_sepolia', 'base', 'base_sepolia'])(
606
- 'should query the OP-stack gas oracle for %s (not return 0)',
607
- async (currencyId) => {
608
- const api = createLedgerNodeApi(ledgerConfig, testLogger)
609
- jest.spyOn(axios, 'request').mockImplementationOnce(async () => ({
610
- data: [
611
- {
612
- info: {
613
- contract: '0x420000000000000000000000000000000000000F',
614
- data: '0xSerializedTransaction',
615
- blockNumber: 123,
616
- },
617
- response: '100000000',
597
+ it.each([
598
+ ['blast', CHAIN_ID.BLAST],
599
+ ['blast_sepolia', CHAIN_ID.BLAST_SEPOLIA],
600
+ ['base', CHAIN_ID.BASE],
601
+ ['base_sepolia', CHAIN_ID.BASE_SEPOLIA],
602
+ ])('should query the OP-stack gas oracle for %s (not return 0)', async (_name, chainId) => {
603
+ const api = createLedgerNodeApi({ ...ledgerConfig, chainId }, testLogger)
604
+ jest.spyOn(axios, 'request').mockImplementationOnce(async () => ({
605
+ data: [
606
+ {
607
+ info: {
608
+ contract: '0x420000000000000000000000000000000000000F',
609
+ data: '0xSerializedTransaction',
610
+ blockNumber: 123,
618
611
  },
619
- ],
620
- }))
621
-
622
- const transaction = Transaction.from({
623
- to: '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d',
624
- value: 1n,
625
- gasLimit: 2n,
626
- chainId: 1,
627
- nonce: 0,
628
- gasPrice: 3n,
629
- type: 0,
630
- signature: {
631
- r: '0xffffffffffffffffffffffffffffffffffffffff',
632
- s: '0xffffffffffffffffffffffffffffffffffffffff',
633
- v: 27,
612
+ response: '100000000',
634
613
  },
635
- })
614
+ ],
615
+ }))
636
616
 
637
- expect(await api.getOptimismAdditionalFees(currencyId, transaction.serialized)).toEqual(
638
- new BigNumber('100000000')
639
- )
640
- }
641
- )
617
+ const transaction = Transaction.from({
618
+ to: '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d',
619
+ value: 1n,
620
+ gasLimit: 2n,
621
+ chainId: 1,
622
+ nonce: 0,
623
+ gasPrice: 3n,
624
+ type: 0,
625
+ signature: {
626
+ r: '0xffffffffffffffffffffffffffffffffffffffff',
627
+ s: '0xffffffffffffffffffffffffffffffffffffffff',
628
+ v: 27,
629
+ },
630
+ })
631
+
632
+ expect(await api.getOptimismAdditionalFees(transaction.serialized)).toEqual(
633
+ new BigNumber('100000000')
634
+ )
635
+ })
642
636
  })
643
637
 
644
638
  describe('getScrollAdditionalFees', () => {
645
639
  it('should return 0 for an incompatible currency', async () => {
646
640
  const api = createLedgerNodeApi(ledgerConfig, testLogger)
647
- expect(await api.getScrollAdditionalFees(currencyId, '')).toEqual(new BigNumber(0))
641
+ expect(await api.getScrollAdditionalFees('')).toEqual(new BigNumber(0))
648
642
  })
649
643
 
650
644
  it('should return the expected payload', async () => {
651
- const api = createLedgerNodeApi(ledgerConfig, testLogger)
645
+ const api = createLedgerNodeApi({ ...ledgerConfig, chainId: CHAIN_ID.SCROLL }, testLogger)
652
646
  jest.spyOn(axios, 'request').mockImplementationOnce(async () => ({
653
647
  data: [
654
648
  {
@@ -677,7 +671,7 @@ describe('EVM Family', () => {
677
671
  },
678
672
  })
679
673
 
680
- expect(await api.getScrollAdditionalFees('scroll', transaction.serialized)).toEqual(
674
+ expect(await api.getScrollAdditionalFees(transaction.serialized)).toEqual(
681
675
  new BigNumber('100000000')
682
676
  )
683
677
  })