@ledgerhq/coin-evm 15.0.0 → 16.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 (258) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/lib/adapters/etherscan.d.ts.map +1 -1
  3. package/lib/adapters/etherscan.js +14 -0
  4. package/lib/adapters/etherscan.js.map +1 -1
  5. package/lib/adapters/ledger.d.ts.map +1 -1
  6. package/lib/adapters/ledger.js +2 -0
  7. package/lib/adapters/ledger.js.map +1 -1
  8. package/lib/api/index.d.ts +1 -1
  9. package/lib/api/index.d.ts.map +1 -1
  10. package/lib/api/index.js +14 -15
  11. package/lib/api/index.js.map +1 -1
  12. package/lib/chains.d.ts +7 -0
  13. package/lib/chains.d.ts.map +1 -1
  14. package/lib/chains.js +17 -1
  15. package/lib/chains.js.map +1 -1
  16. package/lib/config.d.ts +1 -1
  17. package/lib/config.d.ts.map +1 -1
  18. package/lib/config.js +2 -1
  19. package/lib/config.js.map +1 -1
  20. package/lib/errors.d.ts +11 -0
  21. package/lib/errors.d.ts.map +1 -1
  22. package/lib/errors.js +17 -1
  23. package/lib/errors.js.map +1 -1
  24. package/lib/logic/broadcast.d.ts +1 -1
  25. package/lib/logic/broadcast.d.ts.map +1 -1
  26. package/lib/logic/broadcast.js +2 -2
  27. package/lib/logic/broadcast.js.map +1 -1
  28. package/lib/logic/craftTransaction.d.ts +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 +1 -1
  33. package/lib/logic/estimateFees.d.ts.map +1 -1
  34. package/lib/logic/estimateFees.js +19 -4
  35. package/lib/logic/estimateFees.js.map +1 -1
  36. package/lib/logic/getBalance.d.ts +1 -2
  37. package/lib/logic/getBalance.d.ts.map +1 -1
  38. package/lib/logic/getBalance.js +5 -6
  39. package/lib/logic/getBalance.js.map +1 -1
  40. package/lib/logic/getBlock.d.ts +1 -1
  41. package/lib/logic/getBlock.d.ts.map +1 -1
  42. package/lib/logic/getBlock.js +23 -6
  43. package/lib/logic/getBlock.js.map +1 -1
  44. package/lib/logic/getBlockInfo.d.ts +1 -1
  45. package/lib/logic/getBlockInfo.d.ts.map +1 -1
  46. package/lib/logic/getBlockInfo.js +2 -2
  47. package/lib/logic/getBlockInfo.js.map +1 -1
  48. package/lib/logic/getNextSequence.d.ts +1 -1
  49. package/lib/logic/getNextSequence.d.ts.map +1 -1
  50. package/lib/logic/getNextSequence.js +2 -2
  51. package/lib/logic/getNextSequence.js.map +1 -1
  52. package/lib/logic/getStakes.d.ts +1 -1
  53. package/lib/logic/getStakes.d.ts.map +1 -1
  54. package/lib/logic/getStakes.js +2 -2
  55. package/lib/logic/getStakes.js.map +1 -1
  56. package/lib/logic/lastBlock.d.ts +1 -1
  57. package/lib/logic/lastBlock.d.ts.map +1 -1
  58. package/lib/logic/lastBlock.js +2 -2
  59. package/lib/logic/lastBlock.js.map +1 -1
  60. package/lib/logic/listOperations.d.ts +1 -1
  61. package/lib/logic/listOperations.d.ts.map +1 -1
  62. package/lib/logic/listOperations.js +4 -2
  63. package/lib/logic/listOperations.js.map +1 -1
  64. package/lib/logic/validateIntent.d.ts +1 -1
  65. package/lib/logic/validateIntent.d.ts.map +1 -1
  66. package/lib/logic/validateIntent.js +3 -3
  67. package/lib/logic/validateIntent.js.map +1 -1
  68. package/lib/logic.d.ts.map +1 -1
  69. package/lib/logic.js +5 -10
  70. package/lib/logic.js.map +1 -1
  71. package/lib/network/node/explorerProxy.d.ts.map +1 -1
  72. package/lib/network/node/explorerProxy.js +2 -0
  73. package/lib/network/node/explorerProxy.js.map +1 -1
  74. package/lib/network/node/ledger.d.ts.map +1 -1
  75. package/lib/network/node/ledger.js +2 -9
  76. package/lib/network/node/ledger.js.map +1 -1
  77. package/lib/network/node/rpc.common.d.ts.map +1 -1
  78. package/lib/network/node/rpc.common.js +18 -9
  79. package/lib/network/node/rpc.common.js.map +1 -1
  80. package/lib/network/node/types.d.ts +3 -1
  81. package/lib/network/node/types.d.ts.map +1 -1
  82. package/lib/network/node/types.js.map +1 -1
  83. package/lib/staking/detectOperationType.js +1 -1
  84. package/lib/staking/validators/index.d.ts +1 -1
  85. package/lib/staking/validators/index.d.ts.map +1 -1
  86. package/lib/staking/validators/index.js +2 -2
  87. package/lib/staking/validators/index.js.map +1 -1
  88. package/lib/staking/validators/monadResolver.js +1 -1
  89. package/lib/staking/validators/monadResolver.js.map +1 -1
  90. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  91. package/lib-es/adapters/etherscan.js +14 -0
  92. package/lib-es/adapters/etherscan.js.map +1 -1
  93. package/lib-es/adapters/ledger.d.ts.map +1 -1
  94. package/lib-es/adapters/ledger.js +2 -0
  95. package/lib-es/adapters/ledger.js.map +1 -1
  96. package/lib-es/api/index.d.ts +1 -1
  97. package/lib-es/api/index.d.ts.map +1 -1
  98. package/lib-es/api/index.js +14 -15
  99. package/lib-es/api/index.js.map +1 -1
  100. package/lib-es/chains.d.ts +7 -0
  101. package/lib-es/chains.d.ts.map +1 -1
  102. package/lib-es/chains.js +16 -0
  103. package/lib-es/chains.js.map +1 -1
  104. package/lib-es/config.d.ts +1 -1
  105. package/lib-es/config.d.ts.map +1 -1
  106. package/lib-es/config.js +1 -1
  107. package/lib-es/config.js.map +1 -1
  108. package/lib-es/errors.d.ts +11 -0
  109. package/lib-es/errors.d.ts.map +1 -1
  110. package/lib-es/errors.js +15 -0
  111. package/lib-es/errors.js.map +1 -1
  112. package/lib-es/logic/broadcast.d.ts +1 -1
  113. package/lib-es/logic/broadcast.d.ts.map +1 -1
  114. package/lib-es/logic/broadcast.js +2 -2
  115. package/lib-es/logic/broadcast.js.map +1 -1
  116. package/lib-es/logic/craftTransaction.d.ts +1 -1
  117. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  118. package/lib-es/logic/craftTransaction.js +3 -3
  119. package/lib-es/logic/craftTransaction.js.map +1 -1
  120. package/lib-es/logic/estimateFees.d.ts +1 -1
  121. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  122. package/lib-es/logic/estimateFees.js +19 -4
  123. package/lib-es/logic/estimateFees.js.map +1 -1
  124. package/lib-es/logic/getBalance.d.ts +1 -2
  125. package/lib-es/logic/getBalance.d.ts.map +1 -1
  126. package/lib-es/logic/getBalance.js +5 -6
  127. package/lib-es/logic/getBalance.js.map +1 -1
  128. package/lib-es/logic/getBlock.d.ts +1 -1
  129. package/lib-es/logic/getBlock.d.ts.map +1 -1
  130. package/lib-es/logic/getBlock.js +23 -6
  131. package/lib-es/logic/getBlock.js.map +1 -1
  132. package/lib-es/logic/getBlockInfo.d.ts +1 -1
  133. package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
  134. package/lib-es/logic/getBlockInfo.js +2 -2
  135. package/lib-es/logic/getBlockInfo.js.map +1 -1
  136. package/lib-es/logic/getNextSequence.d.ts +1 -1
  137. package/lib-es/logic/getNextSequence.d.ts.map +1 -1
  138. package/lib-es/logic/getNextSequence.js +2 -2
  139. package/lib-es/logic/getNextSequence.js.map +1 -1
  140. package/lib-es/logic/getStakes.d.ts +1 -1
  141. package/lib-es/logic/getStakes.d.ts.map +1 -1
  142. package/lib-es/logic/getStakes.js +2 -2
  143. package/lib-es/logic/getStakes.js.map +1 -1
  144. package/lib-es/logic/lastBlock.d.ts +1 -1
  145. package/lib-es/logic/lastBlock.d.ts.map +1 -1
  146. package/lib-es/logic/lastBlock.js +2 -2
  147. package/lib-es/logic/lastBlock.js.map +1 -1
  148. package/lib-es/logic/listOperations.d.ts +1 -1
  149. package/lib-es/logic/listOperations.d.ts.map +1 -1
  150. package/lib-es/logic/listOperations.js +4 -2
  151. package/lib-es/logic/listOperations.js.map +1 -1
  152. package/lib-es/logic/validateIntent.d.ts +1 -1
  153. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  154. package/lib-es/logic/validateIntent.js +3 -3
  155. package/lib-es/logic/validateIntent.js.map +1 -1
  156. package/lib-es/logic.d.ts.map +1 -1
  157. package/lib-es/logic.js +6 -11
  158. package/lib-es/logic.js.map +1 -1
  159. package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
  160. package/lib-es/network/node/explorerProxy.js +2 -0
  161. package/lib-es/network/node/explorerProxy.js.map +1 -1
  162. package/lib-es/network/node/ledger.d.ts.map +1 -1
  163. package/lib-es/network/node/ledger.js +3 -10
  164. package/lib-es/network/node/ledger.js.map +1 -1
  165. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  166. package/lib-es/network/node/rpc.common.js +19 -10
  167. package/lib-es/network/node/rpc.common.js.map +1 -1
  168. package/lib-es/network/node/types.d.ts +3 -1
  169. package/lib-es/network/node/types.d.ts.map +1 -1
  170. package/lib-es/network/node/types.js.map +1 -1
  171. package/lib-es/staking/detectOperationType.js +1 -1
  172. package/lib-es/staking/validators/index.d.ts +1 -1
  173. package/lib-es/staking/validators/index.d.ts.map +1 -1
  174. package/lib-es/staking/validators/index.js +2 -2
  175. package/lib-es/staking/validators/index.js.map +1 -1
  176. package/lib-es/staking/validators/monadResolver.js +1 -1
  177. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  178. package/package.json +2 -2
  179. package/src/adapters/etherscan.test.ts +57 -5
  180. package/src/adapters/etherscan.ts +15 -0
  181. package/src/adapters/ledger.test.ts +57 -9
  182. package/src/adapters/ledger.ts +2 -0
  183. package/src/api/index.ts +14 -17
  184. package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +7 -7
  185. package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +4 -4
  186. package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +4 -4
  187. package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +4 -4
  188. package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +4 -4
  189. package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +4 -4
  190. package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +8 -8
  191. package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +4 -4
  192. package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +5 -5
  193. package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +4 -4
  194. package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +4 -4
  195. package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +4 -4
  196. package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +4 -4
  197. package/src/api/{index.test.ts → tests/index.test.ts} +10 -10
  198. package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +3 -3
  199. package/src/chains.ts +17 -0
  200. package/src/config.ts +1 -1
  201. package/src/errors.ts +14 -0
  202. package/src/fixtures/context.fixtures.ts +2 -4
  203. package/src/logic/broadcast.ts +1 -2
  204. package/src/logic/craftTransaction.ts +2 -3
  205. package/src/logic/estimateFees.ts +22 -4
  206. package/src/logic/getBalance.ts +3 -6
  207. package/src/logic/getBlock.ts +39 -10
  208. package/src/logic/getBlockInfo.ts +2 -6
  209. package/src/logic/getNextSequence.ts +2 -6
  210. package/src/logic/getStakes.ts +1 -2
  211. package/src/logic/lastBlock.ts +2 -2
  212. package/src/logic/listOperations.ts +3 -2
  213. package/src/logic/tests/broadcast.integ.test.ts +1 -1
  214. package/src/logic/tests/broadcast.test.ts +5 -5
  215. package/src/logic/tests/broadcastSource.test.ts +4 -4
  216. package/src/logic/tests/common.test.ts +1 -1
  217. package/src/logic/tests/craftTransaction.test.ts +16 -21
  218. package/src/logic/tests/estimateFees.test.ts +40 -18
  219. package/src/logic/tests/getBalance.test.ts +20 -23
  220. package/src/logic/tests/getBlock.test.ts +159 -39
  221. package/src/logic/tests/getBlockInfo.test.ts +6 -6
  222. package/src/logic/tests/getNextSequence.test.ts +2 -2
  223. package/src/logic/tests/getStakes.test.ts +14 -14
  224. package/src/logic/tests/internalTransactionsFetcher.test.ts +1 -1
  225. package/src/logic/tests/lastBlock.test.ts +4 -4
  226. package/src/logic/tests/listOperations.test.ts +51 -55
  227. package/src/logic/tests/validateIntent.test.ts +39 -61
  228. package/src/logic/validateIntent.ts +2 -3
  229. package/src/logic.test.ts +24 -7
  230. package/src/logic.ts +6 -11
  231. package/src/network/node/explorerProxy.ts +2 -0
  232. package/src/network/node/ledger.ts +3 -10
  233. package/src/network/node/rpc.common.ts +23 -10
  234. package/src/network/node/types.ts +5 -2
  235. package/src/network/{explorer → tests/explorer}/etherscan.test.ts +8 -8
  236. package/src/network/{explorer → tests/explorer}/index.test.ts +11 -11
  237. package/src/network/{explorer → tests/explorer}/ledger.test.ts +11 -11
  238. package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
  239. package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
  240. package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
  241. package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
  242. package/src/network/{node → tests/node}/explorerProxy.test.ts +5 -2
  243. package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
  244. package/src/network/{node → tests/node}/index.memoization.test.ts +3 -3
  245. package/src/network/{node → tests/node}/index.test.ts +3 -3
  246. package/src/network/{node → tests/node}/ledger.test.ts +9 -6
  247. package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
  248. package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
  249. package/src/network/{node → tests/node}/rpc.test.ts +57 -6
  250. package/src/network/{node → tests/node}/types.test.ts +1 -1
  251. package/src/network/{node → tests/node}/withNodeSources.test.ts +3 -3
  252. package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
  253. package/src/staking/detectOperationType.ts +1 -1
  254. package/src/staking/redelegations.test.ts +3 -3
  255. package/src/staking/validators/index.ts +1 -2
  256. package/src/staking/validators/monadResolver.ts +1 -1
  257. package/src/staking/validators.integ.test.ts +1 -1
  258. package/src/staking/validators.test.ts +1 -1
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
5
- import { createMockEvmContext } from '../fixtures/context.fixtures'
6
- import { createApi } from './index'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
6
+ import { createApi } from '../index'
7
7
 
