@ledgerhq/coin-evm 5.3.1 → 5.3.3

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 (255) hide show
  1. package/.oxlintrc.json +3 -13
  2. package/CHANGELOG.md +13 -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.map +1 -1
  27. package/lib/logic/getBlock.d.ts +1 -1
  28. package/lib/logic/getBlock.d.ts.map +1 -1
  29. package/lib/logic/getBlock.js.map +1 -1
  30. package/lib/logic/getStakes.d.ts +1 -1
  31. package/lib/logic/getStakes.d.ts.map +1 -1
  32. package/lib/logic/internalTransactionsFetcher.d.ts +1 -1
  33. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  34. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  35. package/lib/logic/validateIntent.d.ts +1 -1
  36. package/lib/logic/validateIntent.d.ts.map +1 -1
  37. package/lib/logic/validateIntent.js.map +1 -1
  38. package/lib/logic.d.ts +1 -1
  39. package/lib/logic.d.ts.map +1 -1
  40. package/lib/network/explorer/etherscan.d.ts +4 -4
  41. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  42. package/lib/network/explorer/etherscan.js.map +1 -1
  43. package/lib/network/explorer/index.d.ts +2 -2
  44. package/lib/network/explorer/index.d.ts.map +1 -1
  45. package/lib/network/explorer/index.js.map +1 -1
  46. package/lib/network/explorer/ledger.d.ts +2 -2
  47. package/lib/network/explorer/ledger.d.ts.map +1 -1
  48. package/lib/network/explorer/ledger.js.map +1 -1
  49. package/lib/network/explorer/none.d.ts +1 -1
  50. package/lib/network/explorer/none.d.ts.map +1 -1
  51. package/lib/network/explorer/none.js.map +1 -1
  52. package/lib/network/explorer/types.d.ts +1 -1
  53. package/lib/network/explorer/types.d.ts.map +1 -1
  54. package/lib/network/gasTracker/index.d.ts +2 -2
  55. package/lib/network/gasTracker/index.d.ts.map +1 -1
  56. package/lib/network/gasTracker/index.js.map +1 -1
  57. package/lib/network/gasTracker/ledger.d.ts +3 -3
  58. package/lib/network/gasTracker/ledger.d.ts.map +1 -1
  59. package/lib/network/gasTracker/ledger.js.map +1 -1
  60. package/lib/network/gasTracker/types.d.ts +2 -2
  61. package/lib/network/gasTracker/types.d.ts.map +1 -1
  62. package/lib/network/node/ledger.d.ts +2 -2
  63. package/lib/network/node/ledger.d.ts.map +1 -1
  64. package/lib/network/node/ledger.js.map +1 -1
  65. package/lib/network/node/rpc.common.d.ts +1 -1
  66. package/lib/network/node/rpc.common.d.ts.map +1 -1
  67. package/lib/network/node/rpc.common.js.map +1 -1
  68. package/lib/network/node/types.d.ts +3 -3
  69. package/lib/network/node/types.d.ts.map +1 -1
  70. package/lib/staking/validators/monad.d.ts +2 -1
  71. package/lib/staking/validators/monad.d.ts.map +1 -1
  72. package/lib/staking/validators/monad.js.map +1 -1
  73. package/lib/staking/validators/monadResolver.d.ts +2 -1
  74. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  75. package/lib/staking/validators/monadResolver.js.map +1 -1
  76. package/lib/staking/validators/somnia.d.ts.map +1 -1
  77. package/lib/staking/validators/somnia.js.map +1 -1
  78. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  79. package/lib/staking/validators/zero_gravity.js.map +1 -1
  80. package/lib/types/assets.d.ts +1 -1
  81. package/lib/types/assets.d.ts.map +1 -1
  82. package/lib/types/transaction.d.ts +1 -1
  83. package/lib/types/transaction.d.ts.map +1 -1
  84. package/lib-es/adapters/blockOperations.d.ts +2 -2
  85. package/lib-es/adapters/blockOperations.d.ts.map +1 -1
  86. package/lib-es/adapters/blockOperations.js.map +1 -1
  87. package/lib-es/api/index.d.ts +1 -1
  88. package/lib-es/api/index.d.ts.map +1 -1
  89. package/lib-es/config.d.ts +1 -1
  90. package/lib-es/config.d.ts.map +1 -1
  91. package/lib-es/logic/combine.d.ts +2 -1
  92. package/lib-es/logic/combine.d.ts.map +1 -1
  93. package/lib-es/logic/combine.js.map +1 -1
  94. package/lib-es/logic/common.d.ts +2 -1
  95. package/lib-es/logic/common.d.ts.map +1 -1
  96. package/lib-es/logic/common.js +1 -1
  97. package/lib-es/logic/common.js.map +1 -1
  98. package/lib-es/logic/craftTransaction.d.ts +1 -1
  99. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  100. package/lib-es/logic/craftTransaction.js.map +1 -1
  101. package/lib-es/logic/craftTransactionData.d.ts +1 -1
  102. package/lib-es/logic/craftTransactionData.d.ts.map +1 -1
  103. package/lib-es/logic/estimateFees.d.ts +1 -1
  104. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  105. package/lib-es/logic/estimateFees.js.map +1 -1
  106. package/lib-es/logic/getBalance.d.ts +1 -1
  107. package/lib-es/logic/getBalance.d.ts.map +1 -1
  108. package/lib-es/logic/getBalance.js.map +1 -1
  109. package/lib-es/logic/getBlock.d.ts +1 -1
  110. package/lib-es/logic/getBlock.d.ts.map +1 -1
  111. package/lib-es/logic/getBlock.js.map +1 -1
  112. package/lib-es/logic/getStakes.d.ts +1 -1
  113. package/lib-es/logic/getStakes.d.ts.map +1 -1
  114. package/lib-es/logic/internalTransactionsFetcher.d.ts +1 -1
  115. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  116. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  117. package/lib-es/logic/validateIntent.d.ts +1 -1
  118. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  119. package/lib-es/logic/validateIntent.js.map +1 -1
  120. package/lib-es/logic.d.ts +1 -1
  121. package/lib-es/logic.d.ts.map +1 -1
  122. package/lib-es/network/explorer/etherscan.d.ts +4 -4
  123. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  124. package/lib-es/network/explorer/etherscan.js.map +1 -1
  125. package/lib-es/network/explorer/index.d.ts +2 -2
  126. package/lib-es/network/explorer/index.d.ts.map +1 -1
  127. package/lib-es/network/explorer/index.js.map +1 -1
  128. package/lib-es/network/explorer/ledger.d.ts +2 -2
  129. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  130. package/lib-es/network/explorer/ledger.js.map +1 -1
  131. package/lib-es/network/explorer/none.d.ts +1 -1
  132. package/lib-es/network/explorer/none.d.ts.map +1 -1
  133. package/lib-es/network/explorer/none.js.map +1 -1
  134. package/lib-es/network/explorer/types.d.ts +1 -1
  135. package/lib-es/network/explorer/types.d.ts.map +1 -1
  136. package/lib-es/network/gasTracker/index.d.ts +2 -2
  137. package/lib-es/network/gasTracker/index.d.ts.map +1 -1
  138. package/lib-es/network/gasTracker/index.js.map +1 -1
  139. package/lib-es/network/gasTracker/ledger.d.ts +3 -3
  140. package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
  141. package/lib-es/network/gasTracker/ledger.js +1 -1
  142. package/lib-es/network/gasTracker/ledger.js.map +1 -1
  143. package/lib-es/network/gasTracker/types.d.ts +2 -2
  144. package/lib-es/network/gasTracker/types.d.ts.map +1 -1
  145. package/lib-es/network/node/ledger.d.ts +2 -2
  146. package/lib-es/network/node/ledger.d.ts.map +1 -1
  147. package/lib-es/network/node/ledger.js.map +1 -1
  148. package/lib-es/network/node/rpc.common.d.ts +1 -1
  149. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  150. package/lib-es/network/node/rpc.common.js +1 -1
  151. package/lib-es/network/node/rpc.common.js.map +1 -1
  152. package/lib-es/network/node/types.d.ts +3 -3
  153. package/lib-es/network/node/types.d.ts.map +1 -1
  154. package/lib-es/staking/validators/monad.d.ts +2 -1
  155. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  156. package/lib-es/staking/validators/monad.js.map +1 -1
  157. package/lib-es/staking/validators/monadResolver.d.ts +2 -1
  158. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  159. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  160. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  161. package/lib-es/staking/validators/somnia.js.map +1 -1
  162. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  163. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  164. package/lib-es/types/assets.d.ts +1 -1
  165. package/lib-es/types/assets.d.ts.map +1 -1
  166. package/lib-es/types/transaction.d.ts +1 -1
  167. package/lib-es/types/transaction.d.ts.map +1 -1
  168. package/package.json +2 -2
  169. package/src/adapters/blockOperations.test.ts +29 -31
  170. package/src/adapters/blockOperations.ts +3 -2
  171. package/src/adapters/etherscan.test.ts +7 -7
  172. package/src/adapters/ledger.test.ts +2 -2
  173. package/src/api/getBlock.integ.test.ts +1 -1
  174. package/src/api/index.fantom.integ.test.ts +1 -1
  175. package/src/api/index.flare.integ.test.ts +2 -14
  176. package/src/api/index.integ.test.ts +330 -246
  177. package/src/api/index.linea.integ.test.ts +1 -1
  178. package/src/api/index.optimism.integ.test.ts +1 -1
  179. package/src/api/index.shape.integ.test.ts +1 -1
  180. package/src/api/index.ts +1 -1
  181. package/src/config.ts +1 -1
  182. package/src/fixtures/context.fixtures.ts +79 -1
  183. package/src/fixtures/ethers.fixtures.ts +26 -0
  184. package/src/fixtures/ledger.fixtures.ts +1 -1
  185. package/src/internalTxSources.test.ts +3 -6
  186. package/src/logic/broadcast.integ.test.ts +6 -18
  187. package/src/logic/broadcast.test.ts +19 -31
  188. package/src/logic/broadcastSource.test.ts +6 -7
  189. package/src/logic/combine.test.ts +2 -2
  190. package/src/logic/combine.ts +2 -1
  191. package/src/logic/common.test.ts +120 -112
  192. package/src/logic/common.ts +2 -7
  193. package/src/logic/craftTransaction.test.ts +163 -200
  194. package/src/logic/craftTransaction.ts +3 -2
  195. package/src/logic/craftTransactionData.test.ts +6 -6
  196. package/src/logic/craftTransactionData.ts +1 -1
  197. package/src/logic/estimateFees.test.ts +19 -15
  198. package/src/logic/estimateFees.ts +6 -3
  199. package/src/logic/getBalance.test.ts +16 -15
  200. package/src/logic/getBalance.ts +4 -3
  201. package/src/logic/getBlock.test.ts +379 -388
  202. package/src/logic/getBlock.ts +3 -2
  203. package/src/logic/getBlockInfo.test.ts +7 -9
  204. package/src/logic/getNextSequence.test.ts +5 -5
  205. package/src/logic/getStakes.test.ts +35 -35
  206. package/src/logic/getStakes.ts +1 -1
  207. package/src/logic/internalTransactionsFetcher.test.ts +26 -24
  208. package/src/logic/internalTransactionsFetcher.ts +1 -1
  209. package/src/logic/lastBlock.test.ts +29 -20
  210. package/src/logic/listOperations.test.ts +44 -40
  211. package/src/logic/validateIntent.test.ts +152 -101
  212. package/src/logic/validateIntent.ts +4 -2
  213. package/src/logic.test.ts +13 -18
  214. package/src/logic.ts +1 -1
  215. package/src/network/explorer/etherscan.test.ts +6 -6
  216. package/src/network/explorer/etherscan.ts +12 -10
  217. package/src/network/explorer/index.test.ts +52 -22
  218. package/src/network/explorer/index.ts +2 -2
  219. package/src/network/explorer/ledger.test.ts +17 -5
  220. package/src/network/explorer/ledger.ts +3 -2
  221. package/src/network/explorer/none.ts +2 -1
  222. package/src/network/explorer/types.ts +1 -1
  223. package/src/network/gasTracker/index.test.ts +14 -8
  224. package/src/network/gasTracker/index.ts +2 -2
  225. package/src/network/gasTracker/ledger.test.ts +34 -29
  226. package/src/network/gasTracker/ledger.ts +5 -7
  227. package/src/network/gasTracker/types.ts +2 -2
  228. package/src/network/node/index.memoization.test.ts +25 -31
  229. package/src/network/node/index.test.ts +14 -25
  230. package/src/network/node/ledger.test.ts +45 -60
  231. package/src/network/node/ledger.ts +6 -5
  232. package/src/network/node/node.fixtures.ts +0 -2
  233. package/src/network/node/rpc.common.ts +14 -14
  234. package/src/network/node/rpc.test.ts +153 -184
  235. package/src/network/node/types.ts +3 -3
  236. package/src/staking/detectOperationType.test.ts +1 -1
  237. package/src/staking/encoder.test.ts +14 -22
  238. package/src/staking/logic.test.ts +20 -14
  239. package/src/staking/operations/index.test.ts +29 -29
  240. package/src/staking/prepareIntents.test.ts +26 -20
  241. package/src/staking/redelegations.test.ts +50 -33
  242. package/src/staking/rewards.test.ts +29 -17
  243. package/src/staking/rewardsFromReceipt.test.ts +20 -21
  244. package/src/staking/transactionData.test.ts +23 -23
  245. package/src/staking/validators/monad.test.ts +65 -24
  246. package/src/staking/validators/monad.ts +2 -1
  247. package/src/staking/validators/monadResolver.ts +2 -1
  248. package/src/staking/validators/somnia.test.ts +21 -13
  249. package/src/staking/validators/somnia.ts +2 -1
  250. package/src/staking/validators/zero_gravity.test.ts +118 -48
  251. package/src/staking/validators/zero_gravity.ts +2 -1
  252. package/src/staking/validators.integ.test.ts +13 -25
  253. package/src/staking/validators.test.ts +7 -2
  254. package/src/types/assets.ts +1 -1
  255. package/src/types/transaction.ts +1 -1
