@ledgerhq/coin-evm 8.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 (278) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/docs/getBlock-internal-txs-schema.md +1 -1
  3. package/docs/network/node/index.md +3 -1
  4. package/lib/adapters/blockOperations.d.ts +4 -3
  5. package/lib/adapters/blockOperations.d.ts.map +1 -1
  6. package/lib/adapters/blockOperations.js +17 -17
  7. package/lib/adapters/blockOperations.js.map +1 -1
  8. package/lib/adapters/etherscan.d.ts +7 -6
  9. package/lib/adapters/etherscan.d.ts.map +1 -1
  10. package/lib/adapters/etherscan.js +19 -19
  11. package/lib/adapters/etherscan.js.map +1 -1
  12. package/lib/adapters/ledger.d.ts +6 -5
  13. package/lib/adapters/ledger.d.ts.map +1 -1
  14. package/lib/adapters/ledger.js +15 -15
  15. package/lib/adapters/ledger.js.map +1 -1
  16. package/lib/api/index.d.ts.map +1 -1
  17. package/lib/api/index.js +1 -2
  18. package/lib/api/index.js.map +1 -1
  19. package/lib/logic/common.js +1 -1
  20. package/lib/logic/common.js.map +1 -1
  21. package/lib/logic/getBalance.d.ts.map +1 -1
  22. package/lib/logic/getBalance.js +3 -3
  23. package/lib/logic/getBalance.js.map +1 -1
  24. package/lib/logic/getBlock.d.ts.map +1 -1
  25. package/lib/logic/getBlock.js +22 -23
  26. package/lib/logic/getBlock.js.map +1 -1
  27. package/lib/logic/getStakes.d.ts.map +1 -1
  28. package/lib/logic/getStakes.js +2 -2
  29. package/lib/logic/getStakes.js.map +1 -1
  30. package/lib/logic/internalTransactionsFetcher.d.ts +3 -2
  31. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  32. package/lib/logic/internalTransactionsFetcher.js +13 -10
  33. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  34. package/lib/logic/listOperations.js +1 -1
  35. package/lib/logic/listOperations.js.map +1 -1
  36. package/lib/logic-public/utils.d.ts +3 -2
  37. package/lib/logic-public/utils.d.ts.map +1 -1
  38. package/lib/logic-public/utils.js +7 -6
  39. package/lib/logic-public/utils.js.map +1 -1
  40. package/lib/network/explorer/etherscan.d.ts +3 -2
  41. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  42. package/lib/network/explorer/etherscan.js +13 -12
  43. package/lib/network/explorer/etherscan.js.map +1 -1
  44. package/lib/network/explorer/ledger.d.ts.map +1 -1
  45. package/lib/network/explorer/ledger.js +11 -11
  46. package/lib/network/explorer/ledger.js.map +1 -1
  47. package/lib/network/explorer/types.d.ts +2 -2
  48. package/lib/network/explorer/types.d.ts.map +1 -1
  49. package/lib/network/explorer/types.js.map +1 -1
  50. package/lib/network/node/explorerProxy.js +3 -3
  51. package/lib/network/node/explorerProxy.js.map +1 -1
  52. package/lib/network/node/index.d.ts.map +1 -1
  53. package/lib/network/node/index.js +2 -2
  54. package/lib/network/node/index.js.map +1 -1
  55. package/lib/network/node/ledger.d.ts +2 -1
  56. package/lib/network/node/ledger.d.ts.map +1 -1
  57. package/lib/network/node/ledger.js +9 -10
  58. package/lib/network/node/ledger.js.map +1 -1
  59. package/lib/network/node/rpc.common.d.ts +3 -2
  60. package/lib/network/node/rpc.common.d.ts.map +1 -1
  61. package/lib/network/node/rpc.common.js +37 -29
  62. package/lib/network/node/rpc.common.js.map +1 -1
  63. package/lib/staking/contracts.js +2 -2
  64. package/lib/staking/contracts.js.map +1 -1
  65. package/lib/staking/fetchers.d.ts.map +1 -1
  66. package/lib/staking/fetchers.js +7 -7
  67. package/lib/staking/fetchers.js.map +1 -1
  68. package/lib/staking/prepareIntents.d.ts +2 -1
  69. package/lib/staking/prepareIntents.d.ts.map +1 -1
  70. package/lib/staking/prepareIntents.js +4 -4
  71. package/lib/staking/prepareIntents.js.map +1 -1
  72. package/lib/staking/redelegations.d.ts +5 -4
  73. package/lib/staking/redelegations.d.ts.map +1 -1
  74. package/lib/staking/redelegations.js +13 -14
  75. package/lib/staking/redelegations.js.map +1 -1
  76. package/lib/staking/rewards.d.ts +2 -1
  77. package/lib/staking/rewards.d.ts.map +1 -1
  78. package/lib/staking/rewards.js +4 -5
  79. package/lib/staking/rewards.js.map +1 -1
  80. package/lib/staking/rewardsFromReceipt.d.ts +2 -1
  81. package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
  82. package/lib/staking/rewardsFromReceipt.js +2 -3
  83. package/lib/staking/rewardsFromReceipt.js.map +1 -1
  84. package/lib/staking/unbondings.d.ts +2 -1
  85. package/lib/staking/unbondings.d.ts.map +1 -1
  86. package/lib/staking/unbondings.js +4 -5
  87. package/lib/staking/unbondings.js.map +1 -1
  88. package/lib/staking/validators/index.d.ts +9 -4
  89. package/lib/staking/validators/index.d.ts.map +1 -1
  90. package/lib/staking/validators/index.js +19 -10
  91. package/lib/staking/validators/index.js.map +1 -1
  92. package/lib/staking/validators/monad.d.ts +6 -5
  93. package/lib/staking/validators/monad.d.ts.map +1 -1
  94. package/lib/staking/validators/monad.js +33 -29
  95. package/lib/staking/validators/monad.js.map +1 -1
  96. package/lib/staking/validators/monadResolver.d.ts +2 -1
  97. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  98. package/lib/staking/validators/monadResolver.js +2 -3
  99. package/lib/staking/validators/monadResolver.js.map +1 -1
  100. package/lib/staking/validators/somnia.d.ts +3 -2
  101. package/lib/staking/validators/somnia.d.ts.map +1 -1
  102. package/lib/staking/validators/somnia.js +16 -15
  103. package/lib/staking/validators/somnia.js.map +1 -1
  104. package/lib/staking/validators/types.d.ts +2 -1
  105. package/lib/staking/validators/types.d.ts.map +1 -1
  106. package/lib/staking/validators/zero_gravity.d.ts +2 -1
  107. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  108. package/lib/staking/validators/zero_gravity.js +7 -8
  109. package/lib/staking/validators/zero_gravity.js.map +1 -1
  110. package/lib/types/staking.d.ts +4 -3
  111. package/lib/types/staking.d.ts.map +1 -1
  112. package/lib-es/adapters/blockOperations.d.ts +4 -3
  113. package/lib-es/adapters/blockOperations.d.ts.map +1 -1
  114. package/lib-es/adapters/blockOperations.js +17 -17
  115. package/lib-es/adapters/blockOperations.js.map +1 -1
  116. package/lib-es/adapters/etherscan.d.ts +7 -6
  117. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  118. package/lib-es/adapters/etherscan.js +19 -19
  119. package/lib-es/adapters/etherscan.js.map +1 -1
  120. package/lib-es/adapters/ledger.d.ts +6 -5
  121. package/lib-es/adapters/ledger.d.ts.map +1 -1
  122. package/lib-es/adapters/ledger.js +15 -15
  123. package/lib-es/adapters/ledger.js.map +1 -1
  124. package/lib-es/api/index.d.ts.map +1 -1
  125. package/lib-es/api/index.js +1 -2
  126. package/lib-es/api/index.js.map +1 -1
  127. package/lib-es/logic/common.js +1 -1
  128. package/lib-es/logic/common.js.map +1 -1
  129. package/lib-es/logic/getBalance.d.ts.map +1 -1
  130. package/lib-es/logic/getBalance.js +3 -3
  131. package/lib-es/logic/getBalance.js.map +1 -1
  132. package/lib-es/logic/getBlock.d.ts.map +1 -1
  133. package/lib-es/logic/getBlock.js +22 -23
  134. package/lib-es/logic/getBlock.js.map +1 -1
  135. package/lib-es/logic/getStakes.d.ts.map +1 -1
  136. package/lib-es/logic/getStakes.js +2 -2
  137. package/lib-es/logic/getStakes.js.map +1 -1
  138. package/lib-es/logic/internalTransactionsFetcher.d.ts +3 -2
  139. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  140. package/lib-es/logic/internalTransactionsFetcher.js +13 -10
  141. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  142. package/lib-es/logic/listOperations.js +1 -1
  143. package/lib-es/logic/listOperations.js.map +1 -1
  144. package/lib-es/logic-public/utils.d.ts +3 -2
  145. package/lib-es/logic-public/utils.d.ts.map +1 -1
  146. package/lib-es/logic-public/utils.js +7 -6
  147. package/lib-es/logic-public/utils.js.map +1 -1
  148. package/lib-es/network/explorer/etherscan.d.ts +3 -2
  149. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  150. package/lib-es/network/explorer/etherscan.js +13 -12
  151. package/lib-es/network/explorer/etherscan.js.map +1 -1
  152. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  153. package/lib-es/network/explorer/ledger.js +11 -11
  154. package/lib-es/network/explorer/ledger.js.map +1 -1
  155. package/lib-es/network/explorer/types.d.ts +2 -2
  156. package/lib-es/network/explorer/types.d.ts.map +1 -1
  157. package/lib-es/network/explorer/types.js.map +1 -1
  158. package/lib-es/network/node/explorerProxy.js +3 -3
  159. package/lib-es/network/node/explorerProxy.js.map +1 -1
  160. package/lib-es/network/node/index.d.ts.map +1 -1
  161. package/lib-es/network/node/index.js +2 -2
  162. package/lib-es/network/node/index.js.map +1 -1
  163. package/lib-es/network/node/ledger.d.ts +2 -1
  164. package/lib-es/network/node/ledger.d.ts.map +1 -1
  165. package/lib-es/network/node/ledger.js +9 -10
  166. package/lib-es/network/node/ledger.js.map +1 -1
  167. package/lib-es/network/node/rpc.common.d.ts +3 -2
  168. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  169. package/lib-es/network/node/rpc.common.js +37 -29
  170. package/lib-es/network/node/rpc.common.js.map +1 -1
  171. package/lib-es/staking/contracts.js +2 -2
  172. package/lib-es/staking/contracts.js.map +1 -1
  173. package/lib-es/staking/fetchers.d.ts.map +1 -1
  174. package/lib-es/staking/fetchers.js +7 -7
  175. package/lib-es/staking/fetchers.js.map +1 -1
  176. package/lib-es/staking/prepareIntents.d.ts +2 -1
  177. package/lib-es/staking/prepareIntents.d.ts.map +1 -1
  178. package/lib-es/staking/prepareIntents.js +4 -4
  179. package/lib-es/staking/prepareIntents.js.map +1 -1
  180. package/lib-es/staking/redelegations.d.ts +5 -4
  181. package/lib-es/staking/redelegations.d.ts.map +1 -1
  182. package/lib-es/staking/redelegations.js +13 -14
  183. package/lib-es/staking/redelegations.js.map +1 -1
  184. package/lib-es/staking/rewards.d.ts +2 -1
  185. package/lib-es/staking/rewards.d.ts.map +1 -1
  186. package/lib-es/staking/rewards.js +4 -5
  187. package/lib-es/staking/rewards.js.map +1 -1
  188. package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
  189. package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
  190. package/lib-es/staking/rewardsFromReceipt.js +2 -3
  191. package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
  192. package/lib-es/staking/unbondings.d.ts +2 -1
  193. package/lib-es/staking/unbondings.d.ts.map +1 -1
  194. package/lib-es/staking/unbondings.js +4 -5
  195. package/lib-es/staking/unbondings.js.map +1 -1
  196. package/lib-es/staking/validators/index.d.ts +9 -4
  197. package/lib-es/staking/validators/index.d.ts.map +1 -1
  198. package/lib-es/staking/validators/index.js +18 -10
  199. package/lib-es/staking/validators/index.js.map +1 -1
  200. package/lib-es/staking/validators/monad.d.ts +6 -5
  201. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  202. package/lib-es/staking/validators/monad.js +33 -29
  203. package/lib-es/staking/validators/monad.js.map +1 -1
  204. package/lib-es/staking/validators/monadResolver.d.ts +2 -1
  205. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  206. package/lib-es/staking/validators/monadResolver.js +2 -3
  207. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  208. package/lib-es/staking/validators/somnia.d.ts +3 -2
  209. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  210. package/lib-es/staking/validators/somnia.js +16 -15
  211. package/lib-es/staking/validators/somnia.js.map +1 -1
  212. package/lib-es/staking/validators/types.d.ts +2 -1
  213. package/lib-es/staking/validators/types.d.ts.map +1 -1
  214. package/lib-es/staking/validators/zero_gravity.d.ts +2 -1
  215. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  216. package/lib-es/staking/validators/zero_gravity.js +7 -8
  217. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  218. package/lib-es/types/staking.d.ts +4 -3
  219. package/lib-es/types/staking.d.ts.map +1 -1
  220. package/package.json +2 -3
  221. package/src/adapters/blockOperations.test.ts +86 -67
  222. package/src/adapters/blockOperations.ts +28 -17
  223. package/src/adapters/etherscan.test.ts +151 -85
  224. package/src/adapters/etherscan.ts +27 -18
  225. package/src/adapters/ledger.test.ts +210 -83
  226. package/src/adapters/ledger.ts +21 -15
  227. package/src/api/index.integ.test.ts +7 -6
  228. package/src/api/index.test.ts +2 -2
  229. package/src/api/index.ts +1 -2
  230. package/src/logic/common.ts +1 -1
  231. package/src/logic/getBalance.ts +4 -3
  232. package/src/logic/getBlock.ts +43 -27
  233. package/src/logic/getStakes.ts +2 -1
  234. package/src/logic/internalTransactionsFetcher.ts +16 -10
  235. package/src/logic/listOperations.ts +2 -2
  236. package/src/logic/tests/getBalance.test.ts +5 -3
  237. package/src/logic/tests/getBlock.test.ts +16 -15
  238. package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -5
  239. package/src/logic/tests/listOperations.test.ts +4 -4
  240. package/src/logic-public/tests/utils.test.ts +6 -5
  241. package/src/logic-public/utils.ts +8 -5
  242. package/src/logic.test.ts +5 -5
  243. package/src/network/explorer/etherscan.test.ts +169 -55
  244. package/src/network/explorer/etherscan.ts +27 -16
  245. package/src/network/explorer/index.test.ts +2 -1
  246. package/src/network/explorer/ledger.test.ts +207 -35
  247. package/src/network/explorer/ledger.ts +12 -8
  248. package/src/network/explorer/types.ts +3 -2
  249. package/src/network/node/explorerProxy.ts +3 -3
  250. package/src/network/node/index.ts +3 -2
  251. package/src/network/node/ledger.test.ts +25 -25
  252. package/src/network/node/ledger.ts +13 -10
  253. package/src/network/node/rpc.common.ts +84 -28
  254. package/src/network/node/rpc.test.ts +45 -31
  255. package/src/staking/contracts.ts +2 -2
  256. package/src/staking/fetchers.ts +20 -8
  257. package/src/staking/prepareIntents.test.ts +33 -12
  258. package/src/staking/prepareIntents.ts +9 -5
  259. package/src/staking/redelegations.test.ts +96 -35
  260. package/src/staking/redelegations.ts +20 -12
  261. package/src/staking/rewards.test.ts +15 -10
  262. package/src/staking/rewards.ts +8 -5
  263. package/src/staking/rewardsFromReceipt.test.ts +5 -4
  264. package/src/staking/rewardsFromReceipt.ts +4 -3
  265. package/src/staking/unbondings.test.ts +15 -12
  266. package/src/staking/unbondings.ts +7 -5
  267. package/src/staking/validators/index.ts +30 -10
  268. package/src/staking/validators/monad.test.ts +57 -43
  269. package/src/staking/validators/monad.ts +55 -32
  270. package/src/staking/validators/monadResolver.ts +4 -3
  271. package/src/staking/validators/somnia.test.ts +14 -13
  272. package/src/staking/validators/somnia.ts +35 -19
  273. package/src/staking/validators/types.ts +2 -0
  274. package/src/staking/validators/zero_gravity.test.ts +48 -26
  275. package/src/staking/validators/zero_gravity.ts +14 -8
  276. package/src/staking/validators.integ.test.ts +2 -2
  277. package/src/staking/validators.test.ts +30 -26
  278. package/src/types/staking.ts +9 -2
