@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
@@ -6,6 +6,7 @@ import type { OperationLike } from './redelegations'
6
6
  import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
7
7
  import { BigNumber } from 'bignumber.js'
8
8
  import { ethers } from 'ethers'
9
+ import { testLogger } from '../fixtures/context.fixtures'
9
10
  import { getStakingABI } from './abis'
10
11
  import { STAKING_CONTRACTS } from './contracts'
11
12
  import {
@@ -40,6 +41,7 @@ const mockConfig: EvmConfigInfo = {
40
41
  status: { type: 'active' },
41
42
  chainId: 1,
42
43
  name: 'Test EVM',
44
+ unit: { name: 'test', code: 'TEST', magnitude: 18 },
43
45
  node: mockNode,
44
46
  explorer: { type: 'none' },
45
47
  }
@@ -92,11 +94,11 @@ describe('redelegations', () => {
92
94
  })
93
95
 
94
96
  it('should return [] for an unknown currencyId', async () => {
95
- expect(await fetchRedelegations(mockConfig, 'unknown_chain', '0xabc')).toEqual([])
97
+ expect(await fetchRedelegations(mockConfig, 'unknown_chain', '0xabc', testLogger)).toEqual([])
96
98
  })
97
99
 
98
100
  it("should return [] when the strategy type is 'none'", async () => {
99
- expect(await fetchRedelegations(mockConfig, 'celo', '0xabc')).toEqual([])
101
+ expect(await fetchRedelegations(mockConfig, 'celo', '0xabc', testLogger)).toEqual([])
100
102
  })
101
103
 
102
104
  it('should return [] when the network call fails', async () => {
@@ -105,7 +107,8 @@ describe('redelegations', () => {
105
107
  await fetchRedelegations(
106
108
  mockConfig,
107
109
  'sei_evm',
108
- '0x1234567890abcdef1234567890abcdef12345678'
110
+ '0x1234567890abcdef1234567890abcdef12345678',
111
+ testLogger
109
112
  )
110
113
  ).toEqual([])
111
114
  })
@@ -116,7 +119,8 @@ describe('redelegations', () => {
116
119
  await fetchRedelegations(
117
120
  mockConfig,
118
121
  'sei_evm',
119
- '0x1234567890abcdef1234567890abcdef12345678'
122
+ '0x1234567890abcdef1234567890abcdef12345678',
123
+ testLogger
120
124
  )
121
125
  ).toEqual([])
122
126
  })
@@ -148,7 +152,8 @@ describe('redelegations', () => {
148
152
  await fetchRedelegations(
149
153
  mockConfig,
150
154
  'sei_evm',
151
- '0x1234567890abcdef1234567890abcdef12345678'
155
+ '0x1234567890abcdef1234567890abcdef12345678',
156
+ testLogger
152
157
  )
153
158
  ).toEqual([])
154
159
  })