8
8
  describe('EVM Avalanche C-Chain Fuji', () => {
9
9
  let module: ReturnType<typeof createApi>
@@ -20,7 +20,7 @@ describe('EVM Avalanche C-Chain Fuji', () => {
20
20
  },
21
21
  }
22
22
  beforeAll(() => {
23
- module = createApi('avalanche_c_chain_fuji')
23
+ module = createApi()
24
24
  })
25
25
 
26
26
  describe('listOperations', () => {
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
5
- import { createMockEvmContext } from '../fixtures/context.fixtures'
6
- import { createApi } from './index'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
6
+ import { createApi } from '../index'
7
7
 
8
8
  describe('EVM Cronos Network (blockscout explorer)', () => {
9
9
  let module: ReturnType<typeof createApi>
@@ -20,7 +20,7 @@ describe('EVM Cronos Network (blockscout explorer)', () => {
20
20
  },
21
21
  }
22
22
  beforeAll(() => {
23
- module = createApi('cronos')
23
+ module = createApi()
24
24
  })
25
25
 
26
26
  describe('listOperations', () => {
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
5
- import { createMockEvmContext } from '../fixtures/context.fixtures'
6
- import { createApi } from './index'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
6
+ import { createApi } from '../index'
7
7
 
8
8
  describe('Flare (external node)', () => {
9
9
  describe('getBlock', () => {
@@ -24,7 +24,7 @@ describe('Flare (external node)', () => {
24
24
  },
25
25
  }
26
26
  beforeAll(() => {
27
- module = createApi('flare')
27
+ module = createApi()
28
28
  })
29
29
 
30
30
  it('internal txs can be retrieved from node', async () => {
@@ -12,9 +12,9 @@ import {
12
12
  mkExternalNode,
13
13
  mkLedgerExplorer,
14
14
  mkLedgerNode,
15
- } from '../fixtures/context.fixtures'
16
- import { isNative } from '../types/assets'
17
- import { createApi } from './index'
15
+ } from '../../fixtures/context.fixtures'
16
+ import { isNative } from '../../types/assets'
17
+ import { createApi } from '../index'
18
18
 
19
19
  describe.each([
20
20
  [
@@ -41,7 +41,7 @@ describe.each([
41
41
  // carry this suite's node/explorer config — not the empty default fixture.
42
42
  const context = createMockEvmContext(config)
43
43
  beforeAll(() => {
44
- module = createApi('ethereum')
44
+ module = createApi()
45
45
  })
46
46
 
47
47
  describe('getNextSequence', () => {
@@ -341,7 +341,7 @@ describe.each([
341
341
  * "To send batches over 10 items, consider using a dedicated API provider"
342
342
  */
343
343
  it('returns at least 10 token balances on Optimisim', async () => {
344
- const module = createApi('optimism')
344
+ const module = createApi()
345
345
  const context = createMockEvmContext(
346
346
  createMockEvmConfigInfo({
347
347
  chainId: 10,
@@ -878,7 +878,7 @@ describe('EVM Api: external node and explorer ONLY', () => {
878
878
  )
879
879
 
880
880
  beforeAll(() => {
881
- module = createApi('ethereum')
881
+ module = createApi()
882
882
  })
883
883
 
884
884
  describe('getBlock', () => {
@@ -970,7 +970,7 @@ describe('EVM Api (SEI Network)', () => {
970
970
  )
971
971
 
972
972
  beforeAll(() => {
973
- module = createApi('sei_evm')
973
+ module = createApi()
974
974
  })
975
975
 
976
976
  describe('craftTransaction', () => {
@@ -1110,7 +1110,7 @@ describe('EVM Api (Zero Gravity)', () => {
1110
1110
  )
1111
1111
 
1112
1112
  beforeAll(() => {
1113
- module = createApi('zero_gravity')
1113
+ module = createApi()
1114
1114
  })
1115
1115
 
1116
1116
  describe('listOperations', () => {
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
5
- import { createMockEvmContext } from '../fixtures/context.fixtures'
6
- import { createApi } from './index'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
6
+ import { createApi } from '../index'
7
7
 
8
8
  /**
9
9
  * Integration tests for getBlock with internal transactions (etherscan/blockscout).
@@ -41,7 +41,7 @@ describe('Linea (etherscan explorer)', () => {
41
41
  }
42
42
 
43
43
  beforeAll(() => {
44
- module = createApi('linea')
44
+ module = createApi()
45
45
  })
46
46
 
47
47
  it('should include internal native transfer in block transaction', async () => {
@@ -5,10 +5,10 @@ import {
5
5
  createMockEvmConfigInfo,
6
6
  createMockEvmContext,
7
7
  testLogger,
8
- } from '../fixtures/context.fixtures'
9
- import { getNodeApi } from '../network/node'
10
- import { nodeSourcesFromList } from '../nodeSources'
11
- import { createApi } from './index'
8
+ } from '../../fixtures/context.fixtures'
9
+ import { getNodeApi } from '../../network/node'
10
+ import { nodeSourcesFromList } from '../../nodeSources'
11
+ import { createApi } from '../index'
12
12
 
13
13
  describe('EVM Api (Monad Testnet)', () => {
14
14
  let module: ReturnType<typeof createApi>
@@ -23,7 +23,7 @@ describe('EVM Api (Monad Testnet)', () => {
23
23
  nodeSources: nodeSourcesFromList(['explorer-proxy', 'node']),
24
24
  })
25
25
  beforeAll(() => {
26
- module = createApi('monad_testnet')
26
+ module = createApi()
27
27
  })
28
28
 
29
29
  describe('listOperations', () => {
@@ -1,10 +1,10 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
4
+ import type { EvmConfigInfo } from '../../config'
5
5
  import type { Operation } from '@ledgerhq/coin-module-framework/api/types'
6
- import { createMockEvmContext } from '../fixtures/context.fixtures'
7
- import { createApi } from './index'
6
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
7
+ import { createApi } from '../index'
8
8
 
9
9
  describe('EVM Optimism Network', () => {
10
10
  let module: ReturnType<typeof createApi>
@@ -21,7 +21,7 @@ describe('EVM Optimism Network', () => {
21
21
  },
22
22
  }
23
23
  beforeAll(() => {
24
- module = createApi('optimism')
24
+ module = createApi()
25
25
  })
26
26
 
27
27
  describe('getBlock fee correctness', () => {
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
5
- import { createMockEvmContext } from '../fixtures/context.fixtures'
6
- import { createApi } from './index'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
6
+ import { createApi } from '../index'
7
7
 
8
8
  describe('EVM RSK Network', () => {
9
9
  let module: ReturnType<typeof createApi>
@@ -20,7 +20,7 @@ describe('EVM RSK Network', () => {
20
20
  },
21
21
  }
22
22
  beforeAll(() => {
23
- module = createApi('rsk')
23
+ module = createApi()
24
24
  })
25
25
 
26
26
  describe('getBalance with EIP-1191 checksummed address', () => {
@@ -1,10 +1,10 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
4
+ import type { EvmConfigInfo } from '../../config'
5
5
  import { fail } from 'assert'
6
- import { createMockEvmContext } from '../fixtures/context.fixtures'
7
- import { createApi } from './index'
6
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
7
+ import { createApi } from '../index'
8
8
 
9
9
  describe('Shape (external node)', () => {
10
10
  describe('getBlock', () => {
@@ -23,7 +23,7 @@ describe('Shape (external node)', () => {
23
23
  },
24
24
  supportedTokens: ['erc721', 'erc1155'],
25
25
  }
26
- const module = createApi('shape')
26
+ const module = createApi()
27
27
 
28
28
  it('should return WETH mint from Deposit log in block 26327282 (tx 0x08761e…) see BACK-10995', async () => {
29
29
  const weth = '0x4200000000000000000000000000000000000006'
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { EvmConfigInfo } from '../config'
5
- import { createMockEvmContext } from '../fixtures/context.fixtures'
6
- import { createApi } from './index'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import { createMockEvmContext } from '../../fixtures/context.fixtures'
6
+ import { createApi } from '../index'
7
7
 
8
8
  describe('EVM Api (Somnia)', () => {
9
9
  let module: ReturnType<typeof createApi>
@@ -15,7 +15,7 @@ describe('EVM Api (Somnia)', () => {
15
15
  }
16
16
 
17
17
  beforeAll(() => {
18
- module = createApi('somnia')
18
+ module = createApi()
19
19
  })
20
20
 
21
21
  describe('listOperations', () => {
@@ -1,11 +1,11 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { mockEvmContext } from '../fixtures/context.fixtures'
5
- import { getValidatorsPage } from '../staking/validators'
6
- import { createApi, parseCallParams } from './index'
4
+ import { mockEvmContext } from '../../fixtures/context.fixtures'
5
+ import { getValidatorsPage } from '../../staking/validators'
6
+ import { createApi, parseCallParams } from '../index'
7
7
 
8
- jest.mock('../staking/validators', () => ({
8
+ jest.mock('../../staking/validators', () => ({
9
9
  getValidatorsPage: jest.fn(),
10
10
  }))
11
11
 
@@ -54,11 +54,11 @@ describe.each([
54
54
  ],
55
55
  ])('coin-framework methods %s', (_s, _config, methods) => {
56
56
  it('declares every method the chain supports', () => {
57
- expect(createApi('ethereum')).toEqual(methods)
57
+ expect(createApi()).toEqual(methods)
58
58
  })
59
59
 
60
60
  it('omits the capabilities the chain has none of', () => {
61
- const impl = createApi('ethereum')
61
+ const impl = createApi()
62
62
  for (const method of ['craftRawTransaction', 'register', 'getStakes', 'getRewards'] as const) {
63
63
  expect(impl).not.toHaveProperty(method)
64
64
  }
@@ -118,7 +118,7 @@ describe('parseCallParams', () => {
118
118
  })
119
119
 
120
120
  it('rejects invalid params as a rejected promise, not a synchronous throw', async () => {
121
- const api = createApi('ethereum')
121
+ const api = createApi()
122
122
  await expect(api.call(mockEvmContext, {})).rejects.toThrow('Invalid EVM call params')
123
123
  })
124
124
  })
@@ -141,12 +141,12 @@ describe('staking support capability', () => {
141
141
  }
142
142
  mockGetValidatorsPage.mockResolvedValue(expectedPage)
143
143
 
144
- const api = createApi('sei_evm')
144
+ const api = createApi()
145
145
 
146
146
  await expect(api.getValidators(mockEvmContext)).resolves.toEqual(expectedPage)
147
- expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, 'sei_evm', undefined)
147
+ expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, undefined)
148
148
 
149
149
  await expect(api.getValidators(mockEvmContext, { cursor: '42' })).resolves.toEqual(expectedPage)
150
- expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, 'sei_evm', '42')
150
+ expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, '42')
151
151
  })
152
152
  })
@@ -1,8 +1,8 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { createMockEvmContext, mkExternalNode } from '../fixtures/context.fixtures'
5
- import { createApi } from './index'
4
+ import { createMockEvmContext, mkExternalNode } from '../../fixtures/context.fixtures'
5
+ import { createApi } from '../index'
6
6
 
7
7
  /**
8
8
  * Non regression for GET /v1/zksync/account/{address}/operations?minHeight=0&order=asc&limit=1,
@@ -18,7 +18,7 @@ describe('ZkSync (blockscout explorer)', () => {
18
18
  let module: ReturnType<typeof createApi>
19
19
 
20
20
  beforeAll(() => {
21
- module = createApi('zksync')
21
+ module = createApi()
22
22
  })
23
23
 
24
24
  it('listOperations completes without timing out', async () => {
package/src/chains.ts CHANGED
@@ -64,6 +64,7 @@ export const CHAIN_ID = {
64
64
  BASE: 8453,
65
65
  MONAD_TESTNET: 10143,
66
66
  ZERO_GRAVITY: 16661,
67
+ ALPEN_TESTNET: 20310,
67
68
  ETHERSOCIAL: 31102,
68
69
  ADI: 36900,
69
70
  ARBITRUM: 42161,
@@ -95,3 +96,19 @@ export const CHAIN_ID = {
95
96
  } as const
96
97
 
97
98
  export type ChainId = (typeof CHAIN_ID)[keyof typeof CHAIN_ID]
99
+
100
+ /**
101
+ * OP Stack chains that bill an L1 data fee on top of L2 execution gas.
102
+ * The fee is read from the GasPriceOracle predeploy (`getL1Fee`).
103
+ * @see https://docs.optimism.io/stack/transactions/fees
104
+ */
105
+ export const OP_STACK_L1_FEE_CHAIN_IDS: readonly ChainId[] = [
106
+ CHAIN_ID.OPTIMISM,
107
+ CHAIN_ID.OPTIMISM_SEPOLIA,
108
+ CHAIN_ID.BASE,
109
+ CHAIN_ID.BASE_SEPOLIA,
110
+ CHAIN_ID.BLAST,
111
+ CHAIN_ID.BLAST_SEPOLIA,
112
+ CHAIN_ID.SHAPE,
113
+ CHAIN_ID.BOBA,
114
+ ]
package/src/config.ts CHANGED
@@ -6,7 +6,7 @@ import type { InternalTxSourceList } from './internalTxSources'
6
6
  import type { NodeSourceList } from './nodeSources'
7
7
  import type { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
8
8
 
9
- export { CHAIN_ID } from './chains'
9
+ export { CHAIN_ID, OP_STACK_L1_FEE_CHAIN_IDS } from './chains'
10
10
  export type { ChainId } from './chains'
11
11
 
12
12
  export type { InternalTxSource, InternalTxSourceList, NonEmptySource } from './internalTxSources'
package/src/errors.ts CHANGED
@@ -133,6 +133,20 @@ export class GasPriceTooLow extends Error {
133
133
  }
134
134
  }
135
135
 
136
+ /**
137
+ * The L1 data fee of a rollup (e.g. OP Stack `GasPriceOracle.getL1Fee`) could not be read.
138
+ * Raised instead of reporting a zero fee, which would under-estimate the total fee.
139
+ */
140
+ export class L1DataFeeUnavailableError extends Error {
141
+ override name = 'L1DataFeeUnavailableError'
142
+ readonly statusCode = 503
143
+ constructor(message?: string, fields?: Record<string, unknown>, options?: { cause?: unknown }) {
144
+ super(message || 'L1 data fee is unavailable, please retry later')
145
+ if (fields) Object.assign(this, fields)
146
+ if (options?.cause !== undefined) Object.assign(this, { cause: options.cause })
147
+ }
148
+ }
149
+
136
150
  export class GasEstimationError extends Error {
137
151
  override name = 'GasEstimationError'
138
152
  constructor(message?: string, fields?: Record<string, unknown>) {
@@ -88,14 +88,12 @@ export const createMockEvmCoinConfig = (
88
88
  /**
89
89
  * Builds a mock {@link EvmContext} for tests.
90
90
  *
91
- * The logic layer resolves its configuration through `context.config(currency.id)`, so this
91
+ * The logic layer resolves its configuration through `context.config()`, so this
92
92
  * accessor is the single source of config for the delegated calls. Pass an optional `config`
93
93
  * to override what `context.config()` resolves to (merged over an `active` status default).
94
- * The `currencyId` argument is accepted for signature parity but ignored — the mock always
95
- * resolves the same config regardless of currency.
96
94
  */
97
95
  export const createMockEvmContext = (config?: Partial<EvmConfigInfo>): EvmContext => ({
98
- config: async (_currencyId?: string): Promise<EvmConfigInfo> =>
96
+ config: async (): Promise<EvmConfigInfo> =>
99
97
  createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode(), ...config }),
100
98
  logger: jest.fn(),
101
99
  })
@@ -7,7 +7,6 @@ import { getNodeApi } from '../network/node/index'
7
7
 
8
8
  export async function broadcast(
9
9
  context: EvmContext,
10
- currencyId: string,
11
10
  {
12
11
  signature,
13
12
  broadcastConfig,
@@ -16,7 +15,7 @@ export async function broadcast(
16
15
  broadcastConfig?: BroadcastConfig | undefined
17
16
  }
18
17
  ): Promise<string> {
19
- const config = await context.config(currencyId)
18
+ const config = await context.config()
20
19
  const nodeApi = getNodeApi(config, context.logger)
21
20
  return await nodeApi.broadcastTransaction(signature, broadcastConfig)
22
21
  }
@@ -20,7 +20,6 @@ import { isFeesStrategy } from './predicates'
20
20
 
21
21
  export async function craftTransaction(
22
22
  context: EvmContext,
23
- currencyId: string,
24
23
  {
25
24
  transactionIntent,
26
25
  customFees,
@@ -29,7 +28,7 @@ export async function craftTransaction(
29
28
  customFees?: FeeEstimation | undefined
30
29
  }
31
30
  ): Promise<CraftedTransaction> {
32
- const config = await context.config(currencyId)
31
+ const config = await context.config()
33
32
  const { type, to, data, value, gasLimit } = await prepareUnsignedTxParams(
34
33
  config,
35
34
  transactionIntent,
@@ -48,7 +47,7 @@ export async function craftTransaction(
48
47
  const nonce =
49
48
  typeof transactionIntent.sequence === 'bigint' && transactionIntent.sequence >= 0n
50
49
  ? transactionIntent.sequence
51
- : await getNextSequence(context, currencyId, transactionIntent.sender)
50
+ : await getNextSequence(context, transactionIntent.sender)
52
51
  const chainId = config.chainId
53
52
 
54
53
  const unsignedTransaction: TransactionLike = {
@@ -14,6 +14,7 @@ import type { Logger } from '@ledgerhq/coin-module-framework/config'
14
14
  import type { TransactionLike } from 'ethers'
15
15
  import BigNumber from 'bignumber.js'
16
16
  import { Transaction } from 'ethers'
17
+ import { L1DataFeeUnavailableError } from '../errors'
17
18
  import { getAdditionalLayer2Fees } from '../logic'
18
19
  import { isEthAddress, isStakingIntent } from '../logic-public'
19
20
  import { getGasTracker } from '../network/gasTracker'
@@ -24,6 +25,12 @@ import { getTransactionType, prepareUnsignedTxParams } from './common'
24
25
  import { getNextSequence } from './getNextSequence'
25
26
  import { isFeesStrategy } from './predicates'
26
27
 
28
+ /**
29
+ * Multiplier applied to the L1 data fee (`additionalFees`) of a send-max estimate only.
30
+ * The L1 fee follows the L1 base fee, which can rise between estimate and broadcast; for a
31
+ * send-max the amount is balance minus fees, so an under-estimate would make the transaction fail.
32
+ * Other estimates return the raw oracle value.
33
+ */
27
34
  const SEND_MAX_L1_FEE_BUFFER = new BigNumber(2)
28
35
 
29
36
  async function computeAdditionalFees(
@@ -41,11 +48,23 @@ async function computeAdditionalFees(
41
48
  },
42
49
  }
43
50
 
51
+ let serialized: string
44
52
  try {
45
- return await getAdditionalLayer2Fees(config, Transaction.from(transaction).serialized, logger)
53
+ serialized = Transaction.from(transaction).serialized
46
54
  } catch {
47
55
  return new BigNumber(0)
48
56
  }
57
+
58
+ try {
59
+ return await getAdditionalLayer2Fees(config, serialized, logger)
60
+ } catch (error) {
61
+ const reason = error instanceof Error ? error.message : String(error)
62
+ throw new L1DataFeeUnavailableError(
63
+ `Could not get the L1 data fee for chain ${config.name}: ${reason}`,
64
+ { chainId: config.chainId },
65
+ { cause: error }
66
+ )
67
+ }
49
68
  }
50
69
 
51
70
  function toApiFeeData(feeData: FeeData): ApiFeeData {
@@ -117,7 +136,6 @@ function extractGasOptions(
117
136
 
118
137
  export async function estimateFees(
119
138
  context: EvmContext,
120
- currencyId: string,
121
139
  transactionIntent: TransactionIntent<MemoNotSupported, BufferTxData>,
122
140
  customFeesParameters?: FeeEstimation['parameters']
123
141
  ): Promise<FeeEstimation> {
@@ -125,7 +143,7 @@ export async function estimateFees(
125
143
  return { value: 0n }
126
144
  }
127
145
 
128
- const config = await context.config(currencyId)
146
+ const config = await context.config()
129
147
 
130
148
  // Skip fee estimation for redelegate without a destination validator — the
131
149
  // validateStaking step in validateIntent will surface RedelegateDstValAddressRequired.
@@ -147,7 +165,7 @@ export async function estimateFees(
147
165
  const noncePromise: Promise<bigint> =
148
166
  typeof transactionIntent.sequence === 'bigint' && transactionIntent.sequence >= 0n
149
167
  ? Promise.resolve(transactionIntent.sequence)
150
- : getNextSequence(context, currencyId, transactionIntent.sender)
168
+ : getNextSequence(context, transactionIntent.sender)
151
169
 
152
170
  const feeDataPromise = (async (): Promise<{
153
171
  finalFeeData: FeeData
@@ -16,23 +16,21 @@ export const TOKEN_BALANCE_BATCH_SIZE = 8
16
16
  /**
17
17
  * Get all assets linked to the user (native, tokens, ...)
18
18
  * @param context - The coin-module context (config + logger)
19
- * @param currencyId - The currency id we must get the balances of
20
19
  * @param address - The user's address
21
20
  * @returns Promise<Balance[]> - Array of balances for all assets (first element will always be the native asset)
22
21
  */
23
22
  export async function getBalance(
24
23
  context: EvmContext,
25
- currencyId: string,
26
24
  address: string,
27
25
  options?: BalanceOptions
28
26
  ): Promise<Balance[]> {
29
- const config = await context.config(currencyId)
27
+ const config = await context.config()
30
28
  const nodeApi = getNodeApi(config, context.logger)
31
29
  const explorerApi = getExplorerApi(config)
32
30
 
33
31
  const [nativeBalance, tokensBalances] = await Promise.all([
34
32
  getNativeBalance(address, nodeApi),
35
- getTokenBalances(context, currencyId, address, nodeApi, explorerApi, config, options),
33
+ getTokenBalances(context, address, nodeApi, explorerApi, config, options),
36
34
  ])
37
35
 
38
36
  return [nativeBalance].concat(tokensBalances)
@@ -50,7 +48,6 @@ async function getNativeBalance(address: string, nodeApi: NodeApi): Promise<Bala
50
48
 
51
49
  async function getTokenBalances(
52
50
  context: EvmContext,
53
- currencyId: string,
54
51
  address: string,
55
52
  nodeApi: NodeApi,
56
53
  explorerApi: ExplorerApi,
@@ -124,7 +121,7 @@ async function getTokenBalances(
124
121
  // Staking and token-asset collection run in parallel; staking depends on the coin operations
125
122
  // fetched above (Monad only), token-asset collection on the discovered/known assets union.
126
123
  const [stakingResult, tokenAssetsResult] = await Promise.allSettled([
127
- getStakes(context, currencyId, address, { knownValidatorIds }),
124
+ getStakes(context, address, { knownValidatorIds }),
128
125
  collectTokenAssets(
129
126
  Array.from(knownAssetsByReference.values()),
130
127
  address,
@@ -21,11 +21,7 @@ import { getNodeApi } from '../network/node'
21
21
  import { createInternalTransactionsFetcher } from './internalTransactionsFetcher'
22
22
  import { dropRootTraceDuplicates } from './rootTraceDedup'
23
23
 
24
- export async function getBlock(
25
- context: EvmContext,
26
- currencyId: string,
27
- height: number
28
- ): Promise<Block> {
24
+ export async function getBlock(context: EvmContext, height: number): Promise<Block> {
29
25
  // Note: to use RPC calls efficiently, the strategy here is:
30
26
  // - fetch the block + transactions in one call (using prefetchTxs=true)
31
27
  // - fetch transaction receipts in one call using eth_getBlockReceipts
@@ -34,7 +30,7 @@ export async function getBlock(
34
30
  // - unless the block is empty, fetch internal transactions (RPC trace methods or explorer,
35
31
  // per `getBlockInternalTxsSources`) in parallel with the receipts, and merge them into the
36
32
  // block transactions
37
- const config = await context.config(currencyId)
33
+ const config = await context.config()
38
34
  const nodeApi = getNodeApi(config, context.logger)
39
35
  const internalTxSources = config.getBlockInternalTxsSources ?? DEFAULT_INTERNAL_TX_SOURCES
40
36
  const fetchInternalTxs = createInternalTransactionsFetcher(
@@ -229,7 +225,12 @@ function prefetchedTransactionToBlockTransaction(
229
225
  logger
230
226
  )
231
227
 
232
- const details = buildSmartContractDetails(tx.to, tx.input, logger, receipt.contractAddress)
228
+ const details = buildTransactionDetails(
229
+ gasPrice,
230
+ tx.gasLimit,
231
+ tx.nonce,
232
+ buildSmartContractDetails(tx.to, tx.input, logger, receipt.contractAddress)
233
+ )
233
234
 
234
235
  return {
235
236
  hash: tx.hash,
@@ -237,7 +238,7 @@ function prefetchedTransactionToBlockTransaction(
237
238
  operations,
238
239
  fees,
239
240
  feesPayer: tx.from,
240
- ...(details ? { details } : {}),
241
+ details,
241
242
  }
242
243
  }
243
244
 
@@ -256,7 +257,12 @@ async function getTransactionFromHash(
256
257
  const rawOperations = rpcTransactionToBlockOperations(txInfo, logger)
257
258
  const operations = applyChainSpecificCorrections(chainId, rawOperations, txInfo.type, logger)
258
259
 
259
- const details = buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress)
260
+ const details = buildTransactionDetails(
261
+ BigInt(txInfo.gasPrice),
262
+ txInfo.gasLimit,
263
+ txInfo.nonce,
264
+ buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress)
265
+ )
260
266
 
261
267
  return {
262
268
  hash: txHash,
@@ -264,7 +270,30 @@ async function getTransactionFromHash(
264
270
  operations,
265
271
  fees,
266
272
  feesPayer: txInfo.from,
267
- ...(details ? { details } : {}),
273
+ details,
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Builds the transaction details. The gas and nonce keys match the ones set by
279
+ * {@link listOperations}, so consumers get the same keys whichever sync wrote the transaction.
280
+ *
281
+ * @param gasPrice gas price actually paid, in wei
282
+ * @param gasLimit gas limit set by the sender (decimal), when known
283
+ * @param nonce nonce of the transaction, when known
284
+ * @param smartContractDetails details of the contract interaction or deployment, if any
285
+ */
286
+ function buildTransactionDetails(
287
+ gasPrice: bigint,
288
+ gasLimit: string | undefined,
289
+ nonce: number | undefined,
290
+ smartContractDetails: Record<string, unknown> | undefined
291
+ ): Record<string, unknown> {
292
+ return {
293
+ gasPrice: gasPrice.toString(),
294
+ ...(gasLimit !== undefined ? { gasLimit } : {}),
295
+ ...(nonce !== undefined ? { sequence: nonce } : {}),
296
+ ...(smartContractDetails ?? {}),
268
297
  }
269
298
  }
270
299