@ledgerhq/coin-evm 5.2.1 → 5.3.2

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 (268) hide show
  1. package/.oxlintrc.json +2 -12
  2. package/CHANGELOG.md +29 -0
  3. package/lib/adapters/blockOperations.d.ts +2 -2
  4. package/lib/adapters/blockOperations.d.ts.map +1 -1
  5. package/lib/adapters/blockOperations.js.map +1 -1
  6. package/lib/api/index.d.ts +1 -1
  7. package/lib/api/index.d.ts.map +1 -1
  8. package/lib/config.d.ts +1 -1
  9. package/lib/config.d.ts.map +1 -1
  10. package/lib/logic/combine.d.ts +2 -1
  11. package/lib/logic/combine.d.ts.map +1 -1
  12. package/lib/logic/combine.js.map +1 -1
  13. package/lib/logic/common.d.ts +2 -1
  14. package/lib/logic/common.d.ts.map +1 -1
  15. package/lib/logic/common.js.map +1 -1
  16. package/lib/logic/craftTransaction.d.ts +1 -1
  17. package/lib/logic/craftTransaction.d.ts.map +1 -1
  18. package/lib/logic/craftTransaction.js.map +1 -1
  19. package/lib/logic/craftTransactionData.d.ts +1 -1
  20. package/lib/logic/craftTransactionData.d.ts.map +1 -1
  21. package/lib/logic/estimateFees.d.ts +1 -1
  22. package/lib/logic/estimateFees.d.ts.map +1 -1
  23. package/lib/logic/estimateFees.js.map +1 -1
  24. package/lib/logic/getBalance.d.ts +1 -1
  25. package/lib/logic/getBalance.d.ts.map +1 -1
  26. package/lib/logic/getBalance.js +19 -13
  27. package/lib/logic/getBalance.js.map +1 -1
  28. package/lib/logic/getBlock.d.ts +1 -1
  29. package/lib/logic/getBlock.d.ts.map +1 -1
  30. package/lib/logic/getBlock.js.map +1 -1
  31. package/lib/logic/getStakes.d.ts +2 -2
  32. package/lib/logic/getStakes.d.ts.map +1 -1
  33. package/lib/logic/getStakes.js +6 -3
  34. package/lib/logic/getStakes.js.map +1 -1
  35. package/lib/logic/internalTransactionsFetcher.d.ts +1 -1
  36. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  37. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  38. package/lib/logic/listOperations.d.ts.map +1 -1
  39. package/lib/logic/listOperations.js +3 -0
  40. package/lib/logic/listOperations.js.map +1 -1
  41. package/lib/logic/validateIntent.d.ts +1 -1
  42. package/lib/logic/validateIntent.d.ts.map +1 -1
  43. package/lib/logic/validateIntent.js.map +1 -1
  44. package/lib/logic.d.ts +1 -1
  45. package/lib/logic.d.ts.map +1 -1
  46. package/lib/network/explorer/etherscan.d.ts +4 -4
  47. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  48. package/lib/network/explorer/etherscan.js +8 -4
  49. package/lib/network/explorer/etherscan.js.map +1 -1
  50. package/lib/network/explorer/index.d.ts +2 -2
  51. package/lib/network/explorer/index.d.ts.map +1 -1
  52. package/lib/network/explorer/index.js.map +1 -1
  53. package/lib/network/explorer/ledger.d.ts +2 -2
  54. package/lib/network/explorer/ledger.d.ts.map +1 -1
  55. package/lib/network/explorer/ledger.js.map +1 -1
  56. package/lib/network/explorer/none.d.ts +1 -1
  57. package/lib/network/explorer/none.d.ts.map +1 -1
  58. package/lib/network/explorer/none.js.map +1 -1
  59. package/lib/network/explorer/types.d.ts +1 -1
  60. package/lib/network/explorer/types.d.ts.map +1 -1
  61. package/lib/network/gasTracker/index.d.ts +2 -2
  62. package/lib/network/gasTracker/index.d.ts.map +1 -1
  63. package/lib/network/gasTracker/index.js.map +1 -1
  64. package/lib/network/gasTracker/ledger.d.ts +3 -3
  65. package/lib/network/gasTracker/ledger.d.ts.map +1 -1
  66. package/lib/network/gasTracker/ledger.js.map +1 -1
  67. package/lib/network/gasTracker/types.d.ts +2 -2
  68. package/lib/network/gasTracker/types.d.ts.map +1 -1
  69. package/lib/network/node/ledger.d.ts +2 -2
  70. package/lib/network/node/ledger.d.ts.map +1 -1
  71. package/lib/network/node/ledger.js.map +1 -1
  72. package/lib/network/node/rpc.common.d.ts +1 -1
  73. package/lib/network/node/rpc.common.d.ts.map +1 -1
  74. package/lib/network/node/rpc.common.js.map +1 -1
  75. package/lib/network/node/types.d.ts +3 -3
  76. package/lib/network/node/types.d.ts.map +1 -1
  77. package/lib/staking/fetchers.d.ts.map +1 -1
  78. package/lib/staking/fetchers.js +1 -0
  79. package/lib/staking/fetchers.js.map +1 -1
  80. package/lib/staking/validators/monad.d.ts +5 -4
  81. package/lib/staking/validators/monad.d.ts.map +1 -1
  82. package/lib/staking/validators/monad.js +42 -3
  83. package/lib/staking/validators/monad.js.map +1 -1
  84. package/lib/staking/validators/monadResolver.d.ts +2 -1
  85. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  86. package/lib/staking/validators/monadResolver.js.map +1 -1
  87. package/lib/staking/validators/somnia.d.ts.map +1 -1
  88. package/lib/staking/validators/somnia.js.map +1 -1
  89. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  90. package/lib/staking/validators/zero_gravity.js.map +1 -1
  91. package/lib/types/assets.d.ts +1 -1
  92. package/lib/types/assets.d.ts.map +1 -1
  93. package/lib/types/staking.d.ts +3 -2
  94. package/lib/types/staking.d.ts.map +1 -1
  95. package/lib/types/transaction.d.ts +1 -1
  96. package/lib/types/transaction.d.ts.map +1 -1
  97. package/lib-es/adapters/blockOperations.d.ts +2 -2
  98. package/lib-es/adapters/blockOperations.d.ts.map +1 -1
  99. package/lib-es/adapters/blockOperations.js.map +1 -1
  100. package/lib-es/api/index.d.ts +1 -1
  101. package/lib-es/api/index.d.ts.map +1 -1
  102. package/lib-es/config.d.ts +1 -1
  103. package/lib-es/config.d.ts.map +1 -1
  104. package/lib-es/logic/combine.d.ts +2 -1
  105. package/lib-es/logic/combine.d.ts.map +1 -1
  106. package/lib-es/logic/combine.js.map +1 -1
  107. package/lib-es/logic/common.d.ts +2 -1
  108. package/lib-es/logic/common.d.ts.map +1 -1
  109. package/lib-es/logic/common.js +1 -1
  110. package/lib-es/logic/common.js.map +1 -1
  111. package/lib-es/logic/craftTransaction.d.ts +1 -1
  112. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  113. package/lib-es/logic/craftTransaction.js.map +1 -1
  114. package/lib-es/logic/craftTransactionData.d.ts +1 -1
  115. package/lib-es/logic/craftTransactionData.d.ts.map +1 -1
  116. package/lib-es/logic/estimateFees.d.ts +1 -1
  117. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  118. package/lib-es/logic/estimateFees.js.map +1 -1
  119. package/lib-es/logic/getBalance.d.ts +1 -1
  120. package/lib-es/logic/getBalance.d.ts.map +1 -1
  121. package/lib-es/logic/getBalance.js +19 -13
  122. package/lib-es/logic/getBalance.js.map +1 -1
  123. package/lib-es/logic/getBlock.d.ts +1 -1
  124. package/lib-es/logic/getBlock.d.ts.map +1 -1
  125. package/lib-es/logic/getBlock.js.map +1 -1
  126. package/lib-es/logic/getStakes.d.ts +2 -2
  127. package/lib-es/logic/getStakes.d.ts.map +1 -1
  128. package/lib-es/logic/getStakes.js +6 -3
  129. package/lib-es/logic/getStakes.js.map +1 -1
  130. package/lib-es/logic/internalTransactionsFetcher.d.ts +1 -1
  131. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  132. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  133. package/lib-es/logic/listOperations.d.ts.map +1 -1
  134. package/lib-es/logic/listOperations.js +3 -0
  135. package/lib-es/logic/listOperations.js.map +1 -1
  136. package/lib-es/logic/validateIntent.d.ts +1 -1
  137. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  138. package/lib-es/logic/validateIntent.js.map +1 -1
  139. package/lib-es/logic.d.ts +1 -1
  140. package/lib-es/logic.d.ts.map +1 -1
  141. package/lib-es/network/explorer/etherscan.d.ts +4 -4
  142. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  143. package/lib-es/network/explorer/etherscan.js +8 -4
  144. package/lib-es/network/explorer/etherscan.js.map +1 -1
  145. package/lib-es/network/explorer/index.d.ts +2 -2
  146. package/lib-es/network/explorer/index.d.ts.map +1 -1
  147. package/lib-es/network/explorer/index.js.map +1 -1
  148. package/lib-es/network/explorer/ledger.d.ts +2 -2
  149. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  150. package/lib-es/network/explorer/ledger.js.map +1 -1
  151. package/lib-es/network/explorer/none.d.ts +1 -1
  152. package/lib-es/network/explorer/none.d.ts.map +1 -1
  153. package/lib-es/network/explorer/none.js.map +1 -1
  154. package/lib-es/network/explorer/types.d.ts +1 -1
  155. package/lib-es/network/explorer/types.d.ts.map +1 -1
  156. package/lib-es/network/gasTracker/index.d.ts +2 -2
  157. package/lib-es/network/gasTracker/index.d.ts.map +1 -1
  158. package/lib-es/network/gasTracker/index.js.map +1 -1
  159. package/lib-es/network/gasTracker/ledger.d.ts +3 -3
  160. package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
  161. package/lib-es/network/gasTracker/ledger.js +1 -1
  162. package/lib-es/network/gasTracker/ledger.js.map +1 -1
  163. package/lib-es/network/gasTracker/types.d.ts +2 -2
  164. package/lib-es/network/gasTracker/types.d.ts.map +1 -1
  165. package/lib-es/network/node/ledger.d.ts +2 -2
  166. package/lib-es/network/node/ledger.d.ts.map +1 -1
  167. package/lib-es/network/node/ledger.js.map +1 -1
  168. package/lib-es/network/node/rpc.common.d.ts +1 -1
  169. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  170. package/lib-es/network/node/rpc.common.js +1 -1
  171. package/lib-es/network/node/rpc.common.js.map +1 -1
  172. package/lib-es/network/node/types.d.ts +3 -3
  173. package/lib-es/network/node/types.d.ts.map +1 -1
  174. package/lib-es/staking/fetchers.d.ts.map +1 -1
  175. package/lib-es/staking/fetchers.js +2 -1
  176. package/lib-es/staking/fetchers.js.map +1 -1
  177. package/lib-es/staking/validators/monad.d.ts +5 -4
  178. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  179. package/lib-es/staking/validators/monad.js +40 -2
  180. package/lib-es/staking/validators/monad.js.map +1 -1
  181. package/lib-es/staking/validators/monadResolver.d.ts +2 -1
  182. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  183. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  184. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  185. package/lib-es/staking/validators/somnia.js.map +1 -1
  186. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  187. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  188. package/lib-es/types/assets.d.ts +1 -1
  189. package/lib-es/types/assets.d.ts.map +1 -1
  190. package/lib-es/types/staking.d.ts +3 -2
  191. package/lib-es/types/staking.d.ts.map +1 -1
  192. package/lib-es/types/transaction.d.ts +1 -1
  193. package/lib-es/types/transaction.d.ts.map +1 -1
  194. package/package.json +2 -2
  195. package/src/adapters/blockOperations.test.ts +2 -2
  196. package/src/adapters/blockOperations.ts +3 -2
  197. package/src/adapters/etherscan.test.ts +7 -7
  198. package/src/adapters/ledger.test.ts +2 -2
  199. package/src/api/getBlock.integ.test.ts +1 -1
  200. package/src/api/index.fantom.integ.test.ts +1 -1
  201. package/src/api/index.flare.integ.test.ts +1 -1
  202. package/src/api/index.integ.test.ts +265 -153
  203. package/src/api/index.linea.integ.test.ts +1 -1
  204. package/src/api/index.optimism.integ.test.ts +1 -1
  205. package/src/api/index.shape.integ.test.ts +1 -1
  206. package/src/api/index.ts +1 -1
  207. package/src/config.ts +1 -1
  208. package/src/fixtures/ledger.fixtures.ts +1 -1
  209. package/src/internalTxSources.test.ts +3 -6
  210. package/src/logic/combine.test.ts +2 -2
  211. package/src/logic/combine.ts +2 -1
  212. package/src/logic/common.test.ts +3 -3
  213. package/src/logic/common.ts +2 -7
  214. package/src/logic/craftTransaction.test.ts +4 -3
  215. package/src/logic/craftTransaction.ts +3 -2
  216. package/src/logic/craftTransactionData.test.ts +1 -1
  217. package/src/logic/craftTransactionData.ts +1 -1
  218. package/src/logic/estimateFees.ts +6 -3
  219. package/src/logic/getBalance.test.ts +1 -1
  220. package/src/logic/getBalance.ts +30 -24
  221. package/src/logic/getBlock.test.ts +8 -7
  222. package/src/logic/getBlock.ts +3 -2
  223. package/src/logic/getBlockInfo.test.ts +1 -3
  224. package/src/logic/getStakes.test.ts +2 -2
  225. package/src/logic/getStakes.ts +15 -6
  226. package/src/logic/internalTransactionsFetcher.test.ts +4 -6
  227. package/src/logic/internalTransactionsFetcher.ts +1 -1
  228. package/src/logic/lastBlock.test.ts +2 -1
  229. package/src/logic/listOperations.test.ts +75 -2
  230. package/src/logic/listOperations.ts +3 -0
  231. package/src/logic/validateIntent.test.ts +2 -1
  232. package/src/logic/validateIntent.ts +4 -2
  233. package/src/logic.ts +1 -1
  234. package/src/network/explorer/etherscan.test.ts +36 -1
  235. package/src/network/explorer/etherscan.ts +20 -14
  236. package/src/network/explorer/index.test.ts +1 -1
  237. package/src/network/explorer/index.ts +2 -2
  238. package/src/network/explorer/ledger.test.ts +2 -1
  239. package/src/network/explorer/ledger.ts +3 -2
  240. package/src/network/explorer/none.ts +2 -1
  241. package/src/network/explorer/types.ts +1 -1
  242. package/src/network/gasTracker/index.test.ts +1 -1
  243. package/src/network/gasTracker/index.ts +2 -2
  244. package/src/network/gasTracker/ledger.test.ts +10 -17
  245. package/src/network/gasTracker/ledger.ts +5 -7
  246. package/src/network/gasTracker/types.ts +2 -2
  247. package/src/network/node/index.memoization.test.ts +1 -1
  248. package/src/network/node/ledger.ts +6 -5
  249. package/src/network/node/rpc.common.ts +14 -14
  250. package/src/network/node/rpc.test.ts +4 -10
  251. package/src/network/node/types.ts +3 -3
  252. package/src/staking/detectOperationType.test.ts +1 -1
  253. package/src/staking/encoder.test.ts +1 -1
  254. package/src/staking/fetchers.ts +2 -1
  255. package/src/staking/operations/index.test.ts +1 -1
  256. package/src/staking/redelegations.test.ts +23 -15
  257. package/src/staking/rewards.test.ts +6 -2
  258. package/src/staking/rewardsFromReceipt.test.ts +1 -1
  259. package/src/staking/transactionData.test.ts +2 -2
  260. package/src/staking/validators/monad.test.ts +102 -1
  261. package/src/staking/validators/monad.ts +58 -5
  262. package/src/staking/validators/monadResolver.ts +2 -1
  263. package/src/staking/validators/somnia.ts +2 -1
  264. package/src/staking/validators/zero_gravity.ts +2 -1
  265. package/src/staking/validators.test.ts +7 -2
  266. package/src/types/assets.ts +1 -1
  267. package/src/types/staking.ts +4 -2
  268. package/src/types/transaction.ts +1 -1