@@ -179,7 +184,8 @@ describe('redelegations', () => {
179
184
  const result = await fetchRedelegations(
180
185
  mockConfig,
181
186
  'sei_evm',
182
- '0x1234567890abcdef1234567890abcdef12345678'
187
+ '0x1234567890abcdef1234567890abcdef12345678',
188
+ testLogger
183
189
  )
184
190
  expect(result).toHaveLength(1)
185
191
  expect(result[0].validatorSrcAddress).toBe('seivaloper1src')
@@ -200,7 +206,7 @@ describe('redelegations', () => {
200
206
  mockGetSeiAddr.mockResolvedValueOnce(canonicalCosmosAddress)
201
207
  mockNetwork.mockResolvedValueOnce({ data: { redelegation_responses: [] } })
202
208
 
203
- await fetchRedelegations(mockConfig, 'sei_evm', evmAddress)
209
+ await fetchRedelegations(mockConfig, 'sei_evm', evmAddress, testLogger)
204
210
 
205
211
  expect(mockNetwork).toHaveBeenCalledTimes(1)
206
212
  expect(mockNetwork).toHaveBeenCalledWith(
@@ -219,7 +225,8 @@ describe('redelegations', () => {
219
225
  await fetchRedelegations(
220
226
  mockConfig,
221
227
  'sei_evm',
222
- '0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3'
228
+ '0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3',
229
+ testLogger
223
230
  )
224
231
  ).toEqual([])
225
232
  expect(mockNetwork).not.toHaveBeenCalled()
@@ -238,7 +245,7 @@ describe('redelegations', () => {
238
245
  const calldata = encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI)
239
246
  const op = makeOperation({ type: 'REDELEGATE', extra: { contractPayload: calldata } })
240
247
 
241
- const result = await resolveRedelegationValidators(mockConfig, SEI_CURRENCY, op)
248
+ const result = await resolveRedelegationValidators(mockConfig, SEI_CURRENCY, op, testLogger)
242
249
 
243
250
  expect(result).toMatchObject({
244
251
  srcValidatorAddress: SRC,
@@ -258,7 +265,8 @@ describe('redelegations', () => {
258
265
  const result = await resolveRedelegationValidators(
259
266
  mockConfig,
260
267
  SEI_CURRENCY,
261
- makeOperation({ type: 'REDELEGATE', extra: {} })
268
+ makeOperation({ type: 'REDELEGATE', extra: {} }),
269
+ testLogger
262
270
  )
263
271
 
264
272
  expect(result).toMatchObject({
@@ -274,7 +282,8 @@ describe('redelegations', () => {
274
282
  const result = await resolveRedelegationValidators(
275
283
  mockConfig,
276
284
  SEI_CURRENCY,
277
- makeOperation({ type: 'REDELEGATE', extra: {} })
285
+ makeOperation({ type: 'REDELEGATE', extra: {} }),
286
+ testLogger
278
287
  )
279
288
  expect(result).toBeNull()
280
289
  })
@@ -284,12 +293,16 @@ describe('redelegations', () => {
284
293
  type: 'REDELEGATE',
285
294
  extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
286
295
  })
287
- expect(await resolveRedelegationValidators(mockConfig, 'unsupported', op)).toBeNull()
296
+ expect(
297
+ await resolveRedelegationValidators(mockConfig, 'unsupported', op, testLogger)
298
+ ).toBeNull()
288
299
  })
289
300
 
290
301
  it('should return null for malformed calldata', async () => {
291
302
  const op = makeOperation({ type: 'REDELEGATE', extra: { contractPayload: '0xdeadbeef' } })
292
- expect(await resolveRedelegationValidators(mockConfig, SEI_CURRENCY, op)).toBeNull()
303
+ expect(
304
+ await resolveRedelegationValidators(mockConfig, SEI_CURRENCY, op, testLogger)
305
+ ).toBeNull()
293
306
  })
294
307
  })
295
308
 
@@ -305,7 +318,9 @@ describe('redelegations', () => {
305
318
  type: 'DELEGATE',
306
319
  extra: { contractPayload: encodeDelegateCalldata(VALIDATOR) },
307
320
  })
308
- expect(await resolveStakingValidator(mockConfig, 'unsupported', op, 'delegate')).toBeNull()
321
+ expect(
322
+ await resolveStakingValidator(mockConfig, 'unsupported', op, 'delegate', testLogger)
323
+ ).toBeNull()
309
324
  })
310
325
 
311
326
  describe('delegate (Monad, id-keyed validatorId)', () => {
@@ -338,7 +353,13 @@ describe('redelegations', () => {
338
353
  })
339
354
  )
340
355
 
341
- const result = await resolveStakingValidator(mockConfig, 'monad', op, 'delegate')
356
+ const result = await resolveStakingValidator(
357
+ mockConfig,
358
+ 'monad',
359
+ op,
360
+ 'delegate',
361
+ testLogger
362
+ )
342
363
 
343
364
  expect(result).toMatchObject({
344
365
  validatorAddress: ethers.computeAddress(
@@ -360,7 +381,13 @@ describe('redelegations', () => {
360
381
  },
361
382
  })
362
383
 
363
- const result = await resolveStakingValidator(mockConfig, 'zero_gravity', op, 'delegate')
384
+ const result = await resolveStakingValidator(
385
+ mockConfig,
386
+ 'zero_gravity',
387
+ op,
388
+ 'delegate',
389
+ testLogger
390
+ )
364
391
 
365
392
  expect(result).toMatchObject({
366
393
  validatorAddress: '0x2222222222222222222222222222222222222222',
@@ -390,6 +417,7 @@ describe('redelegations', () => {
390
417
  status: { type: 'active' },
391
418
  chainId: 1,
392
419
  name: 'Test EVM',
420
+ unit: { name: 'test', code: 'TEST', magnitude: 18 },
393
421
  node: zgNode,
394
422
  explorer: { type: 'none' },
395
423
  }
@@ -402,7 +430,13 @@ describe('redelegations', () => {
402
430
  })
403
431
  )
404
432
 
405
- const result = await resolveStakingValidator(zgConfig, 'zero_gravity', op, 'undelegate')
433
+ const result = await resolveStakingValidator(
434
+ zgConfig,
435
+ 'zero_gravity',
436
+ op,
437
+ 'undelegate',
438
+ testLogger
439
+ )
406
440
 
407
441
  expect(result).toEqual({
408
442
  validatorAddress: '0x3333333333333333333333333333333333333333',
@@ -418,7 +452,13 @@ describe('redelegations', () => {
418
452
  extra: { contractPayload: encodeDelegateCalldata(VALIDATOR) },
419
453
  })
420
454
 
421
- const result = await resolveStakingValidator(mockConfig, SEI_CURRENCY, op, 'delegate')
455
+ const result = await resolveStakingValidator(
456
+ mockConfig,
457
+ SEI_CURRENCY,
458
+ op,
459
+ 'delegate',
460
+ testLogger
461
+ )
422
462
 
423
463
  expect(result).toMatchObject({ validatorAddress: VALIDATOR })
424
464
  })
@@ -434,7 +474,8 @@ describe('redelegations', () => {
434
474
  mockConfig,
435
475
  SEI_CURRENCY,
436
476
  makeOperation({ type: 'DELEGATE', extra: {} }),
437
- 'delegate'
477
+ 'delegate',
478
+ testLogger
438
479
  )
439
480
 
440
481
  expect(result).toMatchObject({ validatorAddress: VALIDATOR })
@@ -448,7 +489,8 @@ describe('redelegations', () => {
448
489
  mockConfig,
449
490
  SEI_CURRENCY,
450
491
  makeOperation({ type: 'DELEGATE', extra: {} }),
451
- 'delegate'
492
+ 'delegate',
493
+ testLogger
452
494
  )
453
495
  ).toBeNull()
454
496
  })
@@ -461,7 +503,13 @@ describe('redelegations', () => {
461
503
  extra: { contractPayload: encodeUndelegateCalldata(VALIDATOR, AMOUNT_USEI) },
462
504
  })
463
505
 
464
- const result = await resolveStakingValidator(mockConfig, SEI_CURRENCY, op, 'undelegate')
506
+ const result = await resolveStakingValidator(
507
+ mockConfig,
508
+ SEI_CURRENCY,
509
+ op,
510
+ 'undelegate',
511
+ testLogger
512
+ )
465
513
 
466
514
  expect(result).toMatchObject({ validatorAddress: VALIDATOR })
467
515
  expect(result!.amount?.isEqualTo(EXPECTED_WEI.toString())).toBe(true)
@@ -482,7 +530,8 @@ describe('redelegations', () => {
482
530
  mockConfig,
483
531
  SEI_CURRENCY,
484
532
  makeOperation({ type: 'UNDELEGATE', extra: {} }),
485
- 'undelegate'
533
+ 'undelegate',
534
+ testLogger
486
535
  )
487
536
 
488
537
  expect(result).toMatchObject({ validatorAddress: VALIDATOR })
@@ -493,7 +542,9 @@ describe('redelegations', () => {
493
542
  type: 'UNDELEGATE',
494
543
  extra: { contractPayload: '0xdeadbeef' },
495
544
  })
496
- expect(await resolveStakingValidator(mockConfig, SEI_CURRENCY, op, 'undelegate')).toBeNull()
545
+ expect(
546
+ await resolveStakingValidator(mockConfig, SEI_CURRENCY, op, 'undelegate', testLogger)
547
+ ).toBeNull()
497
548
  })
498
549
  })
499
550
  })
@@ -508,14 +559,17 @@ describe('redelegations', () => {
508
559
  beforeEach(() => jest.clearAllMocks())
509
560
 
510
561
  it('should return [] for an unsupported currencyId', async () => {
511
- expect(await buildRedelegationsFromOps(mockConfig, 'unsupported', [])).toEqual([])
562
+ expect(await buildRedelegationsFromOps(mockConfig, 'unsupported', [], testLogger)).toEqual([])
512
563
  })
513
564
 
514
565
  it('should ignore non-REDELEGATE operations', async () => {
515
566
  expect(
516
- await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [
517
- makeOperation({ type: 'DELEGATE' }),
518
- ])
567
+ await buildRedelegationsFromOps(
568
+ mockConfig,
569
+ SEI_CURRENCY,
570
+ [makeOperation({ type: 'DELEGATE' })],
571
+ testLogger
572
+ )
519
573
  ).toEqual([])
520
574
  })
521
575
 
@@ -526,7 +580,9 @@ describe('redelegations', () => {
526
580
  extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
527
581
  date: new Date(),
528
582
  })
529
- expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op])).toEqual([])
583
+ expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op], testLogger)).toEqual(
584
+ []
585
+ )
530
586
  })
