@ledgerhq/coin-evm 7.0.0 → 9.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 (297) hide show
  1. package/.oxlintrc.json +1 -1
  2. package/CHANGELOG.md +62 -0
  3. package/docs/getBlock-internal-txs-schema.md +1 -1
  4. package/docs/network/node/index.md +3 -1
  5. package/lib/adapters/blockOperations.d.ts +4 -3
  6. package/lib/adapters/blockOperations.d.ts.map +1 -1
  7. package/lib/adapters/blockOperations.js +17 -17
  8. package/lib/adapters/blockOperations.js.map +1 -1
  9. package/lib/adapters/etherscan.d.ts +7 -6
  10. package/lib/adapters/etherscan.d.ts.map +1 -1
  11. package/lib/adapters/etherscan.js +19 -19
  12. package/lib/adapters/etherscan.js.map +1 -1
  13. package/lib/adapters/ledger.d.ts +6 -5
  14. package/lib/adapters/ledger.d.ts.map +1 -1
  15. package/lib/adapters/ledger.js +15 -15
  16. package/lib/adapters/ledger.js.map +1 -1
  17. package/lib/api/index.d.ts.map +1 -1
  18. package/lib/api/index.js +1 -2
  19. package/lib/api/index.js.map +1 -1
  20. package/lib/config.d.ts +0 -1
  21. package/lib/config.d.ts.map +1 -1
  22. package/lib/logic/common.js +1 -1
  23. package/lib/logic/common.js.map +1 -1
  24. package/lib/logic/getBalance.d.ts.map +1 -1
  25. package/lib/logic/getBalance.js +3 -3
  26. package/lib/logic/getBalance.js.map +1 -1
  27. package/lib/logic/getBlock.d.ts.map +1 -1
  28. package/lib/logic/getBlock.js +22 -23
  29. package/lib/logic/getBlock.js.map +1 -1
  30. package/lib/logic/getStakes.d.ts.map +1 -1
  31. package/lib/logic/getStakes.js +2 -2
  32. package/lib/logic/getStakes.js.map +1 -1
  33. package/lib/logic/internalTransactionsFetcher.d.ts +3 -2
  34. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  35. package/lib/logic/internalTransactionsFetcher.js +13 -10
  36. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  37. package/lib/logic/listOperations.js +1 -1
  38. package/lib/logic/listOperations.js.map +1 -1
  39. package/lib/logic-public/utils.d.ts +3 -2
  40. package/lib/logic-public/utils.d.ts.map +1 -1
  41. package/lib/logic-public/utils.js +7 -6
  42. package/lib/logic-public/utils.js.map +1 -1
  43. package/lib/network/explorer/etherscan.d.ts +3 -2
  44. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  45. package/lib/network/explorer/etherscan.js +13 -12
  46. package/lib/network/explorer/etherscan.js.map +1 -1
  47. package/lib/network/explorer/ledger.d.ts.map +1 -1
  48. package/lib/network/explorer/ledger.js +11 -11
  49. package/lib/network/explorer/ledger.js.map +1 -1
  50. package/lib/network/explorer/types.d.ts +2 -2
  51. package/lib/network/explorer/types.d.ts.map +1 -1
  52. package/lib/network/explorer/types.js.map +1 -1
  53. package/lib/network/node/explorerProxy.js +3 -3
  54. package/lib/network/node/explorerProxy.js.map +1 -1
  55. package/lib/network/node/index.d.ts.map +1 -1
  56. package/lib/network/node/index.js +2 -2
  57. package/lib/network/node/index.js.map +1 -1
  58. package/lib/network/node/ledger.d.ts +2 -1
  59. package/lib/network/node/ledger.d.ts.map +1 -1
  60. package/lib/network/node/ledger.js +9 -10
  61. package/lib/network/node/ledger.js.map +1 -1
  62. package/lib/network/node/rpc.common.d.ts +3 -2
  63. package/lib/network/node/rpc.common.d.ts.map +1 -1
  64. package/lib/network/node/rpc.common.js +37 -29
  65. package/lib/network/node/rpc.common.js.map +1 -1
  66. package/lib/staking/contracts.js +2 -2
  67. package/lib/staking/contracts.js.map +1 -1
  68. package/lib/staking/fetchers.d.ts.map +1 -1
  69. package/lib/staking/fetchers.js +7 -7
  70. package/lib/staking/fetchers.js.map +1 -1
  71. package/lib/staking/prepareIntents.d.ts +2 -1
  72. package/lib/staking/prepareIntents.d.ts.map +1 -1
  73. package/lib/staking/prepareIntents.js +4 -4
  74. package/lib/staking/prepareIntents.js.map +1 -1
  75. package/lib/staking/redelegations.d.ts +5 -4
  76. package/lib/staking/redelegations.d.ts.map +1 -1
  77. package/lib/staking/redelegations.js +13 -14
  78. package/lib/staking/redelegations.js.map +1 -1
  79. package/lib/staking/rewards.d.ts +2 -1
  80. package/lib/staking/rewards.d.ts.map +1 -1
  81. package/lib/staking/rewards.js +4 -5
  82. package/lib/staking/rewards.js.map +1 -1
  83. package/lib/staking/rewardsFromReceipt.d.ts +2 -1
  84. package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
  85. package/lib/staking/rewardsFromReceipt.js +2 -3
  86. package/lib/staking/rewardsFromReceipt.js.map +1 -1
  87. package/lib/staking/unbondings.d.ts +2 -1
  88. package/lib/staking/unbondings.d.ts.map +1 -1
  89. package/lib/staking/unbondings.js +4 -5
  90. package/lib/staking/unbondings.js.map +1 -1
  91. package/lib/staking/validators/index.d.ts +9 -4
  92. package/lib/staking/validators/index.d.ts.map +1 -1
  93. package/lib/staking/validators/index.js +19 -10
  94. package/lib/staking/validators/index.js.map +1 -1
  95. package/lib/staking/validators/monad.d.ts +6 -5
  96. package/lib/staking/validators/monad.d.ts.map +1 -1
  97. package/lib/staking/validators/monad.js +33 -29
  98. package/lib/staking/validators/monad.js.map +1 -1
  99. package/lib/staking/validators/monadResolver.d.ts +2 -1
  100. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  101. package/lib/staking/validators/monadResolver.js +2 -3
  102. package/lib/staking/validators/monadResolver.js.map +1 -1
  103. package/lib/staking/validators/somnia.d.ts +3 -2
  104. package/lib/staking/validators/somnia.d.ts.map +1 -1
  105. package/lib/staking/validators/somnia.js +16 -15
  106. package/lib/staking/validators/somnia.js.map +1 -1
  107. package/lib/staking/validators/types.d.ts +2 -1
  108. package/lib/staking/validators/types.d.ts.map +1 -1
  109. package/lib/staking/validators/zero_gravity.d.ts +2 -1
  110. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  111. package/lib/staking/validators/zero_gravity.js +7 -8
  112. package/lib/staking/validators/zero_gravity.js.map +1 -1
  113. package/lib/types/staking.d.ts +4 -3
  114. package/lib/types/staking.d.ts.map +1 -1
  115. package/lib-es/adapters/blockOperations.d.ts +4 -3
  116. package/lib-es/adapters/blockOperations.d.ts.map +1 -1
  117. package/lib-es/adapters/blockOperations.js +17 -17
  118. package/lib-es/adapters/blockOperations.js.map +1 -1
  119. package/lib-es/adapters/etherscan.d.ts +7 -6
  120. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  121. package/lib-es/adapters/etherscan.js +19 -19
  122. package/lib-es/adapters/etherscan.js.map +1 -1
  123. package/lib-es/adapters/ledger.d.ts +6 -5
  124. package/lib-es/adapters/ledger.d.ts.map +1 -1
  125. package/lib-es/adapters/ledger.js +15 -15
  126. package/lib-es/adapters/ledger.js.map +1 -1
  127. package/lib-es/api/index.d.ts.map +1 -1
  128. package/lib-es/api/index.js +1 -2
  129. package/lib-es/api/index.js.map +1 -1
  130. package/lib-es/config.d.ts +0 -1
  131. package/lib-es/config.d.ts.map +1 -1
  132. package/lib-es/logic/common.js +1 -1
  133. package/lib-es/logic/common.js.map +1 -1
  134. package/lib-es/logic/getBalance.d.ts.map +1 -1
  135. package/lib-es/logic/getBalance.js +3 -3
  136. package/lib-es/logic/getBalance.js.map +1 -1
  137. package/lib-es/logic/getBlock.d.ts.map +1 -1
  138. package/lib-es/logic/getBlock.js +22 -23
  139. package/lib-es/logic/getBlock.js.map +1 -1
  140. package/lib-es/logic/getStakes.d.ts.map +1 -1
  141. package/lib-es/logic/getStakes.js +2 -2
  142. package/lib-es/logic/getStakes.js.map +1 -1
  143. package/lib-es/logic/internalTransactionsFetcher.d.ts +3 -2
  144. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  145. package/lib-es/logic/internalTransactionsFetcher.js +13 -10
  146. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  147. package/lib-es/logic/listOperations.js +1 -1
  148. package/lib-es/logic/listOperations.js.map +1 -1
  149. package/lib-es/logic-public/utils.d.ts +3 -2
  150. package/lib-es/logic-public/utils.d.ts.map +1 -1
  151. package/lib-es/logic-public/utils.js +7 -6
  152. package/lib-es/logic-public/utils.js.map +1 -1
  153. package/lib-es/network/explorer/etherscan.d.ts +3 -2
  154. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  155. package/lib-es/network/explorer/etherscan.js +13 -12
  156. package/lib-es/network/explorer/etherscan.js.map +1 -1
  157. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  158. package/lib-es/network/explorer/ledger.js +11 -11
  159. package/lib-es/network/explorer/ledger.js.map +1 -1
  160. package/lib-es/network/explorer/types.d.ts +2 -2
  161. package/lib-es/network/explorer/types.d.ts.map +1 -1
  162. package/lib-es/network/explorer/types.js.map +1 -1
  163. package/lib-es/network/node/explorerProxy.js +3 -3
  164. package/lib-es/network/node/explorerProxy.js.map +1 -1
  165. package/lib-es/network/node/index.d.ts.map +1 -1
  166. package/lib-es/network/node/index.js +2 -2
  167. package/lib-es/network/node/index.js.map +1 -1
  168. package/lib-es/network/node/ledger.d.ts +2 -1
  169. package/lib-es/network/node/ledger.d.ts.map +1 -1
  170. package/lib-es/network/node/ledger.js +9 -10
  171. package/lib-es/network/node/ledger.js.map +1 -1
  172. package/lib-es/network/node/rpc.common.d.ts +3 -2
  173. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  174. package/lib-es/network/node/rpc.common.js +37 -29
  175. package/lib-es/network/node/rpc.common.js.map +1 -1
  176. package/lib-es/staking/contracts.js +2 -2
  177. package/lib-es/staking/contracts.js.map +1 -1
  178. package/lib-es/staking/fetchers.d.ts.map +1 -1
  179. package/lib-es/staking/fetchers.js +7 -7
  180. package/lib-es/staking/fetchers.js.map +1 -1
  181. package/lib-es/staking/prepareIntents.d.ts +2 -1
  182. package/lib-es/staking/prepareIntents.d.ts.map +1 -1
  183. package/lib-es/staking/prepareIntents.js +4 -4
  184. package/lib-es/staking/prepareIntents.js.map +1 -1
  185. package/lib-es/staking/redelegations.d.ts +5 -4
  186. package/lib-es/staking/redelegations.d.ts.map +1 -1
  187. package/lib-es/staking/redelegations.js +13 -14
  188. package/lib-es/staking/redelegations.js.map +1 -1
  189. package/lib-es/staking/rewards.d.ts +2 -1
  190. package/lib-es/staking/rewards.d.ts.map +1 -1
  191. package/lib-es/staking/rewards.js +4 -5
  192. package/lib-es/staking/rewards.js.map +1 -1
  193. package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
  194. package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
  195. package/lib-es/staking/rewardsFromReceipt.js +2 -3
  196. package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
  197. package/lib-es/staking/unbondings.d.ts +2 -1
  198. package/lib-es/staking/unbondings.d.ts.map +1 -1
  199. package/lib-es/staking/unbondings.js +4 -5
  200. package/lib-es/staking/unbondings.js.map +1 -1
  201. package/lib-es/staking/validators/index.d.ts +9 -4
  202. package/lib-es/staking/validators/index.d.ts.map +1 -1
  203. package/lib-es/staking/validators/index.js +18 -10
  204. package/lib-es/staking/validators/index.js.map +1 -1
  205. package/lib-es/staking/validators/monad.d.ts +6 -5
  206. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  207. package/lib-es/staking/validators/monad.js +33 -29
  208. package/lib-es/staking/validators/monad.js.map +1 -1
  209. package/lib-es/staking/validators/monadResolver.d.ts +2 -1
  210. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  211. package/lib-es/staking/validators/monadResolver.js +2 -3
  212. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  213. package/lib-es/staking/validators/somnia.d.ts +3 -2
  214. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  215. package/lib-es/staking/validators/somnia.js +16 -15
  216. package/lib-es/staking/validators/somnia.js.map +1 -1
  217. package/lib-es/staking/validators/types.d.ts +2 -1
  218. package/lib-es/staking/validators/types.d.ts.map +1 -1
  219. package/lib-es/staking/validators/zero_gravity.d.ts +2 -1
  220. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  221. package/lib-es/staking/validators/zero_gravity.js +7 -8
  222. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  223. package/lib-es/types/staking.d.ts +4 -3
  224. package/lib-es/types/staking.d.ts.map +1 -1
  225. package/package.json +4 -4
  226. package/src/adapters/blockOperations.test.ts +86 -67
  227. package/src/adapters/blockOperations.ts +28 -17
  228. package/src/adapters/etherscan.test.ts +151 -85
  229. package/src/adapters/etherscan.ts +27 -18
  230. package/src/adapters/ledger.test.ts +210 -83
  231. package/src/adapters/ledger.ts +21 -15
  232. package/src/api/getBlock.integ.test.ts +10 -4
  233. package/src/api/index.arbitrum.integ.test.ts +1 -0
  234. package/src/api/index.arc.integ.test.ts +1 -0
  235. package/src/api/index.avalanche_c_chain_fuji.integ.test.ts +1 -0
  236. package/src/api/index.cronos.integ.test.ts +1 -0
  237. package/src/api/index.flare.integ.test.ts +4 -2
  238. package/src/api/index.integ.test.ts +7 -6
  239. package/src/api/index.linea.integ.test.ts +4 -2
  240. package/src/api/index.optimism.integ.test.ts +1 -0
  241. package/src/api/index.rsk.integ.test.ts +1 -0
  242. package/src/api/index.shape.integ.test.ts +4 -2
  243. package/src/api/index.somnia.integ.test.ts +1 -0
  244. package/src/api/index.test.ts +2 -2
  245. package/src/api/index.ts +1 -2
  246. package/src/config.ts +0 -1
  247. package/src/fixtures/context.fixtures.ts +5 -5
  248. package/src/logic/common.ts +1 -1
  249. package/src/logic/getBalance.ts +4 -3
  250. package/src/logic/getBlock.ts +43 -27
  251. package/src/logic/getStakes.ts +2 -1
  252. package/src/logic/internalTransactionsFetcher.ts +16 -10
  253. package/src/logic/listOperations.ts +2 -2
  254. package/src/logic/tests/getBalance.test.ts +5 -3
  255. package/src/logic/tests/getBlock.test.ts +16 -15
  256. package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -5
  257. package/src/logic/tests/listOperations.test.ts +4 -4
  258. package/src/logic-public/tests/utils.test.ts +6 -5
  259. package/src/logic-public/utils.ts +8 -5
  260. package/src/logic.test.ts +5 -5
  261. package/src/network/explorer/etherscan.test.ts +169 -55
  262. package/src/network/explorer/etherscan.ts +27 -16
  263. package/src/network/explorer/index.test.ts +2 -1
  264. package/src/network/explorer/ledger.test.ts +208 -35
  265. package/src/network/explorer/ledger.ts +12 -8
  266. package/src/network/explorer/types.ts +3 -2
  267. package/src/network/node/explorerProxy.ts +3 -3
  268. package/src/network/node/index.ts +3 -2
  269. package/src/network/node/ledger.test.ts +25 -25
  270. package/src/network/node/ledger.ts +13 -10
  271. package/src/network/node/node.fixtures.ts +2 -1
  272. package/src/network/node/rpc.common.ts +84 -28
  273. package/src/network/node/rpc.test.ts +45 -31
  274. package/src/staking/contracts.ts +2 -2
  275. package/src/staking/fetchers.ts +20 -8
  276. package/src/staking/prepareIntents.test.ts +33 -12
  277. package/src/staking/prepareIntents.ts +9 -5
  278. package/src/staking/redelegations.test.ts +98 -35
  279. package/src/staking/redelegations.ts +20 -12
  280. package/src/staking/rewards.test.ts +15 -10
  281. package/src/staking/rewards.ts +8 -5
  282. package/src/staking/rewardsFromReceipt.test.ts +5 -4
  283. package/src/staking/rewardsFromReceipt.ts +4 -3
  284. package/src/staking/unbondings.test.ts +16 -12
  285. package/src/staking/unbondings.ts +7 -5
  286. package/src/staking/validators/index.ts +30 -10
  287. package/src/staking/validators/monad.test.ts +57 -43
  288. package/src/staking/validators/monad.ts +55 -32
  289. package/src/staking/validators/monadResolver.ts +4 -3
  290. package/src/staking/validators/somnia.test.ts +14 -13
  291. package/src/staking/validators/somnia.ts +35 -19
  292. package/src/staking/validators/types.ts +2 -0
  293. package/src/staking/validators/zero_gravity.test.ts +48 -26
  294. package/src/staking/validators/zero_gravity.ts +14 -8
  295. package/src/staking/validators.integ.test.ts +2 -2
  296. package/src/staking/validators.test.ts +31 -26
  297. package/src/types/staking.ts +9 -2
