@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
@@ -13,6 +13,7 @@ import type {
13
13
  TransferBlockOperation,
14
14
  } from '@ledgerhq/coin-module-framework/api/index'
15
15
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
16
+ import type { Logger } from '@ledgerhq/coin-module-framework/config'
16
17
  import BigNumber from 'bignumber.js'
17
18
  import eip55 from 'eip55'
18
19
  import { InvalidExplorerResponse } from '../errors'
@@ -59,11 +60,13 @@ export const safeDate = (op: { timeStamp?: string; timestamp?: string }): Date =
59
60
  export const etherscanOperationToOperations = (
60
61
  address: string,
61
62
  currencyId: string,
62
- etherscanOp: EtherscanOperation
63
+ etherscanOp: EtherscanOperation,
64
+ logger: Logger
63
65
  ): Array<Operation<MemoNotSupported>> => {
64
66
  const checksummedAddress = eip55.encode(address)
65
- const from = safeEncodeEIP55(etherscanOp.from)
66
- const to = safeEncodeEIP55(etherscanOp.to) || safeEncodeEIP55(etherscanOp.contractAddress)
67
+ const from = safeEncodeEIP55(etherscanOp.from, logger)
68
+ const to =
69
+ safeEncodeEIP55(etherscanOp.to, logger) || safeEncodeEIP55(etherscanOp.contractAddress, logger)
67
70
  const value = safeBigInt(etherscanOp.value)
68
71
  const fees =
69
72
  safeBigInt(etherscanOp.gasUsed) * safeBigInt(etherscanOp.gasPrice) +
@@ -89,6 +92,7 @@ export const etherscanOperationToOperations = (
89
92
  const contractExtra = buildSmartContractDetails(
90
93
  etherscanOp.to,
91
94
  etherscanOp.input,
95
+ logger,
92
96
  etherscanOp.contractAddress
93
97
  )
94
98
 
@@ -131,11 +135,12 @@ export const etherscanOperationToOperations = (
131
135
  export const etherscanERC20EventToOperations = (
132
136
  address: string,
133
137
  event: EtherscanERC20Event,
134
- index = 0
138
+ index = 0,
139
+ logger: Logger
135
140
  ): Array<Operation<MemoNotSupported>> => {
136
141
  const checksummedAddress = eip55.encode(address)
137
- const from = safeEncodeEIP55(event.from)
138
- const to = safeEncodeEIP55(event.to)
142
+ const from = safeEncodeEIP55(event.from, logger)
143
+ const to = safeEncodeEIP55(event.to, logger)
139
144
  const contract = eip55.encode(event.contractAddress)
140
145
  const value = safeBigInt(event.value)
141
146
  const fees = safeBigInt(event.gasUsed) * safeBigInt(event.gasPrice)
@@ -186,11 +191,12 @@ export const etherscanERC20EventToOperations = (
186
191
  export const etherscanERC721EventToOperations = (
187
192
  address: string,
188
193
  event: EtherscanERC721Event,
189
- index = 0
194
+ index = 0,
195
+ logger: Logger
190
196
  ): Array<Operation<MemoNotSupported>> => {
191
197
  const checksummedAddress = eip55.encode(address)
192
- const from = safeEncodeEIP55(event.from)
193
- const to = safeEncodeEIP55(event.to)
198
+ const from = safeEncodeEIP55(event.from, logger)
199
+ const to = safeEncodeEIP55(event.to, logger)
194
200
  const contract = eip55.encode(event.contractAddress)
195
201
  const fees = safeBigInt(event.gasUsed) * safeBigInt(event.gasPrice)
196
202
  const date = safeDate(event)
@@ -239,11 +245,12 @@ export const etherscanERC721EventToOperations = (
239
245
  export const etherscanERC1155EventToOperations = (
240
246
  address: string,
241
247
  event: EtherscanERC1155Event,
242
- index = 0
248
+ index = 0,
249
+ logger: Logger
243
250
  ): Array<Operation<MemoNotSupported>> => {
244
251
  const checksummedAddress = eip55.encode(address)
245
- const from = safeEncodeEIP55(event.from)
246
- const to = safeEncodeEIP55(event.to)
252
+ const from = safeEncodeEIP55(event.from, logger)
253
+ const to = safeEncodeEIP55(event.to, logger)
247
254
  const contract = eip55.encode(event.contractAddress)
248
255
  const value = safeBigInt(event.tokenValue) // value is representing the number of NFT transfered.
249
256
  const fees = safeBigInt(event.gasUsed) * safeBigInt(event.gasPrice)
@@ -305,15 +312,16 @@ function isNonValueTransferInternalTx(
305
312
  export const etherscanInternalTransactionToOperations = (
306
313
  address: string,
307
314
  internalTx: EtherscanInternalTransaction,
308
- index = 0
315
+ index = 0,
316
+ logger: Logger
309
317
  ): Array<Operation<MemoNotSupported>> => {
310
318
  // Phantom IN/OUT guard; `isInternalTransactionValid` applies the same filter on the `getBlock` path.
311
319
  if (isNonValueTransferInternalTx(internalTx)) return []
312
320
 
313
321
  const { hash, blockNumber, isError } = internalTx
314
322
  const checksummedAddress = eip55.encode(address)
315
- const from = safeEncodeEIP55(internalTx.from)
316
- const to = safeEncodeEIP55(internalTx.to)
323
+ const from = safeEncodeEIP55(internalTx.from, logger)
324
+ const to = safeEncodeEIP55(internalTx.to, logger)
317
325
  const value = safeBigInt(internalTx.value)
318
326
  const hasFailed = isError === '1'
319
327
  const date = safeDate(internalTx)
@@ -376,7 +384,8 @@ function isInternalTransactionValid(it: EtherscanInternalTransaction): boolean {
376
384
  * but cannot move native ETH.
377
385
  */
378
386
  export function internalTxsToOperationsByHash(
379
- internalTxs: EtherscanInternalTransaction[]
387
+ internalTxs: EtherscanInternalTransaction[],
388
+ logger: Logger
380
389
  ): Map<string, BlockOperation[]> {
381
390
  const byHash = new Map<string, BlockOperation[]>()
382
391
 
@@ -384,8 +393,8 @@ export function internalTxsToOperationsByHash(
384
393
  if (!isInternalTransactionValid(it)) continue
385
394
 
386
395
  const { from, to, value, hash } = it
387
- const encodedFrom = safeEncodeEIP55(from)
388
- const encodedTo = safeEncodeEIP55(to)
396
+ const encodedFrom = safeEncodeEIP55(from, logger)
397
+ const encodedTo = safeEncodeEIP55(to, logger)
389
398
  const amount = BigInt(value)
390
399
 
391
400
  const ops: BlockOperation[] = []
@@ -9,6 +9,7 @@ import type {
9
9
  LedgerExplorerOperation,
10
10
  } from './../types'
11
11
  import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
12
+ import { testLogger } from '../fixtures/context.fixtures'
12
13
  import {
13
14
  ledgerERC1155EventToOperations,
14
15
  ledgerERC20EventToOperations,
@@ -109,7 +110,7 @@ describe('EVM Family', () => {
109
110
  }
110
111
 
111
112
  expect(
112
- ledgerOperationToOperations(unrelatedAddress, 'ethereum', ledgerExplorerOp)
113
+ ledgerOperationToOperations(unrelatedAddress, 'ethereum', ledgerExplorerOp, testLogger)
113
114
  ).toEqual([expectedOperation])
114
115
  })
115
116
 
@@ -173,9 +174,9 @@ describe('EVM Family', () => {
173
174
  details: { sequence: 75 },
174
175
  }
175
176
 
176
- expect(ledgerOperationToOperations(address, currencyId, ledgerOperation)).toEqual([
177
- expectedOperation,
178
- ])
177
+ expect(
178
+ ledgerOperationToOperations(address, currencyId, ledgerOperation, testLogger)
179
+ ).toEqual([expectedOperation])
179
180
  })
180
181
 
181
182
  it('should convert ledger explorer coin out operation to an Operation', () => {
@@ -238,9 +239,9 @@ describe('EVM Family', () => {
238
239
  details: { sequence: 75 },
239
240
  }
240
241
 
241
- expect(ledgerOperationToOperations(address, currencyId, ledgerOperation)).toEqual([
242
- expectedOperation,
243
- ])
242
+ expect(
243
+ ledgerOperationToOperations(address, currencyId, ledgerOperation, testLogger)
244
+ ).toEqual([expectedOperation])
244
245
  })
245
246
 
246
247
  it('should convert ledger explorer coin in operation to an Operation', () => {
@@ -303,9 +304,9 @@ describe('EVM Family', () => {
303
304
  details: { sequence: 75 },
304
305
  }
305
306
 
306
- expect(ledgerOperationToOperations(address, currencyId, ledgerOperation)).toEqual([
307
- expectedOperation,
308
- ])
307
+ expect(
308
+ ledgerOperationToOperations(address, currencyId, ledgerOperation, testLogger)
309
+ ).toEqual([expectedOperation])
309
310
  })
310
311
 
311
312
  it('should convert ledger explorer coin none operation to an Operation', () => {
@@ -368,9 +369,9 @@ describe('EVM Family', () => {
368
369
  details: { sequence: 75 },
369
370
  }
370
371
 
371
- expect(ledgerOperationToOperations(address, currencyId, ledgerOperation)).toEqual([
372
- expectedOperation,
373
- ])
372
+ expect(
373
+ ledgerOperationToOperations(address, currencyId, ledgerOperation, testLogger)
374
+ ).toEqual([expectedOperation])
374
375
  })
375
376
 
376
377
  it('should convert ledger explorer legacy coin none operation (smart contract creation) to an Operation', () => {
@@ -438,9 +439,9 @@ describe('EVM Family', () => {
438
439
  details: { sequence: 3 },
439
440
  }
440
441
 
441
- expect(ledgerOperationToOperations(address, currencyId, ledgerOperation)).toEqual([
442
- expectedOperation,
443
- ])
442
+ expect(
443
+ ledgerOperationToOperations(address, currencyId, ledgerOperation, testLogger)
444
+ ).toEqual([expectedOperation])
444
445
  })
445
446
 
446
447
  it('should convert ledger explorer self send coin operation to 2 Operations', () => {
@@ -515,10 +516,9 @@ describe('EVM Family', () => {
515
516
  details: { sequence: 75 },
516
517
  }
517
518
 
518
- expect(ledgerOperationToOperations(address, currencyId, ledgerOperation)).toEqual([
519
- expectedOperation1,
520
- expectedOperation2,
521
- ])
519
+ expect(
520
+ ledgerOperationToOperations(address, currencyId, ledgerOperation, testLogger)
521
+ ).toEqual([expectedOperation1, expectedOperation2])
522
522
  })
523
523
 
524
524
  it('should return an operation with the expected amount', () => {
@@ -564,14 +564,24 @@ describe('EVM Family', () => {
564
564
 
565
565
  // Successful Op
566
566
  expect(
567
- ledgerOperationToOperations(unrelatedAddress, 'ethereum', ledgerExplorerNoneOp)[0].value
567
+ ledgerOperationToOperations(
568
+ unrelatedAddress,
569
+ 'ethereum',
570
+ ledgerExplorerNoneOp,
571
+ testLogger
572
+ )[0].value
568
573
  ).toEqual(BigInt(ledgerExplorerNoneOp.value))
569
574
  // Failing Op
570
575
  expect(
571
- ledgerOperationToOperations(unrelatedAddress, 'ethereum', {
572
- ...ledgerExplorerNoneOp,
573
- status: 0,
574
- })[0].value
576
+ ledgerOperationToOperations(
577
+ unrelatedAddress,
578
+ 'ethereum',
579
+ {
580
+ ...ledgerExplorerNoneOp,
581
+ status: 0,
582
+ },
583
+ testLogger
584
+ )[0].value
575
585
  ).toEqual(BigInt(ledgerExplorerNoneOp.value))
576
586
 
577
587
  const ledgerExplorerFeesOp: LedgerExplorerOperation = {
@@ -614,14 +624,20 @@ describe('EVM Family', () => {
614
624
 
615
625
  // Successful Op (value = transferred only; fee is separate; Ledger Wallet adds fee in bridge)
616
626
  expect(
617
- ledgerOperationToOperations(address, currencyId, ledgerExplorerFeesOp)[0].value
627
+ ledgerOperationToOperations(address, currencyId, ledgerExplorerFeesOp, testLogger)[0]
628
+ .value
618
629
  ).toEqual(BigInt(ledgerExplorerFeesOp.value))
619
630
  // Failing Op (value = tx value, same as success)
620
631
  expect(
621
- ledgerOperationToOperations(address, currencyId, {
622
- ...ledgerExplorerFeesOp,
623
- status: 0,
624
- })[0].value
632
+ ledgerOperationToOperations(
633
+ address,
634
+ currencyId,
635
+ {
636
+ ...ledgerExplorerFeesOp,
637
+ status: 0,
638
+ },
639
+ testLogger
640
+ )[0].value
625
641
  ).toEqual(BigInt(ledgerExplorerFeesOp.value))
626
642
 
627
643
  const ledgerOperationOut: LedgerExplorerOperation = {
@@ -663,14 +679,20 @@ describe('EVM Family', () => {
663
679
 
664
680
  // Successful Op (value = transferred only; fee is separate; Ledger Wallet adds fee in bridge)
665
681
  expect(
666
- ledgerOperationToOperations(address, currencyId, ledgerOperationOut)[0].value
682
+ ledgerOperationToOperations(address, currencyId, ledgerOperationOut, testLogger)[0]
683
+ .value
667
684
  ).toEqual(BigInt(ledgerOperationOut.value))
668
685
  // Failing Op (value = tx value, same as success)
669
686
  expect(
670
- ledgerOperationToOperations(address, currencyId, {
671
- ...ledgerOperationOut,
672
- status: 0,
673
- })[0].value
687
+ ledgerOperationToOperations(
688
+ address,
689
+ currencyId,
690
+ {
691
+ ...ledgerOperationOut,
692
+ status: 0,
693
+ },
694
+ testLogger
695
+ )[0].value
674
696
  ).toEqual(BigInt(ledgerOperationOut.value))
675
697
 
676
698
  const ledgerOperationIn: LedgerExplorerOperation = {
@@ -712,12 +734,16 @@ describe('EVM Family', () => {
712
734
 
713
735
  // Successful Op
714
736
  expect(
715
- ledgerOperationToOperations(address, currencyId, ledgerOperationIn)[0].value
737
+ ledgerOperationToOperations(address, currencyId, ledgerOperationIn, testLogger)[0].value
716
738
  ).toEqual(BigInt(ledgerOperationOut.value))
717
739
  // Failing Op
718
740
  expect(
719
- ledgerOperationToOperations(address, currencyId, { ...ledgerOperationIn, status: 0 })[0]
720
- .value
741
+ ledgerOperationToOperations(
742
+ address,
743
+ currencyId,
744
+ { ...ledgerOperationIn, status: 0 },
745
+ testLogger
746
+ )[0].value
721
747
  ).toEqual(BigInt(ledgerOperationOut.value))
722
748
  })
723
749
 
@@ -752,7 +778,7 @@ describe('EVM Family', () => {
752
778
  },
753
779
  }
754
780
 
755
- const result = ledgerOperationToOperations(address, currencyId, ledgerOp)
781
+ const result = ledgerOperationToOperations(address, currencyId, ledgerOp, testLogger)
756
782
 
757
783
  expect(result).toHaveLength(1)
758
784
  expect(result[0].recipients).toEqual([])
@@ -789,7 +815,7 @@ describe('EVM Family', () => {
789
815
  },
790
816
  }
791
817
 
792
- const result = ledgerOperationToOperations(address, currencyId, ledgerOp)
818
+ const result = ledgerOperationToOperations(address, currencyId, ledgerOp, testLogger)
793
819
 
794
820
  expect(result).toHaveLength(1)
795
821
  expect(result[0].senders).toEqual([])
@@ -834,7 +860,12 @@ describe('EVM Family', () => {
834
860
  },
835
861
  }
836
862
 
837
- const result = ledgerOperationToOperations(monadAddress, monadCurrencyId, ledgerOp)
863
+ const result = ledgerOperationToOperations(
864
+ monadAddress,
865
+ monadCurrencyId,
866
+ ledgerOp,
867
+ testLogger
868
+ )
838
869
 
839
870
  expect(result).toHaveLength(1)
840
871
  expect(result[0].type).toBe('WITHDRAW_UNBONDED')
@@ -870,9 +901,9 @@ describe('EVM Family', () => {
870
901
  },
871
902
  }
872
903
 
873
- expect(ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event)).toEqual([
874
- expectedOperation,
875
- ])
904
+ expect(
905
+ ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event, 0, testLogger)
906
+ ).toEqual([expectedOperation])
876
907
  })
877
908
 
878
909
  it('should convert a ledger explorer usdc in event to an Operation', () => {
@@ -903,9 +934,9 @@ describe('EVM Family', () => {
903
934
  },
904
935
  }
905
936
 
906
- expect(ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event)).toEqual([
907
- expectedOperation,
908
- ])
937
+ expect(
938
+ ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event, 0, testLogger)
939
+ ).toEqual([expectedOperation])
909
940
  })
910
941
 
911
942
  it('should ignore a ledger explorer usdc none event and return empty array', () => {
@@ -916,7 +947,9 @@ describe('EVM Family', () => {
916
947
  count: '100000000000000',
917
948
  }
918
949
 
919
- expect(ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event)).toEqual([])
950
+ expect(
951
+ ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event, 0, testLogger)
952
+ ).toEqual([])
920
953
  })
921
954
 
922
955
  it('should convert a ledger explorer self usdc event into 2 Operations', () => {
@@ -966,10 +999,9 @@ describe('EVM Family', () => {
966
999
  },
967
1000
  }
968
1001
 
969
- expect(ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event)).toEqual([
970
- expectedOperation1,
971
- expectedOperation2,
972
- ])
1002
+ expect(
1003
+ ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event, 0, testLogger)
1004
+ ).toEqual([expectedOperation1, expectedOperation2])
973
1005
  })
974
1006
 
975
1007
  it('should produce empty recipients when to is an empty string', () => {
@@ -980,7 +1012,13 @@ describe('EVM Family', () => {
980
1012
  count: '100000000000000',
981
1013
  }
982
1014
 
983
- const result = ledgerERC20EventToOperations(address, coinOperation, ledgerERC20Event)
1015
+ const result = ledgerERC20EventToOperations(
1016
+ address,
1017
+ coinOperation,
1018
+ ledgerERC20Event,
1019
+ 0,
1020
+ testLogger
1021
+ )
984
1022
 
985
1023
  expect(result).toHaveLength(1)
986
1024
  expect(result[0].recipients).toEqual([])
@@ -1019,9 +1057,9 @@ describe('EVM Family', () => {
1019
1057
  },
1020
1058
  }
1021
1059
 
1022
- expect(ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event)).toEqual([
1023
- expectedOperation,
1024
- ])
1060
+ expect(
1061
+ ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event, 0, testLogger)
1062
+ ).toEqual([expectedOperation])
1025
1063
  })
1026
1064
 
1027
1065
  it('should convert a ledger explorer erc721 nft in event to an Operation', () => {
@@ -1055,9 +1093,9 @@ describe('EVM Family', () => {
1055
1093
  },
1056
1094
  }
1057
1095
 
1058
- expect(ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event)).toEqual([
1059
- expectedOperation,
1060
- ])
1096
+ expect(
1097
+ ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event, 0, testLogger)
1098
+ ).toEqual([expectedOperation])
1061
1099
  })
1062
1100
 
1063
1101
  it('should ignore a ledger explorer erc721 nft none event and return empty array', () => {
@@ -1069,9 +1107,9 @@ describe('EVM Family', () => {
1069
1107
  '49183440411075624253866807957299276245920874859439606792850319902048050479106',
1070
1108
  }
1071
1109
 
1072
- expect(ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event)).toEqual(
1073
- []
1074
- )
1110
+ expect(
1111
+ ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event, 0, testLogger)
1112
+ ).toEqual([])
1075
1113
  })
1076
1114
 
1077
1115
  it('should convert a ledger explorer erc721 nft event into 2 Operations', () => {
@@ -1120,10 +1158,9 @@ describe('EVM Family', () => {
1120
1158
  },
1121
1159
  }
1122
1160
 
1123
- expect(ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event)).toEqual([
1124
- expectedOperation1,
1125
- expectedOperation2,
1126
- ])
1161
+ expect(
1162
+ ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event, 0, testLogger)
1163
+ ).toEqual([expectedOperation1, expectedOperation2])
1127
1164
  })
1128
1165
 
1129
1166
  it('should produce empty recipients when receiver is an empty string', () => {
@@ -1135,7 +1172,13 @@ describe('EVM Family', () => {
1135
1172
  '49183440411075624253866807957299276245920874859439606792850319902048050479106',
1136
1173
  }
1137
1174
 
1138
- const result = ledgerERC721EventToOperations(address, coinOperation, ledgerERC721Event)
1175
+ const result = ledgerERC721EventToOperations(
1176
+ address,
1177
+ coinOperation,
1178
+ ledgerERC721Event,
1179
+ 0,
1180
+ testLogger
1181
+ )
1139
1182
 
1140
1183
  // sender matches account → NFT_OUT is emitted, but recipients must not contain empty string
1141
1184
  expect(result).toHaveLength(1)
@@ -1200,7 +1243,13 @@ describe('EVM Family', () => {
1200
1243
  }
1201
1244
 
1202
1245
  expect(
1203
- ledgerERC1155EventToOperations(address, coinOperation, ledgerERC1155Event)
1246
+ ledgerERC1155EventToOperations(
1247
+ address,
1248
+ coinOperation,
1249
+ ledgerERC1155Event,
1250
+ 0,
1251
+ testLogger
1252
+ )
1204
1253
  ).toEqual([expectedOperation1, expectedOperation2])
1205
1254
  })
1206
1255
 
@@ -1260,7 +1309,13 @@ describe('EVM Family', () => {
1260
1309
  }
1261
1310
 
1262
1311
  expect(
1263
- ledgerERC1155EventToOperations(address, coinOperation, ledgerERC1155Event)
1312
+ ledgerERC1155EventToOperations(
1313
+ address,
1314
+ coinOperation,
1315
+ ledgerERC1155Event,
1316
+ 0,
1317
+ testLogger
1318
+ )
1264
1319
  ).toEqual([expectedOperation1, expectedOperation2])
1265
1320
  })
1266
1321
 
@@ -1283,7 +1338,13 @@ describe('EVM Family', () => {
1283
1338
  }
1284
1339
 
1285
1340
  expect(
1286
- ledgerERC1155EventToOperations(address, coinOperation, ledgerERC1155Event)
1341
+ ledgerERC1155EventToOperations(
1342
+ address,
1343
+ coinOperation,
1344
+ ledgerERC1155Event,
1345
+ 0,
1346
+ testLogger
1347
+ )
1287
1348
  ).toEqual([])
1288
1349
  })
1289
1350
 
@@ -1375,7 +1436,13 @@ describe('EVM Family', () => {
1375
1436
  }
1376
1437
 
1377
1438
  expect(
1378
- ledgerERC1155EventToOperations(address, coinOperation, ledgerERC1155Event)
1439
+ ledgerERC1155EventToOperations(
1440
+ address,
1441
+ coinOperation,
1442
+ ledgerERC1155Event,
1443
+ 0,
1444
+ testLogger
1445
+ )
1379
1446
  ).toEqual([
1380
1447
  expectedOperation1,
1381
1448
  expectedOperation2,
@@ -1393,7 +1460,13 @@ describe('EVM Family', () => {
1393
1460
  transfers: [{ id: '10371', value: '1' }],
1394
1461
  }
1395
1462
 
1396
- const result = ledgerERC1155EventToOperations(address, coinOperation, ledgerERC1155Event)
1463
+ const result = ledgerERC1155EventToOperations(
1464
+ address,
1465
+ coinOperation,
1466
+ ledgerERC1155Event,
1467
+ 0,
1468
+ testLogger
1469
+ )
1397
1470
 
1398
1471
  // sender matches account → NFT_OUT is emitted, but recipients must not contain empty string
1399
1472
  expect(result).toHaveLength(1)
@@ -1417,7 +1490,9 @@ describe('EVM Family', () => {
1417
1490
  ledgerInternalTransactionToOperations(
1418
1491
  address,
1419
1492
  { ...coinOperation, tx: { ...coinOperation.tx, failed: true } },
1420
- ledgerAction
1493
+ ledgerAction,
1494
+ 0,
1495
+ testLogger
1421
1496
  )
1422
1497
  ).toEqual([])
1423
1498
  })
@@ -1445,7 +1520,13 @@ describe('EVM Family', () => {
1445
1520
  }
1446
1521
 
1447
1522
  expect(
1448
- ledgerInternalTransactionToOperations(address, coinOperation, ledgerAction)
1523
+ ledgerInternalTransactionToOperations(
1524
+ address,
1525
+ coinOperation,
1526
+ ledgerAction,
1527
+ 0,
1528
+ testLogger
1529
+ )
1449
1530
  ).toEqual([expectedOperation])
1450
1531
  })
1451
1532
 
@@ -1472,7 +1553,13 @@ describe('EVM Family', () => {
1472
1553
  }
1473
1554
 
1474
1555
  expect(
1475
- ledgerInternalTransactionToOperations(address, coinOperation, ledgerAction)
1556
+ ledgerInternalTransactionToOperations(
1557
+ address,
1558
+ coinOperation,
1559
+ ledgerAction,
1560
+ 0,
1561
+ testLogger
1562
+ )
1476
1563
  ).toEqual([expectedOperation])
1477
1564
  })
1478
1565
 
@@ -1508,14 +1595,32 @@ describe('EVM Family', () => {
1508
1595
  }
1509
1596
 
1510
1597
  expect(
1511
- ledgerInternalTransactionToOperations(address, coinOperationFees, ledgerActionOutOrFees)
1598
+ ledgerInternalTransactionToOperations(
1599
+ address,
1600
+ coinOperationFees,
1601
+ ledgerActionOutOrFees,
1602
+ 0,
1603
+ testLogger
1604
+ )
1512
1605
  ).toEqual([])
1513
1606
  expect(
1514
- ledgerInternalTransactionToOperations(address, coinOperationOut, ledgerActionOutOrFees)
1607
+ ledgerInternalTransactionToOperations(
1608
+ address,
1609
+ coinOperationOut,
1610
+ ledgerActionOutOrFees,
1611
+ 0,
1612
+ testLogger
1613
+ )
1515
1614
  ).toEqual([])
1516
1615
 
1517
1616
  expect(
1518
- ledgerInternalTransactionToOperations(address, coinOperationIn, ledgerActionIn)
1617
+ ledgerInternalTransactionToOperations(
1618
+ address,
1619
+ coinOperationIn,
1620
+ ledgerActionIn,
1621
+ 0,
1622
+ testLogger
1623
+ )
1519
1624
  ).toEqual([])
1520
1625
  })
1521
1626
 
@@ -1540,7 +1645,9 @@ describe('EVM Family', () => {
1540
1645
  ledgerInternalTransactionToOperations(
1541
1646
  address,
1542
1647
  coinOpOutWithTransfer,
1543
- actionSameFromToDifferentValue
1648
+ actionSameFromToDifferentValue,
1649
+ 0,
1650
+ testLogger
1544
1651
  )
1545
1652
  ).toEqual([])
1546
1653
 
@@ -1552,7 +1659,9 @@ describe('EVM Family', () => {
1552
1659
  const result = ledgerInternalTransactionToOperations(
1553
1660
  address,
1554
1661
  coinOpOutWithTransfer,
1555
- actionDifferentValue
1662
+ actionDifferentValue,
1663
+ 0,
1664
+ testLogger
1556
1665
  )
1557
1666
  expect(result).toHaveLength(1)
1558
1667
  expect(result[0].value.toString()).toBe('1')
@@ -1570,7 +1679,13 @@ describe('EVM Family', () => {
1570
1679
  }
1571
1680
 
1572
1681
  expect(
1573
- ledgerInternalTransactionToOperations(address, coinOperation, ledgerAction)
1682
+ ledgerInternalTransactionToOperations(
1683
+ address,
1684
+ coinOperation,
1685
+ ledgerAction,
1686
+ 0,
1687
+ testLogger
1688
+ )
1574
1689
  ).toEqual([])
1575
1690
  })
1576
1691
 
@@ -1611,7 +1726,13 @@ describe('EVM Family', () => {
1611
1726
  ]
1612
1727
 
1613
1728
  expect(
1614
- ledgerInternalTransactionToOperations(address, coinOperation, ledgerAction)
1729
+ ledgerInternalTransactionToOperations(
1730
+ address,
1731
+ coinOperation,
1732
+ ledgerAction,
1733
+ 0,
1734
+ testLogger
1735
+ )
1615
1736
  ).toEqual(expectedOperations)
1616
1737
  })
1617
1738
 
@@ -1626,7 +1747,13 @@ describe('EVM Family', () => {
1626
1747
  error: null,
1627
1748
  }
1628
1749
 
1629
- const result = ledgerInternalTransactionToOperations(address, coinOperation, ledgerAction)
1750
+ const result = ledgerInternalTransactionToOperations(
1751
+ address,
1752
+ coinOperation,
1753
+ ledgerAction,
1754
+ 0,
1755
+ testLogger
1756
+ )
1630
1757
 
1631
1758
  // from matches account → OUT is emitted, but recipients must not contain empty string
1632
1759
  expect(result).toHaveLength(1)