531
587
 
532
588
  it('should ignore operations whose unbonding period has already elapsed', async () => {
@@ -535,7 +591,9 @@ describe('redelegations', () => {
535
591
  extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
536
592
  date: new Date(Date.now() - unbondingMs - 1000),
537
593
  })
538
- expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op])).toEqual([])
594
+ expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op], testLogger)).toEqual(
595
+ []
596
+ )
539
597
  })
540
598
 
541
599
  it('should build a redelegation from a recent REDELEGATE op with cached calldata', async () => {
@@ -545,7 +603,7 @@ describe('redelegations', () => {
545
603
  date: new Date(),
546
604
  })
547
605
 
548
- const result = await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op])
606
+ const result = await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op], testLogger)
549
607
 
550
608
  expect(result).toHaveLength(1)
551
609
  expect(result[0]).toMatchObject({
@@ -566,9 +624,12 @@ describe('redelegations', () => {
566
624
  })
567
625
  )
568
626
 
569
- const result = await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [
570
- makeOperation({ type: 'REDELEGATE', extra: {}, date: new Date() }),
571
- ])
627
+ const result = await buildRedelegationsFromOps(
628
+ mockConfig,
629
+ SEI_CURRENCY,
630
+ [makeOperation({ type: 'REDELEGATE', extra: {}, date: new Date() })],
631
+ testLogger
632
+ )
572
633
 
