@ledgerhq/coin-evm 8.0.0 → 9.0.1

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 (288) hide show
  1. package/CHANGELOG.md +25 -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 +52 -31
  62. package/lib/network/node/rpc.common.js.map +1 -1
  63. package/lib/network/node/rpc.errors.d.ts +1 -3
  64. package/lib/network/node/rpc.errors.d.ts.map +1 -1
  65. package/lib/network/node/rpc.errors.js +21 -2
  66. package/lib/network/node/rpc.errors.js.map +1 -1
  67. package/lib/staking/contracts.js +2 -2
  68. package/lib/staking/contracts.js.map +1 -1
  69. package/lib/staking/fetchers.d.ts.map +1 -1
  70. package/lib/staking/fetchers.js +7 -7
  71. package/lib/staking/fetchers.js.map +1 -1
  72. package/lib/staking/prepareIntents.d.ts +2 -1
  73. package/lib/staking/prepareIntents.d.ts.map +1 -1
  74. package/lib/staking/prepareIntents.js +4 -4
  75. package/lib/staking/prepareIntents.js.map +1 -1
  76. package/lib/staking/redelegations.d.ts +5 -4
  77. package/lib/staking/redelegations.d.ts.map +1 -1
  78. package/lib/staking/redelegations.js +13 -14
  79. package/lib/staking/redelegations.js.map +1 -1
  80. package/lib/staking/rewards.d.ts +2 -1
  81. package/lib/staking/rewards.d.ts.map +1 -1
  82. package/lib/staking/rewards.js +4 -5
  83. package/lib/staking/rewards.js.map +1 -1
  84. package/lib/staking/rewardsFromReceipt.d.ts +2 -1
  85. package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
  86. package/lib/staking/rewardsFromReceipt.js +2 -3
  87. package/lib/staking/rewardsFromReceipt.js.map +1 -1
  88. package/lib/staking/unbondings.d.ts +2 -1
  89. package/lib/staking/unbondings.d.ts.map +1 -1
  90. package/lib/staking/unbondings.js +4 -5
  91. package/lib/staking/unbondings.js.map +1 -1
  92. package/lib/staking/validators/index.d.ts +9 -4
  93. package/lib/staking/validators/index.d.ts.map +1 -1
  94. package/lib/staking/validators/index.js +19 -10
  95. package/lib/staking/validators/index.js.map +1 -1
  96. package/lib/staking/validators/monad.d.ts +6 -5
  97. package/lib/staking/validators/monad.d.ts.map +1 -1
  98. package/lib/staking/validators/monad.js +33 -29
  99. package/lib/staking/validators/monad.js.map +1 -1
  100. package/lib/staking/validators/monadResolver.d.ts +2 -1
  101. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  102. package/lib/staking/validators/monadResolver.js +2 -3
  103. package/lib/staking/validators/monadResolver.js.map +1 -1
  104. package/lib/staking/validators/somnia.d.ts +3 -2
  105. package/lib/staking/validators/somnia.d.ts.map +1 -1
  106. package/lib/staking/validators/somnia.js +16 -15
  107. package/lib/staking/validators/somnia.js.map +1 -1
  108. package/lib/staking/validators/types.d.ts +2 -1
  109. package/lib/staking/validators/types.d.ts.map +1 -1
  110. package/lib/staking/validators/zero_gravity.d.ts +2 -1
  111. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  112. package/lib/staking/validators/zero_gravity.js +7 -8
  113. package/lib/staking/validators/zero_gravity.js.map +1 -1
  114. package/lib/types/staking.d.ts +4 -3
  115. package/lib/types/staking.d.ts.map +1 -1
  116. package/lib-es/adapters/blockOperations.d.ts +4 -3
  117. package/lib-es/adapters/blockOperations.d.ts.map +1 -1
  118. package/lib-es/adapters/blockOperations.js +17 -17
  119. package/lib-es/adapters/blockOperations.js.map +1 -1
  120. package/lib-es/adapters/etherscan.d.ts +7 -6
  121. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  122. package/lib-es/adapters/etherscan.js +19 -19
  123. package/lib-es/adapters/etherscan.js.map +1 -1
  124. package/lib-es/adapters/ledger.d.ts +6 -5
  125. package/lib-es/adapters/ledger.d.ts.map +1 -1
  126. package/lib-es/adapters/ledger.js +15 -15
  127. package/lib-es/adapters/ledger.js.map +1 -1
  128. package/lib-es/api/index.d.ts.map +1 -1
  129. package/lib-es/api/index.js +1 -2
  130. package/lib-es/api/index.js.map +1 -1
  131. package/lib-es/logic/common.js +1 -1
  132. package/lib-es/logic/common.js.map +1 -1
  133. package/lib-es/logic/getBalance.d.ts.map +1 -1
  134. package/lib-es/logic/getBalance.js +3 -3
  135. package/lib-es/logic/getBalance.js.map +1 -1
  136. package/lib-es/logic/getBlock.d.ts.map +1 -1
  137. package/lib-es/logic/getBlock.js +22 -23
  138. package/lib-es/logic/getBlock.js.map +1 -1
  139. package/lib-es/logic/getStakes.d.ts.map +1 -1
  140. package/lib-es/logic/getStakes.js +2 -2
  141. package/lib-es/logic/getStakes.js.map +1 -1
  142. package/lib-es/logic/internalTransactionsFetcher.d.ts +3 -2
  143. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  144. package/lib-es/logic/internalTransactionsFetcher.js +13 -10
  145. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  146. package/lib-es/logic/listOperations.js +1 -1
  147. package/lib-es/logic/listOperations.js.map +1 -1
  148. package/lib-es/logic-public/utils.d.ts +3 -2
  149. package/lib-es/logic-public/utils.d.ts.map +1 -1
  150. package/lib-es/logic-public/utils.js +7 -6
  151. package/lib-es/logic-public/utils.js.map +1 -1
  152. package/lib-es/network/explorer/etherscan.d.ts +3 -2
  153. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  154. package/lib-es/network/explorer/etherscan.js +13 -12
  155. package/lib-es/network/explorer/etherscan.js.map +1 -1
  156. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  157. package/lib-es/network/explorer/ledger.js +11 -11
  158. package/lib-es/network/explorer/ledger.js.map +1 -1
  159. package/lib-es/network/explorer/types.d.ts +2 -2
  160. package/lib-es/network/explorer/types.d.ts.map +1 -1
  161. package/lib-es/network/explorer/types.js.map +1 -1
  162. package/lib-es/network/node/explorerProxy.js +3 -3
  163. package/lib-es/network/node/explorerProxy.js.map +1 -1
  164. package/lib-es/network/node/index.d.ts.map +1 -1
  165. package/lib-es/network/node/index.js +2 -2
  166. package/lib-es/network/node/index.js.map +1 -1
  167. package/lib-es/network/node/ledger.d.ts +2 -1
  168. package/lib-es/network/node/ledger.d.ts.map +1 -1
  169. package/lib-es/network/node/ledger.js +9 -10
  170. package/lib-es/network/node/ledger.js.map +1 -1
  171. package/lib-es/network/node/rpc.common.d.ts +3 -2
  172. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  173. package/lib-es/network/node/rpc.common.js +53 -32
  174. package/lib-es/network/node/rpc.common.js.map +1 -1
  175. package/lib-es/network/node/rpc.errors.d.ts +1 -3
  176. package/lib-es/network/node/rpc.errors.d.ts.map +1 -1
  177. package/lib-es/network/node/rpc.errors.js +20 -2
  178. package/lib-es/network/node/rpc.errors.js.map +1 -1
  179. package/lib-es/staking/contracts.js +2 -2
  180. package/lib-es/staking/contracts.js.map +1 -1
  181. package/lib-es/staking/fetchers.d.ts.map +1 -1
  182. package/lib-es/staking/fetchers.js +7 -7
  183. package/lib-es/staking/fetchers.js.map +1 -1
  184. package/lib-es/staking/prepareIntents.d.ts +2 -1
  185. package/lib-es/staking/prepareIntents.d.ts.map +1 -1
  186. package/lib-es/staking/prepareIntents.js +4 -4
  187. package/lib-es/staking/prepareIntents.js.map +1 -1
  188. package/lib-es/staking/redelegations.d.ts +5 -4
  189. package/lib-es/staking/redelegations.d.ts.map +1 -1
  190. package/lib-es/staking/redelegations.js +13 -14
  191. package/lib-es/staking/redelegations.js.map +1 -1
  192. package/lib-es/staking/rewards.d.ts +2 -1
  193. package/lib-es/staking/rewards.d.ts.map +1 -1
  194. package/lib-es/staking/rewards.js +4 -5
  195. package/lib-es/staking/rewards.js.map +1 -1
  196. package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
  197. package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
  198. package/lib-es/staking/rewardsFromReceipt.js +2 -3
  199. package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
  200. package/lib-es/staking/unbondings.d.ts +2 -1
  201. package/lib-es/staking/unbondings.d.ts.map +1 -1
  202. package/lib-es/staking/unbondings.js +4 -5
  203. package/lib-es/staking/unbondings.js.map +1 -1
  204. package/lib-es/staking/validators/index.d.ts +9 -4
  205. package/lib-es/staking/validators/index.d.ts.map +1 -1
  206. package/lib-es/staking/validators/index.js +18 -10
  207. package/lib-es/staking/validators/index.js.map +1 -1
  208. package/lib-es/staking/validators/monad.d.ts +6 -5
  209. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  210. package/lib-es/staking/validators/monad.js +33 -29
  211. package/lib-es/staking/validators/monad.js.map +1 -1
  212. package/lib-es/staking/validators/monadResolver.d.ts +2 -1
  213. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  214. package/lib-es/staking/validators/monadResolver.js +2 -3
  215. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  216. package/lib-es/staking/validators/somnia.d.ts +3 -2
  217. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  218. package/lib-es/staking/validators/somnia.js +16 -15
  219. package/lib-es/staking/validators/somnia.js.map +1 -1
  220. package/lib-es/staking/validators/types.d.ts +2 -1
  221. package/lib-es/staking/validators/types.d.ts.map +1 -1
  222. package/lib-es/staking/validators/zero_gravity.d.ts +2 -1
  223. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  224. package/lib-es/staking/validators/zero_gravity.js +7 -8
  225. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  226. package/lib-es/types/staking.d.ts +4 -3
  227. package/lib-es/types/staking.d.ts.map +1 -1
  228. package/package.json +4 -4
  229. package/src/adapters/blockOperations.test.ts +86 -67
  230. package/src/adapters/blockOperations.ts +28 -17
  231. package/src/adapters/etherscan.test.ts +151 -85
  232. package/src/adapters/etherscan.ts +27 -18
  233. package/src/adapters/ledger.test.ts +210 -83
  234. package/src/adapters/ledger.ts +21 -15
  235. package/src/api/index.integ.test.ts +7 -6
  236. package/src/api/index.test.ts +2 -2
  237. package/src/api/index.ts +1 -2
  238. package/src/logic/common.ts +1 -1
  239. package/src/logic/getBalance.ts +4 -3
  240. package/src/logic/getBlock.ts +43 -27
  241. package/src/logic/getStakes.ts +2 -1
  242. package/src/logic/internalTransactionsFetcher.ts +16 -10
  243. package/src/logic/listOperations.ts +2 -2
  244. package/src/logic/tests/getBalance.test.ts +5 -3
  245. package/src/logic/tests/getBlock.test.ts +16 -15
  246. package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -5
  247. package/src/logic/tests/listOperations.test.ts +4 -4
  248. package/src/logic-public/tests/utils.test.ts +6 -5
  249. package/src/logic-public/utils.ts +8 -5
  250. package/src/logic.test.ts +5 -5
  251. package/src/network/explorer/etherscan.test.ts +169 -55
  252. package/src/network/explorer/etherscan.ts +27 -16
  253. package/src/network/explorer/index.test.ts +2 -1
  254. package/src/network/explorer/ledger.test.ts +207 -35
  255. package/src/network/explorer/ledger.ts +12 -8
  256. package/src/network/explorer/types.ts +3 -2
  257. package/src/network/node/explorerProxy.ts +3 -3
  258. package/src/network/node/index.ts +3 -2
  259. package/src/network/node/ledger.test.ts +25 -25
  260. package/src/network/node/ledger.ts +13 -10
  261. package/src/network/node/rpc.common.ts +107 -30
  262. package/src/network/node/rpc.errors.test.ts +53 -1
  263. package/src/network/node/rpc.errors.ts +25 -2
  264. package/src/network/node/rpc.test.ts +106 -47
  265. package/src/staking/contracts.ts +2 -2
  266. package/src/staking/fetchers.ts +20 -8
  267. package/src/staking/prepareIntents.test.ts +33 -12
  268. package/src/staking/prepareIntents.ts +9 -5
  269. package/src/staking/redelegations.test.ts +96 -35
  270. package/src/staking/redelegations.ts +20 -12
  271. package/src/staking/rewards.test.ts +15 -10
  272. package/src/staking/rewards.ts +8 -5
  273. package/src/staking/rewardsFromReceipt.test.ts +5 -4
  274. package/src/staking/rewardsFromReceipt.ts +4 -3
  275. package/src/staking/unbondings.test.ts +15 -12
  276. package/src/staking/unbondings.ts +7 -5
  277. package/src/staking/validators/index.ts +30 -10
  278. package/src/staking/validators/monad.test.ts +57 -43
  279. package/src/staking/validators/monad.ts +55 -32
  280. package/src/staking/validators/monadResolver.ts +4 -3
  281. package/src/staking/validators/somnia.test.ts +14 -13
  282. package/src/staking/validators/somnia.ts +35 -19
  283. package/src/staking/validators/types.ts +2 -0
  284. package/src/staking/validators/zero_gravity.test.ts +48 -26
  285. package/src/staking/validators/zero_gravity.ts +14 -8
  286. package/src/staking/validators.integ.test.ts +2 -2
  287. package/src/staking/validators.test.ts +30 -26
  288. package/src/types/staking.ts +9 -2