@@ -1,15 +1,14 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import {
4
+ import type { EvmConfig, EvmConfigInfo } from '../config'
5
+ import type {
5
6
  BufferTxData,
6
- FeeEstimation,
7
7
  MemoNotSupported,
8
8
  Operation,
9
9
  StakingTransactionIntent,
10
10
  } from '@ledgerhq/coin-module-framework/api/types'
11
11
  import { ethers } from 'ethers'
12
- import { EvmConfig, EvmConfigInfo } from '../config'
13
12
  import { createMockEvmContext } from '../fixtures/context.fixtures'
14
13
  import { createApi } from './index'
15
14
 
@@ -190,38 +189,16 @@ describe.each([
190
189
  })
191
190
  })
192
191
 
193
- describe.each([
194
- [
195
- 'legacy',
196
- (transaction: ethers.Transaction): void => {
197
- expect(transaction.type).toBe(0)
198
- expect(typeof transaction.gasPrice).toBe('bigint')
199
- expect(transaction.gasPrice).toBeGreaterThan(0)
200
- },
201
- ],
202
- [
203
- 'eip1559',
204
- (transaction: ethers.Transaction): void => {
205
- expect(transaction.type).toBe(2)
206
- expect(transaction.gasPrice).toBeNull()
207
- expect(typeof transaction.maxFeePerGas).toBe('bigint')
208
- expect(typeof transaction.maxPriorityFeePerGas).toBe('bigint')
209
- expect(transaction.maxFeePerGas).toBeGreaterThan(0n)
210
- expect(transaction.maxPriorityFeePerGas).toBeGreaterThan(0n)
211
- },
212
- ],
213
- ])('craftTransaction', (mode, expectTransactionForMode) => {
214
- it('crafts a transaction with the native asset', async () => {
192
+ describe('craftTransaction', () => {
193
+ it('crafts a legacy transaction with the native asset', async () => {
215
194
  const { transaction: result } = await module.craftTransaction(context, {
216
- type: `send-${mode}`,
195
+ type: 'send-legacy',
217
196
  intentType: 'transaction',
218
197
  amount: 10n,
219
198
  sender: '0x9bcd841436ef4f85dacefb1aec772af71619024e',
220
199
  recipient: '0x7b2c7232f9e38f30e2868f0e5bf311cd83554b5a',
221
200
  data: { type: 'buffer', value: Buffer.from([]) },
222
- asset: {
223
- type: 'native',
224
- },
201
+ asset: { type: 'native' },
225
202
  })
226
203
 
227
204
  expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
@@ -229,14 +206,42 @@ describe.each([
229
206
  value: 10n,
230
207
  to: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
231
208
  })
232
- expectTransactionForMode(ethers.Transaction.from(result))
209
+ const tx = ethers.Transaction.from(result)
210
+ expect(tx.type).toBe(0)
211
+ expect(typeof tx.gasPrice).toBe('bigint')
212
+ expect(tx.gasPrice).toBeGreaterThan(0)
233
213
  })
234
214
 
235
- it('crafts a transaction with the USDC asset', async () => {
215
+ it('crafts an eip1559 transaction with the native asset', async () => {
216
+ const { transaction: result } = await module.craftTransaction(context, {
217
+ type: 'send-eip1559',
218
+ intentType: 'transaction',
219
+ amount: 10n,
220
+ sender: '0x9bcd841436ef4f85dacefb1aec772af71619024e',
221
+ recipient: '0x7b2c7232f9e38f30e2868f0e5bf311cd83554b5a',
222
+ data: { type: 'buffer', value: Buffer.from([]) },
223
+ asset: { type: 'native' },
224
+ })
225
+
226
+ expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
227
+ expect(ethers.Transaction.from(result)).toMatchObject({
228
+ value: 10n,
229
+ to: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
230
+ })
231
+ const tx = ethers.Transaction.from(result)
232
+ expect(tx.type).toBe(2)
233
+ expect(tx.gasPrice).toBeNull()
234
+ expect(typeof tx.maxFeePerGas).toBe('bigint')
235
+ expect(typeof tx.maxPriorityFeePerGas).toBe('bigint')
236
+ expect(tx.maxFeePerGas).toBeGreaterThan(0n)
237
+ expect(tx.maxPriorityFeePerGas).toBeGreaterThan(0n)
238
+ })
239
+
240
+ it('crafts a legacy transaction with the USDC asset', async () => {
236
241
  const { transaction: result } = await module.craftTransaction(
237
242
  context,
238
243
  {
239
- type: `send-${mode}`,
244
+ type: 'send-legacy',
240
245
  intentType: 'transaction',
241
246
  amount: 10n,
242
247
  sender: '0x9bcd841436ef4f85dacefb1aec772af71619024e',
@@ -257,7 +262,44 @@ describe.each([
257
262
  value: 0n,
258
263
  to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
259
264
  })
260
- expectTransactionForMode(ethers.Transaction.from(result))
265
+ const tx = ethers.Transaction.from(result)
266
+ expect(tx.type).toBe(0)
267
+ expect(typeof tx.gasPrice).toBe('bigint')
268
+ expect(tx.gasPrice).toBeGreaterThan(0)
269
+ })
270
+
271
+ it('crafts an eip1559 transaction with the USDC asset', async () => {
272
+ const { transaction: result } = await module.craftTransaction(
273
+ context,
274
+ {
275
+ type: 'send-eip1559',
276
+ intentType: 'transaction',
277
+ amount: 10n,
278
+ sender: '0x9bcd841436ef4f85dacefb1aec772af71619024e',
279
+ recipient: '0x7b2c7232f9e38f30e2868f0e5bf311cd83554b5a',
280
+ data: { type: 'buffer', value: Buffer.from([]) },
281
+ asset: {
282
+ type: 'erc20',
283
+ assetReference: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
284
+ },
285
+ },
286
+ // The sender holds no USDC, so estimating this transfer reverts on-chain. Pin the gas
287
+ // limit so the test covers the crafted payload rather than a live token balance.
288
+ { customFees: { value: 0n, parameters: { gasLimit: 60000n } } }
289
+ )
290
+
291
+ expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
292
+ expect(ethers.Transaction.from(result)).toMatchObject({
293
+ value: 0n,
294
+ to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
295
+ })
296
+ const tx = ethers.Transaction.from(result)
297
+ expect(tx.type).toBe(2)
298
+ expect(tx.gasPrice).toBeNull()
299
+ expect(typeof tx.maxFeePerGas).toBe('bigint')
300
+ expect(typeof tx.maxPriorityFeePerGas).toBe('bigint')
301
+ expect(tx.maxFeePerGas).toBeGreaterThan(0n)
302
+ expect(tx.maxPriorityFeePerGas).toBeGreaterThan(0n)
261
303
  })
262
304
  })
263
305
 
@@ -372,7 +414,7 @@ describe.each([
372
414
  expect(op.tx.fees).toBeGreaterThanOrEqual(0n) // fees not available for all internal transactions
373
415
  expect(op.tx.date).toBeInstanceOf(Date)
374
416
  })
375
- expect(isCorrectlyOrdered(result))
417
+ expect(isCorrectlyOrdered(result)).toBe(true)
376
418
  }
377
419
  )
378
420
 
@@ -397,6 +439,7 @@ describe.each([
397
439
  // TODO implement pagination for ledger explorer
398
440
  // Pagination tests only make sense for etherscan-like explorers that support real pagination.
399
441
  // Ledger explorer fetches all data in one call looping over all the pages and returns NO_TOKEN.
442
+ // oxlint-disable jest/no-standalone-expect -- ternary test runner not recognized by static analysis
400
443
  ;(isEtherscanLike ? it.each : it.skip.each)([
401
444
  // note that the ASC mode is really slow
402
445
  ['ascending', 'asc'],
@@ -523,6 +566,7 @@ describe.each([
523
566
  expect(hasOverlap).toBe(false)
524
567
  }
525
568
  })
569
+ // oxlint-enable jest/no-standalone-expect
526
570
  })
527
571
 
528
572
  describe('transactions non-regression', () => {
@@ -715,65 +759,93 @@ describe.each([
715
759
  })
716
760
  })
717
761
 
718
- describe.each([
719
- [
720
- 'legacy',
721
- (estimation: FeeEstimation): void => {
722
- expect(estimation).toEqual({
723
- value: expect.any(BigInt),
724
- parameters: {
725
- gasPrice: expect.any(BigInt),
726
- gasLimit: expect.any(BigInt),
727
- maxFeePerGas: null,
728
- maxPriorityFeePerGas: null,
729
- nextBaseFee: null,
730
- type: 0,
731
- },
732
- })
733
- expect(estimation.value).toBeGreaterThan(0)
734
- expect(estimation.parameters?.gasPrice).toBeGreaterThan(0)
735
- },
736
- ],
737
- [
738
- 'eip1559',
739
- (estimation: FeeEstimation): void => {
740
- expect(estimation).toEqual({
741
- value: expect.any(BigInt),
742
- parameters: {
743
- gasPrice: null,
744
- gasLimit: expect.any(BigInt),
745
- maxFeePerGas: expect.any(BigInt),
746
- maxPriorityFeePerGas: expect.any(BigInt),
747
- nextBaseFee: expect.any(BigInt),
748
- type: 2,
749
- },
750
- })
751
- expect(estimation.value).toBeGreaterThan(0)
752
- expect(estimation.parameters?.maxFeePerGas).toBeGreaterThan(0)
753
- expect(estimation.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
754
- expect(estimation.parameters?.nextBaseFee).toBeGreaterThan(0)
755
- },
756
- ],
757
- ])('estimateFees for %s transaction', (mode, expectEstimationForMode) => {
758
- it('estimates fees for native asset transfer', async () => {
762
+ describe('estimateFees', () => {
763
+ it('estimates fees for legacy native asset transfer', async () => {
764
+ const result = await module.estimateFees(context, {
765
+ type: 'send-legacy',
766
+ intentType: 'transaction',
767
+ amount: 100000000000000n, // 0.0001 ETH (smaller amount)
768
+ sender: '0xDb3812cD8d20F27888677dDC97dF1241850f8c48',
769
+ recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
770
+ data: { type: 'buffer', value: Buffer.from([]) },
771
+ asset: { type: 'native' },
772
+ })
773
+
774
+ expect(result).toEqual({
775
+ value: expect.any(BigInt),
776
+ parameters: {
777
+ gasPrice: expect.any(BigInt),
778
+ gasLimit: expect.any(BigInt),
779
+ maxFeePerGas: null,
780
+ maxPriorityFeePerGas: null,
781
+ nextBaseFee: null,
782
+ type: 0,
783
+ },
784
+ })
785
+ expect(result.value).toBeGreaterThan(0)
786
+ expect(result.parameters?.gasPrice).toBeGreaterThan(0)
787
+ })
788
+
789
+ it('estimates fees for eip1559 native asset transfer', async () => {
759
790
  const result = await module.estimateFees(context, {
760
- type: `send-${mode}`,
791
+ type: 'send-eip1559',
761
792
  intentType: 'transaction',
762
793
  amount: 100000000000000n, // 0.0001 ETH (smaller amount)
763
794
  sender: '0xDb3812cD8d20F27888677dDC97dF1241850f8c48',
764
795
  recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
765
796
  data: { type: 'buffer', value: Buffer.from([]) },
797
+ asset: { type: 'native' },
798
+ })
799
+
800
+ expect(result).toEqual({
801
+ value: expect.any(BigInt),
802
+ parameters: {
803
+ gasPrice: null,
804
+ gasLimit: expect.any(BigInt),
805
+ maxFeePerGas: expect.any(BigInt),
806
+ maxPriorityFeePerGas: expect.any(BigInt),
807
+ nextBaseFee: expect.any(BigInt),
808
+ type: 2,
809
+ },
810
+ })
811
+ expect(result.value).toBeGreaterThan(0)
812
+ expect(result.parameters?.maxFeePerGas).toBeGreaterThan(0)
813
+ expect(result.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
814
+ expect(result.parameters?.nextBaseFee).toBeGreaterThan(0)
815
+ })
816
+
817
+ it('estimates fees for legacy USDC token transfer', async () => {
818
+ const result = await module.estimateFees(context, {
819
+ type: 'send-legacy',
820
+ intentType: 'transaction',
821
+ amount: 1000000n, // 1 USDC (6 decimals)
822
+ sender: '0xDb3812cD8d20F27888677dDC97dF1241850f8c48',
823
+ recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
824
+ data: { type: 'buffer', value: Buffer.from([]) },
766
825
  asset: {
767
- type: 'native',
826
+ type: 'erc20',
827
+ assetReference: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
768
828
  },
769
829
  })
770
830
 
771
- expectEstimationForMode(result)
831
+ expect(result).toEqual({
832
+ value: expect.any(BigInt),
833
+ parameters: {
834
+ gasPrice: expect.any(BigInt),
835
+ gasLimit: expect.any(BigInt),
836
+ maxFeePerGas: null,
837
+ maxPriorityFeePerGas: null,
838
+ nextBaseFee: null,
839
+ type: 0,
840
+ },
841
+ })
842
+ expect(result.value).toBeGreaterThan(0)
843
+ expect(result.parameters?.gasPrice).toBeGreaterThan(0)
772
844
  })
773
845
 
774
- it('estimates fees for USDC token transfer', async () => {
846
+ it('estimates fees for eip1559 USDC token transfer', async () => {
775
847
  const result = await module.estimateFees(context, {
776
- type: `send-${mode}`,
848
+ type: 'send-eip1559',
777
849
  intentType: 'transaction',
778
850
  amount: 1000000n, // 1 USDC (6 decimals)
779
851
  sender: '0xDb3812cD8d20F27888677dDC97dF1241850f8c48',
@@ -785,7 +857,21 @@ describe.each([
785
857
  },
786
858
  })
787
859
 
788
- expectEstimationForMode(result)
860
+ expect(result).toEqual({
861
+ value: expect.any(BigInt),
862
+ parameters: {
863
+ gasPrice: null,
864
+ gasLimit: expect.any(BigInt),
865
+ maxFeePerGas: expect.any(BigInt),
866
+ maxPriorityFeePerGas: expect.any(BigInt),
867
+ nextBaseFee: expect.any(BigInt),
868
+ type: 2,
869
+ },
870
+ })
871
+ expect(result.value).toBeGreaterThan(0)
872
+ expect(result.parameters?.maxFeePerGas).toBeGreaterThan(0)
873
+ expect(result.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
874
+ expect(result.parameters?.nextBaseFee).toBeGreaterThan(0)
789
875
  })
790
876
  })
791
877
  })
@@ -946,30 +1032,10 @@ describe('EVM Api (SEI Network)', () => {
946
1032
  module = createApi('sei_evm')
947
1033
  })
948
1034
 
949
- describe.each([
950
- [
951
- 'legacy',
952
- (transaction: ethers.Transaction): void => {
953
- expect(transaction.type).toBe(0)
954
- expect(typeof transaction.gasPrice).toBe('bigint')
955
- expect(transaction.gasPrice).toBeGreaterThan(0)
956
- },
957
- ],
958
- [
959
- 'eip1559',
960
- (transaction: ethers.Transaction): void => {
961
- expect(transaction.type).toBe(2)
962
- expect(transaction.gasPrice).toBeNull()
963
- expect(typeof transaction.maxFeePerGas).toBe('bigint')
964
- expect(typeof transaction.maxPriorityFeePerGas).toBe('bigint')
965
- expect(transaction.maxFeePerGas).toBeGreaterThan(0n)
966
- expect(transaction.maxPriorityFeePerGas).toBeGreaterThan(0n)
967
- },
968
- ],
969
- ])('craftTransaction', (mode, expectTransactionForMode) => {
970
- it('crafts a delegate transaction', async () => {
1035
+ describe('craftTransaction', () => {
1036
+ it('crafts a legacy delegate transaction', async () => {
971
1037
  const { transaction: result } = await module.craftTransaction(context, {
972
- type: `staking-${mode}`,
1038
+ type: 'staking-legacy',
973
1039
  intentType: 'staking' as const,
974
1040
  amount: seiStakingDelegationAmount,
975
1041
  mode: 'delegate',
@@ -977,9 +1043,31 @@ describe('EVM Api (SEI Network)', () => {
977
1043
  recipient: seiStakingRecipient,
978
1044
  valAddress: 'seivaloper1ummny4p645xraxc4m7nphf7vxawfzt3p5hn47t',
979
1045
  data: { type: 'buffer', value: Buffer.from([]) },
980
- asset: {
981
- type: 'native',
982
- },
1046
+ asset: { type: 'native' },
1047
+ } as StakingTransactionIntent<MemoNotSupported, BufferTxData>)
1048
+
1049
+ expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
1050
+ expect(ethers.Transaction.from(result)).toMatchObject({
1051
+ value: seiStakingDelegationAmount,
1052
+ to: seiStakingRecipient,
1053
+ })
1054
+ const tx = ethers.Transaction.from(result)
1055
+ expect(tx.type).toBe(0)
1056
+ expect(typeof tx.gasPrice).toBe('bigint')
1057
+ expect(tx.gasPrice).toBeGreaterThan(0)
1058
+ })
1059
+
1060
+ it('crafts an eip1559 delegate transaction', async () => {
1061
+ const { transaction: result } = await module.craftTransaction(context, {
1062
+ type: 'staking-eip1559',
1063
+ intentType: 'staking' as const,
1064
+ amount: seiStakingDelegationAmount,
1065
+ mode: 'delegate',
1066
+ sender: seiStakingSender,
1067
+ recipient: seiStakingRecipient,
1068
+ valAddress: 'seivaloper1ummny4p645xraxc4m7nphf7vxawfzt3p5hn47t',
1069
+ data: { type: 'buffer', value: Buffer.from([]) },
1070
+ asset: { type: 'native' },
983
1071
  } as StakingTransactionIntent<MemoNotSupported, BufferTxData>)
984
1072
 
985
1073
  expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
@@ -987,53 +1075,20 @@ describe('EVM Api (SEI Network)', () => {
987
1075
  value: seiStakingDelegationAmount,
988
1076
  to: seiStakingRecipient,
989
1077
  })
990
- expectTransactionForMode(ethers.Transaction.from(result))
1078
+ const tx = ethers.Transaction.from(result)
1079
+ expect(tx.type).toBe(2)
1080
+ expect(tx.gasPrice).toBeNull()
1081
+ expect(typeof tx.maxFeePerGas).toBe('bigint')
1082
+ expect(typeof tx.maxPriorityFeePerGas).toBe('bigint')
1083
+ expect(tx.maxFeePerGas).toBeGreaterThan(0n)
1084
+ expect(tx.maxPriorityFeePerGas).toBeGreaterThan(0n)
991
1085
  })
992
1086
  })
993
1087
 
994
- describe.each([
995
- [
996
- 'legacy',
997
- (estimation: FeeEstimation): void => {
998
- expect(estimation).toEqual({
999
- value: expect.any(BigInt),
1000
- parameters: {
1001
- gasPrice: expect.any(BigInt),
1002
- gasLimit: expect.any(BigInt),
1003
- maxFeePerGas: null,
1004
- maxPriorityFeePerGas: null,
1005
- nextBaseFee: null,
1006
- type: 0,
1007
- },
1008
- })
1009
- expect(estimation.value).toBeGreaterThan(0)
1010
- expect(estimation.parameters?.gasPrice).toBeGreaterThan(0)
1011
- },
1012
- ],
1013
- [
1014
- 'eip1559',
1015
- (estimation: FeeEstimation): void => {
1016
- expect(estimation).toEqual({
1017
- value: expect.any(BigInt),
1018
- parameters: {
1019
- gasPrice: null,
1020
- gasLimit: expect.any(BigInt),
1021
- maxFeePerGas: expect.any(BigInt),
1022
- maxPriorityFeePerGas: expect.any(BigInt),
1023
- nextBaseFee: expect.any(BigInt),
1024
- type: 2,
1025
- },
1026
- })
1027
- expect(estimation.value).toBeGreaterThan(0)
1028
- expect(estimation.parameters?.maxFeePerGas).toBeGreaterThan(0)
1029
- expect(estimation.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
1030
- expect(estimation.parameters?.nextBaseFee).toBeGreaterThan(0)
1031
- },
1032
- ],
1033
- ])('estimateFees for %s transaction', (mode, expectEstimationForMode) => {
1034
- it('estimates fees for staking delegation', async () => {
1088
+ describe('estimateFees', () => {
1089
+ it('estimates fees for legacy staking delegation', async () => {
1035
1090
  const result = await module.estimateFees(context, {
1036
- type: `staking-${mode}`,
1091
+ type: 'staking-legacy',
1037
1092
  intentType: 'staking' as const,
1038
1093
  amount: seiStakingDelegationAmount,
1039
1094
  mode: 'delegate',
@@ -1041,12 +1096,52 @@ describe('EVM Api (SEI Network)', () => {
1041
1096
  recipient: seiStakingRecipient,
1042
1097
  valAddress: 'seivaloper1ummny4p645xraxc4m7nphf7vxawfzt3p5hn47t',
1043
1098
  data: { type: 'buffer', value: Buffer.from([]) },
1044
- asset: {
1045
- type: 'native',
1099
+ asset: { type: 'native' },
1100
+ } as StakingTransactionIntent<MemoNotSupported, BufferTxData>)
1101
+
1102
+ expect(result).toEqual({
1103
+ value: expect.any(BigInt),
1104
+ parameters: {
1105
+ gasPrice: expect.any(BigInt),
1106
+ gasLimit: expect.any(BigInt),
1107
+ maxFeePerGas: null,
1108
+ maxPriorityFeePerGas: null,
1109
+ nextBaseFee: null,
1110
+ type: 0,
1046
1111
  },
1112
+ })
1113
+ expect(result.value).toBeGreaterThan(0)
1114
+ expect(result.parameters?.gasPrice).toBeGreaterThan(0)
1115
+ })
1116
+
1117
+ it('estimates fees for eip1559 staking delegation', async () => {
1118
+ const result = await module.estimateFees(context, {
1119
+ type: 'staking-eip1559',
1120
+ intentType: 'staking' as const,
1121
+ amount: seiStakingDelegationAmount,
1122
+ mode: 'delegate',
1123
+ sender: seiStakingSender,
1124
+ recipient: seiStakingRecipient,
1125
+ valAddress: 'seivaloper1ummny4p645xraxc4m7nphf7vxawfzt3p5hn47t',
1126
+ data: { type: 'buffer', value: Buffer.from([]) },
1127
+ asset: { type: 'native' },
1047
1128
  } as StakingTransactionIntent<MemoNotSupported, BufferTxData>)
1048
1129
 
1049
- expectEstimationForMode(result)
1130
+ expect(result).toEqual({
1131
+ value: expect.any(BigInt),
1132
+ parameters: {
1133
+ gasPrice: null,
1134
+ gasLimit: expect.any(BigInt),
1135
+ maxFeePerGas: expect.any(BigInt),
1136
+ maxPriorityFeePerGas: expect.any(BigInt),
1137
+ nextBaseFee: expect.any(BigInt),
1138
+ type: 2,
1139
+ },
1140
+ })
1141
+ expect(result.value).toBeGreaterThan(0)
1142
+ expect(result.parameters?.maxFeePerGas).toBeGreaterThan(0)
1143
+ expect(result.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
1144
+ expect(result.parameters?.nextBaseFee).toBeGreaterThan(0)
1050
1145
  })
1051
1146
  })
1052
1147
  })
@@ -1137,5 +1232,22 @@ describe('EVM Api (Zero Gravity)', () => {
1137
1232
  expect(blockTime).toBeGreaterThan(cutoff)
1138
1233
  })
1139
1234
  }, 60000)
1235
+
1236
+ it('fills ERC20 tx.block.hash from the parent txlist row when tokentx omits it', async () => {
1237
+ // Regression: chainscan.0g.ai tokentx has no blockHash. Native txlist does, so token
1238
+ // ops must inherit it. Account 0x66c4371a… has ERC20 transfers that used to miss the hash.
1239
+ const address = '0x66c4371ae8ffed2ec1c2ebbbccfb7e494181e1e3'
1240
+ const result = await module.listOperations(context, address, {
1241
+ minHeight: 0,
1242
+ order: 'asc',
1243
+ limit: 256,
1244
+ })
1245
+
1246
+ const erc20Ops = result.items.filter((op) => op.asset.type === 'erc20')
1247
+ expect(erc20Ops.length).toBeGreaterThan(0)
1248
+ result.items.forEach((op) => {
1249
+ expect(op.tx.block.hash).toMatch(/^0x[A-Fa-f0-9]{64}$/)
1250
+ })
1251
+ }, 60000)
1140
1252
  })
1141
1253
  })
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { EvmConfig } from '../config'
4
+ import type { EvmConfig } from '../config'
5
5
  import { createMockEvmContext } from '../fixtures/context.fixtures'
6
6
  import { createApi } from './index'
7
7
 
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { EvmConfigInfo } from '../config'
5
- import { Operation } from '@ledgerhq/coin-module-framework/api/types'
5
+ import type { Operation } from '@ledgerhq/coin-module-framework/api/types'
6
6
  import { createMockEvmContext } from '../fixtures/context.fixtures'
7
7
  import { createApi } from './index'
8
8
 
@@ -1,8 +1,8 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { EvmConfig } from '../config'
4
5
  import { fail } from 'assert'
5
- import { EvmConfig } from '../config'
6
6
  import { createMockEvmContext } from '../fixtures/context.fixtures'
7
7
  import { createApi } from './index'
8
8
 
package/src/api/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { EvmConfigInfo, EvmContext } from '../config'
4
5
  import type { EvmCallParams } from '../network/node/types'
5
6
  import type {
6
7
  CoinModuleImpl,
@@ -22,7 +23,6 @@ import type {
22
23
  Validator,
23
24
  BalanceOptions,
24
25
  } from '@ledgerhq/coin-module-framework/api/index'
25
- import { type EvmConfigInfo, type EvmContext } from '../config'
26
26
  import { craftTransactionData } from '../logic/craftTransactionData'
27
27
  import {
28
28
  broadcast,
package/src/config.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { InternalTxSourceList } from './internalTxSources'
5
- import { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
5
+ import type { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
6
6
  import { log } from '@ledgerhq/logs'
7
7
 
8
8
  export type { InternalTxSource, InternalTxSourceList, NonEmptySource } from './internalTxSources'
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { LedgerExplorerOperation } from '../types'
4
+ import type { LedgerExplorerOperation } from '../types'
5
5
 
6
6
  export const coinOperation1: LedgerExplorerOperation = {
7
7
  hash: '0xf350d4f8e910419e2d5cec294d44e69af8c6185b7089061d33bb4fc246cefb79',
@@ -1,11 +1,8 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import {
5
- DEFAULT_INTERNAL_TX_SOURCES,
6
- internalTxSourcesFromList,
7
- type InternalTxSourceList,
8
- } from './internalTxSources'
4
+ import type { InternalTxSourceList } from './internalTxSources'
5
+ import { DEFAULT_INTERNAL_TX_SOURCES, internalTxSourcesFromList } from './internalTxSources'
9
6
 
10
7
  describe('internalTxSourcesFromList', () => {
11
8
  it('builds the default explorer-first strategy', () => {
@@ -73,7 +70,7 @@ describe('internalTxSourcesFromList', () => {
73
70
  const raw = ['explorer', 'empty'] as const
74
71
  // @ts-expect-error - InternalTxSourceList is branded; only internalTxSourcesFromList can produce it
75
72
  const sources: InternalTxSourceList = raw
76
- void sources
73
+ expect(sources).toEqual(raw)
77
74
  })
78
75
  })
79
76
  })
@@ -136,7 +136,7 @@ describe('combine', () => {
136
136
  const serializedUnsignedTx = ethers.Transaction.from(unsignedTx).unsignedSerialized
137
137
 
138
138
  expect(() => {
139
- combine(serializedUnsignedTx, '0x1234')
140
- }).toThrow()
139
+ combine(serializedUnsignedTx, [])
140
+ }).toThrow('EVM combine expects exactly one signature')
141
141
  })
142
142
  })
@@ -1,7 +1,8 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { Signature, type SignatureLike, Transaction } from 'ethers'
4
+ import type { SignatureLike } from 'ethers'
5
+ import { Signature, Transaction } from 'ethers'
5
6
 
6
7
  function prefixHexString(hex: string): string {
7
8
  return hex.startsWith('0x') ? hex : '0x' + hex