573
634
  expect(result).toHaveLength(1)
574
635
  expect(result[0].validatorSrcAddress).toBe(SRC)
@@ -580,7 +641,9 @@ describe('redelegations', () => {
580
641
  extra: { contractPayload: '0xdeadbeef' },
581
642
  date: new Date(),
582
643
  })
583
- expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op])).toEqual([])
644
+ expect(await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, [op], testLogger)).toEqual(
645
+ []
646
+ )
584
647
  })
585
648
 
586
649
  it('should process multiple operations correctly', async () => {
@@ -597,7 +660,7 @@ describe('redelegations', () => {
597
660
  }),
598
661
  ]
599
662
 
600
- const result = await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, ops)
663
+ const result = await buildRedelegationsFromOps(mockConfig, SEI_CURRENCY, ops, testLogger)
601
664
  expect(result).toHaveLength(2)
602
665
  expect(result[0].validatorSrcAddress).toBe(SRC)
603
666
  expect(result[1].validatorSrcAddress).toBe(DST)
@@ -3,8 +3,8 @@
3
3
 
4
4
  import type { EvmConfigInfo } from '../config'
5
5
  import type { RedelegationStrategy } from '../types/staking'
6
+ import type { Logger } from '@ledgerhq/coin-module-framework/config'
6
7
  import network from '@ledgerhq/live-network'
