@ledgerhq/coin-evm 10.1.0 → 15.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (463) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/docs/getBlock-internal-txs-schema.md +2 -2
  3. package/docs/network/node/index.md +1 -1
  4. package/lib/adapters/etherscan.d.ts +2 -1
  5. package/lib/adapters/etherscan.d.ts.map +1 -1
  6. package/lib/adapters/etherscan.js +16 -2
  7. package/lib/adapters/etherscan.js.map +1 -1
  8. package/lib/adapters/ledger.d.ts +2 -1
  9. package/lib/adapters/ledger.d.ts.map +1 -1
  10. package/lib/adapters/ledger.js +4 -2
  11. package/lib/adapters/ledger.js.map +1 -1
  12. package/lib/api/index.d.ts.map +1 -1
  13. package/lib/api/index.js +1 -2
  14. package/lib/api/index.js.map +1 -1
  15. package/lib/chains.d.ts +95 -0
  16. package/lib/chains.d.ts.map +1 -0
  17. package/lib/chains.js +99 -0
  18. package/lib/chains.js.map +1 -0
  19. package/lib/config.d.ts +4 -1
  20. package/lib/config.d.ts.map +1 -1
  21. package/lib/config.js +3 -1
  22. package/lib/config.js.map +1 -1
  23. package/lib/logic/broadcast.js +2 -2
  24. package/lib/logic/broadcast.js.map +1 -1
  25. package/lib/logic/common.d.ts +1 -1
  26. package/lib/logic/common.d.ts.map +1 -1
  27. package/lib/logic/common.js +11 -11
  28. package/lib/logic/common.js.map +1 -1
  29. package/lib/logic/craftTransaction.d.ts.map +1 -1
  30. package/lib/logic/craftTransaction.js +3 -3
  31. package/lib/logic/craftTransaction.js.map +1 -1
  32. package/lib/logic/estimateFees.d.ts.map +1 -1
  33. package/lib/logic/estimateFees.js +7 -7
  34. package/lib/logic/estimateFees.js.map +1 -1
  35. package/lib/logic/getBalance.d.ts.map +1 -1
  36. package/lib/logic/getBalance.js +9 -9
  37. package/lib/logic/getBalance.js.map +1 -1
  38. package/lib/logic/getBlock.d.ts.map +1 -1
  39. package/lib/logic/getBlock.js +38 -21
  40. package/lib/logic/getBlock.js.map +1 -1
  41. package/lib/logic/getBlockInfo.js +2 -2
  42. package/lib/logic/getBlockInfo.js.map +1 -1
  43. package/lib/logic/getNextSequence.d.ts.map +1 -1
  44. package/lib/logic/getNextSequence.js +1 -1
  45. package/lib/logic/getNextSequence.js.map +1 -1
  46. package/lib/logic/getStakes.d.ts.map +1 -1
  47. package/lib/logic/getStakes.js +10 -10
  48. package/lib/logic/getStakes.js.map +1 -1
  49. package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
  50. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  51. package/lib/logic/internalTransactionsFetcher.js +8 -8
  52. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  53. package/lib/logic/lastBlock.js +2 -2
  54. package/lib/logic/lastBlock.js.map +1 -1
  55. package/lib/logic/listOperations.d.ts.map +1 -1
  56. package/lib/logic/listOperations.js +3 -1
  57. package/lib/logic/listOperations.js.map +1 -1
  58. package/lib/logic/validateIntent.d.ts.map +1 -1
  59. package/lib/logic/validateIntent.js +9 -9
  60. package/lib/logic/validateIntent.js.map +1 -1
  61. package/lib/logic.d.ts +1 -1
  62. package/lib/logic.d.ts.map +1 -1
  63. package/lib/logic.js +14 -13
  64. package/lib/logic.js.map +1 -1
  65. package/lib/network/explorer/etherscan.d.ts +2 -3
  66. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  67. package/lib/network/explorer/etherscan.js +6 -8
  68. package/lib/network/explorer/etherscan.js.map +1 -1
  69. package/lib/network/explorer/ledger.d.ts.map +1 -1
  70. package/lib/network/explorer/ledger.js +5 -5
  71. package/lib/network/explorer/ledger.js.map +1 -1
  72. package/lib/network/explorer/types.d.ts +2 -2
  73. package/lib/network/explorer/types.d.ts.map +1 -1
  74. package/lib/network/explorer/types.js.map +1 -1
  75. package/lib/network/node/explorerProxy.d.ts.map +1 -1
  76. package/lib/network/node/explorerProxy.js +14 -12
  77. package/lib/network/node/explorerProxy.js.map +1 -1
  78. package/lib/network/node/index.d.ts +1 -1
  79. package/lib/network/node/index.d.ts.map +1 -1
  80. package/lib/network/node/index.js +7 -7
  81. package/lib/network/node/index.js.map +1 -1
  82. package/lib/network/node/ledger.d.ts +3 -1
  83. package/lib/network/node/ledger.d.ts.map +1 -1
  84. package/lib/network/node/ledger.js +32 -22
  85. package/lib/network/node/ledger.js.map +1 -1
  86. package/lib/network/node/rpc.common.d.ts +1 -1
  87. package/lib/network/node/rpc.common.d.ts.map +1 -1
  88. package/lib/network/node/rpc.common.js +67 -39
  89. package/lib/network/node/rpc.common.js.map +1 -1
  90. package/lib/network/node/types.d.ts +18 -16
  91. package/lib/network/node/types.d.ts.map +1 -1
  92. package/lib/network/node/types.js.map +1 -1
  93. package/lib/network/node/withNodeSources.d.ts.map +1 -1
  94. package/lib/network/node/withNodeSources.js +15 -15
  95. package/lib/network/node/withNodeSources.js.map +1 -1
  96. package/lib/staking/abis.d.ts +3 -2
  97. package/lib/staking/abis.d.ts.map +1 -1
  98. package/lib/staking/abis.js +10 -9
  99. package/lib/staking/abis.js.map +1 -1
  100. package/lib/staking/contracts.d.ts +3 -2
  101. package/lib/staking/contracts.d.ts.map +1 -1
  102. package/lib/staking/contracts.js +11 -10
  103. package/lib/staking/contracts.js.map +1 -1
  104. package/lib/staking/detectOperationType.d.ts +2 -1
  105. package/lib/staking/detectOperationType.d.ts.map +1 -1
  106. package/lib/staking/detectOperationType.js +7 -7
  107. package/lib/staking/detectOperationType.js.map +1 -1
  108. package/lib/staking/encoder.d.ts +2 -1
  109. package/lib/staking/encoder.d.ts.map +1 -1
  110. package/lib/staking/encoder.js +8 -8
  111. package/lib/staking/encoder.js.map +1 -1
  112. package/lib/staking/fetchers.d.ts +2 -1
  113. package/lib/staking/fetchers.d.ts.map +1 -1
  114. package/lib/staking/fetchers.js +27 -27
  115. package/lib/staking/fetchers.js.map +1 -1
  116. package/lib/staking/logic.d.ts +6 -6
  117. package/lib/staking/logic.d.ts.map +1 -1
  118. package/lib/staking/logic.js +14 -13
  119. package/lib/staking/logic.js.map +1 -1
  120. package/lib/staking/operations/index.d.ts +2 -1
  121. package/lib/staking/operations/index.d.ts.map +1 -1
  122. package/lib/staking/operations/index.js +30 -28
  123. package/lib/staking/operations/index.js.map +1 -1
  124. package/lib/staking/prepareIntents.d.ts +1 -1
  125. package/lib/staking/prepareIntents.d.ts.map +1 -1
  126. package/lib/staking/prepareIntents.js +11 -10
  127. package/lib/staking/prepareIntents.js.map +1 -1
  128. package/lib/staking/redelegations.d.ts +4 -4
  129. package/lib/staking/redelegations.d.ts.map +1 -1
  130. package/lib/staking/redelegations.js +18 -20
  131. package/lib/staking/redelegations.js.map +1 -1
  132. package/lib/staking/rewards.d.ts +1 -1
  133. package/lib/staking/rewards.d.ts.map +1 -1
  134. package/lib/staking/rewards.js +2 -2
  135. package/lib/staking/rewards.js.map +1 -1
  136. package/lib/staking/rewardsFromReceipt.d.ts +2 -1
  137. package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
  138. package/lib/staking/rewardsFromReceipt.js +2 -2
  139. package/lib/staking/rewardsFromReceipt.js.map +1 -1
  140. package/lib/staking/transactionData.d.ts +2 -1
  141. package/lib/staking/transactionData.d.ts.map +1 -1
  142. package/lib/staking/transactionData.js +6 -6
  143. package/lib/staking/transactionData.js.map +1 -1
  144. package/lib/staking/unbondings.d.ts +1 -1
  145. package/lib/staking/unbondings.d.ts.map +1 -1
  146. package/lib/staking/unbondings.js +2 -2
  147. package/lib/staking/unbondings.js.map +1 -1
  148. package/lib/staking/validators/index.d.ts +14 -14
  149. package/lib/staking/validators/index.d.ts.map +1 -1
  150. package/lib/staking/validators/index.js +39 -38
  151. package/lib/staking/validators/index.js.map +1 -1
  152. package/lib/staking/validators/monad.d.ts +5 -5
  153. package/lib/staking/validators/monad.d.ts.map +1 -1
  154. package/lib/staking/validators/monad.js +31 -33
  155. package/lib/staking/validators/monad.js.map +1 -1
  156. package/lib/staking/validators/monadResolver.d.ts +1 -1
  157. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  158. package/lib/staking/validators/monadResolver.js +4 -4
  159. package/lib/staking/validators/monadResolver.js.map +1 -1
  160. package/lib/staking/validators/sei.js +2 -2
  161. package/lib/staking/validators/sei.js.map +1 -1
  162. package/lib/staking/validators/somnia.d.ts +4 -4
  163. package/lib/staking/validators/somnia.d.ts.map +1 -1
  164. package/lib/staking/validators/somnia.js +22 -22
  165. package/lib/staking/validators/somnia.js.map +1 -1
  166. package/lib/staking/validators/types.d.ts +1 -1
  167. package/lib/staking/validators/types.d.ts.map +1 -1
  168. package/lib/staking/validators/zero_gravity.d.ts +1 -1
  169. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  170. package/lib/staking/validators/zero_gravity.js +7 -7
  171. package/lib/staking/validators/zero_gravity.js.map +1 -1
  172. package/lib/types/staking.d.ts +5 -6
  173. package/lib/types/staking.d.ts.map +1 -1
  174. package/lib-es/adapters/etherscan.d.ts +2 -1
  175. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  176. package/lib-es/adapters/etherscan.js +16 -2
  177. package/lib-es/adapters/etherscan.js.map +1 -1
  178. package/lib-es/adapters/ledger.d.ts +2 -1
  179. package/lib-es/adapters/ledger.d.ts.map +1 -1
  180. package/lib-es/adapters/ledger.js +4 -2
  181. package/lib-es/adapters/ledger.js.map +1 -1
  182. package/lib-es/api/index.d.ts.map +1 -1
  183. package/lib-es/api/index.js +1 -2
  184. package/lib-es/api/index.js.map +1 -1
  185. package/lib-es/chains.d.ts +95 -0
  186. package/lib-es/chains.d.ts.map +1 -0
  187. package/lib-es/chains.js +96 -0
  188. package/lib-es/chains.js.map +1 -0
  189. package/lib-es/config.d.ts +4 -1
  190. package/lib-es/config.d.ts.map +1 -1
  191. package/lib-es/config.js +1 -0
  192. package/lib-es/config.js.map +1 -1
  193. package/lib-es/logic/broadcast.js +2 -2
  194. package/lib-es/logic/broadcast.js.map +1 -1
  195. package/lib-es/logic/common.d.ts +1 -1
  196. package/lib-es/logic/common.d.ts.map +1 -1
  197. package/lib-es/logic/common.js +11 -11
  198. package/lib-es/logic/common.js.map +1 -1
  199. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  200. package/lib-es/logic/craftTransaction.js +3 -3
  201. package/lib-es/logic/craftTransaction.js.map +1 -1
  202. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  203. package/lib-es/logic/estimateFees.js +7 -7
  204. package/lib-es/logic/estimateFees.js.map +1 -1
  205. package/lib-es/logic/getBalance.d.ts.map +1 -1
  206. package/lib-es/logic/getBalance.js +9 -9
  207. package/lib-es/logic/getBalance.js.map +1 -1
  208. package/lib-es/logic/getBlock.d.ts.map +1 -1
  209. package/lib-es/logic/getBlock.js +39 -22
  210. package/lib-es/logic/getBlock.js.map +1 -1
  211. package/lib-es/logic/getBlockInfo.js +2 -2
  212. package/lib-es/logic/getBlockInfo.js.map +1 -1
  213. package/lib-es/logic/getNextSequence.d.ts.map +1 -1
  214. package/lib-es/logic/getNextSequence.js +1 -1
  215. package/lib-es/logic/getNextSequence.js.map +1 -1
  216. package/lib-es/logic/getStakes.d.ts.map +1 -1
  217. package/lib-es/logic/getStakes.js +10 -10
  218. package/lib-es/logic/getStakes.js.map +1 -1
  219. package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
  220. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  221. package/lib-es/logic/internalTransactionsFetcher.js +8 -8
  222. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  223. package/lib-es/logic/lastBlock.js +2 -2
  224. package/lib-es/logic/lastBlock.js.map +1 -1
  225. package/lib-es/logic/listOperations.d.ts.map +1 -1
  226. package/lib-es/logic/listOperations.js +3 -1
  227. package/lib-es/logic/listOperations.js.map +1 -1
  228. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  229. package/lib-es/logic/validateIntent.js +9 -9
  230. package/lib-es/logic/validateIntent.js.map +1 -1
  231. package/lib-es/logic.d.ts +1 -1
  232. package/lib-es/logic.d.ts.map +1 -1
  233. package/lib-es/logic.js +14 -13
  234. package/lib-es/logic.js.map +1 -1
  235. package/lib-es/network/explorer/etherscan.d.ts +2 -3
  236. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  237. package/lib-es/network/explorer/etherscan.js +6 -8
  238. package/lib-es/network/explorer/etherscan.js.map +1 -1
  239. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  240. package/lib-es/network/explorer/ledger.js +5 -5
  241. package/lib-es/network/explorer/ledger.js.map +1 -1
  242. package/lib-es/network/explorer/types.d.ts +2 -2
  243. package/lib-es/network/explorer/types.d.ts.map +1 -1
  244. package/lib-es/network/explorer/types.js.map +1 -1
  245. package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
  246. package/lib-es/network/node/explorerProxy.js +14 -12
  247. package/lib-es/network/node/explorerProxy.js.map +1 -1
  248. package/lib-es/network/node/index.d.ts +1 -1
  249. package/lib-es/network/node/index.d.ts.map +1 -1
  250. package/lib-es/network/node/index.js +7 -7
  251. package/lib-es/network/node/index.js.map +1 -1
  252. package/lib-es/network/node/ledger.d.ts +3 -1
  253. package/lib-es/network/node/ledger.d.ts.map +1 -1
  254. package/lib-es/network/node/ledger.js +32 -22
  255. package/lib-es/network/node/ledger.js.map +1 -1
  256. package/lib-es/network/node/rpc.common.d.ts +1 -1
  257. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  258. package/lib-es/network/node/rpc.common.js +67 -39
  259. package/lib-es/network/node/rpc.common.js.map +1 -1
  260. package/lib-es/network/node/types.d.ts +18 -16
  261. package/lib-es/network/node/types.d.ts.map +1 -1
  262. package/lib-es/network/node/types.js.map +1 -1
  263. package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
  264. package/lib-es/network/node/withNodeSources.js +15 -15
  265. package/lib-es/network/node/withNodeSources.js.map +1 -1
  266. package/lib-es/staking/abis.d.ts +3 -2
  267. package/lib-es/staking/abis.d.ts.map +1 -1
  268. package/lib-es/staking/abis.js +10 -9
  269. package/lib-es/staking/abis.js.map +1 -1
  270. package/lib-es/staking/contracts.d.ts +3 -2
  271. package/lib-es/staking/contracts.d.ts.map +1 -1
  272. package/lib-es/staking/contracts.js +11 -10
  273. package/lib-es/staking/contracts.js.map +1 -1
  274. package/lib-es/staking/detectOperationType.d.ts +2 -1
  275. package/lib-es/staking/detectOperationType.d.ts.map +1 -1
  276. package/lib-es/staking/detectOperationType.js +7 -7
  277. package/lib-es/staking/detectOperationType.js.map +1 -1
  278. package/lib-es/staking/encoder.d.ts +2 -1
  279. package/lib-es/staking/encoder.d.ts.map +1 -1
  280. package/lib-es/staking/encoder.js +8 -8
  281. package/lib-es/staking/encoder.js.map +1 -1
  282. package/lib-es/staking/fetchers.d.ts +2 -1
  283. package/lib-es/staking/fetchers.d.ts.map +1 -1
  284. package/lib-es/staking/fetchers.js +27 -27
  285. package/lib-es/staking/fetchers.js.map +1 -1
  286. package/lib-es/staking/logic.d.ts +6 -6
  287. package/lib-es/staking/logic.d.ts.map +1 -1
  288. package/lib-es/staking/logic.js +14 -13
  289. package/lib-es/staking/logic.js.map +1 -1
  290. package/lib-es/staking/operations/index.d.ts +2 -1
  291. package/lib-es/staking/operations/index.d.ts.map +1 -1
  292. package/lib-es/staking/operations/index.js +30 -28
  293. package/lib-es/staking/operations/index.js.map +1 -1
  294. package/lib-es/staking/prepareIntents.d.ts +1 -1
  295. package/lib-es/staking/prepareIntents.d.ts.map +1 -1
  296. package/lib-es/staking/prepareIntents.js +11 -10
  297. package/lib-es/staking/prepareIntents.js.map +1 -1
  298. package/lib-es/staking/redelegations.d.ts +4 -4
  299. package/lib-es/staking/redelegations.d.ts.map +1 -1
  300. package/lib-es/staking/redelegations.js +18 -20
  301. package/lib-es/staking/redelegations.js.map +1 -1
  302. package/lib-es/staking/rewards.d.ts +1 -1
  303. package/lib-es/staking/rewards.d.ts.map +1 -1
  304. package/lib-es/staking/rewards.js +2 -2
  305. package/lib-es/staking/rewards.js.map +1 -1
  306. package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
  307. package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
  308. package/lib-es/staking/rewardsFromReceipt.js +2 -2
  309. package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
  310. package/lib-es/staking/transactionData.d.ts +2 -1
  311. package/lib-es/staking/transactionData.d.ts.map +1 -1
  312. package/lib-es/staking/transactionData.js +6 -6
  313. package/lib-es/staking/transactionData.js.map +1 -1
  314. package/lib-es/staking/unbondings.d.ts +1 -1
  315. package/lib-es/staking/unbondings.d.ts.map +1 -1
  316. package/lib-es/staking/unbondings.js +2 -2
  317. package/lib-es/staking/unbondings.js.map +1 -1
  318. package/lib-es/staking/validators/index.d.ts +14 -14
  319. package/lib-es/staking/validators/index.d.ts.map +1 -1
  320. package/lib-es/staking/validators/index.js +39 -38
  321. package/lib-es/staking/validators/index.js.map +1 -1
  322. package/lib-es/staking/validators/monad.d.ts +5 -5
  323. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  324. package/lib-es/staking/validators/monad.js +31 -33
  325. package/lib-es/staking/validators/monad.js.map +1 -1
  326. package/lib-es/staking/validators/monadResolver.d.ts +1 -1
  327. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  328. package/lib-es/staking/validators/monadResolver.js +4 -4
  329. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  330. package/lib-es/staking/validators/sei.js +2 -2
  331. package/lib-es/staking/validators/sei.js.map +1 -1
  332. package/lib-es/staking/validators/somnia.d.ts +4 -4
  333. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  334. package/lib-es/staking/validators/somnia.js +22 -22
  335. package/lib-es/staking/validators/somnia.js.map +1 -1
  336. package/lib-es/staking/validators/types.d.ts +1 -1
  337. package/lib-es/staking/validators/types.d.ts.map +1 -1
  338. package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
  339. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  340. package/lib-es/staking/validators/zero_gravity.js +7 -7
  341. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  342. package/lib-es/types/staking.d.ts +5 -6
  343. package/lib-es/types/staking.d.ts.map +1 -1
  344. package/package.json +2 -2
  345. package/src/adapters/etherscan.test.ts +91 -43
  346. package/src/adapters/etherscan.ts +18 -2
  347. package/src/adapters/ledger.test.ts +106 -31
  348. package/src/adapters/ledger.ts +5 -2
  349. package/src/api/index.ts +1 -2
  350. package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +5 -4
  351. package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +3 -3
  352. package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +3 -3
  353. package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +3 -3
  354. package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +3 -3
  355. package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +3 -3
  356. package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +3 -3
  357. package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +3 -3
  358. package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +6 -6
  359. package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +3 -3
  360. package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +3 -3
  361. package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +3 -3
  362. package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +3 -3
  363. package/src/api/{index.test.ts → tests/index.test.ts} +4 -4
  364. package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +2 -2
  365. package/src/chains.test.ts +12 -0
  366. package/src/chains.ts +98 -0
  367. package/src/config.ts +5 -1
  368. package/src/fixtures/staking.fixtures.ts +13 -0
  369. package/src/logic/broadcast.ts +2 -2
  370. package/src/logic/common.ts +10 -11
  371. package/src/logic/craftTransaction.ts +2 -3
  372. package/src/logic/estimateFees.ts +6 -23
  373. package/src/logic/getBalance.ts +7 -13
  374. package/src/logic/getBlock.ts +59 -23
  375. package/src/logic/getBlockInfo.ts +2 -2
  376. package/src/logic/getNextSequence.ts +1 -4
  377. package/src/logic/getStakes.ts +11 -12
  378. package/src/logic/internalTransactionsFetcher.ts +6 -8
  379. package/src/logic/lastBlock.ts +2 -2
  380. package/src/logic/listOperations.ts +2 -1
  381. package/src/logic/tests/broadcast.test.ts +5 -5
  382. package/src/logic/tests/broadcastSource.test.ts +1 -4
  383. package/src/logic/tests/common.test.ts +18 -34
  384. package/src/logic/tests/craftTransaction.test.ts +14 -7
  385. package/src/logic/tests/estimateFees.test.ts +17 -8
  386. package/src/logic/tests/getBalance.test.ts +18 -34
  387. package/src/logic/tests/getBlock.test.ts +195 -80
  388. package/src/logic/tests/getBlockInfo.test.ts +2 -2
  389. package/src/logic/tests/getNextSequence.test.ts +2 -2
  390. package/src/logic/tests/getStakes.test.ts +28 -16
  391. package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -6
  392. package/src/logic/tests/lastBlock.test.ts +4 -7
  393. package/src/logic/tests/listOperations.test.ts +8 -7
  394. package/src/logic/tests/validateIntent.test.ts +49 -3
  395. package/src/logic/validateIntent.ts +8 -10
  396. package/src/logic.test.ts +13 -5
  397. package/src/logic.ts +13 -13
  398. package/src/network/explorer/etherscan.ts +8 -24
  399. package/src/network/explorer/ledger.ts +2 -5
  400. package/src/network/explorer/types.ts +0 -2
  401. package/src/network/node/explorerProxy.ts +14 -12
  402. package/src/network/node/index.ts +11 -8
  403. package/src/network/node/ledger.ts +32 -34
  404. package/src/network/node/rpc.common.ts +79 -86
  405. package/src/network/node/types.ts +16 -31
  406. package/src/network/node/withNodeSources.ts +23 -26
  407. package/src/network/{explorer → tests/explorer}/etherscan.test.ts +16 -65
  408. package/src/network/{explorer → tests/explorer}/index.test.ts +8 -8
  409. package/src/network/{explorer → tests/explorer}/ledger.test.ts +34 -142
  410. package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
  411. package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
  412. package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
  413. package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
  414. package/src/network/{node → tests/node}/explorerProxy.test.ts +22 -24
  415. package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
  416. package/src/network/tests/node/index.memoization.test.ts +70 -0
  417. package/src/network/{node → tests/node}/index.test.ts +4 -6
  418. package/src/network/{node → tests/node}/ledger.test.ts +69 -74
  419. package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
  420. package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
  421. package/src/network/{node → tests/node}/rpc.test.ts +100 -119
  422. package/src/network/{node → tests/node}/types.test.ts +1 -1
  423. package/src/network/{node → tests/node}/withNodeSources.test.ts +10 -12
  424. package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
  425. package/src/staking/abis.test.ts +24 -28
  426. package/src/staking/abis.ts +12 -10
  427. package/src/staking/contracts.test.ts +20 -8
  428. package/src/staking/contracts.ts +12 -11
  429. package/src/staking/detectOperationType.test.ts +16 -13
  430. package/src/staking/detectOperationType.ts +9 -8
  431. package/src/staking/encoder.test.ts +38 -27
  432. package/src/staking/encoder.ts +9 -8
  433. package/src/staking/fetchers.ts +28 -39
  434. package/src/staking/logic.test.ts +34 -32
  435. package/src/staking/logic.ts +14 -14
  436. package/src/staking/operations/index.test.ts +48 -39
  437. package/src/staking/operations/index.ts +31 -28
  438. package/src/staking/prepareIntents.test.ts +14 -34
  439. package/src/staking/prepareIntents.ts +10 -13
  440. package/src/staking/redelegations.test.ts +73 -131
  441. package/src/staking/redelegations.ts +12 -26
  442. package/src/staking/rewards.test.ts +19 -21
  443. package/src/staking/rewards.ts +1 -2
  444. package/src/staking/rewardsFromReceipt.test.ts +9 -8
  445. package/src/staking/rewardsFromReceipt.ts +3 -2
  446. package/src/staking/transactionData.test.ts +35 -25
  447. package/src/staking/transactionData.ts +7 -6
  448. package/src/staking/unbondings.test.ts +26 -20
  449. package/src/staking/unbondings.ts +1 -2
  450. package/src/staking/validators/index.ts +45 -51
  451. package/src/staking/validators/monad.test.ts +52 -54
  452. package/src/staking/validators/monad.ts +31 -37
  453. package/src/staking/validators/monadResolver.ts +2 -4
  454. package/src/staking/validators/sei.ts +2 -2
  455. package/src/staking/validators/somnia.test.ts +22 -19
  456. package/src/staking/validators/somnia.ts +20 -27
  457. package/src/staking/validators/types.ts +0 -1
  458. package/src/staking/validators/zero_gravity.test.ts +34 -49
  459. package/src/staking/validators/zero_gravity.ts +5 -11
  460. package/src/staking/validators.integ.test.ts +3 -5
  461. package/src/staking/validators.test.ts +56 -53
  462. package/src/types/staking.ts +3 -6
  463. package/src/network/node/index.memoization.test.ts +0 -63
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { BlockFinalizationTag, EvmConfigInfo, ExternalNodeConfig } from '../../config'
4
+ import type { BlockFinalizationTag, ChainId, EvmConfigInfo, ExternalNodeConfig } from '../../config'
5
5
  import type { FeeHistory, FeeData } from '../../types'
