@ledgerhq/coin-evm 5.4.1 → 8.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 (355) hide show
  1. package/.oxlintrc.json +1 -1
  2. package/CHANGELOG.md +234 -0
  3. package/docs/evm-family-integration-process/README.md +1 -1
  4. package/knip.json +2 -3
  5. package/lib/adapters/blockOperations.js +6 -6
  6. package/lib/adapters/blockOperations.js.map +1 -1
  7. package/lib/adapters/etherscan.js +23 -23
  8. package/lib/adapters/etherscan.js.map +1 -1
  9. package/lib/adapters/ledger.js +17 -17
  10. package/lib/adapters/ledger.js.map +1 -1
  11. package/lib/api/index.js +4 -4
  12. package/lib/api/index.js.map +1 -1
  13. package/lib/config.d.ts +21 -16
  14. package/lib/config.d.ts.map +1 -1
  15. package/lib/config.js +5 -25
  16. package/lib/config.js.map +1 -1
  17. package/lib/errors.d.ts +9 -0
  18. package/lib/errors.d.ts.map +1 -1
  19. package/lib/errors.js +15 -1
  20. package/lib/errors.js.map +1 -1
  21. package/lib/logic/broadcast.js +1 -1
  22. package/lib/logic/broadcast.js.map +1 -1
  23. package/lib/logic/common.d.ts +2 -1
  24. package/lib/logic/common.d.ts.map +1 -1
  25. package/lib/logic/common.js +4 -4
  26. package/lib/logic/common.js.map +1 -1
  27. package/lib/logic/craftTransaction.d.ts.map +1 -1
  28. package/lib/logic/craftTransaction.js +2 -2
  29. package/lib/logic/craftTransaction.js.map +1 -1
  30. package/lib/logic/estimateFees.d.ts.map +1 -1
  31. package/lib/logic/estimateFees.js +9 -9
  32. package/lib/logic/estimateFees.js.map +1 -1
  33. package/lib/logic/getBalance.d.ts.map +1 -1
  34. package/lib/logic/getBalance.js +50 -16
  35. package/lib/logic/getBalance.js.map +1 -1
  36. package/lib/logic/getBlock.d.ts.map +1 -1
  37. package/lib/logic/getBlock.js +19 -11
  38. package/lib/logic/getBlock.js.map +1 -1
  39. package/lib/logic/getBlockInfo.js +1 -1
  40. package/lib/logic/getBlockInfo.js.map +1 -1
  41. package/lib/logic/getNextSequence.d.ts.map +1 -1
  42. package/lib/logic/getNextSequence.js +1 -1
  43. package/lib/logic/getNextSequence.js.map +1 -1
  44. package/lib/logic/index.d.ts +2 -0
  45. package/lib/logic/index.d.ts.map +1 -1
  46. package/lib/logic/index.js +4 -0
  47. package/lib/logic/index.js.map +1 -1
  48. package/lib/logic/lastBlock.js +1 -1
  49. package/lib/logic/lastBlock.js.map +1 -1
  50. package/lib/logic/listOperations.d.ts.map +1 -1
  51. package/lib/logic/listOperations.js +10 -1
  52. package/lib/logic/listOperations.js.map +1 -1
  53. package/lib/logic/validateIntent.d.ts.map +1 -1
  54. package/lib/logic/validateIntent.js +12 -12
  55. package/lib/logic/validateIntent.js.map +1 -1
  56. package/lib/logic-public/index.d.ts +3 -0
  57. package/lib/logic-public/index.d.ts.map +1 -0
  58. package/lib/logic-public/index.js +19 -0
  59. package/lib/logic-public/index.js.map +1 -0
  60. package/lib/{utils.d.ts → logic-public/utils.d.ts} +0 -44
  61. package/lib/logic-public/utils.d.ts.map +1 -0
  62. package/lib/logic-public/utils.js +166 -0
  63. package/lib/logic-public/utils.js.map +1 -0
  64. package/lib/logic.d.ts +2 -1
  65. package/lib/logic.d.ts.map +1 -1
  66. package/lib/logic.js +3 -3
  67. package/lib/logic.js.map +1 -1
  68. package/lib/network/explorer/etherscan.d.ts +16 -3
  69. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  70. package/lib/network/explorer/etherscan.js +61 -6
  71. package/lib/network/explorer/etherscan.js.map +1 -1
  72. package/lib/network/explorer/ledger.d.ts +50 -4
  73. package/lib/network/explorer/ledger.d.ts.map +1 -1
  74. package/lib/network/explorer/ledger.js +286 -37
  75. package/lib/network/explorer/ledger.js.map +1 -1
  76. package/lib/network/explorer/none.d.ts +1 -0
  77. package/lib/network/explorer/none.d.ts.map +1 -1
  78. package/lib/network/explorer/none.js +4 -1
  79. package/lib/network/explorer/none.js.map +1 -1
  80. package/lib/network/explorer/types.d.ts +15 -2
  81. package/lib/network/explorer/types.d.ts.map +1 -1
  82. package/lib/network/explorer/types.js.map +1 -1
  83. package/lib/network/index.d.ts +5 -0
  84. package/lib/network/index.d.ts.map +1 -0
  85. package/lib/network/index.js +23 -0
  86. package/lib/network/index.js.map +1 -0
  87. package/lib/network/node/explorerProxy.d.ts +27 -0
  88. package/lib/network/node/explorerProxy.d.ts.map +1 -0
  89. package/lib/network/node/explorerProxy.js +262 -0
  90. package/lib/network/node/explorerProxy.js.map +1 -0
  91. package/lib/network/node/index.d.ts +2 -1
  92. package/lib/network/node/index.d.ts.map +1 -1
  93. package/lib/network/node/index.js +11 -10
  94. package/lib/network/node/index.js.map +1 -1
  95. package/lib/network/node/ledger.js +7 -7
  96. package/lib/network/node/ledger.js.map +1 -1
  97. package/lib/network/node/rpc.common.d.ts +2 -2
  98. package/lib/network/node/rpc.common.js +19 -19
  99. package/lib/network/node/rpc.common.js.map +1 -1
  100. package/lib/network/node/withNodeSources.d.ts +21 -0
  101. package/lib/network/node/withNodeSources.d.ts.map +1 -0
  102. package/lib/network/node/withNodeSources.js +78 -0
  103. package/lib/network/node/withNodeSources.js.map +1 -0
  104. package/lib/nodeSources.d.ts +15 -0
  105. package/lib/nodeSources.d.ts.map +1 -0
  106. package/lib/nodeSources.js +33 -0
  107. package/lib/nodeSources.js.map +1 -0
  108. package/lib/staking/contracts.js +1 -1
  109. package/lib/staking/contracts.js.map +1 -1
  110. package/lib/staking/fetchers.js +1 -1
  111. package/lib/staking/fetchers.js.map +1 -1
  112. package/lib/staking/operations/sei.js +1 -1
  113. package/lib/staking/operations/sei.js.map +1 -1
  114. package/lib/staking/prepareIntents.js +3 -3
  115. package/lib/staking/prepareIntents.js.map +1 -1
  116. package/lib/staking/rewards.js +1 -1
  117. package/lib/staking/rewards.js.map +1 -1
  118. package/lib/staking/transactionData.js +2 -2
  119. package/lib/staking/transactionData.js.map +1 -1
  120. package/lib/staking/utils.d.ts +45 -0
  121. package/lib/staking/utils.d.ts.map +1 -0
  122. package/lib/{utils.js → staking/utils.js} +5 -164
  123. package/lib/staking/utils.js.map +1 -0
  124. package/lib/staking/validators/sei.js +1 -1
  125. package/lib/staking/validators/sei.js.map +1 -1
  126. package/lib/types/staking.d.ts +2 -2
  127. package/lib-es/adapters/blockOperations.js +1 -1
  128. package/lib-es/adapters/blockOperations.js.map +1 -1
  129. package/lib-es/adapters/etherscan.js +1 -1
  130. package/lib-es/adapters/etherscan.js.map +1 -1
  131. package/lib-es/adapters/ledger.js +1 -1
  132. package/lib-es/adapters/ledger.js.map +1 -1
  133. package/lib-es/api/index.js +2 -2
  134. package/lib-es/api/index.js.map +1 -1
  135. package/lib-es/config.d.ts +21 -16
  136. package/lib-es/config.d.ts.map +1 -1
  137. package/lib-es/config.js +1 -21
  138. package/lib-es/config.js.map +1 -1
  139. package/lib-es/errors.d.ts +9 -0
  140. package/lib-es/errors.d.ts.map +1 -1
  141. package/lib-es/errors.js +13 -0
  142. package/lib-es/errors.js.map +1 -1
  143. package/lib-es/logic/broadcast.js +1 -1
  144. package/lib-es/logic/broadcast.js.map +1 -1
  145. package/lib-es/logic/common.d.ts +2 -1
  146. package/lib-es/logic/common.d.ts.map +1 -1
  147. package/lib-es/logic/common.js +3 -3
  148. package/lib-es/logic/common.js.map +1 -1
  149. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  150. package/lib-es/logic/craftTransaction.js +2 -2
  151. package/lib-es/logic/craftTransaction.js.map +1 -1
  152. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  153. package/lib-es/logic/estimateFees.js +6 -6
  154. package/lib-es/logic/estimateFees.js.map +1 -1
  155. package/lib-es/logic/getBalance.d.ts.map +1 -1
  156. package/lib-es/logic/getBalance.js +50 -16
  157. package/lib-es/logic/getBalance.js.map +1 -1
  158. package/lib-es/logic/getBlock.d.ts.map +1 -1
  159. package/lib-es/logic/getBlock.js +16 -8
  160. package/lib-es/logic/getBlock.js.map +1 -1
  161. package/lib-es/logic/getBlockInfo.js +1 -1
  162. package/lib-es/logic/getBlockInfo.js.map +1 -1
  163. package/lib-es/logic/getNextSequence.d.ts.map +1 -1
  164. package/lib-es/logic/getNextSequence.js +1 -1
  165. package/lib-es/logic/getNextSequence.js.map +1 -1
  166. package/lib-es/logic/index.d.ts +2 -0
  167. package/lib-es/logic/index.d.ts.map +1 -1
  168. package/lib-es/logic/index.js +4 -0
  169. package/lib-es/logic/index.js.map +1 -1
  170. package/lib-es/logic/lastBlock.js +1 -1
  171. package/lib-es/logic/lastBlock.js.map +1 -1
  172. package/lib-es/logic/listOperations.d.ts.map +1 -1
  173. package/lib-es/logic/listOperations.js +10 -1
  174. package/lib-es/logic/listOperations.js.map +1 -1
  175. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  176. package/lib-es/logic/validateIntent.js +4 -4
  177. package/lib-es/logic/validateIntent.js.map +1 -1
  178. package/lib-es/logic-public/index.d.ts +3 -0
  179. package/lib-es/logic-public/index.d.ts.map +1 -0
  180. package/lib-es/logic-public/index.js +4 -0
  181. package/lib-es/logic-public/index.js.map +1 -0
  182. package/lib-es/{utils.d.ts → logic-public/utils.d.ts} +0 -44
  183. package/lib-es/logic-public/utils.d.ts.map +1 -0
  184. package/lib-es/logic-public/utils.js +150 -0
  185. package/lib-es/logic-public/utils.js.map +1 -0
  186. package/lib-es/logic.d.ts +2 -1
  187. package/lib-es/logic.d.ts.map +1 -1
  188. package/lib-es/logic.js +3 -3
  189. package/lib-es/logic.js.map +1 -1
  190. package/lib-es/network/explorer/etherscan.d.ts +16 -3
  191. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  192. package/lib-es/network/explorer/etherscan.js +60 -5
  193. package/lib-es/network/explorer/etherscan.js.map +1 -1
  194. package/lib-es/network/explorer/ledger.d.ts +50 -4
  195. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  196. package/lib-es/network/explorer/ledger.js +283 -37
  197. package/lib-es/network/explorer/ledger.js.map +1 -1
  198. package/lib-es/network/explorer/none.d.ts +1 -0
  199. package/lib-es/network/explorer/none.d.ts.map +1 -1
  200. package/lib-es/network/explorer/none.js +2 -0
  201. package/lib-es/network/explorer/none.js.map +1 -1
  202. package/lib-es/network/explorer/types.d.ts +15 -2
  203. package/lib-es/network/explorer/types.d.ts.map +1 -1
  204. package/lib-es/network/explorer/types.js.map +1 -1
  205. package/lib-es/network/index.d.ts +5 -0
  206. package/lib-es/network/index.d.ts.map +1 -0
  207. package/lib-es/network/index.js +7 -0
  208. package/lib-es/network/index.js.map +1 -0
  209. package/lib-es/network/node/explorerProxy.d.ts +27 -0
  210. package/lib-es/network/node/explorerProxy.d.ts.map +1 -0
  211. package/lib-es/network/node/explorerProxy.js +254 -0
  212. package/lib-es/network/node/explorerProxy.js.map +1 -0
  213. package/lib-es/network/node/index.d.ts +2 -1
  214. package/lib-es/network/node/index.d.ts.map +1 -1
  215. package/lib-es/network/node/index.js +11 -10
  216. package/lib-es/network/node/index.js.map +1 -1
  217. package/lib-es/network/node/ledger.js +1 -1
  218. package/lib-es/network/node/ledger.js.map +1 -1
  219. package/lib-es/network/node/rpc.common.d.ts +2 -2
  220. package/lib-es/network/node/rpc.common.js +3 -3
  221. package/lib-es/network/node/rpc.common.js.map +1 -1
  222. package/lib-es/network/node/withNodeSources.d.ts +21 -0
  223. package/lib-es/network/node/withNodeSources.d.ts.map +1 -0
  224. package/lib-es/network/node/withNodeSources.js +74 -0
  225. package/lib-es/network/node/withNodeSources.js.map +1 -0
  226. package/lib-es/nodeSources.d.ts +15 -0
  227. package/lib-es/nodeSources.d.ts.map +1 -0
  228. package/lib-es/nodeSources.js +28 -0
  229. package/lib-es/nodeSources.js.map +1 -0
  230. package/lib-es/staking/contracts.js +1 -1
  231. package/lib-es/staking/contracts.js.map +1 -1
  232. package/lib-es/staking/fetchers.js +1 -1
  233. package/lib-es/staking/fetchers.js.map +1 -1
  234. package/lib-es/staking/operations/sei.js +1 -1
  235. package/lib-es/staking/operations/sei.js.map +1 -1
  236. package/lib-es/staking/prepareIntents.js +1 -1
  237. package/lib-es/staking/prepareIntents.js.map +1 -1
  238. package/lib-es/staking/rewards.js +1 -1
  239. package/lib-es/staking/rewards.js.map +1 -1
  240. package/lib-es/staking/transactionData.js +1 -1
  241. package/lib-es/staking/transactionData.js.map +1 -1
  242. package/lib-es/staking/utils.d.ts +45 -0
  243. package/lib-es/staking/utils.d.ts.map +1 -0
  244. package/lib-es/{utils.js → staking/utils.js} +1 -147
  245. package/lib-es/staking/utils.js.map +1 -0
  246. package/lib-es/staking/validators/sei.js +1 -1
  247. package/lib-es/staking/validators/sei.js.map +1 -1
  248. package/lib-es/types/staking.d.ts +2 -2
  249. package/package.json +75 -9
  250. package/src/adapters/blockOperations.ts +1 -1
  251. package/src/adapters/etherscan.ts +1 -1
  252. package/src/adapters/ledger.ts +1 -1
  253. package/src/api/getBlock.integ.test.ts +10 -4
  254. package/src/api/index.arbitrum.integ.test.ts +1 -0
  255. package/src/api/index.arc.integ.test.ts +1 -0
  256. package/src/api/index.avalanche_c_chain_fuji.integ.test.ts +1 -0
  257. package/src/api/index.cronos.integ.test.ts +1 -0
  258. package/src/api/index.flare.integ.test.ts +4 -2
  259. package/src/api/index.linea.integ.test.ts +4 -2
  260. package/src/api/index.monad_testnet.integ.test.ts +95 -4
  261. package/src/api/index.optimism.integ.test.ts +1 -0
  262. package/src/api/index.rsk.integ.test.ts +1 -0
  263. package/src/api/index.shape.integ.test.ts +4 -2
  264. package/src/api/index.somnia.integ.test.ts +1 -0
  265. package/src/api/index.ts +2 -2
  266. package/src/config.ts +22 -35
  267. package/src/errors.ts +13 -0
  268. package/src/fixtures/context.fixtures.ts +9 -4
  269. package/src/logic/broadcast.ts +1 -1
  270. package/src/logic/common.ts +4 -2
  271. package/src/logic/craftTransaction.ts +2 -1
  272. package/src/logic/estimateFees.ts +20 -6
  273. package/src/logic/getBalance.ts +72 -26
  274. package/src/logic/getBlock.ts +26 -14
  275. package/src/logic/getBlockInfo.ts +1 -1
  276. package/src/logic/getNextSequence.ts +4 -1
  277. package/src/logic/index.ts +4 -0
  278. package/src/logic/lastBlock.ts +1 -1
  279. package/src/logic/listOperations.ts +14 -1
  280. package/src/logic/tests/broadcast.integ.test.ts +53 -0
  281. package/src/logic/{broadcast.test.ts → tests/broadcast.test.ts} +7 -7
  282. package/src/logic/{broadcastSource.test.ts → tests/broadcastSource.test.ts} +6 -6
  283. package/src/logic/{combine.test.ts → tests/combine.test.ts} +1 -1
  284. package/src/logic/{common.test.ts → tests/common.test.ts} +45 -21
  285. package/src/logic/{computeGasLimit.test.ts → tests/computeGasLimit.test.ts} +2 -2
  286. package/src/logic/{craftTransaction.test.ts → tests/craftTransaction.test.ts} +7 -7
  287. package/src/logic/{craftTransactionData.test.ts → tests/craftTransactionData.test.ts} +4 -4
  288. package/src/logic/{estimateFees.test.ts → tests/estimateFees.test.ts} +12 -12
  289. package/src/logic/tests/getBalance.test.ts +602 -0
  290. package/src/logic/{getBlock.test.ts → tests/getBlock.test.ts} +182 -89
  291. package/src/logic/{getBlockInfo.test.ts → tests/getBlockInfo.test.ts} +8 -8
  292. package/src/logic/{getErc20Data.test.ts → tests/getErc20Data.test.ts} +1 -1
  293. package/src/logic/{getNextSequence.test.ts → tests/getNextSequence.test.ts} +7 -7
  294. package/src/logic/{getStakes.test.ts → tests/getStakes.test.ts} +13 -13
  295. package/src/logic/{internalTransactionsFetcher.test.ts → tests/internalTransactionsFetcher.test.ts} +8 -8
  296. package/src/logic/{lastBlock.test.ts → tests/lastBlock.test.ts} +7 -7
  297. package/src/logic/{listOperations.test.ts → tests/listOperations.test.ts} +125 -6
  298. package/src/logic/{validateAddress.test.ts → tests/validateAddress.test.ts} +1 -1
  299. package/src/logic/{validateIntent.test.ts → tests/validateIntent.test.ts} +80 -78
  300. package/src/logic/validateIntent.ts +7 -4
  301. package/src/logic-public/index.ts +18 -0
  302. package/src/{utils.test.ts → logic-public/tests/utils.test.ts} +1 -27
  303. package/src/logic-public/utils.ts +184 -0
  304. package/src/logic.test.ts +5 -59
  305. package/src/logic.ts +5 -3
  306. package/src/network/explorer/etherscan.test.ts +403 -195
  307. package/src/network/explorer/etherscan.ts +99 -10
  308. package/src/network/explorer/index.test.ts +27 -0
  309. package/src/network/explorer/ledger.test.ts +792 -62
  310. package/src/network/explorer/ledger.ts +426 -54
  311. package/src/network/explorer/none.ts +3 -0
  312. package/src/network/explorer/types.ts +29 -5
  313. package/src/network/index.ts +7 -0
  314. package/src/network/node/explorerProxy.test.ts +673 -0
  315. package/src/network/node/explorerProxy.ts +308 -0
  316. package/src/network/node/index.memoization.test.ts +22 -10
  317. package/src/network/node/index.test.ts +6 -3
  318. package/src/network/node/index.ts +11 -7
  319. package/src/network/node/ledger.ts +1 -1
  320. package/src/network/node/node.fixtures.ts +2 -1
  321. package/src/network/node/rpc.common.ts +3 -3
  322. package/src/network/node/rpc.test.ts +66 -105
  323. package/src/network/node/withNodeSources.test.ts +240 -0
  324. package/src/network/node/withNodeSources.ts +95 -0
  325. package/src/nodeSources.ts +38 -0
  326. package/src/staking/contracts.ts +1 -1
  327. package/src/staking/encoder.test.ts +1 -1
  328. package/src/staking/fetchers.ts +1 -1
  329. package/src/staking/operations/sei.ts +1 -1
  330. package/src/staking/prepareIntents.ts +1 -1
  331. package/src/staking/redelegations.test.ts +3 -1
  332. package/src/staking/rewards.test.ts +1 -1
  333. package/src/staking/rewards.ts +1 -1
  334. package/src/staking/transactionData.ts +1 -1
  335. package/src/staking/unbondings.test.ts +2 -1
  336. package/src/staking/utils.test.ts +25 -0
  337. package/src/{utils.ts → staking/utils.ts} +2 -182
  338. package/src/staking/validators/sei.ts +1 -1
  339. package/src/staking/validators.test.ts +1 -0
  340. package/src/types/staking.ts +2 -2
  341. package/lib/constants.d.ts +0 -2
  342. package/lib/constants.d.ts.map +0 -1
  343. package/lib/constants.js +0 -11
  344. package/lib/constants.js.map +0 -1
  345. package/lib/utils.d.ts.map +0 -1
  346. package/lib/utils.js.map +0 -1
  347. package/lib-es/constants.d.ts +0 -2
  348. package/lib-es/constants.d.ts.map +0 -1
  349. package/lib-es/constants.js +0 -7
  350. package/lib-es/constants.js.map +0 -1
  351. package/lib-es/utils.d.ts.map +0 -1
  352. package/lib-es/utils.js.map +0 -1
  353. package/src/constants.ts +0 -9
  354. package/src/logic/broadcast.integ.test.ts +0 -46
  355. package/src/logic/getBalance.test.ts +0 -362
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { EvmContext } from '../../config'
4
5
  import type {
5
6
  BufferTxData,
6
7
  MemoNotSupported,
@@ -16,7 +17,6 @@ import {
16
17
  } from '@ledgerhq/coin-module-framework/errors'
17
18
  import { createStakingTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
18
19
  import BigNumber from 'bignumber.js'
19
- import { createContext, setCoinConfig } from '../config'
20
20
  import {
21
21
  ClaimRewardsFeesWarning,
22
22
  ETHAddressNonEIP,
@@ -30,27 +30,28 @@ import {
30
30
  RecipientIsNewAccount,
31
31
  RedelegateDstValAddressRequired,
32
32
  ValAddressRequired,
33
- } from '../errors'
33
+ } from '../../errors'
34
34
  import {
35
- createMockEvmCoinConfig,
35
+ createMockEvmConfigInfo,
36
+ createMockEvmContext,
36
37
  mkLedgerExplorer,
37
38
  mkLedgerGasTracker,
38
39
  mkLedgerNode,
39
- } from '../fixtures/context.fixtures'
40
- import ledgerExplorer from '../network/explorer/ledger'
41
- import ledgerGasTracker from '../network/gasTracker/ledger'
42
- import { getNodeApi } from '../network/node'
43
- import { mockNodeApi } from '../network/node/node.fixtures'
44
- import * as computeGasLimitModule from './computeGasLimit'
45
- import { validateIntent } from './validateIntent'
46
-
47
- jest.mock('./computeGasLimit', () => ({
48
- ...jest.requireActual('./computeGasLimit'),
40
+ } from '../../fixtures/context.fixtures'
41
+ import ledgerExplorer from '../../network/explorer/ledger'
42
+ import ledgerGasTracker from '../../network/gasTracker/ledger'
43
+ import { getNodeApi } from '../../network/node'
44
+ import { mockNodeApi } from '../../network/node/node.fixtures'
45
+ import * as computeGasLimitModule from '../computeGasLimit'
46
+ import { validateIntent } from '../validateIntent'
47
+
48
+ jest.mock('../computeGasLimit', () => ({
49
+ ...jest.requireActual('../computeGasLimit'),
49
50
  computeEIP7623GasLimit: jest.fn().mockReturnValue(0n),
50
51
  }))
51
52
 
52
- jest.mock('../network/node', () => ({
53
- ...jest.requireActual('../network/node'),
53
+ jest.mock('../../network/node', () => ({
54
+ ...jest.requireActual('../../network/node'),
54
55
  getNodeApi: jest.fn(),
55
56
  }))
56
57
 
@@ -88,10 +89,11 @@ function eip1559Intent(
88
89
 
89
90
  describe('validateIntent', () => {
90
91
  const nodeApiMock = mockNodeApi()
92
+ let context: EvmContext
91
93
 
92
94
  beforeEach(() => {
93
- setCoinConfig(() =>
94
- createMockEvmCoinConfig({
95
+ context = createMockEvmContext(
96
+ createMockEvmConfigInfo({
95
97
  chainId: 1,
96
98
  node: mkLedgerNode({ explorerId: 'eth' }),
97
99
  name: 'Ethereum',
@@ -155,7 +157,7 @@ describe('validateIntent', () => {
155
157
  ['does not warn', 'erc20', {}],
156
158
  ])('%s with too high fees on a %s asset', async (_s, assetType, expectedWarnings) => {
157
159
  const res = await validateIntent(
158
- createContext(),
160
+ context,
159
161
  'ethereum',
160
162
  eip1559Intent({
161
163
  amount: 1n,
@@ -175,7 +177,7 @@ describe('validateIntent', () => {
175
177
  describe('recipient', () => {
176
178
  it('detects the missing recipient with an error', async () => {
177
179
  const res = await validateIntent(
178
- createContext(),
180
+ context,
179
181
  'ethereum',
180
182
  eip1559Intent({ amount: 1n, recipient: '' }),
181
183
  [{ value: 50n, asset: { type: 'native' } }]
@@ -190,7 +192,7 @@ describe('validateIntent', () => {
190
192
 
191
193
  it('detects the incorrect recipient not being an eth address with an error', async () => {
192
194
  const res = await validateIntent(
193
- createContext(),
195
+ context,
194
196
  'ethereum',
195
197
  eip1559Intent({ amount: 1n, recipient: 'invalid-address' }),
196
198
  [{ value: 50n, asset: { type: 'native' } }]
@@ -207,7 +209,7 @@ describe('validateIntent', () => {
207
209
 
208
210
  it('detects the recipient being an ICAP with an error', async () => {
209
211
  const res = await validateIntent(
210
- createContext(),
212
+ context,
211
213
  'ethereum',
212
214
  eip1559Intent({
213
215
  amount: 1n,
@@ -229,7 +231,7 @@ describe('validateIntent', () => {
229
231
 
230
232
  function nativeSendToRecipient(overrides = {}) {
231
233
  return validateIntent(
232
- createContext(),
234
+ context,
233
235
  'ethereum',
234
236
  eip1559Intent({ amount: 1n, recipient: RECIPIENT, ...overrides }),
235
237
  [{ value: 50n, asset: { type: 'native' } }],
@@ -318,7 +320,7 @@ describe('validateIntent', () => {
318
320
 
319
321
  it('detects the recipient not being an EIP55 address with a warning', async () => {
320
322
  const res = await validateIntent(
321
- createContext(),
323
+ context,
322
324
  'ethereum',
323
325
  eip1559Intent({
324
326
  amount: 1n,
@@ -338,7 +340,7 @@ describe('validateIntent', () => {
338
340
  describe('amount', () => {
339
341
  it('detects an intent for a smart contract interaction without amount-related errors', async () => {
340
342
  const res = await validateIntent(
341
- createContext(),
343
+ context,
342
344
  'ethereum',
343
345
  eip1559Intent({
344
346
  amount: 0n,
@@ -357,7 +359,7 @@ describe('validateIntent', () => {
357
359
 
358
360
  it('detects an intent for native asset sending without amount with an error', async () => {
359
361
  const res = await validateIntent(
360
- createContext(),
362
+ context,
361
363
  'ethereum',
362
364
  eip1559Intent({
363
365
  amount: 0n,
@@ -377,7 +379,7 @@ describe('validateIntent', () => {
377
379
  nodeApiMock.getTransactionCount.mockResolvedValue(10)
378
380
 
379
381
  const res = await validateIntent(
380
- createContext(),
382
+ context,
381
383
  'ethereum',
382
384
  eip1559Intent({
383
385
  recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
@@ -396,7 +398,7 @@ describe('validateIntent', () => {
396
398
 
397
399
  it('detects native asset sending intent with an error', async () => {
398
400
  const res = await validateIntent(
399
- createContext(),
401
+ context,
400
402
  'ethereum',
401
403
  eip1559Intent({
402
404
  amount: 20n,
@@ -442,7 +444,7 @@ describe('validateIntent', () => {
442
444
  })
443
445
 
444
446
  const res = await validateIntent(
445
- createContext(),
447
+ context,
446
448
  'ethereum',
447
449
  eip1559Intent({
448
450
  sender: 'sender-address',
@@ -474,7 +476,7 @@ describe('validateIntent', () => {
474
476
 
475
477
  it('detects NotEnoughBalance when spending would dip into locked funds', async () => {
476
478
  const res = await validateIntent(
477
- createContext(),
479
+ context,
478
480
  'ethereum',
479
481
  eip1559Intent({
480
482
  recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
@@ -509,7 +511,7 @@ describe('validateIntent', () => {
509
511
  })
510
512
 
511
513
  const res = await validateIntent(
512
- createContext(),
514
+ context,
513
515
  'ethereum',
514
516
  legacyIntent({
515
517
  recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
@@ -532,7 +534,7 @@ describe('validateIntent', () => {
532
534
  describe('staking', () => {
533
535
  it('detects missing validator address for delegate with an error', async () => {
534
536
  const res = await validateIntent(
535
- createContext(),
537
+ context,
536
538
  'sei_evm',
537
539
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
538
540
  type: 'staking-legacy',
@@ -556,7 +558,7 @@ describe('validateIntent', () => {
556
558
 
557
559
  it('detects missing destination validator address for redelegate with an error', async () => {
558
560
  const res = await validateIntent(
559
- createContext(),
561
+ context,
560
562
  'sei_evm',
561
563
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
562
564
  type: 'staking-legacy',
@@ -580,7 +582,7 @@ describe('validateIntent', () => {
580
582
 
581
583
  it('detects delegate total spent greater than spendable balance with an error', async () => {
582
584
  const res = await validateIntent(
583
- createContext(),
585
+ context,
584
586
  'sei_evm',
585
587
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
586
588
  type: 'staking-legacy',
@@ -605,7 +607,7 @@ describe('validateIntent', () => {
605
607
 
606
608
  it('allows undelegate when amount exceeds spendable but fees fit in spendable balance', async () => {
607
609
  const res = await validateIntent(
608
- createContext(),
610
+ context,
609
611
  'sei_evm',
610
612
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
611
613
  type: 'staking-legacy',
@@ -627,7 +629,7 @@ describe('validateIntent', () => {
627
629
 
628
630
  it('allows redelegate when amount exceeds spendable but fees fit in spendable balance', async () => {
629
631
  const res = await validateIntent(
630
- createContext(),
632
+ context,
631
633
  'sei_evm',
632
634
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
633
635
  type: 'staking-legacy',
@@ -650,7 +652,7 @@ describe('validateIntent', () => {
650
652
 
651
653
  it('detects staking fees greater than native balance with an error', async () => {
652
654
  const res = await validateIntent(
653
- createContext(),
655
+ context,
654
656
  'sei_evm',
655
657
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
656
658
  type: 'staking-legacy',
@@ -675,7 +677,7 @@ describe('validateIntent', () => {
675
677
 
676
678
  it('should return an error when not enough balance for a claim reward', async () => {
677
679
  const res = await validateIntent(
678
- createContext(),
680
+ context,
679
681
  'sei_evm',
680
682
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
681
683
  type: 'staking-legacy',
@@ -698,7 +700,7 @@ describe('validateIntent', () => {
698
700
 
699
701
  it('should return an error when no validator specified for a claim reward', async () => {
700
702
  const res = await validateIntent(
701
- createContext(),
703
+ context,
702
704
  'sei_evm',
703
705
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
704
706
  type: 'staking-legacy',
@@ -721,7 +723,7 @@ describe('validateIntent', () => {
721
723
 
722
724
  it('should return no error for a valid claim reward', async () => {
723
725
  const res = await validateIntent(
724
- createContext(),
726
+ context,
725
727
  'sei_evm',
726
728
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
727
729
  type: 'staking-legacy',
@@ -750,7 +752,7 @@ describe('validateIntent', () => {
750
752
  const balance = 1_000_000n
751
753
  const totalFees = 100_000n // gasLimit(100_000) × gasPrice(1)
752
754
  const res = await validateIntent(
753
- createContext(),
755
+ context,
754
756
  'unknown_chain',
755
757
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
756
758
  type: 'staking-legacy',
@@ -773,7 +775,7 @@ describe('validateIntent', () => {
773
775
  const balance = 10n ** 18n
774
776
  const fees = 2n * 10n ** 17n // > configuredReserve
775
777
  const res = await validateIntent(
776
- createContext(),
778
+ context,
777
779
  'sei_evm',
778
780
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
779
781
  type: 'staking-legacy',
@@ -801,7 +803,7 @@ describe('validateIntent', () => {
801
803
  const balance = 10n ** 18n
802
804
  const fees = 10n ** 14n // < configuredReserve
803
805
  const res = await validateIntent(
804
- createContext(),
806
+ context,
805
807
  'sei_evm',
806
808
  createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
807
809
  type: 'staking-legacy',
@@ -854,7 +856,7 @@ describe('validateIntent', () => {
854
856
  },
855
857
  ])('$name', async ({ amount, native }) => {
856
858
  const res = await validateIntent(
857
- createContext(),
859
+ context,
858
860
  'sei_evm',
859
861
  claimRewardIntent({ amount, native }),
860
862
  claimRewardBalances(native),
@@ -881,7 +883,7 @@ describe('validateIntent', () => {
881
883
  },
882
884
  ])('$name', async ({ amount, native }) => {
883
885
  const res = await validateIntent(
884
- createContext(),
886
+ context,
885
887
  'sei_evm',
886
888
  claimRewardIntent({ amount, native }),
887
889
  claimRewardBalances(native),
@@ -899,7 +901,7 @@ describe('validateIntent', () => {
899
901
  ])('for %s', (_s, createIntent) => {
900
902
  it('detects missing fees with an error', async () => {
901
903
  const res = await validateIntent(
902
- createContext(),
904
+ context,
903
905
  'ethereum',
904
906
  createIntent({}),
905
907
  [{ value: 50n, asset: { type: 'native' } }],
@@ -915,7 +917,7 @@ describe('validateIntent', () => {
915
917
 
916
918
  it('detects a missing gasLimit with an error', async () => {
917
919
  const res = await validateIntent(
918
- createContext(),
920
+ context,
919
921
  'ethereum',
920
922
  createIntent({}),
921
923
  [{ value: 50n, asset: { type: 'native' } }],
@@ -934,7 +936,7 @@ describe('validateIntent', () => {
934
936
 
935
937
  it('detects a gasLimit = 0 with an error', async () => {
936
938
  const res = await validateIntent(
937
- createContext(),
939
+ context,
938
940
  'ethereum',
939
941
  createIntent({}),
940
942
  [{ value: 50n, asset: { type: 'native' } }],
@@ -953,7 +955,7 @@ describe('validateIntent', () => {
953
955
 
954
956
  it('detects a customGasLimit = 0 with an error', async () => {
955
957
  const res = await validateIntent(
956
- createContext(),
958
+ context,
957
959
  'ethereum',
958
960
  createIntent({}),
959
961
  [{ value: 50n, asset: { type: 'native' } }],
@@ -972,7 +974,7 @@ describe('validateIntent', () => {
972
974
 
973
975
  it('if the recipient has been set, detects fees being too high for the account balance with an error', async () => {
974
976
  const notEnoughBalanceRes = await validateIntent(
975
- createContext(),
977
+ context,
976
978
  'ethereum',
977
979
  createIntent({ recipient: 'recipient-address' }),
978
980
  [{ value: 10n, asset: { type: 'native' } }],
@@ -987,7 +989,7 @@ describe('validateIntent', () => {
987
989
  }
988
990
  )
989
991
  const notEnoughBalanceSponsoredRes = await validateIntent(
990
- createContext(),
992
+ context,
991
993
  'ethereum',
992
994
  createIntent({ recipient: 'recipient-address' }),
993
995
  [{ value: 10n, asset: { type: 'native' } }],
@@ -1003,7 +1005,7 @@ describe('validateIntent', () => {
1003
1005
  }
1004
1006
  )
1005
1007
  const enoughBalanceRes = await validateIntent(
1006
- createContext(),
1008
+ context,
1007
1009
  'ethereum',
1008
1010
  createIntent({ recipient: 'recipient-address' }),
1009
1011
  [{ value: 10n, asset: { type: 'native' } }],
@@ -1039,7 +1041,7 @@ describe('validateIntent', () => {
1039
1041
  // gas fee alone fits in the available balance, but the additionalFees
1040
1042
  // (e.g. L1 data fee on L2s) push the total above the native balance.
1041
1043
  const res = await validateIntent(
1042
- createContext(),
1044
+ context,
1043
1045
  'ethereum',
1044
1046
  createIntent({ recipient: 'recipient-address' }),
1045
1047
  [{ value: 10n, asset: { type: 'native' } }],
@@ -1064,7 +1066,7 @@ describe('validateIntent', () => {
1064
1066
 
1065
1067
  it('if the recipient has not been set, does not detect gas being too high', async () => {
1066
1068
  const notEnoughBalanceRes = await validateIntent(
1067
- createContext(),
1069
+ context,
1068
1070
  'ethereum',
1069
1071
  createIntent({ recipient: '' }),
1070
1072
  [{ value: 10n, asset: { type: 'native' } }],
@@ -1078,7 +1080,7 @@ describe('validateIntent', () => {
1078
1080
  }
1079
1081
  )
1080
1082
  const enoughBalanceRes = await validateIntent(
1081
- createContext(),
1083
+ context,
1082
1084
  'ethereum',
1083
1085
  createIntent({ recipient: '' }),
1084
1086
  [{ value: 10n, asset: { type: 'native' } }],
@@ -1109,7 +1111,7 @@ describe('validateIntent', () => {
1109
1111
  jest.mocked(computeGasLimitModule.computeEIP7623GasLimit).mockReturnValue(eip7623GasLimit)
1110
1112
 
1111
1113
  const res = await validateIntent(
1112
- createContext(),
1114
+ context,
1113
1115
  'ethereum',
1114
1116
  createIntent({}),
1115
1117
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1133,7 +1135,7 @@ describe('validateIntent', () => {
1133
1135
  jest.mocked(computeGasLimitModule.computeEIP7623GasLimit).mockReturnValue(eip7623GasLimit)
1134
1136
 
1135
1137
  const res = await validateIntent(
1136
- createContext(),
1138
+ context,
1137
1139
  'ethereum',
1138
1140
  createIntent({}),
1139
1141
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1154,8 +1156,8 @@ describe('validateIntent', () => {
1154
1156
 
1155
1157
  describe('calldata floor coin config', () => {
1156
1158
  it('forwards the configured floor parameters to computeEIP7623GasLimit', async () => {
1157
- setCoinConfig(() =>
1158
- createMockEvmCoinConfig({
1159
+ context = createMockEvmContext(
1160
+ createMockEvmConfigInfo({
1159
1161
  chainId: 1,
1160
1162
  node: mkLedgerNode({ explorerId: 'eth' }),
1161
1163
  explorer: mkLedgerExplorer({ explorerId: 'eth' }),
@@ -1166,7 +1168,7 @@ describe('validateIntent', () => {
1166
1168
  )
1167
1169
 
1168
1170
  await validateIntent(
1169
- createContext(),
1171
+ context,
1170
1172
  'ethereum',
1171
1173
  createIntent({}),
1172
1174
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1182,7 +1184,7 @@ describe('validateIntent', () => {
1182
1184
 
1183
1185
  it('forwards the EIP-7623 defaults when the coin config sets none', async () => {
1184
1186
  await validateIntent(
1185
- createContext(),
1187
+ context,
1186
1188
  'ethereum',
1187
1189
  createIntent({}),
1188
1190
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1199,7 +1201,7 @@ describe('validateIntent', () => {
1199
1201
 
1200
1202
  it('detects customGasLimit being lower than gasLimit with a warning', async () => {
1201
1203
  const res = await validateIntent(
1202
- createContext(),
1204
+ context,
1203
1205
  'ethereum',
1204
1206
  createIntent({}),
1205
1207
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1224,7 +1226,7 @@ describe('validateIntent', () => {
1224
1226
  describe('eip1559 specific', () => {
1225
1227
  it('detects a maxPriorityFeePerGas = 0 with an error', async () => {
1226
1228
  const res = await validateIntent(
1227
- createContext(),
1229
+ context,
1228
1230
  'ethereum',
1229
1231
  eip1559Intent({}),
1230
1232
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1243,7 +1245,7 @@ describe('validateIntent', () => {
1243
1245
 
1244
1246
  it('detects maxFeePerGas being greater than max gasOptions maxFeePerGas with an error', async () => {
1245
1247
  const res = await validateIntent(
1246
- createContext(),
1248
+ context,
1247
1249
  'ethereum',
1248
1250
  eip1559Intent({}),
1249
1251
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1283,7 +1285,7 @@ describe('validateIntent', () => {
1283
1285
  })
1284
1286
 
1285
1287
  const res = await validateIntent(
1286
- createContext(),
1288
+ context,
1287
1289
  'ethereum',
1288
1290
  eip1559Intent({}),
1289
1291
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1323,7 +1325,7 @@ describe('validateIntent', () => {
1323
1325
  })
1324
1326
 
1325
1327
  const res = await validateIntent(
1326
- createContext(),
1328
+ context,
1327
1329
  'ethereum',
1328
1330
  eip1559Intent({}),
1329
1331
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1363,7 +1365,7 @@ describe('validateIntent', () => {
1363
1365
  })
1364
1366
 
1365
1367
  const res = await validateIntent(
1366
- createContext(),
1368
+ context,
1367
1369
  'ethereum',
1368
1370
  eip1559Intent({}),
1369
1371
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1382,8 +1384,8 @@ describe('validateIntent', () => {
1382
1384
 
1383
1385
  describe('minGasPrice', () => {
1384
1386
  beforeEach(() => {
1385
- setCoinConfig(() =>
1386
- createMockEvmCoinConfig({
1387
+ context = createMockEvmContext(
1388
+ createMockEvmConfigInfo({
1387
1389
  chainId: 1,
1388
1390
  node: mkLedgerNode({ explorerId: 'eth' }),
1389
1391
  explorer: mkLedgerExplorer({ explorerId: 'eth' }),
@@ -1395,7 +1397,7 @@ describe('validateIntent', () => {
1395
1397
 
1396
1398
  it('raises an error when maxPriorityFeePerGas is below the chain minGasPrice', async () => {
1397
1399
  const res = await validateIntent(
1398
- createContext(),
1400
+ context,
1399
1401
  'ethereum',
1400
1402
  eip1559Intent({}),
1401
1403
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1414,7 +1416,7 @@ describe('validateIntent', () => {
1414
1416
 
1415
1417
  it('does not raise an error when maxPriorityFeePerGas is above the chain minGasPrice', async () => {
1416
1418
  const res = await validateIntent(
1417
- createContext(),
1419
+ context,
1418
1420
  'ethereum',
1419
1421
  eip1559Intent({}),
1420
1422
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1436,8 +1438,8 @@ describe('validateIntent', () => {
1436
1438
  describe('legacy specific', () => {
1437
1439
  describe('minGasPrice', () => {
1438
1440
  beforeEach(() => {
1439
- setCoinConfig(() =>
1440
- createMockEvmCoinConfig({
1441
+ context = createMockEvmContext(
1442
+ createMockEvmConfigInfo({
1441
1443
  chainId: 1,
1442
1444
  node: mkLedgerNode({ explorerId: 'eth' }),
1443
1445
  explorer: mkLedgerExplorer({ explorerId: 'eth' }),
@@ -1449,7 +1451,7 @@ describe('validateIntent', () => {
1449
1451
 
1450
1452
  it('raises an error when gasPrice is below the chain minGasPrice', async () => {
1451
1453
  const res = await validateIntent(
1452
- createContext(),
1454
+ context,
1453
1455
  'ethereum',
1454
1456
  legacyIntent({ recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29' }),
1455
1457
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1468,7 +1470,7 @@ describe('validateIntent', () => {
1468
1470
 
1469
1471
  it('does not raise an error when gasPrice is above the chain minGasPrice', async () => {
1470
1472
  const res = await validateIntent(
1471
- createContext(),
1473
+ context,
1472
1474
  'ethereum',
1473
1475
  legacyIntent({ recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29' }),
1474
1476
  [{ value: 50n, asset: { type: 'native' } }],
@@ -1612,7 +1614,7 @@ describe('validateIntent', () => {
1612
1614
  })
1613
1615
 
1614
1616
  const res = await validateIntent(
1615
- createContext(),
1617
+ context,
1616
1618
  'ethereum',
1617
1619
  legacyIntent({
1618
1620
  ...amount,
@@ -1688,7 +1690,7 @@ describe('validateIntent', () => {
1688
1690
  })
1689
1691
 
1690
1692
  const res = await validateIntent(
1691
- createContext(),
1693
+ context,
1692
1694
  'ethereum',
1693
1695
  eip1559Intent({
1694
1696
  ...amount,
@@ -1769,7 +1771,7 @@ describe('validateIntent', () => {
1769
1771
  })
1770
1772
 
1771
1773
  const res = await validateIntent(
1772
- createContext(),
1774
+ context,
1773
1775
  'ethereum',
1774
1776
  eip1559Intent({
1775
1777
  ...amount,
@@ -1835,7 +1837,7 @@ describe('validateIntent', () => {
1835
1837
  async (_s, createIntent, estimation) => {
1836
1838
  expect(
1837
1839
  await validateIntent(
1838
- createContext(),
1840
+ context,
1839
1841
  'ethereum',
1840
1842
  createIntent({
1841
1843
  amount: 2n,
@@ -13,6 +13,7 @@ import type {
13
13
  TransactionIntent,
14
14
  TransactionValidation,
15
15
  } from '@ledgerhq/coin-module-framework/api/types'
16
+ import type { Logger } from '@ledgerhq/coin-module-framework/config'
16
17
  import { formatCurrencyUnit } from '@ledgerhq/coin-module-framework/currencies/formatCurrencyUnit'
17
18
  import {
18
19
  AmountRequired,
@@ -37,11 +38,11 @@ import {
37
38
  RedelegateDstValAddressRequired,
38
39
  ValAddressRequired,
39
40
  } from '../errors'
41
+ import { DEFAULT_GAS_LIMIT, isEthAddress, isStakingIntent } from '../logic-public'
40
42
  import { getGasTracker } from '../network/gasTracker'
41
43
  import { getNodeApi } from '../network/node'
42
44
  import { STAKING_CONTRACTS } from '../staking'
43
45
  import { isNative, TransactionTypes } from '../types'
44
- import { DEFAULT_GAS_LIMIT, isEthAddress, isStakingIntent } from '../utils'
45
46
  import {
46
47
  getTransactionType,
47
48
  isApiGasOptions,
@@ -124,7 +125,8 @@ async function validateNewAccountRecipient(
124
125
  config: EvmConfigInfo,
125
126
  currencyId: string,
126
127
  intent: TransactionIntent<MemoNotSupported, BufferTxData>,
127
- amount: bigint
128
+ amount: bigint,
129
+ logger: Logger
128
130
  ): Promise<Pick<TransactionValidation, 'errors' | 'warnings'>> {
129
131
  const none = { errors: {}, warnings: {} }
130
132
  const isPlainNativeSend =
@@ -135,7 +137,7 @@ async function validateNewAccountRecipient(
135
137
  }
136
138
 
137
139
  try {
138
- const nodeApi = getNodeApi(config, currencyId)
140
+ const nodeApi = getNodeApi(config, currencyId, logger)
139
141
  const [balance, nonce] = await Promise.all([
140
142
  nodeApi.getCoinBalance(currencyId, intent.recipient),
141
143
  nodeApi.getTransactionCount(currencyId, intent.recipient),
@@ -509,7 +511,8 @@ export async function validateIntent(
509
511
  config,
510
512
  currencyId,
511
513
  intent,
512
- amount
514
+ amount,
515
+ context.logger
513
516
  )
514
517
 
515
518
  const errors = {
@@ -0,0 +1,18 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export {
5
+ DEFAULT_GAS_LIMIT,
6
+ DEFAULT_NONCE,
7
+ buildSmartContractDetails,
8
+ isEthAddress,
9
+ isHexString,
10
+ isSmartContractInput,
11
+ isStakingIntent,
12
+ normalizeAddress,
13
+ padHexString,
14
+ safeBigInt,
15
+ safeEncodeEIP55,
16
+ unwrapProxy,
17
+ } from './utils'
18
+ export type { ContractInteractionKind, EvmStakingIntent } from './utils'
@@ -1,12 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import {
5
- buildSmartContractDetails,
6
- isSmartContractInput,
7
- parseDecimalIntegerPart,
8
- safeEncodeEIP55,
9
- } from './utils'
4
+ import { buildSmartContractDetails, isSmartContractInput, safeEncodeEIP55 } from '../utils'
10
5
 
11
6
  describe('isSmartContractInput', () => {
12
7
  it.each([
@@ -65,24 +60,3 @@ describe('buildSmartContractDetails', () => {
65
60
  })
66
61
  })
67
62
  })
68
-
69
- describe('parseDecimalIntegerPart', () => {
70
- it.each([
71
- ['100', 100n],
72
- ['569.024692675122000000', 569n],
73
- ['0.019211023787000000', 0n],
74
- [' 42 ', 42n],
75
- ['1.', 1n],
76
- ['1000000000000000000', 1000000000000000000n],
77
- ['-5.9', -5n],
78
- ] as const)('parseDecimalIntegerPart(%p) === %s', (input, expected) => {
79
- expect(parseDecimalIntegerPart(input)).toBe(expected)
80
- })
81
-
82
- it.each(['', '.', 'not-a-number', 'abc.123'])(
83
- 'returns 0n when the integer part is not parseable (%p)',
84
- (input) => {
85
- expect(parseDecimalIntegerPart(input)).toBe(0n)
86
- }
87
- )
88
- })