@@ -21,6 +21,7 @@ import {
21
21
  deserializePagingToken,
22
22
  serializePagingToken,
23
23
  } from '../adapters'
24
+ import { testLogger } from '../fixtures/context.fixtures'
24
25
  import { NO_TOKEN } from '../network/explorer/types'
25
26
 
26
27
  describe('EVM Family', () => {
@@ -83,9 +84,9 @@ describe('EVM Family', () => {
83
84
  },
84
85
  }
85
86
 
86
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual([
87
- expectedOperation,
88
- ])
87
+ expect(
88
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
89
+ ).toEqual([expectedOperation])
89
90
  })
90
91
 
91
92
  it('should convert an etherscan-like smart contract operation (from their API) to an Operation', () => {
@@ -144,9 +145,9 @@ describe('EVM Family', () => {
144
145
  },
145
146
  }
146
147
 
147
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual([
148
- expectedOperation,
149
- ])
148
+ expect(
149
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
150
+ ).toEqual([expectedOperation])
150
151
  })
151
152
 
152
153
  it('should convert an etherscan-like coin out operation (from their API) to an Operation', () => {
@@ -198,9 +199,9 @@ describe('EVM Family', () => {
198
199
  details: { sequence: '11898499' },
199
200
  }
200
201
 
201
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual([
202
- expectedOperation,
203
- ])
202
+ expect(
203
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
204
+ ).toEqual([expectedOperation])
204
205
  })
205
206
 
206
207
  it('should convert an etherscan-like coin in operation (from their API) to an Operation', () => {
@@ -252,9 +253,9 @@ describe('EVM Family', () => {
252
253
  details: { sequence: '11898499' },
253
254
  }
254
255
 
255
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual([
256
- expectedOperation,
257
- ])
256
+ expect(
257
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
258
+ ).toEqual([expectedOperation])
258
259
  })
259
260
 
260
261
  it('should convert an etherscan-like coin none operation (from their API) to an Operation', () => {
@@ -306,9 +307,9 @@ describe('EVM Family', () => {
306
307
  details: { sequence: '11898499' },
307
308
  }
308
309
 
309
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual([
310
- expectedOperation,
311
- ])
310
+ expect(
311
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
312
+ ).toEqual([expectedOperation])
312
313
  })
313
314
 
314
315
  it('should convert an etherscan-like self send coin operation (from their API) to 2 Operations', () => {
@@ -374,9 +375,9 @@ describe('EVM Family', () => {
374
375
  },
375
376
  ]
376
377
 
377
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual(
378
- expectedOperations
379
- )
378
+ expect(
379
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
380
+ ).toEqual(expectedOperations)
380
381
  })
381
382
 
382
383
  it('should return an operation with the expected amount', () => {
@@ -409,14 +410,20 @@ describe('EVM Family', () => {
409
410
 
410
411
  // Successful Op (value = transferred only; fee is separate; Ledger Wallet adds fee in bridge)
411
412
  expect(
412
- etherscanOperationToOperations(address, currencyId, etherscanOpFees)[0].value
413
+ etherscanOperationToOperations(address, currencyId, etherscanOpFees, testLogger)[0]
414
+ .value
413
415
  ).toEqual(BigInt(etherscanOpFees.value))
414
416
  // Failing Op (value = tx value, same as success)
415
417
  expect(
416
- etherscanOperationToOperations(address, currencyId, {
417
- ...etherscanOpFees,
418
- isError: '1',
419
- })[0].value
418
+ etherscanOperationToOperations(
419
+ address,
420
+ currencyId,
421
+ {
422
+ ...etherscanOpFees,
423
+ isError: '1',
424
+ },
425
+ testLogger
426
+ )[0].value
420
427
  ).toEqual(BigInt(etherscanOpFees.value))
421
428
 
422
429
  const etherscanOpOut: EtherscanOperation = {
@@ -444,14 +451,19 @@ describe('EVM Family', () => {
444
451
 
445
452
  // Successful Op (value = transferred only; fee is separate; Ledger Wallet adds fee in bridge)
446
453
  expect(
447
- etherscanOperationToOperations(address, currencyId, etherscanOpOut)[0].value
454
+ etherscanOperationToOperations(address, currencyId, etherscanOpOut, testLogger)[0].value
448
455
  ).toEqual(BigInt(etherscanOpOut.value))
449
456
  // Failing Op (value = tx value, same as success)
450
457
  expect(
451
- etherscanOperationToOperations(address, currencyId, {
452
- ...etherscanOpOut,
453
- isError: '1',
454
- })[0].value
458
+ etherscanOperationToOperations(
459
+ address,
460
+ currencyId,
461
+ {
462
+ ...etherscanOpOut,
463
+ isError: '1',
464
+ },
465
+ testLogger
466
+ )[0].value
455
467
  ).toEqual(BigInt(etherscanOpOut.value))
456
468
 
457
469
  const etherscanOpIn: EtherscanOperation = {
@@ -479,14 +491,19 @@ describe('EVM Family', () => {
479
491
 
480
492
  // Successful Op
481
493
  expect(
482
- etherscanOperationToOperations(address, currencyId, etherscanOpIn)[0].value
494
+ etherscanOperationToOperations(address, currencyId, etherscanOpIn, testLogger)[0].value
483
495
  ).toEqual(BigInt(etherscanOpIn.value))
484
496
  // Failing Op
485
497
  expect(
486
- etherscanOperationToOperations(address, currencyId, {
487
- ...etherscanOpIn,
488
- isError: '1',
489
- })[0].value
498
+ etherscanOperationToOperations(
499
+ address,
500
+ currencyId,
501
+ {
502
+ ...etherscanOpIn,
503
+ isError: '1',
504
+ },
505
+ testLogger
506
+ )[0].value
490
507
  ).toEqual(BigInt(etherscanOpIn.value))
491
508
  })
492
509
 
@@ -523,7 +540,8 @@ describe('EVM Family', () => {
523
540
  const result = etherscanOperationToOperations(
524
541
  address,
525
542
  currencyId,
526
- rawBlockscoutTransaction
543
+ rawBlockscoutTransaction,
544
+ testLogger
527
545
  )
528
546
 
529
547
  expect(result).toHaveLength(1)
@@ -546,7 +564,12 @@ describe('EVM Family', () => {
546
564
  hash: '0xb7ae1fdaa0d0bcde82cdb12d91898862fbcc5308bc844f508916b434080bb218',
547
565
  }
548
566
 
549
- const result = etherscanOperationToOperations(address, currencyId, failedTransaction)
567
+ const result = etherscanOperationToOperations(
568
+ address,
569
+ currencyId,
570
+ failedTransaction,
571
+ testLogger
572
+ )
550
573
 
551
574
  expect(result).toHaveLength(1)
552
575
  expect(result[0].tx.fees).toEqual(0n)
@@ -563,7 +586,12 @@ describe('EVM Family', () => {
563
586
  value: '',
564
587
  }
565
588
 
566
- const result = etherscanOperationToOperations(address, currencyId, txWithEmptyValue)
589
+ const result = etherscanOperationToOperations(
590
+ address,
591
+ currencyId,
592
+ txWithEmptyValue,
593
+ testLogger
594
+ )
567
595
 
568
596
  expect(result).toHaveLength(1)
569
597
  expect(result[0].tx.fees).toEqual(0n)
@@ -596,7 +624,12 @@ describe('EVM Family', () => {
596
624
  const address = '0x9aa99c23f67c81701c772b106b4f83f6e858dd2e'
597
625
  const currencyId = 'ethereum'
598
626
 
599
- const result = etherscanOperationToOperations(address, currencyId, etherscanOp)
627
+ const result = etherscanOperationToOperations(
628
+ address,
629
+ currencyId,
630
+ etherscanOp,
631
+ testLogger
632
+ )
600
633
 
601
634
  expect(result).toHaveLength(1)
602
635
  expect(result[0].recipients).toEqual([])
@@ -628,7 +661,12 @@ describe('EVM Family', () => {
628
661
  const address = '0x9aa99c23f67c81701c772b106b4f83f6e858dd2e'
629
662
  const currencyId = 'ethereum'
630
663
 
631
- const result = etherscanOperationToOperations(address, currencyId, etherscanOp)
664
+ const result = etherscanOperationToOperations(
665
+ address,
666
+ currencyId,
667
+ etherscanOp,
668
+ testLogger
669
+ )
632
670
 
633
671
  expect(result).toHaveLength(1)
634
672
  expect(result[0].senders).toEqual([])
@@ -661,7 +699,12 @@ describe('EVM Family', () => {
661
699
  }
662
700
 
663
701
  const address = '0x83802741df938c6cd94c46481cadba5b1b0c2f70'
664
- const result = etherscanOperationToOperations(address, 'optimism', etherscanOp)
702
+ const result = etherscanOperationToOperations(
703
+ address,
704
+ 'optimism',
705
+ etherscanOp,
706
+ testLogger
707
+ )
665
708
 
666
709
  expect(result).toHaveLength(1)
667
710
  // fees = gasUsed * gasPrice + L1FeesPaid
@@ -695,7 +738,8 @@ describe('EVM Family', () => {
695
738
  const result = etherscanOperationToOperations(
696
739
  '0x9aa99c23f67c81701c772b106b4f83f6e858dd2e',
697
740
  'ethereum',
698
- etherscanOp
741
+ etherscanOp,
742
+ testLogger
699
743
  )
700
744
 
701
745
  expect(result[0].tx.fees).toEqual(57168n * 125521409858n)
@@ -759,7 +803,9 @@ describe('EVM Family', () => {
759
803
  },
760
804
  }
761
805
 
762
- expect(etherscanERC20EventToOperations(address, etherscanOp)).toEqual([expectedOperation])
806
+ expect(etherscanERC20EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([
807
+ expectedOperation,
808
+ ])
763
809
  })
764
810
 
765
811
  it('should convert an etherscan-like usdc in event (from their API) to an Operation', () => {
@@ -818,7 +864,9 @@ describe('EVM Family', () => {
818
864
  },
819
865
  }
820
866
 
821
- expect(etherscanERC20EventToOperations(address, etherscanOp)).toEqual([expectedOperation])
867
+ expect(etherscanERC20EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([
868
+ expectedOperation,
869
+ ])
822
870
  })
823
871
 
824
872
  it('should ignore an etherscan-like usdc none event (from their API) and return empty array', () => {
@@ -846,7 +894,7 @@ describe('EVM Family', () => {
846
894
 
847
895
  const address = '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d'
848
896
 
849
- expect(etherscanERC20EventToOperations(address, etherscanOp)).toEqual([])
897
+ expect(etherscanERC20EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([])
850
898
  })
851
899
 
852
900
  it('should convert an etherscan-like self usdc event (from their API) into 2 Operations', () => {
@@ -929,7 +977,9 @@ describe('EVM Family', () => {
929
977
  },
930
978
  ]
931
979
 
932
- expect(etherscanERC20EventToOperations(address, etherscanOp)).toEqual(expectedOperations)
980
+ expect(etherscanERC20EventToOperations(address, etherscanOp, 0, testLogger)).toEqual(
981
+ expectedOperations
982
+ )
933
983
  })
934
984
 
935
985
  it('should handle ERC20 event with empty gasPrice (Blockscout Optimism)', () => {
@@ -957,7 +1007,7 @@ describe('EVM Family', () => {
957
1007
  confirmations: '29885597',
958
1008
  }
959
1009
 
960
- const result = etherscanERC20EventToOperations(address, erc20Event)
1010
+ const result = etherscanERC20EventToOperations(address, erc20Event, 0, testLogger)
961
1011
 
962
1012
  expect(result).toHaveLength(1)
963
1013
  expect(result[0].tx.fees).toEqual(0n)
@@ -989,7 +1039,7 @@ describe('EVM Family', () => {
989
1039
 
990
1040
  const address = '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d'
991
1041
 
992
- const result = etherscanERC20EventToOperations(address, etherscanOp)
1042
+ const result = etherscanERC20EventToOperations(address, etherscanOp, 0, testLogger)
993
1043
 
994
1044
  expect(result).toHaveLength(1)
995
1045
  result.forEach((op) => expect(op.recipients).toEqual([]))
@@ -1053,7 +1103,7 @@ describe('EVM Family', () => {
1053
1103
  },
1054
1104
  }
1055
1105
 
1056
- expect(etherscanERC721EventToOperations(address, etherscanOp)).toEqual([
1106
+ expect(etherscanERC721EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([
1057
1107
  expectedOperation,
1058
1108
  ])
1059
1109
  })
@@ -1111,7 +1161,7 @@ describe('EVM Family', () => {
1111
1161
  },
1112
1162
  }
1113
1163
 
1114
- expect(etherscanERC721EventToOperations(address, etherscanOp)).toEqual([
1164
+ expect(etherscanERC721EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([
1115
1165
  expectedOperation,
1116
1166
  ])
1117
1167
  })
@@ -1141,7 +1191,7 @@ describe('EVM Family', () => {
1141
1191
 
1142
1192
  const address = '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d'
1143
1193
 
1144
- expect(etherscanERC721EventToOperations(address, etherscanOp)).toEqual([])
1194
+ expect(etherscanERC721EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([])
1145
1195
  })
1146
1196
 
1147
1197
  it('should convert an etherscan-like erc721 nft event (from their API) into 2 Operations', () => {
@@ -1218,7 +1268,9 @@ describe('EVM Family', () => {
1218
1268
  },
1219
1269
  ]
1220
1270
 
1221
- expect(etherscanERC721EventToOperations(address, etherscanOp)).toEqual(expectedOperations)
1271
+ expect(etherscanERC721EventToOperations(address, etherscanOp, 0, testLogger)).toEqual(
1272
+ expectedOperations
1273
+ )
1222
1274
  })
1223
1275
 
1224
1276
  it('should produce empty recipients when to is an empty string', () => {
@@ -1246,7 +1298,7 @@ describe('EVM Family', () => {
1246
1298
 
1247
1299
  const address = '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d'
1248
1300
 
1249
- const result = etherscanERC721EventToOperations(address, etherscanOp)
1301
+ const result = etherscanERC721EventToOperations(address, etherscanOp, 0, testLogger)
1250
1302
 
1251
1303
  // from matches account → NFT_OUT is emitted, but recipients must not contain empty string
1252
1304
  expect(result).toHaveLength(1)
@@ -1311,7 +1363,7 @@ describe('EVM Family', () => {
1311
1363
  },
1312
1364
  }
1313
1365
 
1314
- expect(etherscanERC1155EventToOperations(address, etherscanOp)).toEqual([
1366
+ expect(etherscanERC1155EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([
1315
1367
  expectedOperation,
1316
1368
  ])
1317
1369
  })
@@ -1369,7 +1421,7 @@ describe('EVM Family', () => {
1369
1421
  },
1370
1422
  }
1371
1423
 
1372
- expect(etherscanERC1155EventToOperations(address, etherscanOp)).toEqual([
1424
+ expect(etherscanERC1155EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([
1373
1425
  expectedOperation,
1374
1426
  ])
1375
1427
  })
@@ -1399,7 +1451,7 @@ describe('EVM Family', () => {
1399
1451
 
1400
1452
  const address = '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d'
1401
1453
 
1402
- expect(etherscanERC1155EventToOperations(address, etherscanOp)).toEqual([])
1454
+ expect(etherscanERC1155EventToOperations(address, etherscanOp, 0, testLogger)).toEqual([])
1403
1455
  })
1404
1456
 
1405
1457
  it('should convert an etherscan-like erc1155 nft event (from their API) into 2 Operations', () => {
@@ -1476,7 +1528,7 @@ describe('EVM Family', () => {
1476
1528
  },
1477
1529
  ]
1478
1530
 
1479
- expect(etherscanERC1155EventToOperations(address, etherscanOp)).toEqual(
1531
+ expect(etherscanERC1155EventToOperations(address, etherscanOp, 0, testLogger)).toEqual(
1480
1532
  expectedOperations
1481
1533
  )
1482
1534
  })
@@ -1506,7 +1558,7 @@ describe('EVM Family', () => {
1506
1558
 
1507
1559
  const address = '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d'
1508
1560
 
1509
- const result = etherscanERC1155EventToOperations(address, etherscanOp)
1561
+ const result = etherscanERC1155EventToOperations(address, etherscanOp, 0, testLogger)
1510
1562
 
1511
1563
  // from matches account → NFT_OUT is emitted, but recipients must not contain empty string
1512
1564
  expect(result).toHaveLength(1)
@@ -1554,9 +1606,9 @@ describe('EVM Family', () => {
1554
1606
  details: { internal: true },
1555
1607
  }
1556
1608
 
1557
- expect(etherscanInternalTransactionToOperations(address, etherscanOp)).toEqual([
1558
- expectedOperation,
1559
- ])
1609
+ expect(
1610
+ etherscanInternalTransactionToOperations(address, etherscanOp, 0, testLogger)
1611
+ ).toEqual([expectedOperation])
1560
1612
  })
1561
1613
 
1562
1614
  it('should convert a etherscan-like in internal transaction (from their API) to an Operation', () => {
@@ -1596,9 +1648,9 @@ describe('EVM Family', () => {
1596
1648
  details: { internal: true },
1597
1649
  }
1598
1650
 
1599
- expect(etherscanInternalTransactionToOperations(address, etherscanOp)).toEqual([
1600
- expectedOperation,
1601
- ])
1651
+ expect(
1652
+ etherscanInternalTransactionToOperations(address, etherscanOp, 0, testLogger)
1653
+ ).toEqual([expectedOperation])
1602
1654
  })
1603
1655
 
1604
1656
  it('should convert a etherscan-like none internal transaction (from their API) to an Operation', () => {
@@ -1621,7 +1673,9 @@ describe('EVM Family', () => {
1621
1673
 
1622
1674
  const address = '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d'
1623
1675
 
1624
- expect(etherscanInternalTransactionToOperations(address, etherscanOp)).toEqual([])
1676
+ expect(
1677
+ etherscanInternalTransactionToOperations(address, etherscanOp, 0, testLogger)
1678
+ ).toEqual([])
1625
1679
  })
1626
1680
 
1627
1681
  it('should convert a etherscan-like self internal transaction (from their API) to 2 Operations', () => {
@@ -1675,9 +1729,9 @@ describe('EVM Family', () => {
1675
1729
  },
1676
1730
  ]
1677
1731
 
1678
- expect(etherscanInternalTransactionToOperations(address, etherscanOp)).toEqual(
1679
- expectedOperations
1680
- )
1732
+ expect(
1733
+ etherscanInternalTransactionToOperations(address, etherscanOp, 0, testLogger)
1734
+ ).toEqual(expectedOperations)
1681
1735
  })
1682
1736
 
1683
1737
  it('should produce empty recipients when to is an empty string', () => {
@@ -1700,7 +1754,12 @@ describe('EVM Family', () => {
1700
1754
 
1701
1755
  const address = '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d'
1702
1756
 
1703
- const result = etherscanInternalTransactionToOperations(address, etherscanOp)
1757
+ const result = etherscanInternalTransactionToOperations(
1758
+ address,
1759
+ etherscanOp,
1760
+ 0,
1761
+ testLogger
1762
+ )
1704
1763
 
1705
1764
  // from matches account → OUT is emitted, but recipients must not contain empty string
1706
1765
  expect(result).toHaveLength(1)
@@ -1741,7 +1800,12 @@ describe('EVM Family', () => {
1741
1800
  { type: 'callcode' },
1742
1801
  ])('returns no operations for non-value-transferring call type %o', (overrides) => {
1743
1802
  expect(
1744
- etherscanInternalTransactionToOperations(addressForCallType, makeInternalTx(overrides))
1803
+ etherscanInternalTransactionToOperations(
1804
+ addressForCallType,
1805
+ makeInternalTx(overrides),
1806
+ 0,
1807
+ testLogger
1808
+ )
1745
1809
  ).toEqual([])
1746
1810
  })
1747
1811
 
@@ -1749,7 +1813,9 @@ describe('EVM Family', () => {
1749
1813
  expect(
1750
1814
  etherscanInternalTransactionToOperations(
1751
1815
  addressForCallType,
1752
- makeInternalTx({ callType: 'DelegateCall' })
1816
+ makeInternalTx({ callType: 'DelegateCall' }),
1817
+ 0,
1818
+ testLogger
1753
1819
  )
1754
1820
  ).toEqual([])
1755
1821
  })
@@ -1813,9 +1879,9 @@ describe('EVM Family', () => {
1813
1879
  },
1814
1880
  }
1815
1881
 
1816
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual([
1817
- expectedOperation,
1818
- ])
1882
+ expect(
1883
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
1884
+ ).toEqual([expectedOperation])
1819
1885
  })
1820
1886
 
1821
1887
  it('should convert an etherscan-like staking smart contract redelegate operation (from their API) to an Operation', () => {
@@ -1870,9 +1936,9 @@ describe('EVM Family', () => {
1870
1936
  },
1871
1937
  }
1872
1938
 
1873
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual([
1874
- expectedOperation,
1875
- ])
1939
+ expect(
1940
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
1941
+ ).toEqual([expectedOperation])
1876
1942
  })
1877
1943
 
1878
1944
  it('should convert an etherscan-like staking smart contract undelegate operation (from their API) to an Operation', () => {
@@ -1925,9 +1991,9 @@ describe('EVM Family', () => {
1925
1991
  },
1926
1992
  }
1927
1993
 
1928
- expect(etherscanOperationToOperations(address, currencyId, etherscanOp)).toEqual([
1929
- expectedOperation,
1930
- ])
1994
+ expect(
1995
+ etherscanOperationToOperations(address, currencyId, etherscanOp, testLogger)
1996
+ ).toEqual([expectedOperation])
1931
1997
  })
1932
1998
  })
1933
1999
 
@@ -1997,7 +2063,7 @@ describe('EVM Family', () => {
1997
2063
 
1998
2064
  it('groups internal txs by hash and converts to native transfer operations', () => {
1999
2065
  const internalTxs = [{ ...baseInternalTx, hash: '0xtx1', value: '1000000000000000000' }]
2000
- const byHash = internalTxsToOperationsByHash(internalTxs)
2066
+ const byHash = internalTxsToOperationsByHash(internalTxs, testLogger)
2001
2067
  expect(byHash.size).toBe(1)
2002
2068
  const ops = byHash.get('0xtx1')!
2003
2069
  expect(ops).toHaveLength(2) // sender + receiver
@@ -2010,18 +2076,18 @@ describe('EVM Family', () => {
2010
2076
 
2011
2077
  it("skips internal txs with isError === '1'", () => {
2012
2078
  const internalTxs = [{ ...baseInternalTx, hash: '0xtx1', isError: '1', value: '1000' }]
2013
- const byHash = internalTxsToOperationsByHash(internalTxs)
2079
+ const byHash = internalTxsToOperationsByHash(internalTxs, testLogger)
2014
2080
  expect(byHash.size).toBe(0)
2015
2081
  })
2016
2082
 
2017
2083
  it("skips internal txs with value === '0'", () => {
2018
2084
  const internalTxs = [{ ...baseInternalTx, hash: '0xtx1', value: '0' }]
2019
- const byHash = internalTxsToOperationsByHash(internalTxs)
2085
+ const byHash = internalTxsToOperationsByHash(internalTxs, testLogger)
2020
2086
  expect(byHash.size).toBe(0)
2021
2087
  })
2022
2088
 
2023
2089
  it('returns empty map for empty internal txs array', () => {
2024
- const byHash = internalTxsToOperationsByHash([])
2090
+ const byHash = internalTxsToOperationsByHash([], testLogger)
2025
2091
  expect(byHash.size).toBe(0)
2026
2092
  })
2027
2093
 
@@ -2030,7 +2096,7 @@ describe('EVM Family', () => {
2030
2096
  { ...baseInternalTx, hash: '0xtx1', value: '1000', from: '0xa', to: '0xb' },
2031
2097
  { ...baseInternalTx, hash: '0xtx1', value: '2000', from: '0xc', to: '0xd' },
2032
2098
  ]
2033
- const byHash = internalTxsToOperationsByHash(internalTxs)
2099
+ const byHash = internalTxsToOperationsByHash(internalTxs, testLogger)
2034
2100
  expect(byHash.size).toBe(1)
2035
2101
  expect(byHash.get('0xtx1')!.length).toBe(4) // 2 internal txs × 2 ops each
2036
2102
  })
@@ -2039,7 +2105,7 @@ describe('EVM Family', () => {
2039
2105
  'skips internal txs whose Blockscout callType is %s (no native value moves)',
2040
2106
  (callType) => {
2041
2107
  const internalTxs = [{ ...baseInternalTx, hash: '0xtx1', callType }]
2042
- const byHash = internalTxsToOperationsByHash(internalTxs)
2108
+ const byHash = internalTxsToOperationsByHash(internalTxs, testLogger)
2043
2109
  expect(byHash.size).toBe(0)
2044
2110
  }
2045
2111
  )
@@ -2048,7 +2114,7 @@ describe('EVM Family', () => {
2048
2114
  'skips internal txs whose Etherscan type is %s (no native value moves)',
2049
2115
  (type) => {
2050
2116
  const internalTxs = [{ ...baseInternalTx, hash: '0xtx1', type }]
2051
- const byHash = internalTxsToOperationsByHash(internalTxs)
2117
+ const byHash = internalTxsToOperationsByHash(internalTxs, testLogger)
2052
2118
  expect(byHash.size).toBe(0)
2053
2119
  }
2054
2120
  )