6
6
  import type {
7
7
  NodeApi,
@@ -22,6 +22,7 @@ import { ethers, FetchRequest, JsonRpcProvider } from 'ethers'
22
22
  import ERC20Abi from '../../abis/erc20.abi.json'
23
23
  import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
24
24
  import ScrollGasPriceOracleAbi from '../../abis/scrollGasPriceOracle.abi.json'
25
+ import { CHAIN_ID } from '../../config'
25
26
  import { GasEstimationError, InsufficientFunds, UnsupportedRpcMethodError } from '../../errors'
26
27
  import { isSmartContractInput, safeEncodeEIP55, normalizeAddress } from '../../logic-public'
27
28
  import {
@@ -197,12 +198,12 @@ export const DEFAULT_RETRIES_RPC_METHODS =
197
198
  * Without this, ethers will create a new provider and use the `eth_chainId` RPC call
198
199
  * at instanciation which could result in rate limits being reached
199
200
  * on some specific nodes (E.g. the main Optimism RPC)
200
- * Keyed by currency id + RPC URI so the same chain with different uri gets distinct providers.
201
+ * Keyed by chain id + RPC URI so the same chain with different uri gets distinct providers.
201
202
  */
202
203
  const PROVIDERS_BY_RPC: Record<string, JsonRpcProvider> = {}
203
204
 
204
- function providerCacheKey(currencyId: string, uri: string): string {
205
- return `${currencyId}:${uri}`
205
+ function providerCacheKey(chainId: ChainId, uri: string): string {
206
+ return `${chainId}:${uri}`
206
207
  }
207
208
 
208
209
  /**
@@ -230,16 +231,15 @@ export function destroyAllRpcProviders(): void {
230
231
  */
231
232
  export async function withApi<T>(
232
233
  config: EvmConfigInfo,
233
- currencyId: string,
234
234
  execute: (api: JsonRpcProvider) => Promise<T>,
235
235
  nodeConfig: ExternalNodeConfig
236
236
  ): Promise<T> {
237
237
  const retries = nodeConfig.retries ?? DEFAULT_RETRIES_RPC_METHODS
238
238
  return withRetries(
239
239
  async () => {
240
- const key = providerCacheKey(currencyId, nodeConfig.uri)
240
+ const chainId = config.chainId
241
+ const key = providerCacheKey(chainId, nodeConfig.uri)
241
242
  if (!PROVIDERS_BY_RPC[key]) {
242
- const chainId = config.chainId
243
243
  const fetchReq = new FetchRequest(nodeConfig.uri)
244
244
  // Disable ethers' built-in HTTP-level retries: withRetries handles all retry logic.
245
245
  fetchReq.setThrottleParams({ maxAttempts: 1 })
@@ -268,7 +268,6 @@ function parseReceiptL1Fee(raw: Record<string, unknown>): string | undefined {
268
268
 
269
269
  async function getTransaction(
270
270
  api: JsonRpcProvider,
271
- _currencyId: string,
272
271
  txHash: string,
273
272
  logger: Logger
274
273
  ): Promise<TransactionInfo> {
@@ -302,6 +301,7 @@ async function getTransaction(
302
301
  nonce: tx.nonce,
303
302
  gasUsed: quantityToDecimal(receipt.gasUsed),
304
303
  gasPrice: receiptGasPrice(receipt),
304
+ gasLimit: tx.gasLimit.toString(),
305
305
  status: receiptStatus(receipt.status),
306
306
  value: tx.value.toString(),
307
307
  from: tx.from,
@@ -316,20 +316,12 @@ async function getTransaction(
316
316
  }
317
317
  }
318
318
 
319
- async function getCoinBalance(
320
- api: JsonRpcProvider,
321
- _currencyId: string,
322
- address: string
323
- ): Promise<BigNumber> {
319
+ async function getCoinBalance(api: JsonRpcProvider, address: string): Promise<BigNumber> {
324
320
  const balance = await api.getBalance(normalizeAddress(address))
325
321
  return new BigNumber(balance.toString())
326
322
  }
327
323
 
328
- async function call(
329
- api: JsonRpcProvider,
330
- _currencyId: string,
331
- params: EvmCallParams
332
- ): Promise<string> {
324
+ async function call(api: JsonRpcProvider, params: EvmCallParams): Promise<string> {
333
325
  const block = typeof params.block === 'number' ? ethers.toQuantity(params.block) : params.block
334
326
  return api.send('eth_call', [
335
327
  {
@@ -342,7 +334,6 @@ async function call(
342
334
 
343
335
  async function getTokenBalance(
344
336
  api: JsonRpcProvider,
345
- _currencyId: string,
346
337
  address: string,
347
338
  contractAddress: string
348
339
  ): Promise<BigNumber> {
@@ -353,7 +344,6 @@ async function getTokenBalance(
353
344
 
354
345
  async function getTokenAllowance(
355
346
  api: JsonRpcProvider,
356
- _currencyId: string,
357
347
  ownerAddress: string,
358
348
  contractAddress: string,
359
349
  spenderAddress: string
@@ -366,11 +356,7 @@ async function getTokenAllowance(
366
356
  return new BigNumber(allowance.toString())
367
357
  }
368
358
 
369
- async function getTransactionCount(
370
- api: JsonRpcProvider,
371
- _currencyId: string,
372
- address: string
373
- ): Promise<number> {
359
+ async function getTransactionCount(api: JsonRpcProvider, address: string): Promise<number> {
374
360
  return api.getTransactionCount(normalizeAddress(address), 'pending')
375
361
  }
376
362
 
@@ -403,8 +389,8 @@ function makeGetGasEstimation(
403
389
  nodeConfig: ExternalNodeConfig,
404
390
  logger: Logger
405
391
  ): NodeApi['getGasEstimation'] {
406
- return (currencyId, address, transaction) =>
407
- withApi(evmConfig, currencyId, (api) => getGasEstimation(api, address, transaction, logger), {
392
+ return (address, transaction) =>
393
+ withApi(evmConfig, (api) => getGasEstimation(api, address, transaction, logger), {
408
394
  ...nodeConfig,
409
395
  retries: 0,
410
396
  })
@@ -413,7 +399,6 @@ function makeGetGasEstimation(
413
399
  async function getFeeData(
414
400
  api: JsonRpcProvider,
415
401
  config: EvmConfigInfo,
416
- currencyId: string,
417
402
  transaction: { type?: number | undefined; feesStrategy?: string | null | undefined }
418
403
  ): Promise<FeeData> {
419
404
  const block = await api.getBlock('latest')
@@ -486,7 +471,7 @@ async function getFeeData(
486
471
  // As a safety measure, if maxPriorityFeePerGas is zero
487
472
  // we enforce a 1 Gwei value
488
473
  let maxPriorityFeePerGas = maxPriorityFeeAverage.isZero()
489
- ? getMaxPriorityFeePerGas(currencyId)
474
+ ? getMaxPriorityFeePerGas(config.chainId)
490
475
  : maxPriorityFeeAverage
491
476
 
492
477
  // Apply the per-chain config floor on top, for networks (typically sparse testnets)
@@ -525,7 +510,6 @@ async function getFeeData(
525
510
 
526
511
  async function broadcastTransaction(
527
512
  api: JsonRpcProvider,
528
- _currencyId: string,
529
513
  signedTxHex: string,
530
514
  logger: Logger
531
515
  ): Promise<string> {
@@ -557,7 +541,6 @@ function assertNotStubBlock(
557
541
 
558
542
  async function getBlockByHeight(
559
543
  api: JsonRpcProvider,
560
- _currencyId: string,
561
544
  blockHeight: number | BlockFinalizationTag,
562
545
  logger: Logger,
563
546
  prefetchTxs?: boolean
@@ -615,6 +598,10 @@ async function getBlockByHeight(
615
598
  ...(typeof data === 'string' && isSmartContractInput(data) ? { input: data } : {}),
616
599
  // EIP-1559 transactions have gasPrice: null; fall back to maxFeePerGas then 0
617
600
  gasPrice: (tx.gasPrice ?? tx.maxFeePerGas ?? 0n).toString(),
601
+ ...(tx.gasLimit !== null && tx.gasLimit !== undefined
602
+ ? { gasLimit: BigInt(tx.gasLimit).toString() }
603
+ : {}),
604
+ ...(typeof tx.nonce === 'number' ? { nonce: tx.nonce } : {}),
618
605
  }
619
606
  })
620
607
 
@@ -709,6 +696,12 @@ async function getBlockByHeightFromRawRpc(
709
696
  throw new Error(
710
697
  'Malformed prefetched transaction gasPrice in eth_getBlockByNumber response'
711
698
  )
699
+ if ('gas' in tx && tx.gas !== undefined && typeof tx.gas !== 'string')
700
+ throw new Error('Malformed prefetched transaction gas in eth_getBlockByNumber response')
701
+ if ('nonce' in tx && tx.nonce !== undefined && typeof tx.nonce !== 'string')
702
+ throw new Error(
703
+ 'Malformed prefetched transaction nonce in eth_getBlockByNumber response'
704
+ )
712
705
  if (
713
706
  'input' in tx &&
714
707
  tx.input !== undefined &&
@@ -728,6 +721,12 @@ async function getBlockByHeightFromRawRpc(
728
721
  ? { input: tx.input }
729
722
  : {}),
730
723
  gasPrice: BigInt(tx.gasPrice ?? '0x0').toString(),
724
+ ...('gas' in tx && typeof tx.gas === 'string'
725
+ ? { gasLimit: BigInt(tx.gas).toString() }
726
+ : {}),
727
+ ...('nonce' in tx && typeof tx.nonce === 'string'
728
+ ? { nonce: Number(BigInt(tx.nonce)) }
729
+ : {}),
731
730
  }
732
731
  })
733
732
  : undefined
@@ -744,7 +743,6 @@ async function getBlockByHeightFromRawRpc(
744
743
 
745
744
  async function getBlockReceipts(
746
745
  api: JsonRpcProvider,
747
- _currencyId: string,
748
746
  blockHeight: number | 'latest',
749
747
  logger: Logger
750
748
  ): Promise<BlockReceiptInfo[]> {
@@ -796,7 +794,6 @@ async function getBlockReceipts(
796
794
 
797
795
  async function traceBlockGeth(
798
796
  api: JsonRpcProvider,
799
- _currencyId: string,
800
797
  blockHeight: number
801
798
  ): Promise<TraceBlockItem[]> {
802
799
  const rpcBlockTag = ethers.toQuantity(blockHeight) // convert to hex string
@@ -824,7 +821,6 @@ async function traceBlockGeth(
824
821
 
825
822
  async function traceBlockErigon(
826
823
  api: JsonRpcProvider,
827
- _currencyId: string,
828
824
  blockHeight: number | 'latest'
829
825
  ): Promise<TraceBlockItem[]> {
830
826
  const blockTag = blockHeight === 'latest' ? 'latest' : ethers.toQuantity(blockHeight)
@@ -859,6 +855,8 @@ type EthersPrefetchedTransaction = {
859
855
  data?: string | null
860
856
  gasPrice?: bigint | string | null
861
857
  maxFeePerGas?: bigint | string | null
858
+ gasLimit?: bigint | string | null
859
+ nonce?: number | null
862
860
  }
863
861
 
864
862
  function recordOf(value: object): Record<string, unknown> {
@@ -875,6 +873,8 @@ function isPrefetchedBlockTransaction(value: unknown): value is EthersPrefetched
875
873
  isOptionalString(value.to) &&
876
874
  isOptionalQuantity(value.gasPrice) &&
877
875
  isOptionalQuantity(value.maxFeePerGas) &&
876
+ isOptionalQuantity(value.gasLimit) &&
877
+ (value.nonce === undefined || value.nonce === null || typeof value.nonce === 'number') &&
878
878
  isOptionalString(value.data)
879
879
  )
880
880
  }
@@ -911,14 +911,18 @@ function receiptEnvelopeType(type: TransactionReceipt['type']): number | undefin
911
911
 
912
912
  async function getOptimismAdditionalFees(
913
913
  api: JsonRpcProvider,
914
- currencyId: string,
914
+ chainId: ChainId,
915
915
  transaction: string
916
916
  ): Promise<BigNumber> {
917
- if (
918
- !['optimism', 'optimism_sepolia', 'base', 'base_sepolia', 'blast', 'blast_sepolia'].includes(
919
- currencyId
920
- )
921
- ) {
917
+ const optimismFeeChainIds: readonly ChainId[] = [
918
+ CHAIN_ID.OPTIMISM,
919
+ CHAIN_ID.OPTIMISM_SEPOLIA,
920
+ CHAIN_ID.BASE,
921
+ CHAIN_ID.BASE_SEPOLIA,
922
+ CHAIN_ID.BLAST,
923
+ CHAIN_ID.BLAST_SEPOLIA,
924
+ ]
925
+ if (!optimismFeeChainIds.includes(chainId)) {
922
926
  return new BigNumber(0)
923
927
  }
924
928
 
@@ -939,10 +943,10 @@ async function getOptimismAdditionalFees(
939
943
 
940
944
  async function getScrollAdditionalFees(
941
945
  api: JsonRpcProvider,
942
- currencyId: string,
946
+ chainId: ChainId,
943
947
  transaction: string
944
948
  ): Promise<BigNumber> {
945
- if (currencyId !== 'scroll') {
949
+ if (chainId !== CHAIN_ID.SCROLL) {
946
950
  return new BigNumber(0)
947
951
  }
948
952
 
@@ -962,9 +966,9 @@ async function getScrollAdditionalFees(
962
966
  }
963
967
 
964
968
  /* Get default maxPriorityFeePerGas by chain */
965
- const getMaxPriorityFeePerGas = (currencyId: string): BigNumber => {
966
- switch (currencyId) {
967
- case 'zero_gravity':
969
+ const getMaxPriorityFeePerGas = (chainId: ChainId): BigNumber => {
970
+ switch (chainId) {
971
+ case CHAIN_ID.ZERO_GRAVITY:
968
972
  return new BigNumber(2e9) // 2 Gwei
969
973
  default:
970
974
  return new BigNumber(1e9) // 1 Gwei
@@ -972,21 +976,20 @@ const getMaxPriorityFeePerGas = (currencyId: string): BigNumber => {
972
976
  }
973
977
 
974
978
  function cacheKeyOptimismL1Fees(
975
- currencyId: string,
976
- transaction: Parameters<NodeApi['getOptimismAdditionalFees']>[1]
979
+ chainId: ChainId,
980
+ transaction: Parameters<NodeApi['getOptimismAdditionalFees']>[0]
977
981
  ): string {
978
- return 'getOptimismL1BaseFee_' + currencyId + '_' + transaction
982
+ return 'getOptimismL1BaseFee_' + chainId + '_' + transaction
979
983
  }
980
984
 
981
985
  function make<Args extends readonly unknown[], R>(
982
- f: (api: JsonRpcProvider, currencyId: string, ...args: Args) => Promise<R>,
986
+ f: (api: JsonRpcProvider, ...args: Args) => Promise<R>,
983
987
  evmConfig: EvmConfigInfo,
984
988
  nodeConfig: ExternalNodeConfig,
985
989
  configOverride: Partial<ExternalNodeConfig> = {}
986
- ): (currencyId: string, ...args: Args) => Promise<R> {
990
+ ): (...args: Args) => Promise<R> {
987
991
  const mergedConfig = { ...nodeConfig, ...configOverride }
988
- return (currencyId, ...args) =>
989
- withApi(evmConfig, currencyId, (api) => f(api, currencyId, ...args), mergedConfig)
992
+ return (...args) => withApi(evmConfig, (api) => f(api, ...args), mergedConfig)
990
993
  }
991
994
 
992
995
  export function createNodeApi(
@@ -996,55 +999,45 @@ export function createNodeApi(
996
999
  ): NodeApi {
997
1000
  return {
998
1001
  call: make(call, evmConfig, nodeConfig),
999
- getBlockByHeight: (currencyId, blockHeight, prefetchTxs) =>
1002
+ getBlockByHeight: (blockHeight, prefetchTxs) =>
1000
1003
  withApi(
1001
1004
  evmConfig,
1002
- currencyId,
1003
- (api) => getBlockByHeight(api, currencyId, blockHeight, logger, prefetchTxs),
1005
+ (api) => getBlockByHeight(api, blockHeight, logger, prefetchTxs),
1004
1006
  nodeConfig
1005
1007
  ),
1006
1008
  getCoinBalance: make(getCoinBalance, evmConfig, nodeConfig),
1007
1009
  getTokenBalance: make(getTokenBalance, evmConfig, nodeConfig),
1008
1010
  getTokenAllowance: make(getTokenAllowance, evmConfig, nodeConfig),
1009
1011
  getTransactionCount: make(getTransactionCount, evmConfig, nodeConfig),
1010
- getTransaction: (currencyId, txHash) =>
1011
- withApi(
1012
- evmConfig,
1013
- currencyId,
1014
- (api) => getTransaction(api, currencyId, txHash, logger),
1015
- nodeConfig
1016
- ),
1017
- getBlockReceipts: (currencyId, blockHeight) =>
1018
- withApi(
1019
- evmConfig,
1020
- currencyId,
1021
- (api) => getBlockReceipts(api, currencyId, blockHeight, logger),
1022
- nodeConfig
1023
- ),
1012
+ getTransaction: (txHash) =>
1013
+ withApi(evmConfig, (api) => getTransaction(api, txHash, logger), nodeConfig),
1014
+ getBlockReceipts: (blockHeight) =>
1015
+ withApi(evmConfig, (api) => getBlockReceipts(api, blockHeight, logger), nodeConfig),
1024
1016
  traceBlockErigon: make(traceBlockErigon, evmConfig, nodeConfig),
1025
1017
  traceBlockGeth: make(traceBlockGeth, evmConfig, nodeConfig),
1026
1018
  getGasEstimation: makeGetGasEstimation(evmConfig, nodeConfig, logger),
1027
- // getFeeData takes `config` first (not `currencyId`), so it can't use the currencyId-first
1028
- // `make` wrapper; bind it explicitly and pull `currencyId` from the second argument for `withApi`.
1029
- getFeeData: (config, currencyId, transaction) =>
1030
- withApi(
1019
+ // getFeeData takes `config` first, so it can't use the `make` wrapper; bind it explicitly.
1020
+ getFeeData: (config, transaction) =>
1021
+ withApi(evmConfig, (api) => getFeeData(api, config, transaction), nodeConfig),
1022
+ broadcastTransaction: (signedTxHex) =>
1023
+ withApi(evmConfig, (api) => broadcastTransaction(api, signedTxHex, logger), {
1024
+ ...nodeConfig,
1025
+ retries: 0,
1026
+ }),
1027
+ getOptimismAdditionalFees: makeLRUCache(
1028
+ make(
1029
+ (api, transaction: string) =>
1030
+ getOptimismAdditionalFees(api, evmConfig.chainId, transaction),
1031
1031
  evmConfig,
1032
- currencyId,
1033
- (api) => getFeeData(api, config, currencyId, transaction),
1034
1032
  nodeConfig
1035
1033
  ),
1036
- broadcastTransaction: (currencyId, signedTxHex) =>
1037
- withApi(
1038
- evmConfig,
1039
- currencyId,
1040
- (api) => broadcastTransaction(api, currencyId, signedTxHex, logger),
1041
- { ...nodeConfig, retries: 0 }
1042
- ),
1043
- getOptimismAdditionalFees: makeLRUCache(
1044
- make(getOptimismAdditionalFees, evmConfig, nodeConfig),
1045
- cacheKeyOptimismL1Fees,
1034
+ (transaction) => cacheKeyOptimismL1Fees(evmConfig.chainId, transaction),
1046
1035
  { ttl: 15 * 1000 } // prevent rate limit by caching for at least 15s
1047
1036
  ),
1048
- getScrollAdditionalFees: make(getScrollAdditionalFees, evmConfig, nodeConfig),
1037
+ getScrollAdditionalFees: make(
1038
+ (api, transaction: string) => getScrollAdditionalFees(api, evmConfig.chainId, transaction),
1039
+ evmConfig,
1040
+ nodeConfig
1041
+ ),
1049
1042
  }
1050
1043
  }
@@ -105,6 +105,8 @@ export type TransactionInfo = {
105
105
  nonce: number
106
106
  gasUsed: string
107
107
  gasPrice: string
108
+ /** Gas limit set by the sender (decimal), when the source reports it */
109
+ gasLimit?: string
108
110
  value: string | bigint // can be returned as bigint by ethers prefetched txs, or string in raw payloads
109
111
  status: number | null
110
112
  from: string
@@ -123,8 +125,9 @@ export type TransactionInfo = {
123
125
 
124
126
  export type PrefetchedBlockTransaction = Pick<
125
127
  TransactionInfo,
126
- 'hash' | 'value' | 'from' | 'to' | 'input' | 'gasPrice'
127
- >
128
+ 'hash' | 'value' | 'from' | 'to' | 'input' | 'gasPrice' | 'gasLimit'
129
+ > &
130
+ Partial<Pick<TransactionInfo, 'nonce'>>
128
131
 
129
132
  export type BlockReceiptInfo = Pick<
130
133
  TransactionInfo,
@@ -154,53 +157,35 @@ export type EvmCallParams = {
154
157
  }
155
158
 
156
159
  export type NodeApi = {
157
- call: (currencyId: string, params: EvmCallParams) => Promise<string>
158
- getTransaction: (currencyId: string, hash: string) => Promise<TransactionInfo>
159
- getCoinBalance: (currencyId: string, address: string) => Promise<BigNumber>
160
- getTokenBalance: (
161
- currencyId: string,
162
- address: string,
163
- contractAddress: string
164
- ) => Promise<BigNumber>
160
+ call: (params: EvmCallParams) => Promise<string>
161
+ getTransaction: (hash: string) => Promise<TransactionInfo>
162
+ getCoinBalance: (address: string) => Promise<BigNumber>
163
+ getTokenBalance: (address: string, contractAddress: string) => Promise<BigNumber>
165
164
  getTokenAllowance: (
166
- currencyId: string,
167
165
  ownerAddress: string,
168
166
  contractAddress: string,
169
167
  spenderAddress: string
170
168
  ) => Promise<BigNumber>
171
- getTransactionCount: (currencyId: string, address: string) => Promise<number>
169
+ getTransactionCount: (address: string) => Promise<number>
172
170
  getGasEstimation: (
173
- currencyId: string,
174
171
  address: string,
175
172
  transaction: { amount: BigNumber; data?: Buffer | null | undefined; recipient: string }
176
173
  ) => Promise<BigNumber>
177
174
  getFeeData: (
178
175
  config: EvmConfigInfo,
179
- currencyId: string,
180
176
  transaction: { type?: number | undefined; feesStrategy?: string | null | undefined }
181
177
  ) => Promise<FeeData>
182
- broadcastTransaction: (
183
- currencyId: string,
184
- signedTxHex: string,
185
- broadcastConfig?: BroadcastConfig
186
- ) => Promise<string>
178
+ broadcastTransaction: (signedTxHex: string, broadcastConfig?: BroadcastConfig) => Promise<string>
187
179
  getBlockByHeight: (
188
- currencyId: string,
189
180
  blockHeight: number | BlockFinalizationTag,
190
181
  prefetchTxs?: boolean
191
182
  // timestamp is in milliseconds
192
183
  ) => Promise<BlockByHeightResult>
193
- getBlockReceipts?: (
194
- currencyId: string,
195
- blockHeight: number | 'latest'
196
- ) => Promise<BlockReceiptInfo[]>
197
- traceBlockErigon?: (
198
- currencyId: string,
199
- blockHeight: number | 'latest'
200
- ) => Promise<TraceBlockItem[]>
201
- traceBlockGeth?: (currencyId: string, blockHeight: number) => Promise<TraceBlockItem[]>
202
- getOptimismAdditionalFees: (currencyId: string, transaction: string) => Promise<BigNumber>
203
- getScrollAdditionalFees: (currencyId: string, transaction: string) => Promise<BigNumber>
184
+ getBlockReceipts?: (blockHeight: number | 'latest') => Promise<BlockReceiptInfo[]>
185
+ traceBlockErigon?: (blockHeight: number | 'latest') => Promise<TraceBlockItem[]>
186
+ traceBlockGeth?: (blockHeight: number) => Promise<TraceBlockItem[]>
187
+ getOptimismAdditionalFees: (transaction: string) => Promise<BigNumber>
188
+ getScrollAdditionalFees: (transaction: string) => Promise<BigNumber>
204
189
  }
205
190
 
206
191
  type NodeConfig = EvmConfigInfo['node']
@@ -34,37 +34,34 @@ export function createFailoverNodeApi(sources: NodeApi[], logger: Logger): NodeA
34
34
  }
35
35
 
36
36
  const base: NodeApi = {
37
- call: (c, p) => tryInOrder('call', (api) => api.call(c, p)),
38
- getCoinBalance: (c, a) => tryInOrder('getCoinBalance', (api) => api.getCoinBalance(c, a)),
39
- getTokenBalance: (c, a, ca) =>
40
- tryInOrder('getTokenBalance', (api) => api.getTokenBalance(c, a, ca)),
41
- getTokenAllowance: (c, o, ca, s) =>
42
- tryInOrder('getTokenAllowance', (api) => api.getTokenAllowance(c, o, ca, s)),
43
- getTransactionCount: (c, a) =>
44
- tryInOrder('getTransactionCount', (api) => api.getTransactionCount(c, a)),
45
- getGasEstimation: (c, a, t) =>
46
- tryInOrder('getGasEstimation', (api) => api.getGasEstimation(c, a, t)),
47
- getFeeData: (cfg, c, t) => tryInOrder('getFeeData', (api) => api.getFeeData(cfg, c, t)),
48
- broadcastTransaction: (c, tx, bc) =>
49
- tryInOrder('broadcastTransaction', (api) => api.broadcastTransaction(c, tx, bc)),
50
- getOptimismAdditionalFees: (c, t) =>
51
- tryInOrder('getOptimismAdditionalFees', (api) => api.getOptimismAdditionalFees(c, t)),
52
- getScrollAdditionalFees: (c, t) =>
53
- tryInOrder('getScrollAdditionalFees', (api) => api.getScrollAdditionalFees(c, t)),
54
- getBlockByHeight: (c, h, p) =>
55
- tryInOrder('getBlockByHeight', (api) => api.getBlockByHeight(c, h, p)),
56
- getTransaction: (c, h) => tryInOrder('getTransaction', (api) => api.getTransaction(c, h)),
37
+ call: (p) => tryInOrder('call', (api) => api.call(p)),
38
+ getCoinBalance: (a) => tryInOrder('getCoinBalance', (api) => api.getCoinBalance(a)),
39
+ getTokenBalance: (a, ca) => tryInOrder('getTokenBalance', (api) => api.getTokenBalance(a, ca)),
40
+ getTokenAllowance: (o, ca, s) =>
41
+ tryInOrder('getTokenAllowance', (api) => api.getTokenAllowance(o, ca, s)),
42
+ getTransactionCount: (a) =>
43
+ tryInOrder('getTransactionCount', (api) => api.getTransactionCount(a)),
44
+ getGasEstimation: (a, t) => tryInOrder('getGasEstimation', (api) => api.getGasEstimation(a, t)),
45
+ getFeeData: (cfg, t) => tryInOrder('getFeeData', (api) => api.getFeeData(cfg, t)),
46
+ broadcastTransaction: (tx, bc) =>
47
+ tryInOrder('broadcastTransaction', (api) => api.broadcastTransaction(tx, bc)),
48
+ getOptimismAdditionalFees: (t) =>
49
+ tryInOrder('getOptimismAdditionalFees', (api) => api.getOptimismAdditionalFees(t)),
50
+ getScrollAdditionalFees: (t) =>
51
+ tryInOrder('getScrollAdditionalFees', (api) => api.getScrollAdditionalFees(t)),
52
+ getBlockByHeight: (h, p) => tryInOrder('getBlockByHeight', (api) => api.getBlockByHeight(h, p)),
53
+ getTransaction: (h) => tryInOrder('getTransaction', (api) => api.getTransaction(h)),
57
54
  }
58
55
  // Optional methods: wired when at least one source implements them; undefined sources skipped
59
56
  if (sources.some((api) => api.getBlockReceipts))
60
- base.getBlockReceipts = (c, h): Promise<BlockReceiptInfo[]> =>
61
- tryInOrder('getBlockReceipts', (api) => api.getBlockReceipts?.(c, h))
57
+ base.getBlockReceipts = (h): Promise<BlockReceiptInfo[]> =>
58
+ tryInOrder('getBlockReceipts', (api) => api.getBlockReceipts?.(h))
62
59
  if (sources.some((api) => api.traceBlockErigon))
63
- base.traceBlockErigon = (c, h): Promise<TraceBlockItem[]> =>
64
- tryInOrder('traceBlockErigon', (api) => api.traceBlockErigon?.(c, h))
60
+ base.traceBlockErigon = (h): Promise<TraceBlockItem[]> =>
61
+ tryInOrder('traceBlockErigon', (api) => api.traceBlockErigon?.(h))
65
62
  if (sources.some((api) => api.traceBlockGeth))
66
- base.traceBlockGeth = (c, h): Promise<TraceBlockItem[]> =>
67
- tryInOrder('traceBlockGeth', (api) => api.traceBlockGeth?.(c, h))
63
+ base.traceBlockGeth = (h): Promise<TraceBlockItem[]> =>
64
+ tryInOrder('traceBlockGeth', (api) => api.traceBlockGeth?.(h))
68
65
  return base
69
66
  }
70
67