7
- import { log } from '@ledgerhq/logs'
8
8
  import { BigNumber } from 'bignumber.js'
9
9
  import { ethers } from 'ethers'
10
10
  import { withApi } from '../network/node/rpc.common'
@@ -108,6 +108,7 @@ async function fetchCosmosRestRedelegations(
108
108
  strategy: Extract<RedelegationStrategy, { type: 'cosmos-rest' }>,
109
109
  evmAddress: string,
110
110
  calldataAmountScale: bigint,
111
+ logger: Logger,
111
112
  evmRpcUrl?: string,
112
113
  precompileAddress?: { address: string; abi: string }
113
114
  ): Promise<EvmRedelegation[]> {
@@ -121,7 +122,7 @@ async function fetchCosmosRestRedelegations(
121
122
  const res = await network<CosmosRedelegationsApiResponse>({ url, method: 'GET' })
122
123
  data = res.data
123
124
  } catch (e) {
124
- log('coin-evm/staking', 'fetchCosmosRestRedelegations: REST request failed', {
125
+ logger('coin-evm/staking', 'fetchCosmosRestRedelegations: REST request failed', {
125
126
  url,
126
127
  error: e instanceof Error ? e.message : String(e),
127
128
  })
@@ -167,7 +168,8 @@ async function fetchCosmosRestRedelegations(
167
168
  export async function fetchRedelegations(
168
169
  evmConfig: EvmConfigInfo,
169
170
  currencyId: string,
170
- evmAddress: string
171
+ evmAddress: string,
172
+ logger: Logger
171
173
  ): Promise<EvmRedelegation[]> {
172
174
  const config = STAKING_CONTRACTS[currencyId]
173
175
  const strategy = config?.redelegationStrategy
@@ -183,6 +185,7 @@ export async function fetchRedelegations(
183
185
  strategy,
184
186
  evmAddress,
185
187
  config.calldataAmountScale ?? 1n,
188
+ logger,
186
189
  evmRpcUrl,
187
190
  config.apiConfig.precompileAddress
188
191
  )
@@ -207,7 +210,8 @@ function isRecord(value: unknown): value is Record<string, unknown> {
207
210
  async function fetchTxDataFromRpc(
208
211
  config: EvmConfigInfo,
209
212
  currencyId: string,
210
- txHash: string
213
+ txHash: string,
214
+ logger: Logger
211
215
  ): Promise<string | undefined> {
212
216
  try {
213
217
  const node = config.node
@@ -223,7 +227,7 @@ async function fetchTxDataFromRpc(
223
227
  )
224
228
  return data && data !== '0x' ? data : undefined
225
229
  } catch (e) {
226
- log('coin-evm/staking', 'fetchTxDataFromRpc: getTransaction failed', {
230
+ logger('coin-evm/staking', 'fetchTxDataFromRpc: getTransaction failed', {
227
231
  currencyId,
228
232
  txHash,
229
233
  error: e instanceof Error ? e.message : String(e),
@@ -244,7 +248,8 @@ async function fetchTxDataFromRpc(
244
248
  export async function resolveRedelegationValidators(
245
249
  evmConfig: EvmConfigInfo,
246
250
  currencyId: string,
247
- operation: OperationLike
251
+ operation: OperationLike,
252
+ logger: Logger
248
253
  ): Promise<{
249
254
  srcValidatorAddress: string
250
255
  dstValidatorAddress: string
@@ -255,7 +260,7 @@ export async function resolveRedelegationValidators(
255
260
  const payload =
256
261
  typeof cached === 'string'
257
262
  ? cached
258
- : await fetchTxDataFromRpc(evmConfig, currencyId, operation.hash)
263
+ : await fetchTxDataFromRpc(evmConfig, currencyId, operation.hash, logger)
259
264
 
260
265
  if (!payload) return null
261
266
 
@@ -296,14 +301,15 @@ export async function resolveStakingValidator(
296
301
  evmConfig: EvmConfigInfo,
297
302
  currencyId: string,
298
303
  operation: OperationLike,
299
- operationType: 'delegate' | 'undelegate' | 'withdraw'
304
+ operationType: 'delegate' | 'undelegate' | 'withdraw',
305
+ logger: Logger
300
306
  ): Promise<{ validatorAddress: string; amount: BigNumber | null } | null> {
301
307
  const extra = isRecord(operation.extra) ? operation.extra : undefined
302
308
  const cached = extra?.contractPayload
303
309
  const payload =
304
310
  typeof cached === 'string'
305
311
  ? cached
306
- : await fetchTxDataFromRpc(evmConfig, currencyId, operation.hash)
312
+ : await fetchTxDataFromRpc(evmConfig, currencyId, operation.hash, logger)
307
313
 
308
314
  if (!payload) return null
309
315
 
@@ -318,7 +324,8 @@ export async function resolveStakingValidator(
318
324
  const validatorAddress = await config.resolveValidatorAddress(
319
325
  evmConfig,
320
326
  d,
321
- operation.recipients[0]
327
+ operation.recipients[0],
328
+ logger
322
329
  )
323
330
  if (!validatorAddress) return null
324
331
 
@@ -339,7 +346,8 @@ export async function resolveStakingValidator(
339
346
  export async function buildRedelegationsFromOps(
340
347
  evmConfig: EvmConfigInfo,
341
348
  currencyId: string,
342
- operations: OperationLike[]
349
+ operations: OperationLike[],
350
+ logger: Logger
343
351
  ): Promise<EvmRedelegation[]> {
344
352
  const config = STAKING_CONTRACTS[currencyId]
345
353
  if (!config?.functions.redelegate) return []
@@ -367,7 +375,7 @@ export async function buildRedelegationsFromOps(
367
375
  const payload =
368
376
  typeof cached === 'string'
369
377
  ? cached
370
- : await fetchTxDataFromRpc(evmConfig, currencyId, op.hash)
378
+ : await fetchTxDataFromRpc(evmConfig, currencyId, op.hash, logger)
371
379
  if (!payload) return null
372
380
  try {
373
381
  const d = iface.decodeFunctionData(functionName, payload)
@@ -3,7 +3,7 @@
3
3
 
4
4
  import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
5
5
  import { ethers } from 'ethers'
6
- import { createMockEvmConfigInfo, mkExternalNode } from '../fixtures/context.fixtures'
6
+ import { createMockEvmConfigInfo, mkExternalNode, testLogger } from '../fixtures/context.fixtures'
7
7
  import { fetchRewards } from './rewards'
8
8
  import { USEI_TO_EVM_SCALE } from './utils'
9
9
 
@@ -74,7 +74,7 @@ describe('fetchRewards', () => {
74
74
  },
75
75
  ])('returns an empty map when $case', async ({ currencyId, setup }) => {
76
76
  setup()
77
- expect(await fetchRewards(mockConfig, currencyId, EVM_ADDRESS)).toEqual(new Map())
77
+ expect(await fetchRewards(mockConfig, currencyId, EVM_ADDRESS, testLogger)).toEqual(new Map())
78
78
  })
79
79
 
80
80
  it('resolves the EVM address to its canonical Cosmos bech32 via the precompile', async () => {
@@ -82,7 +82,12 @@ describe('fetchRewards', () => {
82
82
  mockGetSeiAddr.mockResolvedValueOnce(canonicalCosmosAddress)
83
83
  mockNetwork.mockResolvedValueOnce(restResponse([]))
84
84
 
85
- await fetchRewards(mockConfig, 'sei_evm', '0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3')
85
+ await fetchRewards(
86
+ mockConfig,
87
+ 'sei_evm',
88
+ '0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3',
89
+ testLogger
90
+ )
86
91
 
87
92
  expect(mockNetwork.mock.calls[0][0]).toMatchObject({
88
93
  url: expect.stringContaining(canonicalCosmosAddress),
@@ -100,7 +105,7 @@ describe('fetchRewards', () => {
100
105
  ])
101
106
  )
102
107
 
103
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS)
108
+ const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
104
109
 
105
110
  expect(result.size).toBe(1)
106
111
  expect(result.get('seivaloper1one')).toBe(569n * USEI_TO_EVM_SCALE)
@@ -119,7 +124,7 @@ describe('fetchRewards', () => {
119
124
  ])
120
125
  )
121
126
 
122
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS)
127
+ const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
123
128
 
124
129
  expect(result.get('seivaloper1one')).toBe(123n * USEI_TO_EVM_SCALE)
125
130
  })
@@ -137,7 +142,7 @@ describe('fetchRewards', () => {
137
142
  ])
138
143
  )
139
144
 
140
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS)
145
+ const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
141
146
 
142
147
  expect(result.get('seivaloper1one')).toBe(500n * USEI_TO_EVM_SCALE)
143
148
  })
@@ -153,7 +158,7 @@ describe('fetchRewards', () => {
153
158
  ])
154
159
  )
155
160
 
156
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS)
161
+ const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
157
162
 
158
163
  expect(result.has('seivaloper1dust')).toBe(false)
159
164
  expect(result.get('seivaloper1real')).toBe(42n * USEI_TO_EVM_SCALE)
@@ -168,7 +173,7 @@ describe('fetchRewards', () => {
168
173
  ])
169
174
  )
170
175
 
171
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS)
176
+ const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
172
177
 
173
178
  expect(result.size).toBe(3)
174
179
  expect(result.get('seivaloper1a')).toBe(10n * USEI_TO_EVM_SCALE)
@@ -186,7 +191,7 @@ describe('fetchRewards', () => {
186
191
  ])
187
192
  )
188
193
 
189
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS)
194
+ const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
190
195
 
191
196
  expect(result.has('seivaloper1bad')).toBe(false)
192
197
  })
@@ -204,7 +209,7 @@ describe('fetchRewards', () => {
204
209
  ])
205
210
  )
206
211
 
207
- const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS)
212
+ const result = await fetchRewards(mockConfig, 'sei_evm', EVM_ADDRESS, testLogger)
208
213
 
209
214
  expect(result.get('seivaloper1mixed')).toBe(100n * USEI_TO_EVM_SCALE)
210
215
  })
@@ -3,8 +3,8 @@
3
3
 
4
4
  import type { EvmConfigInfo } from '../config'
5
5
  import type { RewardsStrategy } from '../types/staking'
6
+ import type { Logger } from '@ledgerhq/coin-module-framework/config'
6
7
  import network from '@ledgerhq/live-network'
7
- import { log } from '@ledgerhq/logs'
8
8
  import { isExternalNodeConfig } from '../network/node/types'
9
9
  import { STAKING_CONTRACTS } from './contracts'
10
10
  import { getCosmosAddr } from './redelegations'
@@ -22,7 +22,8 @@ async function fetchCosmosRestRewards(
22
22
  strategy: Extract<RewardsStrategy, { type: 'cosmos-rest' }>,
23
23
  evmAddress: string,
24
24
  evmRpcUrl: string,
25
- precompileAddress: { address: string; abi: string }
25
+ precompileAddress: { address: string; abi: string },
26
+ logger: Logger
26
27
  ): Promise<Map<string, bigint>> {
27
28
  const cosmosAddress = await getCosmosAddr(evmRpcUrl, precompileAddress, evmAddress)
28
29
  if (!cosmosAddress) return new Map()
@@ -45,7 +46,7 @@ async function fetchCosmosRestRewards(
45
46
  }
46
47
  return result
47
48
  } catch (e) {
48
- log('coin-evm/staking', 'fetchCosmosRestRewards: REST request or response parsing failed', {
49
+ logger('coin-evm/staking', 'fetchCosmosRestRewards: REST request or response parsing failed', {
49
50
  url,
50
51
  error: e instanceof Error ? e.message : String(e),
51
52
  })
@@ -59,7 +60,8 @@ async function fetchCosmosRestRewards(
59
60
  export async function fetchRewards(
60
61
  evmConfig: EvmConfigInfo,
61
62
  currencyId: string,
62
- evmAddress: string
63
+ evmAddress: string,
64
+ logger: Logger
63
65
  ): Promise<Map<string, bigint>> {
64
66
  try {
65
67
  const config = STAKING_CONTRACTS[currencyId]
@@ -78,7 +80,8 @@ export async function fetchRewards(
78
80
  strategy,
79
81
  evmAddress,
80
82
  evmRpcUrl,
81
- apiConfig.precompileAddress
83
+ apiConfig.precompileAddress,
84
+ logger
82
85
  )
83
86
  }
84
87
  default:
@@ -3,6 +3,7 @@
3
3
 
4
4
  import type { LogWithAddress } from '../network/node/types'
5
5
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
6
+ import { testLogger } from '../fixtures/context.fixtures'
6
7
  import { STAKING_CONTRACTS } from './contracts'
7
8
  import { enrichRewardOperationsValue, sumRewardFromReceiptLogs } from './rewardsFromReceipt'
8
9
 
@@ -107,7 +108,7 @@ describe('enrichRewardOperationsValue', () => {
107
108
  .fn()
108
109
  .mockResolvedValue({ logs: [monadClaimRewardsLog(MONAD_DELEGATOR_TOPIC, '030405ea888e')] })
109
110
 
110
- await enrichRewardOperationsValue('monad', [op], getReceipt)
111
+ await enrichRewardOperationsValue('monad', [op], getReceipt, testLogger)
111
112
 
112
113
  expect(getReceipt).toHaveBeenCalledWith('0xabc')
113
114
  expect(op.value).toStrictEqual(3315814008974n)
@@ -117,7 +118,7 @@ describe('enrichRewardOperationsValue', () => {
117
118
  const op = rewardOp('0xabc', MONAD_DELEGATOR)
118
119
  const getReceipt = jest.fn()
119
120
 
120
- await enrichRewardOperationsValue('ethereum', [op], getReceipt)
121
+ await enrichRewardOperationsValue('ethereum', [op], getReceipt, testLogger)
121
122
 
122
123
  expect(getReceipt).not.toHaveBeenCalled()
123
124
  expect(op.value).toStrictEqual(0n)
@@ -134,7 +135,7 @@ describe('enrichRewardOperationsValue', () => {
134
135
  }
135
136
  const getReceipt = jest.fn().mockResolvedValue(null)
136
137
 
137
- await enrichRewardOperationsValue('monad', [out, nonZero], getReceipt)
138
+ await enrichRewardOperationsValue('monad', [out, nonZero], getReceipt, testLogger)
138
139
 
139
140
  expect(getReceipt).not.toHaveBeenCalled()
140
141
  })
@@ -143,7 +144,7 @@ describe('enrichRewardOperationsValue', () => {
143
144
  const op = rewardOp('0xabc', MONAD_DELEGATOR)
144
145
  const getReceipt = jest.fn().mockRejectedValue(new Error('rpc down'))
145
146
 
146
- await enrichRewardOperationsValue('monad', [op], getReceipt)
147
+ await enrichRewardOperationsValue('monad', [op], getReceipt, testLogger)
147
148
 
148
149
  expect(op.value).toStrictEqual(0n)
149
150
  })