@@ -5,7 +5,7 @@ import type { EvmConfigInfo } from '../config'
5
5
  import type { InternalTxSource } from '../internalTxSources'
6
6
  import type { NodeApi } from '../network/node/types'
7
7
  import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
8
- import { log } from '@ledgerhq/logs'
8
+ import type { Logger } from '@ledgerhq/coin-module-framework/config'
9
9
  import { traceBlockItemsToOperationsByHash } from '../adapters/blockOperations'
10
10
  import { internalTxsToOperationsByHash } from '../adapters/etherscan'
11
11
  import { SourceUnavailableError } from '../errors'
@@ -71,14 +71,15 @@ export function composeInternalTxsFetcher(
71
71
  export function makeSourceFetchers(
72
72
  config: EvmConfigInfo,
73
73
  nodeApi: NodeApi,
74
- currencyId: string
74
+ currencyId: string,
75
+ logger: Logger
75
76
  ): Record<InternalTxSource, SourceFetcher> {
76
77
  const { explorer } = config || {}
77
78
 
78
79
  return {
79
80
  trace_block: (height: number) => {
80
81
  if (nodeApi.traceBlockErigon === undefined) {
81
- log('coin-evm', 'debug: trace_block internal tx source unavailable', {
82
+ logger('coin-evm', 'debug: trace_block internal tx source unavailable', {
82
83
  currencyId,
83
84
  blockHeight: height,
84
85
  })
@@ -86,11 +87,13 @@ export function makeSourceFetchers(
86
87
  new SourceUnavailableError('trace_block is not supported by this RPC provider')
87
88
  )
88
89
  }
89
- return nodeApi.traceBlockErigon(currencyId, height).then(traceBlockItemsToOperationsByHash)
90
+ return nodeApi
91
+ .traceBlockErigon(currencyId, height)
92
+ .then((items) => traceBlockItemsToOperationsByHash(items, logger))
90
93
  },
91
94
  debug_traceBlockByNumber: (height: number) => {
92
95
  if (nodeApi.traceBlockGeth === undefined) {
93
- log('coin-evm', 'debug: debug_traceBlockByNumber internal tx source unavailable', {
96
+ logger('coin-evm', 'debug: debug_traceBlockByNumber internal tx source unavailable', {
94
97
  currencyId,
95
98
  blockHeight: height,
96
99
  })
@@ -100,7 +103,9 @@ export function makeSourceFetchers(
100
103
  )
101
104
  )
102
105
  }
103
- return nodeApi.traceBlockGeth(currencyId, height).then(traceBlockItemsToOperationsByHash)
106
+ return nodeApi
107
+ .traceBlockGeth(currencyId, height)
108
+ .then((items) => traceBlockItemsToOperationsByHash(items, logger))
104
109
  },
105
110
  explorer: (height: number) => {
106
111
  if (!isEtherscanLikeExplorerConfig(explorer)) {
@@ -111,9 +116,9 @@ export function makeSourceFetchers(
111
116
  )
112
117
  }
113
118
  return getInternalTransactionsByBlock(config, height)
114
- .then(internalTxsToOperationsByHash)
119
+ .then((txs) => internalTxsToOperationsByHash(txs, logger))
115
120
  .catch((error) => {
116
- log('coin-evm', 'debug: explorer internal txs failed, falling through', {
121
+ logger('coin-evm', 'debug: explorer internal txs failed, falling through', {
117
122
  currencyId,
118
123
  blockHeight: height,
119
124
  error,
@@ -129,7 +134,8 @@ export function createInternalTransactionsFetcher(
129
134
  config: EvmConfigInfo,
130
135
  nodeApi: NodeApi,
131
136
  currencyId: string,
132
- sources: readonly InternalTxSource[]
137
+ sources: readonly InternalTxSource[],
138
+ logger: Logger
133
139
  ): SourceFetcher {
134
- return composeInternalTxsFetcher(sources, makeSourceFetchers(config, nodeApi, currencyId))
140
+ return composeInternalTxsFetcher(sources, makeSourceFetchers(config, nodeApi, currencyId, logger))
135
141
  }
@@ -70,14 +70,14 @@ export async function listOperations(
70
70
  nextPagingToken,
71
71
  } = await explorerApi.getOperations(
72
72
  config,
73
+ context.logger,
73
74
  currencyId,
74
75
  address,
75
76
  options.minHeight,
76
77
  undefined,
77
78
  options.cursor,
78
79
  options.limit,
79
- explorerOrder,
80
- context.logger
80
+ explorerOrder
81
81
  )
82
82
 
83
83
  const tokenOrNftHashes = new Set(
@@ -427,6 +427,7 @@ describe('getBalance', () => {
427
427
  })
428
428
 
429
429
  expect(discoverTokenAssets).toHaveBeenCalledWith(
430
+ expect.anything(),
430
431
  expect.anything(),
431
432
  'currency',
432
433
  'address',
@@ -445,6 +446,7 @@ describe('getBalance', () => {
445
446
  // A resume without the known set drops every asset whose last transfer predates that
446
447
  // height, and the framework reads a missing asset as a zero balance on a held token.
447
448
  expect(discoverTokenAssets).toHaveBeenCalledWith(
449
+ expect.anything(),
448
450
  expect.anything(),
449
451
  'currency',
450
452
  'address',
@@ -550,9 +552,10 @@ describe('getBalance', () => {
550
552
 
551
553
  const result = await getBalance(context, 'monad', 'address')
552
554
 
553
- // The explorer's `getOperations` now takes the logger as its last argument; the walk this
555
+ // The explorer's `getOperations` takes the logger as its second argument; the walk this
554
556
  // branch reuses passes it like every other caller.
555
557
  expect(getOperations).toHaveBeenCalledWith(
558
+ expect.anything(),
556
559
  expect.anything(),
557
560
  'monad',
558
561
  'address',
@@ -560,8 +563,7 @@ describe('getBalance', () => {
560
563
  undefined,
561
564
  undefined,
562
565
  undefined,
563
- undefined,
564
- expect.anything()
566
+ undefined
565
567
  )
566
568
  expect(discoverTokenAssets).not.toHaveBeenCalled()
567
569
  expect(result).toEqual([
@@ -21,6 +21,7 @@ import {
21
21
  mkExternalNode,
22
22
  mkEtherscanExplorer,
23
23
  mkLedgerExplorer,
24
+ testLogger,
24
25
  } from '../../fixtures/context.fixtures'
25
26
  import { safeEncodeEIP55 } from '../../logic-public'
26
27
  import { getInternalTransactionsByBlock } from '../../network/explorer/etherscan'
@@ -325,7 +326,7 @@ describe('getBlock', () => {
325
326
  hash: '0xtx1',
326
327
  details: {
327
328
  contractInteraction: 'SmartContractInteraction',
328
- contractAddress: safeEncodeEIP55(address2),
329
+ contractAddress: safeEncodeEIP55(address2, testLogger),
329
330
  contractPayload: calldata,
330
331
  },
331
332
  })
@@ -370,7 +371,7 @@ describe('getBlock', () => {
370
371
  hash: '0xdeploy',
371
372
  details: {
372
373
  contractInteraction: 'SmartContractDeployment',
373
- contractAddress: safeEncodeEIP55(address2),
374
+ contractAddress: safeEncodeEIP55(address2, testLogger),
374
375
  contractPayload: initCode,
375
376
  },
376
377
  })
@@ -450,7 +451,7 @@ describe('getBlock', () => {
450
451
  hash: '0xtx1',
451
452
  details: {
452
453
  contractInteraction: 'SmartContractInteraction',
453
- contractAddress: safeEncodeEIP55(address2),
454
+ contractAddress: safeEncodeEIP55(address2, testLogger),
454
455
  contractPayload: calldata,
455
456
  },
456
457
  })
@@ -629,8 +630,8 @@ describe('getBlock', () => {
629
630
 
630
631
  const result = await getBlock(context, '', 12345)
631
632
 
632
- const encodedFrom = safeEncodeEIP55(address1)
633
- const encodedTo = safeEncodeEIP55(address2)
633
+ const encodedFrom = safeEncodeEIP55(address1, testLogger)
634
+ const encodedTo = safeEncodeEIP55(address2, testLogger)
634
635
  expect(result).toMatchObject({
635
636
  info: {
636
637
  height: 12345,
@@ -767,13 +768,13 @@ describe('getBlock', () => {
767
768
  expect(nativeOps).toEqual(
768
769
  expect.arrayContaining([
769
770
  expect.objectContaining({
770
- address: safeEncodeEIP55(address2),
771
- peer: safeEncodeEIP55(nestedRecipient),
771
+ address: safeEncodeEIP55(address2, testLogger),
772
+ peer: safeEncodeEIP55(nestedRecipient, testLogger),
772
773
  amount: -nestedAmount,
773
774
  }),
774
775
  expect.objectContaining({
775
- address: safeEncodeEIP55(nestedRecipient),
776
- peer: safeEncodeEIP55(address2),
776
+ address: safeEncodeEIP55(nestedRecipient, testLogger),
777
+ peer: safeEncodeEIP55(address2, testLogger),
777
778
  amount: nestedAmount,
778
779
  }),
779
780
  ])
@@ -814,8 +815,8 @@ describe('getBlock', () => {
814
815
  expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
815
816
  expect(mockTraceBlock).toHaveBeenCalledWith(expect.anything(), 12345)
816
817
 
817
- const encodedFrom = safeEncodeEIP55(address1)
818
- const encodedTo = safeEncodeEIP55(address2)
818
+ const encodedFrom = safeEncodeEIP55(address1, testLogger)
819
+ const encodedTo = safeEncodeEIP55(address2, testLogger)
819
820
  expect(result.transactions[0].operations).toEqual(
820
821
  expect.arrayContaining([
821
822
  expect.objectContaining({
@@ -955,8 +956,8 @@ describe('getBlock', () => {
955
956
  const result = await getBlock(context, '', 12345)
956
957
 
957
958
  expect(mockTraceBlock).toHaveBeenCalledWith(expect.anything(), 12345)
958
- const encodedFrom = safeEncodeEIP55(address1)
959
- const encodedTo = safeEncodeEIP55(address2)
959
+ const encodedFrom = safeEncodeEIP55(address1, testLogger)
960
+ const encodedTo = safeEncodeEIP55(address2, testLogger)
960
961
  expect(result).toMatchObject({
961
962
  info: {
962
963
  height: 12345,
@@ -1113,8 +1114,8 @@ describe('getBlock', () => {
1113
1114
 
1114
1115
  expect(mockTraceBlockErigon).toHaveBeenCalledWith(expect.anything(), 12345)
1115
1116
  expect(mockTraceBlockGeth).toHaveBeenCalledWith(expect.anything(), 12345)
1116
- const encodedFrom = safeEncodeEIP55(address1)
1117
- const encodedTo = safeEncodeEIP55(address2)
1117
+ const encodedFrom = safeEncodeEIP55(address1, testLogger)
1118
+ const encodedTo = safeEncodeEIP55(address2, testLogger)
1118
1119
  expect(result.transactions[0].operations).toEqual(
1119
1120
  expect.arrayContaining([
1120
1121
  expect.objectContaining({
@@ -10,6 +10,7 @@ import {
10
10
  mkEtherscanExplorer,
11
11
  mkExternalNode,
12
12
  mkLedgerExplorer,
13
+ testLogger,
13
14
  } from '../../fixtures/context.fixtures'
14
15
  import { getInternalTransactionsByBlock } from '../../network/explorer/etherscan'
15
16
  import { mockNodeApi } from '../../network/node/node.fixtures'
@@ -175,7 +176,7 @@ describe('makeSourceFetchers', () => {
175
176
  explorer: mkLedgerExplorer(),
176
177
  })
177
178
 
178
- const fetchers = makeSourceFetchers(config, mockNodeApi(), '')
179
+ const fetchers = makeSourceFetchers(config, mockNodeApi(), '', testLogger)
179
180
  await expect(fetchers.explorer(1)).rejects.toBeInstanceOf(SourceUnavailableError)
180
181
  })
181
182
 
@@ -183,7 +184,7 @@ describe('makeSourceFetchers', () => {
183
184
  const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
184
185
 
185
186
  const { traceBlockErigon: _traceBlockErigon, ...nodeApiWithoutErigon } = mockNodeApi()
186
- const fetchers = makeSourceFetchers(config, nodeApiWithoutErigon, '')
187
+ const fetchers = makeSourceFetchers(config, nodeApiWithoutErigon, '', testLogger)
187
188
  await expect(fetchers.trace_block(1)).rejects.toBeInstanceOf(SourceUnavailableError)
188
189
  })
189
190
 
@@ -197,7 +198,7 @@ describe('makeSourceFetchers', () => {
197
198
  const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
198
199
  mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
199
200
 
200
- const fetchers = makeSourceFetchers(config, mockNodeApi(), 'ethereum')
201
+ const fetchers = makeSourceFetchers(config, mockNodeApi(), 'ethereum', testLogger)
201
202
  await expect(fetchers.explorer(99)).rejects.toBeInstanceOf(SourceUnavailableError)
202
203
  })
203
204
 
@@ -211,7 +212,7 @@ describe('makeSourceFetchers', () => {
211
212
  const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
212
213
  mockGetInternalTransactionsByBlock.mockResolvedValueOnce([])
213
214
 
214
- const fetchers = makeSourceFetchers(config, mockNodeApi(), 'ethereum')
215
+ const fetchers = makeSourceFetchers(config, mockNodeApi(), 'ethereum', testLogger)
215
216
  await fetchers.explorer(99)
216
217
 
217
218
  expect(mockGetInternalTransactionsByBlock).toHaveBeenCalledWith(config, 99)
@@ -220,7 +221,7 @@ describe('makeSourceFetchers', () => {
220
221
  it('empty always resolves to an empty map', async () => {
221
222
  const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
222
223
 
223
- const fetchers = makeSourceFetchers(config, mockNodeApi(), '')
224
+ const fetchers = makeSourceFetchers(config, mockNodeApi(), '', testLogger)
224
225
  await expect(fetchers.empty(1)).resolves.toEqual(new Map<string, BlockOperation[]>())
225
226
  })
226
227
  })
@@ -567,6 +567,7 @@ describe('listOperations', () => {
567
567
  calls: [
568
568
  [
569
569
  expect.anything(),
570
+ testContext.logger,
570
571
  currency,
571
572
  address,
572
573
  minHeight,
@@ -575,7 +576,6 @@ describe('listOperations', () => {
575
576
  // defaults to "desc" without limit
576
577
  undefinedLimit,
577
578
  'desc',
578
- testContext.logger,
579
579
  ],
580
580
  ],
581
581
  })
@@ -1208,9 +1208,9 @@ describe('listOperations', () => {
1208
1208
  expect(result.length).toBeGreaterThan(1)
1209
1209
 
1210
1210
  // check how the explorer is called
1211
- const actualExplorerLimit = getOperationsSpy.mock.calls[0][6]
1211
+ const actualExplorerLimit = getOperationsSpy.mock.calls[0][7]
1212
1212
  expect(actualExplorerLimit).toBe(limit)
1213
- const actualExplorerOrder = getOperationsSpy.mock.calls[0][7]
1213
+ const actualExplorerOrder = getOperationsSpy.mock.calls[0][8]
1214
1214
  expect(actualExplorerOrder).toBe(expectedExplorerOrder)
1215
1215
 
1216
1216
  // check the result order
@@ -1562,7 +1562,7 @@ describe('listOperations', () => {
1562
1562
  }
1563
1563
  return jest
1564
1564
  .spyOn(ledgerExplorer, 'getOperations')
1565
- .mockImplementation(async (_currency, _config, queriedAddress) => {
1565
+ .mockImplementation(async (_config, _logger, _currencyId, queriedAddress) => {
1566
1566
  const coinOps: Array<Operation<MemoNotSupported>> = (
1567
1567
  response.lastCoinOperations ?? []
1568
1568
  ).map((op, i) => ({
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { testLogger } from '../../fixtures/context.fixtures'
4
5
  import { buildSmartContractDetails, isSmartContractInput, safeEncodeEIP55 } from '../utils'
5
6
 
6
7
  describe('isSmartContractInput', () => {
@@ -30,7 +31,7 @@ describe('buildSmartContractDetails', () => {
30
31
  ] as const)(
31
32
  'classifies sentinel to %s with calldata as deployment and omits contractAddress without deployed address',
32
33
  (to, input) => {
33
- expect(buildSmartContractDetails(to, input)).toEqual({
34
+ expect(buildSmartContractDetails(to, input, testLogger)).toEqual({
34
35
  contractInteraction: 'SmartContractDeployment',
35
36
  contractPayload: calldata,
36
37
  })
@@ -39,22 +40,22 @@ describe('buildSmartContractDetails', () => {
39
40
 
40
41
  it('sets contractAddress from deployed address when to is sentinel', () => {
41
42
  const deployed = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
42
- expect(buildSmartContractDetails('0x', calldata, deployed)).toEqual({
43
+ expect(buildSmartContractDetails('0x', calldata, testLogger, deployed)).toEqual({
43
44
  contractInteraction: 'SmartContractDeployment',
44
- contractAddress: safeEncodeEIP55(deployed),
45
+ contractAddress: safeEncodeEIP55(deployed, testLogger),
45
46
  contractPayload: calldata,
46
47
  })
47
48
  })
48
49
 
49
50
  it('normalizes uppercase 0X hex prefix to a single 0x-prefixed payload', () => {
50
- expect(buildSmartContractDetails(undefined, '0Xabcdef')).toEqual({
51
+ expect(buildSmartContractDetails(undefined, '0Xabcdef', testLogger)).toEqual({
51
52
  contractInteraction: 'SmartContractDeployment',
52
53
  contractPayload: '0xabcdef',
53
54
  })
54
55
  })
55
56
 
56
57
  it('builds contractPayload from trim-aware input (matches isSmartContractInput)', () => {
57
- expect(buildSmartContractDetails(undefined, ' 0xabcdef ')).toEqual({
58
+ expect(buildSmartContractDetails(undefined, ' 0xabcdef ', testLogger)).toEqual({
58
59
  contractInteraction: 'SmartContractDeployment',
59
60
  contractPayload: '0xabcdef',
60
61
  })
@@ -5,7 +5,7 @@ import type {
5
5
  StakingTransactionIntent,
6
6
  TransactionIntent,
7
7
  } from '@ledgerhq/coin-module-framework/api/types'
8
- import { log } from '@ledgerhq/logs'
8
+ import type { Logger } from '@ledgerhq/coin-module-framework/config'
9
9
  import BigNumber from 'bignumber.js'
10
10
  import eip55 from 'eip55'
11
11
 
@@ -26,7 +26,7 @@ import eip55 from 'eip55'
26
26
  * For now this has only been observed on the from or to fields of an operation
27
27
  * so we only use this function for these fields.
28
28
  */
29
- export const safeEncodeEIP55 = (addr: string): string => {
29
+ export const safeEncodeEIP55 = (addr: string, logger: Logger): string => {
30
30
  if (!addr || addr === '0x' || addr === '0x0') {
31
31
  return ''
32
32
  }
@@ -34,7 +34,7 @@ export const safeEncodeEIP55 = (addr: string): string => {
34
34
  try {
35
35
  return eip55.encode(addr)
36
36
  } catch (e) {
37
- log('EVM Family - utils.ts', 'Failed to eip55 encode address', {
37
+ logger('EVM Family - utils.ts', 'Failed to eip55 encode address', {
38
38
  address: addr,
39
39
  error: e,
40
40
  })
@@ -110,20 +110,23 @@ export function isSmartContractInput(input: string | null | undefined): input is
110
110
  export function buildSmartContractDetails(
111
111
  to: string | undefined,
112
112
  input: string | undefined,
113
+ logger: Logger,
113
114
  deployedContractAddress?: string | undefined
114
115
  ): Record<string, unknown> | undefined {
115
116
  if (!isSmartContractInput(input)) {
116
117
  return undefined
117
118
  }
118
119
  const trimmedInput = input.trim()
119
- const encodedTo = to ? safeEncodeEIP55(to) : ''
120
+ const encodedTo = to ? safeEncodeEIP55(to, logger) : ''
120
121
  const contractInteraction: ContractInteractionKind = encodedTo
121
122
  ? 'SmartContractInteraction'
122
123
  : 'SmartContractDeployment'
123
124
  const contractPayload = /^0x/i.test(trimmedInput)
124
125
  ? `0x${trimmedInput.slice(2)}`
125
126
  : `0x${trimmedInput}`
126
- const encodedDeployed = deployedContractAddress ? safeEncodeEIP55(deployedContractAddress) : ''
127
+ const encodedDeployed = deployedContractAddress
128
+ ? safeEncodeEIP55(deployedContractAddress, logger)
129
+ : ''
127
130
  const contractAddress = encodedDeployed || encodedTo
128
131
  return {
129
132
  contractInteraction,
package/src/logic.test.ts CHANGED
@@ -55,31 +55,31 @@ describe('EVM Family', () => {
55
55
  describe('safeEncodeEIP55', () => {
56
56
  it('Should return encoded address if valid address', () => {
57
57
  const address = '0x9aa99c23f67c81701c772b106b4f83f6e858dd2e'
58
- const encodedAddress = safeEncodeEIP55(address)
58
+ const encodedAddress = safeEncodeEIP55(address, testLogger)
59
59
  expect(encodedAddress).toBe('0x9AA99C23F67c81701C772B106b4F83f6e858dd2E')
60
60
  })
61
61
 
62
62
  it('Should return empty string if empty address', () => {
63
63
  const address = ''
64
- const encodedAddress = safeEncodeEIP55(address)
64
+ const encodedAddress = safeEncodeEIP55(address, testLogger)
65
65
  expect(encodedAddress).toBe('')
66
66
  })
67
67
 
68
68
  it('Should return empty string if 0x0 address', () => {
69
69
  const address = '0x0'
70
- const encodedAddress = safeEncodeEIP55(address)
70
+ const encodedAddress = safeEncodeEIP55(address, testLogger)
71
71
  expect(encodedAddress).toBe('')
72
72
  })
73
73
 
74
74
  it('Should return empty string if 0x address', () => {
75
75
  const address = '0x'
76
- const encodedAddress = safeEncodeEIP55(address)
76
+ const encodedAddress = safeEncodeEIP55(address, testLogger)
77
77
  expect(encodedAddress).toBe('')
78
78
  })
79
79
 
80
80
  it('Should return address if invalid address', () => {
81
81
  const address = '0x00000'
82
- const encodedAddress = safeEncodeEIP55(address)
82
+ const encodedAddress = safeEncodeEIP55(address, testLogger)
83
83
  expect(encodedAddress).toBe(address)
84
84
  })
85
85
  })