@@ -1,29 +1,61 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { EvmConfigInfo } from '../../config'
4
5
  import { AssertionError, fail } from 'assert'
5
- import { EvmConfigInfo } from '../../config'
6
6
  import { UnknownExplorer } from '../../errors'
7
+ import {
8
+ createMockEvmConfigInfo,
9
+ mkEtherscanExplorer,
10
+ mkExternalNode,
11
+ mkLedgerExplorer,
12
+ } from '../../fixtures/context.fixtures'
7
13
  import etherscanLikeApi from './etherscan'
8
14
  import ledgerExplorerApi from './ledger'
9
15
  import { getExplorerApi } from './index'
10
16
 
11
17
  const configFor = (currencyId: string): EvmConfigInfo => {
18
+ const node = mkExternalNode()
12
19
  switch (currencyId) {
13
20
  case 'anything-coin':
14
- return { explorer: { type: 'anything', uri: 'notworking' } } as any
21
+ return createMockEvmConfigInfo({
22
+ chainId: 1,
23
+ node,
24
+ // @ts-expect-error — intentional invalid explorer type to test UnknownExplorer error path
25
+ explorer: { type: 'anything', uri: 'notworking' },
26
+ })
15
27
  case 'etherscan-coin':
16
- return { explorer: { type: 'etherscan', uri: 'working' } } as any
28
+ return createMockEvmConfigInfo({
29
+ chainId: 1,
30
+ node,
31
+ explorer: mkEtherscanExplorer({ uri: 'working' }),
32
+ })
17
33
  case 'blockscout-coin':
18
- return { explorer: { type: 'blockscout', uri: 'working' } } as any
34
+ return createMockEvmConfigInfo({
35
+ chainId: 1,
36
+ node,
37
+ explorer: { type: 'blockscout', uri: 'working' },
38
+ })
19
39
  case 'etherscan-coin-no-cache':
20
- return { explorer: { type: 'etherscan', uri: 'working', noCache: true } } as any
40
+ return createMockEvmConfigInfo({
41
+ chainId: 1,
42
+ node,
43
+ explorer: mkEtherscanExplorer({ uri: 'working', noCache: true }),
44
+ })
21
45
  case 'blockscout-coin-no-cache':
22
- return { explorer: { type: 'blockscout', uri: 'working', noCache: true } } as any
46
+ return createMockEvmConfigInfo({
47
+ chainId: 1,
48
+ node,
49
+ explorer: { type: 'blockscout', uri: 'working', noCache: true },
50
+ })
23
51
  case 'ledger-coin':
24
- return { explorer: { type: 'ledger', explorerId: 'eth' } } as any
52
+ return createMockEvmConfigInfo({
53
+ chainId: 1,
54
+ node,
55
+ explorer: mkLedgerExplorer({ explorerId: 'eth' }),
56
+ })
25
57
  default:
26
- return {} as any
58
+ return createMockEvmConfigInfo({ chainId: 1, node })
27
59
  }
28
60
  }