@@ -14,6 +14,7 @@ import type {
14
14
  LedgerExplorerInternalTransaction,
15
15
  } from '../types'
16
16
  import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
17
+ import { testLogger } from '../fixtures/context.fixtures'
17
18
  import {
18
19
  ledgerTransactionToBlockOperations,
19
20
  rpcTransactionToBlockOperations,
@@ -25,12 +26,15 @@ describe('EVM Family', () => {
25
26
  describe('blockOperations', () => {
26
27
  describe('rpcTransactionToBlockOperations', () => {
27
28
  it('should extract native ETH transfer operations from transaction with value', () => {
28
- const operations = rpcTransactionToBlockOperations({
29
- from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
30
- value: '1000000000000000000',
31
- to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
32
- erc20Transfers: [],
33
- })
29
+ const operations = rpcTransactionToBlockOperations(
30
+ {
31
+ from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
32
+ value: '1000000000000000000',
33
+ to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
34
+ erc20Transfers: [],
35
+ },
36
+ testLogger
37
+ )
34
38
  expect(operations).toEqual([
35
39
  {
36
40
  type: 'transfer',
@@ -50,23 +54,29 @@ describe('EVM Family', () => {
50
54
  })
51
55
 
52
56
  it('should return empty array for transaction with zero value', () => {
53
- const operations = rpcTransactionToBlockOperations({
54
- from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
55
- value: '0',
56
- to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
57
- erc20Transfers: [],
58
- })
57
+ const operations = rpcTransactionToBlockOperations(
58
+ {
59
+ from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
60
+ value: '0',
61
+ to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
62
+ erc20Transfers: [],
63
+ },
64
+ testLogger
65
+ )
59
66
 
60
67
  expect(operations).toHaveLength(0)
61
68
  })
62
69
 
63
70
  it('should handle transaction with undefined to address (contract creation)', () => {
64
- const operations = rpcTransactionToBlockOperations({
65
- from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
66
- value: '500000000000000000',
67
- to: undefined,
68
- erc20Transfers: [],
69
- })
71
+ const operations = rpcTransactionToBlockOperations(
72
+ {
73
+ from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
74
+ value: '500000000000000000',
75
+ to: undefined,
76
+ erc20Transfers: [],
77
+ },
78
+ testLogger
79
+ )
70
80
 
71
81
  expect(operations).toHaveLength(1)
72
82
  expect(operations[0]).toEqual({
@@ -79,12 +89,15 @@ describe('EVM Family', () => {
79
89
  })
80
90
 
81
91
  it('should handle transaction with empty from address', () => {
82
- const operations = rpcTransactionToBlockOperations({
83
- from: '',
84
- value: '2000000000000000000',
85
- to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
86
- erc20Transfers: [],
87
- })
92
+ const operations = rpcTransactionToBlockOperations(
93
+ {
94
+ from: '',
95
+ value: '2000000000000000000',
96
+ to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
97
+ erc20Transfers: [],
98
+ },
99
+ testLogger
100
+ )
88
101
 
89
102
  expect(operations).toHaveLength(1)
90
103
  expect(operations[0]).toEqual({
@@ -97,33 +110,39 @@ describe('EVM Family', () => {
97
110
  })
98
111
 
99
112
  it('should handle invalid addresses gracefully', () => {
100
- const operations = rpcTransactionToBlockOperations({
101
- from: '0x0',
102
- value: '1000000000000000000',
103
- to: '0x',
104
- erc20Transfers: [],
105
- })
113
+ const operations = rpcTransactionToBlockOperations(
114
+ {
115
+ from: '0x0',
116
+ value: '1000000000000000000',
117
+ to: '0x',
118
+ erc20Transfers: [],
119
+ },
120
+ testLogger
121
+ )
106
122
 
107
123
  expect(operations).toHaveLength(0)
108
124
  })
109
125
 
110
126
  it('should extract ERC20 transfers from erc20Transfers', () => {
111
- const operations = rpcTransactionToBlockOperations({
112
- from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
113
- value: '0',
114
- to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
115
- erc20Transfers: [
116
- {
117
- asset: {
118
- type: 'erc20',
119
- assetReference: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
127
+ const operations = rpcTransactionToBlockOperations(
128
+ {
129
+ from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
130
+ value: '0',
131
+ to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
132
+ erc20Transfers: [
133
+ {
134
+ asset: {
135
+ type: 'erc20',
136
+ assetReference: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
137
+ },
138
+ from: '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d',
139
+ to: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
140
+ value: '1000000',
120
141
  },
121
- from: '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d',
122
- to: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
123
- value: '1000000',
124
- },
125
- ],
126
- })
142
+ ],
143
+ },
144
+ testLogger
145
+ )
127
146
 
128
147
  expect(operations).toEqual([
129
148
  {
@@ -203,7 +222,7 @@ describe('EVM Family', () => {
203
222
  }),
204
223
  ]
205
224
 
206
- const byHash = traceBlockItemsToOperationsByHash(items)
225
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
207
226
 
208
227
  expect(byHash.size).toBe(2)
209
228
  expect(byHash.get('0xhash1')).toEqual([
@@ -248,7 +267,7 @@ describe('EVM Family', () => {
248
267
  }),
249
268
  ]
250
269
 
251
- const byHash = traceBlockItemsToOperationsByHash(items)
270
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
252
271
 
253
272
  expect(byHash.size).toBe(0)
254
273
  })
@@ -261,7 +280,7 @@ describe('EVM Family', () => {
261
280
  }),
262
281
  ]
263
282
 
264
- const byHash = traceBlockItemsToOperationsByHash(items)
283
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
265
284
 
266
285
  expect(byHash.size).toBe(0)
267
286
  })
@@ -274,7 +293,7 @@ describe('EVM Family', () => {
274
293
  }),
275
294
  ]
276
295
 
277
- const byHash = traceBlockItemsToOperationsByHash(items)
296
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
278
297
 
279
298
  expect(byHash.size).toBe(0)
280
299
  })
@@ -288,7 +307,7 @@ describe('EVM Family', () => {
288
307
  }),
289
308
  ]
290
309
 
291
- const byHash = traceBlockItemsToOperationsByHash(items)
310
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
292
311
 
293
312
  expect(byHash.size).toBe(1)
294
313
  expect(byHash.get('0xsame')).toHaveLength(4)
@@ -297,7 +316,7 @@ describe('EVM Family', () => {
297
316
  it('should skip reward traces', () => {
298
317
  const items: TraceBlockItem[] = [makeRewardTraceItem()]
299
318
 
300
- const byHash = traceBlockItemsToOperationsByHash(items)
319
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
301
320
 
302
321
  expect(byHash.size).toBe(0)
303
322
  })
@@ -308,7 +327,7 @@ describe('EVM Family', () => {
308
327
  makeTraceItem({ transactionHash: '0xhash1' }),
309
328
  ]
310
329
 
311
- const byHash = traceBlockItemsToOperationsByHash(items)
330
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
312
331
 
313
332
  expect(byHash.size).toBe(1)
314
333
  expect(byHash.get('0xhash1')).toHaveLength(2)
@@ -319,13 +338,13 @@ describe('EVM Family', () => {
319
338
  makeTraceItem({ transactionHash: '0xhash1', traceAddress: [] }),
320
339
  ]
321
340
 
322
- const byHash = traceBlockItemsToOperationsByHash(items)
341
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
323
342
 
324
343
  expect(byHash.size).toBe(0)
325
344
  })
326
345
 
327
346
  it('should return empty map for empty input', () => {
328
- const byHash = traceBlockItemsToOperationsByHash([])
347
+ const byHash = traceBlockItemsToOperationsByHash([], testLogger)
329
348
  expect(byHash.size).toBe(0)
330
349
  })
331
350
 
@@ -338,7 +357,7 @@ describe('EVM Family', () => {
338
357
  action: makeAction({ callType }),
339
358
  }),
340
359
  ]
341
- const byHash = traceBlockItemsToOperationsByHash(items)
360
+ const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
342
361
  expect(byHash.size).toBe(0)
343
362
  }
344
363
  )
@@ -381,7 +400,7 @@ describe('EVM Family', () => {
381
400
  value: '1000000000000000000', // 1 ETH
382
401
  }
383
402
 
384
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
403
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
385
404
 
386
405
  expect(operations).toHaveLength(2)
387
406
  expect(operations[0]).toEqual({
@@ -401,7 +420,7 @@ describe('EVM Family', () => {
401
420
  })
402
421
 
403
422
  it('should return empty array for transaction with zero value and no events', () => {
404
- const operations = ledgerTransactionToBlockOperations(baseLedgerTx)
423
+ const operations = ledgerTransactionToBlockOperations(baseLedgerTx, testLogger)
405
424
 
406
425
  expect(operations).toHaveLength(0)
407
426
  })
@@ -419,7 +438,7 @@ describe('EVM Family', () => {
419
438
  transfer_events: [erc20Event],
420
439
  }
421
440
 
422
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
441
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
423
442
 
424
443
  expect(operations).toHaveLength(2)
425
444
  expect(operations[0]).toEqual({
@@ -459,7 +478,7 @@ describe('EVM Family', () => {
459
478
  transfer_events: erc20Events,
460
479
  }
461
480
 
462
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
481
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
463
482
 
464
483
  expect(operations).toHaveLength(4)
465
484
  expect(operations[0].asset).toEqual({
@@ -485,7 +504,7 @@ describe('EVM Family', () => {
485
504
  erc721_transfer_events: [erc721Event],
486
505
  }
487
506
 
488
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
507
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
489
508
 
490
509
  expect(operations).toHaveLength(2)
491
510
  expect(operations[0]).toEqual({
@@ -521,7 +540,7 @@ describe('EVM Family', () => {
521
540
  erc1155_transfer_events: [erc1155Event],
522
541
  }
523
542
 
524
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
543
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
525
544
 
526
545
  expect(operations).toHaveLength(4) // 2 transfers × 2 addresses
527
546
  expect(operations[0]).toEqual({
@@ -564,7 +583,7 @@ describe('EVM Family', () => {
564
583
  actions: [internalTx],
565
584
  }
566
585
 
567
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
586
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
568
587
 
569
588
  expect(operations).toHaveLength(2)
570
589
  expect(operations[0]).toEqual({
@@ -599,7 +618,7 @@ describe('EVM Family', () => {
599
618
  actions: [internalTx],
600
619
  }
601
620
 
602
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
621
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
603
622
 
604
623
  expect(operations).toHaveLength(0)
605
624
  })
@@ -620,7 +639,7 @@ describe('EVM Family', () => {
620
639
  actions: [internalTx],
621
640
  }
622
641
 
623
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
642
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
624
643
 
625
644
  expect(operations).toHaveLength(0)
626
645
  })
@@ -667,7 +686,7 @@ describe('EVM Family', () => {
667
686
  ],
668
687
  }
669
688
 
670
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
689
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
671
690
 
672
691
  // Native: 2, ERC20: 2, ERC721: 2, ERC1155: 2, Internal: 2 = 10 total
673
692
  expect(operations).toHaveLength(10)
@@ -704,7 +723,7 @@ describe('EVM Family', () => {
704
723
  to: '',
705
724
  }
706
725
 
707
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
726
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
708
727
 
709
728
  expect(operations).toHaveLength(1)
710
729
  expect(operations[0]).toEqual({
@@ -724,7 +743,7 @@ describe('EVM Family', () => {
724
743
  to: '0x',
725
744
  }
726
745
 
727
- const operations = ledgerTransactionToBlockOperations(ledgerTx)
746
+ const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
728
747
 
729
748
  expect(operations).toHaveLength(0)
730
749
  })
@@ -8,6 +8,7 @@ import type {
8
8
  BlockOperation,
9
9
  TransferBlockOperation,
10
10
  } from '@ledgerhq/coin-module-framework/api/index'
11
+ import type { Logger } from '@ledgerhq/coin-module-framework/config'
11
12
  import { safeEncodeEIP55 } from '../logic-public'
12
13
  import { isTraceBlockCallAction } from '../network/node/types'
13
14
  import { NON_VALUE_TRANSFER_CALL_TYPES } from './nonValueTransferCallTypes'
@@ -21,10 +22,11 @@ function addTransferOperations(
21
22
  from: string | null,
22
23
  to: string | undefined,
23
24
  asset: AssetInfo,
24
- amount: bigint
25
+ amount: bigint,
26
+ logger: Logger
25
27
  ): void {
26
- const encodedFrom = from ? safeEncodeEIP55(from) : ''
27
- const encodedTo = to ? safeEncodeEIP55(to) : ''
28
+ const encodedFrom = from ? safeEncodeEIP55(from, logger) : ''
29
+ const encodedTo = to ? safeEncodeEIP55(to, logger) : ''
28
30
 
29
31
  if (encodedFrom) {
30
32
  const op: TransferBlockOperation = {
@@ -54,14 +56,15 @@ function addTransferOperations(
54
56
  * This extracts native transfers from the transaction value field and ERC20 transfers from logs.
55
57
  */
56
58
  export function rpcTransactionToBlockOperations(
57
- tx: Pick<TransactionInfo, 'from' | 'value' | 'to' | 'erc20Transfers'>
59
+ tx: Pick<TransactionInfo, 'from' | 'value' | 'to' | 'erc20Transfers'>,
60
+ logger: Logger
58
61
  ): BlockOperation[] {
59
62
  const operations: BlockOperation[] = []
60
63
 
61
64
  // Native value transfer
62
65
  const value = BigInt(tx.value)
63
66
  if (value > 0n) {
64
- addTransferOperations(operations, tx.from, tx.to, { type: 'native' }, value)
67
+ addTransferOperations(operations, tx.from, tx.to, { type: 'native' }, value, logger)
65
68
  }
66
69
 
67
70
  // ERC20 transfers extracted from receipt logs
@@ -71,7 +74,8 @@ export function rpcTransactionToBlockOperations(
71
74
  transfer.from,
72
75
  transfer.to,
73
76
  transfer.asset,
74
- BigInt(transfer.value)
77
+ BigInt(transfer.value),
78
+ logger
75
79
  )
76
80
  }
77
81
 
@@ -112,7 +116,8 @@ function extractActionFields(
112
116
  * Only includes internal calls with native value transfer (value > 0) and no error.
113
117
  */
114
118
  export function traceBlockItemsToOperationsByHash(
115
- items: TraceBlockItem[]
119
+ items: TraceBlockItem[],
120
+ logger: Logger
116
121
  ): Map<string, BlockOperation[]> {
117
122
  const byHash = new Map<string, BlockOperation[]>()
118
123
 
@@ -125,7 +130,8 @@ export function traceBlockItemsToOperationsByHash(
125
130
  actionFields.from,
126
131
  actionFields.to,
127
132
  { type: 'native' },
128
- actionFields.value
133
+ actionFields.value,
134
+ logger
129
135
  )
130
136
  const hash = actionFields.hash
131
137
  let arr = byHash.get(hash)
@@ -141,7 +147,8 @@ export function traceBlockItemsToOperationsByHash(
141
147
  }
142
148
 
143
149
  export function ledgerTransactionToBlockOperations(
144
- ledgerTx: LedgerExplorerOperation
150
+ ledgerTx: LedgerExplorerOperation,
151
+ logger: Logger
145
152
  ): BlockOperation[] {
146
153
  const operations: BlockOperation[] = []
147
154
 
@@ -151,37 +158,40 @@ export function ledgerTransactionToBlockOperations(
151
158
  ledgerTx.from,
152
159
  ledgerTx.to,
153
160
  { type: 'native' },
154
- BigInt(ledgerTx.value)
161
+ BigInt(ledgerTx.value),
162
+ logger
155
163
  )
156
164
  }
157
165
 
158
166
  // Extract ERC20 token transfers
159
167
  for (const event of ledgerTx.transfer_events) {
160
- const contract = safeEncodeEIP55(event.contract)
168
+ const contract = safeEncodeEIP55(event.contract, logger)
161
169
  addTransferOperations(
162
170
  operations,
163
171
  event.from,
164
172
  event.to,
165
173
  { type: 'erc20', assetReference: contract },
166
- BigInt(event.count)
174
+ BigInt(event.count),
175
+ logger
167
176
  )
168
177
  }
169
178
 
170
179
  // Extract ERC721 NFT transfers
171
180
  for (const event of ledgerTx.erc721_transfer_events) {
172
- const contract = safeEncodeEIP55(event.contract)
181
+ const contract = safeEncodeEIP55(event.contract, logger)
173
182
  addTransferOperations(
174
183
  operations,
175
184
  event.sender,
176
185
  event.receiver,
177
186
  { type: 'erc721', assetReference: contract },
178
- 1n
187
+ 1n,
188
+ logger
179
189
  )
180
190
  }
181
191
 
182
192
  // Extract ERC1155 NFT transfers
183
193
  for (const event of ledgerTx.erc1155_transfer_events) {
184
- const contract = safeEncodeEIP55(event.contract)
194
+ const contract = safeEncodeEIP55(event.contract, logger)
185
195
 
186
196
  for (const transfer of event.transfers) {
187
197
  addTransferOperations(
@@ -189,7 +199,8 @@ export function ledgerTransactionToBlockOperations(
189
199
  event.sender,
190
200
  event.receiver,
191
201
  { type: 'erc1155', assetReference: contract },
192
- BigInt(transfer.value)
202
+ BigInt(transfer.value),
203
+ logger
193
204
  )
194
205
  }
195
206
  }
@@ -202,7 +213,7 @@ export function ledgerTransactionToBlockOperations(
202
213
 
203
214
  const value = BigInt(action.value)
204
215
  if (value > 0n) {
205
- addTransferOperations(operations, action.from, action.to, { type: 'native' }, value)
216
+ addTransferOperations(operations, action.from, action.to, { type: 'native' }, value, logger)
206
217
  }
207
218
  }
208
219