29
61
 
@@ -32,7 +64,7 @@ describe('EVM Family', () => {
32
64
  describe('getExplorerApi', () => {
33
65
  it('should throw when requesting a non existing explorer', () => {
34
66
  try {
35
- getExplorerApi(configFor('anything-coin'), { id: 'anything-coin' } as any)
67
+ getExplorerApi(configFor('anything-coin'), 'anything-coin')
36
68
  fail('Promise should have been rejected')
37
69
  } catch (e) {
38
70
  if (e instanceof AssertionError) {
@@ -43,31 +75,29 @@ describe('EVM Family', () => {
43
75
  })
44
76
 
45
77
  it('should return the etherscan api', () => {
46
- const explorerA = getExplorerApi(configFor('etherscan-coin'), {
47
- id: 'etherscan-coin',
48
- } as any)
49
- const explorerB = getExplorerApi(configFor('blockscout-coin'), {
50
- id: 'blockscout-coin',
51
- } as any)
78
+ const explorerA = getExplorerApi(configFor('etherscan-coin'), 'etherscan-coin')
79
+ const explorerB = getExplorerApi(configFor('blockscout-coin'), 'blockscout-coin')
52
80
 
53
81
  expect(explorerA).toBe(etherscanLikeApi.explorerApi)
54
82
  expect(explorerB).toBe(etherscanLikeApi.explorerApi)
55
83
  })
56
84
 
57
85
  it('should return the no cache etherscan api', () => {
58
- const explorerA = getExplorerApi(configFor('etherscan-coin-no-cache'), {
59
- id: 'etherscan-coin-no-cache',
60
- } as any)
61
- const explorerB = getExplorerApi(configFor('blockscout-coin-no-cache'), {
62
- id: 'blockscout-coin-no-cache',
63
- } as any)
86
+ const explorerA = getExplorerApi(
87
+ configFor('etherscan-coin-no-cache'),
88
+ 'etherscan-coin-no-cache'
89
+ )
90
+ const explorerB = getExplorerApi(
91
+ configFor('blockscout-coin-no-cache'),
92
+ 'blockscout-coin-no-cache'
93
+ )
64
94
 
65
95
  expect(explorerA).toBe(etherscanLikeApi.explorerApiNoCache)
66
96
  expect(explorerB).toBe(etherscanLikeApi.explorerApiNoCache)
67
97
  })
68
98
 
69
99
  it('should return the ledger api', () => {
70
- const explorerA = getExplorerApi(configFor('ledger-coin'), { id: 'ledger-coin' } as any)
100
+ const explorerA = getExplorerApi(configFor('ledger-coin'), 'ledger-coin')
71
101
 
72
102
  expect(explorerA).toBe(ledgerExplorerApi)
73
103
  })
@@ -1,12 +1,12 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { EvmConfigInfo } from '../../config'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import type { ExplorerApi } from './types'
5
6
  import { UnknownExplorer } from '../../errors'
6
7
  import etherscanLikeApi from './etherscan'
7
8
  import ledgerExplorerApi from './ledger'
8
9
  import noExplorerAPI from './none'
9
- import { ExplorerApi } from './types'
10
10
 
11
11
  /**
12
12
  * Switch to select one of the compatible explorer
@@ -1,11 +1,12 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { NftStandard } from '../../config'
4
5
  import { AssertionError, fail } from 'assert'
5
6
  import { delay } from '@ledgerhq/coin-module-framework/promises'
6
7
  import axios from 'axios'
7
8
  import eip55 from 'eip55'
8
- import { DEFAULT_LEDGER_EXPLORER_URI, getCoinConfig, NftStandard } from '../../config'
9
+ import { DEFAULT_LEDGER_EXPLORER_URI, getCoinConfig } from '../../config'
9
10
  import { LedgerExplorerUsedIncorrectly } from '../../errors'
10
11
  import {
11
12
  coinOperation1,
@@ -17,7 +18,7 @@ import * as LEDGER_API from './ledger'
17
18
 
18
19
  jest.mock('axios')
19
20
  jest.mock('@ledgerhq/coin-module-framework/promises')
20
- ;(delay as jest.Mock).mockImplementation(
21
+ jest.mocked(delay).mockImplementation(
21
22
  () => new Promise((resolve) => setTimeout(resolve, 1)) // mocking the delay supposed to happen after each try
22
23
  )
23
24
 
@@ -54,7 +55,12 @@ describe('EVM Family', () => {
54
55
  }
55
56
  return { data: { data: [] } }
56
57
  })
57
- const response = await LEDGER_API.fetchPaginatedOpsWithRetries({} as any, null, [], retries)
58
+ const response = await LEDGER_API.fetchPaginatedOpsWithRetries(
59
+ { explorerId: 'test', address: '0x', fromBlock: 0, batchSize: 10 },
60
+ null,
61
+ [],
62
+ retries
63
+ )
58
64
 
59
65
  expect(response).toEqual([])
60
66
  // it should fail 2 times and succeed on the next try
@@ -73,7 +79,10 @@ describe('EVM Family', () => {
73
79
  return { data: { data: [] } }
74
80
  })
75
81
  try {
76
- await LEDGER_API.fetchPaginatedOpsWithRetries({} as any, null)
82
+ await LEDGER_API.fetchPaginatedOpsWithRetries(
83
+ { explorerId: 'test', address: '0x', fromBlock: 0, batchSize: 10 },
84
+ null
85
+ )
77
86
  fail('Promise should have been rejected')
78
87
  } catch (e) {
79
88
  if (e instanceof AssertionError) {
@@ -112,7 +121,10 @@ describe('EVM Family', () => {
112
121
  }
113
122
  })
114
123
 
115
- const response = await LEDGER_API.fetchPaginatedOpsWithRetries({} as any, null)
124
+ const response = await LEDGER_API.fetchPaginatedOpsWithRetries(
125
+ { explorerId: 'test', address: '0x', fromBlock: 0, batchSize: 10 },
126
+ null
127
+ )
116
128
 
117
129
  expect(response).toEqual([coinOperation1, coinOperation2, coinOperation3])
118
130
  })
@@ -1,6 +1,8 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { LedgerExplorerOperation } from '../../types'
5
+ import type { ExplorerApi } from './types'
4
6
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
5
7
  import { delay } from '@ledgerhq/coin-module-framework/promises'
6
8
  import axios from 'axios'
@@ -13,9 +15,8 @@ import {
13
15
  } from '../../adapters/index'
14
16
  import { DEFAULT_LEDGER_EXPLORER_URI } from '../../config'
15
17
  import { LedgerExplorerUsedIncorrectly } from '../../errors'
16
- import { LedgerExplorerOperation } from '../../types'
17
18
  import { nftEnabled } from '../../utils'
18
- import { ExplorerApi, isLedgerExplorerConfig, NO_TOKEN } from './types'
19
+ import { isLedgerExplorerConfig, NO_TOKEN } from './types'
19
20
 
20
21
  export const DEFAULT_BATCH_SIZE = 10_000
21
22
  export const LEDGER_TIMEOUT = 200 // 200ms between 2 calls
@@ -1,7 +1,8 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { ExplorerApi, NO_TOKEN } from './types'
4
+ import type { ExplorerApi } from './types'
5
+ import { NO_TOKEN } from './types'
5
6
 
6
7
  /**
7
8
  * Returns all operation types from an address
@@ -1,8 +1,8 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { EvmConfigInfo } from '../../config'
4
5
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
5
- import { EvmConfigInfo } from '../../config'
6
6
 
7
7
  /** Constant representing no pagination token (end of pagination or first page) */
8
8
  export const NO_TOKEN = ''
@@ -1,18 +1,24 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { EvmConfigInfo } from '../../config'
4
+ import {
5
+ createMockEvmConfigInfo,
6
+ mkLedgerGasTracker,
7
+ mkLedgerNode,
8
+ } from '../../fixtures/context.fixtures'
5
9
  import { getGasOptions as ledgerGetGasOptions } from './ledger'
6
10
  import { getGasTracker } from './index'
7
11
 
8
- const configWithGasTracker = {
9
- node: { type: 'ledger', explorerId: 'eth' },
10
- gasTracker: { type: 'ledger', explorerId: 'eth' },
11
- } as unknown as EvmConfigInfo
12
+ const configWithGasTracker = createMockEvmConfigInfo({
13
+ chainId: 1,
14
+ node: mkLedgerNode({ explorerId: 'eth' }),
15
+ gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
16
+ })
12
17
 
13
- const configWithoutGasTracker = {
14
- node: { type: 'ledger', explorerId: 'eth' },
15
- } as unknown as EvmConfigInfo
18
+ const configWithoutGasTracker = createMockEvmConfigInfo({
19
+ chainId: 1,
20
+ node: mkLedgerNode({ explorerId: 'eth' }),
21
+ })
16
22
 
17
23
  describe('EVM Family', () => {
18
24
  describe('network/gasTracker/index.ts', () => {
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { EvmConfigInfo } from '../../config'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import type { GasTrackerApi } from './types'
5
6
  import ledgerGasTracker from './ledger'
6
- import { GasTrackerApi } from './types'
7
7
 
8
8
  export const getGasTracker = (config: EvmConfigInfo): GasTrackerApi | null => {
9
9
  switch (config?.gasTracker?.type) {
@@ -1,24 +1,28 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { GasOptions } from '../../types'
4
5
  import { AssertionError } from 'assert'
5
6
  import network from '@ledgerhq/live-network/network'
6
7
  import BigNumber from 'bignumber.js'
7
- import { EvmConfigInfo } from '../../config'
8
8
  import { LedgerGasTrackerUsedIncorrectly, NoGasTrackerFound } from '../../errors'
9
- import { GasOptions } from '../../types'
9
+ import {
10
+ createMockEvmConfigInfo,
11
+ mkExternalNode,
12
+ mkLedgerGasTracker,
13
+ mkLedgerNode,
14
+ } from '../../fixtures/context.fixtures'
10
15
  import { getGasOptions } from './ledger'
11
16
 
12
17
  jest.mock('@ledgerhq/live-network/network')
13
18
  const mockedNetwork = jest.mocked(network)
14
19
 
15
- const TEST_EIP1559_BASE_FEE_MULTIPLIER = 2
16
-
17
- const ledgerGasTrackerConfig = {
18
- node: { type: 'ledger', explorerId: 'eth' },
19
- gasTracker: { type: 'ledger', explorerId: 'eth' },
20
- eip1559BaseFeeMultiplier: TEST_EIP1559_BASE_FEE_MULTIPLIER,
21
- } as unknown as EvmConfigInfo
20
+ const ledgerGasTrackerConfig = createMockEvmConfigInfo({
21
+ chainId: 1,
22
+ node: mkLedgerNode({ explorerId: 'eth' }),
23
+ gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
24
+ eip1559BaseFeeMultiplier: 2,
25
+ })
22
26
 
23
27
  describe('EVM Family', () => {
24
28
  describe('network/gasTracker/index.ts', () => {
@@ -96,12 +100,10 @@ describe('EVM Family', () => {
96
100
  },
97
101
  })
98
102
 
99
- Object.entries(gasOptions).forEach(([key, value]) => {
103
+ Object.values(gasOptions).forEach((value) => {
100
104
  const { maxFeePerGas } = value
101
105
 
102
- expect(maxFeePerGas?.isInteger(), `${key}:maxFeePerGas - got ${maxFeePerGas}`).toBe(
103
- true
104
- )
106
+ expect(maxFeePerGas?.isInteger()).toBe(true)
105
107
  })
106
108
  })
107
109
 
@@ -129,24 +131,19 @@ describe('EVM Family', () => {
129
131
  },
130
132
  })
131
133
 
132
- Object.entries(gasOptions).forEach(([key, value]) => {
134
+ Object.values(gasOptions).forEach((value) => {
133
135
  const { maxFeePerGas, maxPriorityFeePerGas, nextBaseFee } = value
134
136
 
135
- expect(maxFeePerGas?.isInteger(), `${key}:maxFeePerGas - got ${maxFeePerGas}`).toBe(
136
- true
137
- )
138
- expect(
139
- maxPriorityFeePerGas?.isInteger(),
140
- `${key}:maxPriorityFeePerGas - got ${maxPriorityFeePerGas}`
141
- ).toBe(true)
142
- expect(nextBaseFee?.isInteger(), `${key}:nextBaseFee - got ${nextBaseFee}`).toBe(true)
137
+ expect(maxFeePerGas?.isInteger()).toBe(true)
138
+ expect(maxPriorityFeePerGas?.isInteger()).toBe(true)
139
+ expect(nextBaseFee?.isInteger()).toBe(true)
143
140
  })
144
141
  })
145
142
 
146
143
  it('should use overrideGasTracker', async () => {
147
144
  await getGasOptions({
148
145
  currencyId: 'ethereum',
149
- config: { gasTracker: { type: 'other', explorerId: 'anything' } } as any,
146
+ config: createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() }),
150
147
  options: {
151
148
  useEIP1559: true,
152
149
  overrideGasTracker: { type: 'ledger', explorerId: 'eth_sepolia' },
@@ -197,7 +194,11 @@ describe('EVM Family', () => {
197
194
  it('should return legacy gas options when EIP-1559 not supported by gas tracker', async () => {
198
195
  const gasOptions: GasOptions = await getGasOptions({
199
196
  currencyId: 'ethereum_classic',
200
- config: { gasTracker: { type: 'ledger', explorerId: 'etc' } } as any,
197
+ config: createMockEvmConfigInfo({
198
+ chainId: 1,
199
+ node: mkExternalNode(),
200
+ gasTracker: mkLedgerGasTracker({ explorerId: 'etc' }),
201
+ }),
201
202
  options: { useEIP1559: true },
202
203
  })
203
204
 
@@ -249,17 +250,17 @@ describe('EVM Family', () => {
249
250
  },
250
251
  })
251
252
 
252
- Object.entries(gasOptions).forEach(([key, value]) => {
253
+ Object.values(gasOptions).forEach((value) => {
253
254
  const { gasPrice } = value
254
255
 
255
- expect(gasPrice?.isInteger(), `${key}:gasPrice - got ${gasPrice}`).toBe(true)
256
+ expect(gasPrice?.isInteger()).toBe(true)
256
257
  })
257
258
  })
258
259
 
259
260
  it('should use overrideGasTracker', async () => {
260
261
  await getGasOptions({
261
262
  currencyId: 'ethereum',
262
- config: { gasTracker: { type: 'other', explorerId: 'anything' } } as any,
263
+ config: createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() }),
263
264
  options: {
264
265
  useEIP1559: false,
265
266
  overrideGasTracker: { type: 'ledger', explorerId: 'eth_sepolia' },
@@ -277,7 +278,7 @@ describe('EVM Family', () => {
277
278
  try {
278
279
  await getGasOptions({
279
280
  currencyId: 'ethereum',
280
- config: { gasTracker: { type: 'wrong', explorerId: 'anything' } } as any,
281
+ config: createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() }),
281
282
  })
282
283
  fail('Promise should have been rejected')
283
284
  } catch (e) {
@@ -292,7 +293,11 @@ describe('EVM Family', () => {
292
293
  try {
293
294
  await getGasOptions({
294
295
  currencyId: 'ethereum',
295
- config: { gasTracker: { type: 'ledger', explorerId: 'anything' } } as any,
296
+ config: createMockEvmConfigInfo({
297
+ chainId: 1,
298
+ node: mkExternalNode(),
299
+ gasTracker: mkLedgerGasTracker({ explorerId: 'anything' }),
300
+ }),
296
301
  })
297
302
  fail('Promise should have been rejected')
298
303
  } catch (e) {
@@ -1,16 +1,14 @@
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 type { GasOptions } from '../../types'
6
+ import type { GasTrackerApi } from './types'
4
7
  import network from '@ledgerhq/live-network/network'
5
8
  import { BigNumber } from 'bignumber.js'
6
- import {
7
- DEFAULT_EIP1559_BASE_FEE_MULTIPLIER,
8
- DEFAULT_LEDGER_EXPLORER_URI,
9
- EvmConfigInfo,
10
- } from '../../config'
9
+ import { DEFAULT_EIP1559_BASE_FEE_MULTIPLIER, DEFAULT_LEDGER_EXPLORER_URI } from '../../config'
11
10
  import { LedgerGasTrackerUsedIncorrectly, NoGasTrackerFound } from '../../errors'
12
- import { GasOptions } from '../../types'
13
- import { GasTrackerApi, isLedgerGasTracker } from './types'
11
+ import { isLedgerGasTracker } from './types'
14
12
 
15
13
  type GasTracker = {
16
14
  compatibilty: {
@@ -1,8 +1,8 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { EvmConfigInfo } from '../../config'
5
- import { GasOptions } from '../../types'
4
+ import type { EvmConfigInfo } from '../../config'
5
+ import type { GasOptions } from '../../types'
6
6
 
7
7
  export type GasTrackerApi = {
8
8
  getGasOptions: ({
@@ -1,57 +1,51 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { EvmConfigInfo } from '../../config'
4
+ import { createMockEvmConfigInfo, mkExternalNode } from '../../fixtures/context.fixtures'
5
5
  import { getNodeApi } from './index'
6
6
 
7
- const externalNodeConfig = (): EvmConfigInfo =>
8
- ({ node: { type: 'external', uri: 'working' } }) as unknown as EvmConfigInfo
9
-
10
7
  describe('getNodeApi memoization', () => {
11
8
  it('should return the same NodeApi instance for same currency and retries (memoization)', () => {
12
- const node1 = getNodeApi(externalNodeConfig(), 'ethereum')
13
- const node2 = getNodeApi(externalNodeConfig(), 'ethereum')
14
-
15
- expect(node1).toBe(node2)
9
+ const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
10
+ expect(getNodeApi(config, 'ethereum')).toBe(getNodeApi(config, 'ethereum'))
16
11
  })
17
12
 
18
13
  it('should return cached NodeApi on subsequent calls (createNodeApi called once)', () => {
19
- const cachedInstance = getNodeApi(externalNodeConfig(), 'cached_value_test')
20
- const second = getNodeApi(externalNodeConfig(), 'cached_value_test')
21
- const third = getNodeApi(externalNodeConfig(), 'cached_value_test')
14
+ const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
15
+ const cachedInstance = getNodeApi(config, 'cached_value_test')
22
16
 
23
- expect(second).toBe(cachedInstance)
24
- expect(third).toBe(cachedInstance)
17
+ expect(getNodeApi(config, 'cached_value_test')).toBe(cachedInstance)
18
+ expect(getNodeApi(config, 'cached_value_test')).toBe(cachedInstance)
25
19
  })
26
20
 
27
- function generateConfig(node: { type: string; uri: string; retries: number }): EvmConfigInfo {
28
- return { node } as unknown as EvmConfigInfo
29
- }
30
21
  it('should return different NodeApi instances for different retries', () => {
31
- const nodeConf1 = { type: 'external', uri: 'u', retries: 2 }
32
- const node1 = getNodeApi(generateConfig(nodeConf1), 'ethereum')
33
-
34
- const nodeConf2 = { ...nodeConf1, retries: 5 }
35
- const node2 = getNodeApi(generateConfig(nodeConf2), 'ethereum')
22
+ const node1 = getNodeApi(
23
+ createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u', retries: 2 }) }),
24
+ 'ethereum'
25
+ )
26
+ const node2 = getNodeApi(
27
+ createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u', retries: 5 }) }),
28
+ 'ethereum'
29
+ )
36
30
  expect(node1).not.toBe(node2)
37
31
  })
38
32
 
39
33
  it('should return different NodeApi instances for different uris', () => {
40
- const nodeConf1 = { type: 'external', uri: 'u1', retries: 2 }
41
- const node1 = getNodeApi(generateConfig(nodeConf1), 'ethereum')
42
-
43
- const nodeConf2 = { ...nodeConf1, uri: 'u2' }
44
- const node2 = getNodeApi(generateConfig(nodeConf2), 'ethereum')
34
+ const node1 = getNodeApi(
35
+ createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u1' }) }),
36
+ 'ethereum'
37
+ )
38
+ const node2 = getNodeApi(
39
+ createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u2' }) }),
40
+ 'ethereum'
41
+ )
45
42
 
46
43
  expect(node1).not.toBe(node2)
47
44
  })
48
45
 
49
46
  it('should return different NodeApi instances for different currencies', () => {
50
- const conf = generateConfig({ type: 'external', uri: 'u1', retries: 2 })
51
-
52
- const node1 = getNodeApi(conf, 'ethereum1')
53
- const node2 = getNodeApi(conf, 'ethereum2')
47
+ const conf = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u1' }) })
54
48
 
55
- expect(node1).not.toBe(node2)
49
+ expect(getNodeApi(conf, 'ethereum1')).not.toBe(getNodeApi(conf, 'ethereum2'))
56
50
  })
57
51
  })
@@ -1,36 +1,27 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { AssertionError, fail } from 'assert'
5
4
  import { UnknownNode } from '../../errors'
5
+ import {
6
+ createMockEvmConfigInfo,
7
+ mkExternalNode,
8
+ mkLedgerNode,
9
+ } from '../../fixtures/context.fixtures'
6
10
  import { getNodeApi } from './index'
7
11
 
8
12
  describe('EVM Family', () => {
9
13
  describe('network/node/index.ts', () => {
10
14
  describe('getNodeApi', () => {
11
- it('should throw when requesting a non existing node type', async () => {
12
- try {
13
- getNodeApi(
14
- {
15
- node: { type: 'anything', uri: 'notworking' },
16
- } as any,
17
- { id: 'not-existing' } as any
18
- )
19
- fail('Promise should have been rejected')
20
- } catch (e) {
21
- if (e instanceof AssertionError) {
22
- throw e
23
- }
24
- expect(e).toBeInstanceOf(UnknownNode)
25
- }
15
+ it('should throw when requesting a non existing node type', () => {
16
+ const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
17
+ Object.assign(config, { node: { type: 'anything', uri: 'notworking' } })
18
+ expect(() => getNodeApi(config, 'not-existing')).toThrow(UnknownNode)
26
19
  })
27
20
 
28
- it('should return the rpc api', async () => {
21
+ it('should return the rpc api', () => {
29
22
  const node = getNodeApi(
30
- {
31
- node: { type: 'external', uri: 'working' },
32
- } as any,
33
- { id: 'external' } as any
23
+ createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'working' }) }),
24
+ 'external'
34
25
  )
35
26
 
36
27
  expect(node).toEqual(
@@ -50,10 +41,8 @@ describe('EVM Family', () => {
50
41
 
51
42
  it('should return the ledger api', () => {
52
43
  const node = getNodeApi(
53
- {
54
- node: { type: 'ledger', explorerId: 'eth' },
55
- } as any,
56
- { id: 'ledger-supported' } as any
44
+ createMockEvmConfigInfo({ chainId: 1, node: mkLedgerNode({ explorerId: 'eth' }) }),
45
+ 'ledger-supported'
57
46
  )
58
47
 
59
48
  expect(node).toEqual(