@ledgerhq/coin-evm 2.28.0-nightly.3 → 2.28.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 (260) hide show
  1. package/.eslintrc.js +0 -1
  2. package/.turbo/turbo-build.log +1 -1
  3. package/CHANGELOG.md +20 -32
  4. package/{lib-es/__fixtures__/ethereum-erc20-weth.json → lib/__fixtures__/ethereum-erc20-usd_tether__erc20_.json} +8 -8
  5. package/lib/__fixtures__/{optimism-erc20-usd_coin.json → scroll_sepolia-erc20-new_token_mock.json} +20 -21
  6. package/lib/__tests__/fixtures/accounts.fixtures.d.ts +1 -1
  7. package/lib/__tests__/fixtures/accounts.fixtures.d.ts.map +1 -1
  8. package/lib/__tests__/fixtures/accounts.fixtures.js +19 -2
  9. package/lib/__tests__/fixtures/accounts.fixtures.js.map +1 -1
  10. package/lib/__tests__/fixtures/common.fixtures.d.ts +0 -1
  11. package/lib/__tests__/fixtures/common.fixtures.d.ts.map +1 -1
  12. package/lib/__tests__/fixtures/common.fixtures.js +0 -1
  13. package/lib/__tests__/fixtures/common.fixtures.js.map +1 -1
  14. package/lib/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -1
  15. package/lib/__tests__/fixtures/prepareTransaction.fixtures.js +2 -3
  16. package/lib/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -1
  17. package/lib/__tests__/fixtures/synchronization.fixtures.d.ts +1 -1
  18. package/lib/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -1
  19. package/lib/__tests__/fixtures/synchronization.fixtures.js +18 -3
  20. package/lib/__tests__/fixtures/synchronization.fixtures.js.map +1 -1
  21. package/lib/__tests__/fixtures/transaction.fixtures.d.ts +2 -2
  22. package/lib/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -1
  23. package/lib/__tests__/fixtures/transaction.fixtures.js +2 -3
  24. package/lib/__tests__/fixtures/transaction.fixtures.js.map +1 -1
  25. package/lib/__tests__/unit/accounts.unit.test.js +27 -0
  26. package/lib/__tests__/unit/accounts.unit.test.js.map +1 -1
  27. package/lib/__tests__/unit/adapters/etherscan.unit.test.js +7 -72
  28. package/lib/__tests__/unit/adapters/etherscan.unit.test.js.map +1 -1
  29. package/lib/__tests__/unit/adapters/ledger.unit.test.js +2 -15
  30. package/lib/__tests__/unit/adapters/ledger.unit.test.js.map +1 -1
  31. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js +0 -8
  32. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -1
  33. package/lib/__tests__/unit/api/explorer/ledger.unit.test.js +0 -12
  34. package/lib/__tests__/unit/api/explorer/ledger.unit.test.js.map +1 -1
  35. package/lib/__tests__/unit/broadcast.unit.test.js +1 -3
  36. package/lib/__tests__/unit/broadcast.unit.test.js.map +1 -1
  37. package/lib/__tests__/unit/buildOptimisticOperation.unit.test.js +1 -3
  38. package/lib/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -1
  39. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts +1 -1
  40. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -1
  41. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js +0 -1
  42. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -1
  43. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js +1 -3
  44. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -1
  45. package/lib/__tests__/unit/getTransactionStatus.unit.test.js +1 -3
  46. package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -1
  47. package/lib/__tests__/unit/logic.unit.test.js +18 -22
  48. package/lib/__tests__/unit/logic.unit.test.js.map +1 -1
  49. package/lib/__tests__/unit/operation.test.js +2 -6
  50. package/lib/__tests__/unit/operation.test.js.map +1 -1
  51. package/lib/__tests__/unit/prepareTransaction.unit.test.js +17 -4
  52. package/lib/__tests__/unit/prepareTransaction.unit.test.js.map +1 -1
  53. package/lib/adapters/etherscan.d.ts.map +1 -1
  54. package/lib/adapters/etherscan.js +2 -2
  55. package/lib/adapters/etherscan.js.map +1 -1
  56. package/lib/adapters/ledger.d.ts.map +1 -1
  57. package/lib/adapters/ledger.js +2 -2
  58. package/lib/adapters/ledger.js.map +1 -1
  59. package/lib/api/index.d.ts.map +1 -1
  60. package/lib/api/index.js +4 -2
  61. package/lib/api/index.js.map +1 -1
  62. package/lib/bridge/js.d.ts +1 -2
  63. package/lib/bridge/js.d.ts.map +1 -1
  64. package/lib/bridge/js.js +1 -3
  65. package/lib/bridge/js.js.map +1 -1
  66. package/lib/bridge/preload.d.ts +0 -1
  67. package/lib/bridge/preload.d.ts.map +1 -1
  68. package/lib/bridge/preload.js +1 -10
  69. package/lib/bridge/preload.js.map +1 -1
  70. package/lib/deviceTransactionConfig.d.ts.map +1 -1
  71. package/lib/deviceTransactionConfig.js +2 -2
  72. package/lib/deviceTransactionConfig.js.map +1 -1
  73. package/lib/logic/common.d.ts +0 -18
  74. package/lib/logic/common.d.ts.map +1 -1
  75. package/lib/logic/common.js +1 -35
  76. package/lib/logic/common.js.map +1 -1
  77. package/lib/logic/estimateFees.d.ts +1 -1
  78. package/lib/logic/estimateFees.d.ts.map +1 -1
  79. package/lib/logic/estimateFees.js +12 -25
  80. package/lib/logic/estimateFees.js.map +1 -1
  81. package/lib/logic/estimateFees.test.js +41 -93
  82. package/lib/logic/estimateFees.test.js.map +1 -1
  83. package/lib/logic/index.d.ts +0 -1
  84. package/lib/logic/index.d.ts.map +1 -1
  85. package/lib/logic/index.js +0 -1
  86. package/lib/logic/index.js.map +1 -1
  87. package/lib/types/transaction.d.ts +0 -9
  88. package/lib/types/transaction.d.ts.map +1 -1
  89. package/{lib/__fixtures__/ethereum-erc20-weth.json → lib-es/__fixtures__/ethereum-erc20-usd_tether__erc20_.json} +8 -8
  90. package/lib-es/__fixtures__/{optimism-erc20-usd_coin.json → scroll_sepolia-erc20-new_token_mock.json} +20 -21
  91. package/lib-es/__tests__/fixtures/accounts.fixtures.d.ts +1 -1
  92. package/lib-es/__tests__/fixtures/accounts.fixtures.d.ts.map +1 -1
  93. package/lib-es/__tests__/fixtures/accounts.fixtures.js +18 -1
  94. package/lib-es/__tests__/fixtures/accounts.fixtures.js.map +1 -1
  95. package/lib-es/__tests__/fixtures/common.fixtures.d.ts +0 -1
  96. package/lib-es/__tests__/fixtures/common.fixtures.d.ts.map +1 -1
  97. package/lib-es/__tests__/fixtures/common.fixtures.js +0 -1
  98. package/lib-es/__tests__/fixtures/common.fixtures.js.map +1 -1
  99. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -1
  100. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js +2 -3
  101. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -1
  102. package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts +1 -1
  103. package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -1
  104. package/lib-es/__tests__/fixtures/synchronization.fixtures.js +18 -3
  105. package/lib-es/__tests__/fixtures/synchronization.fixtures.js.map +1 -1
  106. package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts +2 -2
  107. package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -1
  108. package/lib-es/__tests__/fixtures/transaction.fixtures.js +2 -3
  109. package/lib-es/__tests__/fixtures/transaction.fixtures.js.map +1 -1
  110. package/lib-es/__tests__/unit/accounts.unit.test.js +27 -0
  111. package/lib-es/__tests__/unit/accounts.unit.test.js.map +1 -1
  112. package/lib-es/__tests__/unit/adapters/etherscan.unit.test.js +7 -72
  113. package/lib-es/__tests__/unit/adapters/etherscan.unit.test.js.map +1 -1
  114. package/lib-es/__tests__/unit/adapters/ledger.unit.test.js +2 -15
  115. package/lib-es/__tests__/unit/adapters/ledger.unit.test.js.map +1 -1
  116. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js +0 -8
  117. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -1
  118. package/lib-es/__tests__/unit/api/explorer/ledger.unit.test.js +0 -12
  119. package/lib-es/__tests__/unit/api/explorer/ledger.unit.test.js.map +1 -1
  120. package/lib-es/__tests__/unit/broadcast.unit.test.js +2 -4
  121. package/lib-es/__tests__/unit/broadcast.unit.test.js.map +1 -1
  122. package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.js +2 -4
  123. package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -1
  124. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts +1 -1
  125. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -1
  126. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js +0 -1
  127. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -1
  128. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js +2 -4
  129. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -1
  130. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js +2 -4
  131. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -1
  132. package/lib-es/__tests__/unit/logic.unit.test.js +19 -23
  133. package/lib-es/__tests__/unit/logic.unit.test.js.map +1 -1
  134. package/lib-es/__tests__/unit/operation.test.js +3 -7
  135. package/lib-es/__tests__/unit/operation.test.js.map +1 -1
  136. package/lib-es/__tests__/unit/prepareTransaction.unit.test.js +17 -4
  137. package/lib-es/__tests__/unit/prepareTransaction.unit.test.js.map +1 -1
  138. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  139. package/lib-es/adapters/etherscan.js +2 -2
  140. package/lib-es/adapters/etherscan.js.map +1 -1
  141. package/lib-es/adapters/ledger.d.ts.map +1 -1
  142. package/lib-es/adapters/ledger.js +2 -2
  143. package/lib-es/adapters/ledger.js.map +1 -1
  144. package/lib-es/api/index.d.ts.map +1 -1
  145. package/lib-es/api/index.js +5 -3
  146. package/lib-es/api/index.js.map +1 -1
  147. package/lib-es/bridge/js.d.ts +1 -2
  148. package/lib-es/bridge/js.d.ts.map +1 -1
  149. package/lib-es/bridge/js.js +1 -3
  150. package/lib-es/bridge/js.js.map +1 -1
  151. package/lib-es/bridge/preload.d.ts +0 -1
  152. package/lib-es/bridge/preload.d.ts.map +1 -1
  153. package/lib-es/bridge/preload.js +0 -8
  154. package/lib-es/bridge/preload.js.map +1 -1
  155. package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
  156. package/lib-es/deviceTransactionConfig.js +2 -2
  157. package/lib-es/deviceTransactionConfig.js.map +1 -1
  158. package/lib-es/logic/common.d.ts +0 -18
  159. package/lib-es/logic/common.d.ts.map +1 -1
  160. package/lib-es/logic/common.js +0 -30
  161. package/lib-es/logic/common.js.map +1 -1
  162. package/lib-es/logic/estimateFees.d.ts +1 -1
  163. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  164. package/lib-es/logic/estimateFees.js +12 -25
  165. package/lib-es/logic/estimateFees.js.map +1 -1
  166. package/lib-es/logic/estimateFees.test.js +41 -93
  167. package/lib-es/logic/estimateFees.test.js.map +1 -1
  168. package/lib-es/logic/index.d.ts +0 -1
  169. package/lib-es/logic/index.d.ts.map +1 -1
  170. package/lib-es/logic/index.js +0 -1
  171. package/lib-es/logic/index.js.map +1 -1
  172. package/lib-es/types/transaction.d.ts +0 -9
  173. package/lib-es/types/transaction.d.ts.map +1 -1
  174. package/package.json +13 -13
  175. package/src/__tests__/fixtures/accounts.fixtures.ts +23 -1
  176. package/src/__tests__/fixtures/common.fixtures.ts +0 -1
  177. package/src/__tests__/fixtures/prepareTransaction.fixtures.ts +4 -4
  178. package/src/__tests__/fixtures/synchronization.fixtures.ts +20 -3
  179. package/src/__tests__/fixtures/transaction.fixtures.ts +3 -4
  180. package/src/__tests__/unit/accounts.unit.test.ts +36 -0
  181. package/src/__tests__/unit/adapters/etherscan.unit.test.ts +7 -87
  182. package/src/__tests__/unit/adapters/ledger.unit.test.ts +2 -20
  183. package/src/__tests__/unit/api/explorer/etherscan.unit.test.ts +0 -12
  184. package/src/__tests__/unit/api/explorer/ledger.unit.test.ts +0 -16
  185. package/src/__tests__/unit/broadcast.unit.test.ts +3 -5
  186. package/src/__tests__/unit/buildOptimisticOperation.unit.test.ts +2 -5
  187. package/src/__tests__/unit/deviceTransactionConfig.unit.test.ts +0 -1
  188. package/src/__tests__/unit/estimateMaxSpendable.unit.test.ts +3 -5
  189. package/src/__tests__/unit/getTransactionStatus.unit.test.ts +2 -5
  190. package/src/__tests__/unit/logic.unit.test.ts +29 -41
  191. package/src/__tests__/unit/operation.test.ts +5 -9
  192. package/src/__tests__/unit/prepareTransaction.unit.test.ts +18 -4
  193. package/src/adapters/etherscan.ts +2 -5
  194. package/src/adapters/ledger.ts +2 -5
  195. package/src/api/index.ts +5 -4
  196. package/src/bridge/js.ts +0 -4
  197. package/src/bridge/preload.ts +0 -8
  198. package/src/deviceTransactionConfig.ts +2 -3
  199. package/src/logic/common.ts +0 -52
  200. package/src/logic/estimateFees.test.ts +57 -98
  201. package/src/logic/estimateFees.ts +18 -28
  202. package/src/logic/index.ts +0 -1
  203. package/src/types/transaction.ts +0 -12
  204. package/lib/__fixtures__/cardano-native-8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552.json +0 -52
  205. package/lib/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0.json +0 -20
  206. package/lib/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0.json +0 -19
  207. package/lib/__tests__/fixtures/cryptoAssetsStore.fixtures.d.ts +0 -2
  208. package/lib/__tests__/fixtures/cryptoAssetsStore.fixtures.d.ts.map +0 -1
  209. package/lib/__tests__/fixtures/cryptoAssetsStore.fixtures.js +0 -44
  210. package/lib/__tests__/fixtures/cryptoAssetsStore.fixtures.js.map +0 -1
  211. package/lib/cryptoAssetsStore.d.ts +0 -5
  212. package/lib/cryptoAssetsStore.d.ts.map +0 -1
  213. package/lib/cryptoAssetsStore.js +0 -17
  214. package/lib/cryptoAssetsStore.js.map +0 -1
  215. package/lib/cryptoAssetsStore.test.d.ts +0 -2
  216. package/lib/cryptoAssetsStore.test.d.ts.map +0 -1
  217. package/lib/cryptoAssetsStore.test.js +0 -15
  218. package/lib/cryptoAssetsStore.test.js.map +0 -1
  219. package/lib/logic/validateIntent.d.ts +0 -4
  220. package/lib/logic/validateIntent.d.ts.map +0 -1
  221. package/lib/logic/validateIntent.js +0 -192
  222. package/lib/logic/validateIntent.js.map +0 -1
  223. package/lib/logic/validateIntent.test.d.ts +0 -2
  224. package/lib/logic/validateIntent.test.d.ts.map +0 -1
  225. package/lib/logic/validateIntent.test.js +0 -485
  226. package/lib/logic/validateIntent.test.js.map +0 -1
  227. package/lib-es/__fixtures__/cardano-native-8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552.json +0 -52
  228. package/lib-es/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0.json +0 -20
  229. package/lib-es/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0.json +0 -19
  230. package/lib-es/__tests__/fixtures/cryptoAssetsStore.fixtures.d.ts +0 -2
  231. package/lib-es/__tests__/fixtures/cryptoAssetsStore.fixtures.d.ts.map +0 -1
  232. package/lib-es/__tests__/fixtures/cryptoAssetsStore.fixtures.js +0 -19
  233. package/lib-es/__tests__/fixtures/cryptoAssetsStore.fixtures.js.map +0 -1
  234. package/lib-es/cryptoAssetsStore.d.ts +0 -5
  235. package/lib-es/cryptoAssetsStore.d.ts.map +0 -1
  236. package/lib-es/cryptoAssetsStore.js +0 -12
  237. package/lib-es/cryptoAssetsStore.js.map +0 -1
  238. package/lib-es/cryptoAssetsStore.test.d.ts +0 -2
  239. package/lib-es/cryptoAssetsStore.test.d.ts.map +0 -1
  240. package/lib-es/cryptoAssetsStore.test.js +0 -13
  241. package/lib-es/cryptoAssetsStore.test.js.map +0 -1
  242. package/lib-es/logic/validateIntent.d.ts +0 -4
  243. package/lib-es/logic/validateIntent.d.ts.map +0 -1
  244. package/lib-es/logic/validateIntent.js +0 -185
  245. package/lib-es/logic/validateIntent.js.map +0 -1
  246. package/lib-es/logic/validateIntent.test.d.ts +0 -2
  247. package/lib-es/logic/validateIntent.test.d.ts.map +0 -1
  248. package/lib-es/logic/validateIntent.test.js +0 -480
  249. package/lib-es/logic/validateIntent.test.js.map +0 -1
  250. package/src/__fixtures__/cardano-native-8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552.json +0 -52
  251. package/src/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0.json +0 -20
  252. package/src/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0.json +0 -19
  253. package/src/__fixtures__/ethereum-erc20-usd__coin-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48.json +0 -73
  254. package/src/__fixtures__/ethereum-erc20-weth.json +0 -73
  255. package/src/__fixtures__/optimism-erc20-usd_coin.json +0 -69
  256. package/src/__tests__/fixtures/cryptoAssetsStore.fixtures.ts +0 -24
  257. package/src/cryptoAssetsStore.test.ts +0 -19
  258. package/src/cryptoAssetsStore.ts +0 -16
  259. package/src/logic/validateIntent.test.ts +0 -659
  260. package/src/logic/validateIntent.ts +0 -274
@@ -1,8 +1,7 @@
1
1
  import BigNumber from "bignumber.js";
2
2
  import { encodeAccountId, encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
3
3
  import { Operation } from "@ledgerhq/types-live";
4
- import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
5
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
4
+ import { findTokenById } from "@ledgerhq/cryptoassets";
6
5
  import {
7
6
  etherscanERC1155EventToOperations,
8
7
  etherscanERC20EventToOperations,
@@ -17,39 +16,11 @@ import {
17
16
  EtherscanInternalTransaction,
18
17
  EtherscanOperation,
19
18
  } from "../../../types";
20
- import usdCoinTokenData from "../../../__fixtures__/ethereum-erc20-usd__coin.json";
21
- import outUsdCoinTokenData from "../../../__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0.json";
22
- import inUsdCoinTokenData from "../../../__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0.json";
23
- import { setCryptoAssetsStoreGetter } from "../../../cryptoAssetsStore";
24
-
25
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
26
- const USD_COIN_TOKEN = usdCoinTokenData as unknown as TokenCurrency;
27
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
28
- const OUT_USD_COIN_TOKEN = outUsdCoinTokenData as unknown as TokenCurrency;
29
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
30
- const IN_USD_COIN_TOKEN = inUsdCoinTokenData as unknown as TokenCurrency;
31
19
 
32
20
  describe("EVM Family", () => {
33
21
  describe("adapters", () => {
34
22
  describe("etherscan", () => {
35
23
  describe("etherscanOperationToOperations", () => {
36
- beforeEach(() => {
37
- setCryptoAssetsStoreGetter(
38
- () =>
39
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
40
- ({
41
- findTokenByAddressInCurrency: (address: string, _currencyId: string) => {
42
- if (address === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48") {
43
- return IN_USD_COIN_TOKEN;
44
- } else if (address === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb41") {
45
- return OUT_USD_COIN_TOKEN;
46
- }
47
- return undefined;
48
- },
49
- }) as CryptoAssetsStore,
50
- );
51
- });
52
-
53
24
  it("should convert an etherscan-like smart contract creation operation (from their API) to a Ledger Live Operation", () => {
54
25
  const etherscanOp: EtherscanOperation = {
55
26
  blockNumber: "14923692",
@@ -530,16 +501,6 @@ describe("EVM Family", () => {
530
501
 
531
502
  describe("etherscanERC20EventToOperations", () => {
532
503
  it("should return an empty array for an unknown token", () => {
533
- setCryptoAssetsStoreGetter(
534
- () =>
535
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
536
- ({
537
- findTokenByAddressInCurrency: (_address: string, _currencyId: string) => {
538
- return undefined;
539
- },
540
- }) as unknown as CryptoAssetsStore,
541
- );
542
-
543
504
  const etherscanOp: EtherscanERC20Event = {
544
505
  blockNumber: "16240731",
545
506
  timeStamp: "1671717983",
@@ -603,7 +564,8 @@ describe("EVM Family", () => {
603
564
  xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
604
565
  derivationMode: "",
605
566
  });
606
- const tokenAccountId = encodeTokenAccountId(accountId, USD_COIN_TOKEN);
567
+ const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
568
+ const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency!);
607
569
 
608
570
  const expectedOperation: Operation = {
609
571
  id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd~!underscore!~~!underscore!~coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0",
@@ -622,16 +584,6 @@ describe("EVM Family", () => {
622
584
  extra: {},
623
585
  };
624
586
 
625
- setCryptoAssetsStoreGetter(
626
- () =>
627
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
628
- ({
629
- findTokenByAddressInCurrency: (_address: string, _currencyId: string) => {
630
- return USD_COIN_TOKEN;
631
- },
632
- }) as unknown as CryptoAssetsStore,
633
- );
634
-
635
587
  expect(etherscanERC20EventToOperations(accountId, etherscanOp)).toEqual([
636
588
  expectedOperation,
637
589
  ]);
@@ -667,7 +619,8 @@ describe("EVM Family", () => {
667
619
  xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
668
620
  derivationMode: "",
669
621
  });
670
- const tokenAccountId = encodeTokenAccountId(accountId, USD_COIN_TOKEN);
622
+ const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
623
+ const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency!);
671
624
 
672
625
  const expectedOperation: Operation = {
673
626
  id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd~!underscore!~~!underscore!~coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0",
@@ -755,7 +708,8 @@ describe("EVM Family", () => {
755
708
  xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
756
709
  derivationMode: "",
757
710
  });
758
- const tokenAccountId = encodeTokenAccountId(accountId, USD_COIN_TOKEN);
711
+ const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
712
+ const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency!);
759
713
 
760
714
  const expectedOperations: Operation[] = [
761
715
  {
@@ -799,23 +753,6 @@ describe("EVM Family", () => {
799
753
  });
800
754
 
801
755
  describe("etherscanER721EventToOperation", () => {
802
- beforeEach(() => {
803
- setCryptoAssetsStoreGetter(
804
- () =>
805
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
806
- ({
807
- findTokenByAddressInCurrency: (address: string, _currencyId: string) => {
808
- if (address === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48") {
809
- return IN_USD_COIN_TOKEN;
810
- } else if (address === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb41") {
811
- return OUT_USD_COIN_TOKEN;
812
- }
813
- return undefined;
814
- },
815
- }) as unknown as CryptoAssetsStore,
816
- );
817
- });
818
-
819
756
  it("should convert an etherscan-like erc721 nft out event (from their API) to a Ledger Live Operation", () => {
820
757
  const etherscanOp: EtherscanERC721Event = {
821
758
  blockNumber: "4708120",
@@ -1037,23 +974,6 @@ describe("EVM Family", () => {
1037
974
  });
1038
975
 
1039
976
  describe("etherscanERC1155EventToOperations", () => {
1040
- beforeEach(() => {
1041
- setCryptoAssetsStoreGetter(
1042
- () =>
1043
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1044
- ({
1045
- findTokenByAddressInCurrency: (address: string, _currencyId: string) => {
1046
- if (address === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48") {
1047
- return IN_USD_COIN_TOKEN;
1048
- } else if (address === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb41") {
1049
- return OUT_USD_COIN_TOKEN;
1050
- }
1051
- return undefined;
1052
- },
1053
- }) as unknown as CryptoAssetsStore,
1054
- );
1055
- });
1056
-
1057
977
  it("should convert a etherscan-like erc1155 nft out event (from their API) to a Ledger Live Operation", () => {
1058
978
  const etherscanOp: EtherscanERC1155Event = {
1059
979
  blockNumber: "13472395",
@@ -1,8 +1,7 @@
1
1
  import BigNumber from "bignumber.js";
2
2
  import { Operation } from "@ledgerhq/types-live";
3
3
  import { encodeAccountId, encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
4
- import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
5
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
4
+ import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
6
5
  import {
7
6
  ledgerERC1155EventToOperations,
8
7
  ledgerERC20EventToOperations,
@@ -17,8 +16,6 @@ import {
17
16
  LedgerExplorerInternalTransaction,
18
17
  LedgerExplorerOperation,
19
18
  } from "../../../types";
20
- import usdCoinTokenData from "../../../__fixtures__/ethereum-erc20-usd__coin.json";
21
- import { setCryptoAssetsStoreGetter } from "../../../cryptoAssetsStore";
22
19
 
23
20
  const accountId = encodeAccountId({
24
21
  type: "js",
@@ -731,22 +728,7 @@ describe("EVM Family", () => {
731
728
  });
732
729
 
733
730
  describe("ledgerERC20EventToOperations", () => {
734
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
735
- const tokenCurrency = usdCoinTokenData as TokenCurrency;
736
-
737
- beforeAll(() => {
738
- setCryptoAssetsStoreGetter(
739
- () =>
740
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
741
- ({
742
- findTokenByAddressInCurrency: (_address: string, _currencyId: string) => {
743
- return _address === "0x000000000000000000000000000000000000dead"
744
- ? undefined
745
- : tokenCurrency;
746
- },
747
- }) as CryptoAssetsStore,
748
- );
749
- });
731
+ const tokenCurrency = getTokenById("ethereum/erc20/usd__coin");
750
732
 
751
733
  it("should return an empty array for an unknown token", () => {
752
734
  const ledgerERC20Event: LedgerExplorerERC20TransferEvent = {
@@ -3,7 +3,6 @@ import axios from "axios";
3
3
  import { delay } from "@ledgerhq/live-promise";
4
4
  import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
5
5
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
6
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
7
6
  import { EtherscanLikeExplorerUsedIncorrectly } from "../../../../errors";
8
7
  import * as ETHERSCAN_API from "../../../../network/explorer/etherscan";
9
8
  import { makeAccount } from "../../../fixtures/common.fixtures";
@@ -22,17 +21,6 @@ import {
22
21
  etherscanOperationToOperations,
23
22
  } from "../../../../adapters";
24
23
  import { getCoinConfig } from "../../../../config";
25
- import { setCryptoAssetsStoreGetter } from "../../../../cryptoAssetsStore";
26
-
27
- setCryptoAssetsStoreGetter(
28
- () =>
29
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
30
- ({
31
- findTokenByAddressInCurrency: (_address: string, _currencyId: string) => {
32
- return undefined;
33
- },
34
- }) as CryptoAssetsStore,
35
- );
36
24
 
37
25
  jest.mock("axios");
38
26
  jest.mock("@ledgerhq/live-promise");
@@ -6,7 +6,6 @@ import { delay } from "@ledgerhq/live-promise";
6
6
  import { getEnv, setEnv } from "@ledgerhq/live-env";
7
7
  import { encodeAccountId } from "@ledgerhq/coin-framework/account/index";
8
8
  import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
9
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
10
9
  import { LedgerExplorerUsedIncorrectly } from "../../../../errors";
11
10
  import * as LEDGER_API from "../../../../network/explorer/ledger";
12
11
  import {
@@ -16,21 +15,6 @@ import {
16
15
  coinOperation4,
17
16
  } from "../../../fixtures/explorer/ledger.fixtures";
18
17
  import { getCoinConfig } from "../../../../config";
19
- import tokenData from "../../../../__fixtures__/ethereum-erc20-usd__coin.json";
20
- import { setCryptoAssetsStoreGetter } from "../../../../cryptoAssetsStore";
21
-
22
- setCryptoAssetsStoreGetter(
23
- () =>
24
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
25
- ({
26
- findTokenByAddressInCurrency: (_address: string, _currencyId: string) => {
27
- if (_address === tokenData.contractAddress.toLowerCase()) {
28
- return tokenData;
29
- }
30
- return undefined;
31
- },
32
- }) as CryptoAssetsStore,
33
- );
34
18
 
35
19
  jest.mock("axios");
36
20
  jest.mock("@ledgerhq/live-promise");
@@ -5,8 +5,8 @@ import {
5
5
  encodeERC721OperationId,
6
6
  } from "@ledgerhq/coin-framework/nft/nftOperationId";
7
7
  import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
8
- import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
9
- import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
8
+ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
9
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
10
10
  import { Account, TokenAccount } from "@ledgerhq/types-live";
11
11
  import BigNumber from "bignumber.js";
12
12
  import axios from "axios";
@@ -23,7 +23,6 @@ import {
23
23
  } from "../fixtures/transaction.fixtures";
24
24
  import { getCoinConfig } from "../../config";
25
25
  import { getEstimatedFees } from "../../utils";
26
- import usdtTokenData from "../../__fixtures__/ethereum-erc20-usd__coin.json";
27
26
 
28
27
  jest.useFakeTimers();
29
28
 
@@ -45,8 +44,7 @@ const currency: CryptoCurrency = {
45
44
  ...getCryptoCurrencyById("ethereum").ethereumLikeInfo,
46
45
  } as any,
47
46
  };
48
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
49
- const tokenCurrency = usdtTokenData as TokenCurrency;
47
+ const tokenCurrency = getTokenById("ethereum/erc20/usd__coin");
50
48
  const tokenAccount: TokenAccount = makeTokenAccount(
51
49
  "0x055C1e159E345cB4197e3844a86A61E0a801d856", // jacquie.eth
52
50
  tokenCurrency,
@@ -4,9 +4,8 @@ import {
4
4
  encodeERC721OperationId,
5
5
  } from "@ledgerhq/coin-framework/nft/nftOperationId";
6
6
  import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
7
- import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
7
+ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
8
8
  import BigNumber from "bignumber.js";
9
- import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
10
9
  import buildOptimisticOperation from "../../bridge/buildOptimisticOperation";
11
10
  import { Transaction as EvmTransaction } from "../../types";
12
11
  import { makeAccount, makeTokenAccount } from "../fixtures/common.fixtures";
@@ -16,11 +15,9 @@ import {
16
15
  erc721TokenTransactionRaw,
17
16
  } from "../fixtures/transaction.fixtures";
18
17
  import { getEstimatedFees } from "../../utils";
19
- import usdCoinTokenData from "../../__fixtures__/ethereum-erc20-usd__coin.json";
20
18
 
21
19
  const currency = getCryptoCurrencyById("ethereum");
22
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
23
- const tokenCurrency = usdCoinTokenData as TokenCurrency;
20
+ const tokenCurrency = getTokenById("ethereum/erc20/usd__coin");
24
21
  const tokenAccount = {
25
22
  ...makeTokenAccount(
26
23
  "0x055C1e159E345cB4197e3844a86A61E0a801d856", // jacquie.eth
@@ -7,7 +7,6 @@ import { makeAccount, makeTokenAccount } from "../fixtures/common.fixtures";
7
7
  import getDeviceTransactionConfig from "../../deviceTransactionConfig";
8
8
  import getTransactionStatus from "../../bridge/getTransactionStatus";
9
9
  import { Transaction as EvmTransaction } from "../../types";
10
- import "../fixtures/cryptoAssetsStore.fixtures";
11
10
 
12
11
  enum NFT_CONTRACTS {
13
12
  ERC721 = "0x60F80121C31A0d46B5279700f9DF786054aa5eE5",
@@ -1,12 +1,11 @@
1
1
  import BigNumber from "bignumber.js";
2
- import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
3
- import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
2
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
+ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
4
4
  import { makeAccount, makeTokenAccount } from "../fixtures/common.fixtures";
5
5
  import { EvmTransactionEIP1559, EvmTransactionLegacy } from "../../types";
6
6
  import { estimateMaxSpendable } from "../../bridge/estimateMaxSpendable";
7
7
  import * as nodeApi from "../../network/node/rpc.common";
8
8
  import { getCoinConfig } from "../../config";
9
- import usdCoinTokenData from "../../__fixtures__/ethereum-erc20-usd__coin.json";
10
9
 
11
10
  jest.mock("../../config");
12
11
  const mockGetConfig = jest.mocked(getCoinConfig);
@@ -18,8 +17,7 @@ const currency: CryptoCurrency = {
18
17
  } as any,
19
18
  };
20
19
  const tokenAccount = {
21
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
22
- ...makeTokenAccount("0xkvn", usdCoinTokenData as TokenCurrency),
20
+ ...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
23
21
  balance: new BigNumber(6969),
24
22
  };
25
23
  const account = {
@@ -1,4 +1,4 @@
1
- import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
1
+ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
2
2
  import {
3
3
  AmountRequired,
4
4
  ETHAddressNonEIP,
@@ -18,7 +18,6 @@ import {
18
18
  import { ProtoNFT } from "@ledgerhq/types-live";
19
19
  import BigNumber from "bignumber.js";
20
20
  import fc from "fast-check";
21
- import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
22
21
  import { NotEnoughNftOwned, NotOwnedNft, QuantityNeedsToBePositive } from "../../errors";
23
22
  import * as getTransactionStatusModule from "../../bridge/getTransactionStatus";
24
23
  import {
@@ -33,7 +32,6 @@ import {
33
32
  getMinEip1559Fees,
34
33
  getMinLegacyFees,
35
34
  } from "../../editTransaction/getMinEditTransactionFees";
36
- import usdCoinTokenData from "../../__fixtures__/ethereum-erc20-usd__coin.json";
37
35
 
38
36
  const {
39
37
  default: getTransactionStatus,
@@ -43,8 +41,7 @@ const {
43
41
 
44
42
  const recipient = "0xe2ca7390e76c5A992749bB622087310d2e63ca29"; // rambo.eth
45
43
  const testData = Buffer.from("testBufferString").toString("hex");
46
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
47
- const tokenAccount = makeTokenAccount("0xkvn", usdCoinTokenData as TokenCurrency);
44
+ const tokenAccount = makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin"));
48
45
  const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"), [tokenAccount]);
49
46
  const legacyTx: EvmTransactionLegacy = {
50
47
  amount: new BigNumber(100),
@@ -1,14 +1,10 @@
1
1
  import BigNumber from "bignumber.js";
2
2
  import { getEnv, setEnv } from "@ledgerhq/live-env";
3
3
  import * as EVM_TOOLS from "@ledgerhq/evm-tools/message/EIP712/index";
4
- import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
5
- import {
6
- CryptoCurrency,
7
- CryptoCurrencyId,
8
- TokenCurrency,
9
- Unit,
10
- } from "@ledgerhq/types-cryptoassets";
11
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
4
+ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
5
+ import { CryptoCurrency, CryptoCurrencyId, Unit } from "@ledgerhq/types-cryptoassets";
6
+ import { CryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/type";
7
+ import { setCryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/index";
12
8
  import * as RPC_API from "../../network/node/rpc.common";
13
9
  import { getCoinConfig } from "../../config";
14
10
  import {
@@ -37,13 +33,6 @@ import {
37
33
  } from "../../types";
38
34
  import { getEstimatedFees, getGasLimit, padHexString, safeEncodeEIP55 } from "../../utils";
39
35
  import usdCoinTokenData from "../../__fixtures__/ethereum-erc20-usd__coin.json";
40
- import wethTokenData from "../../__fixtures__/ethereum-erc20-weth.json";
41
- import { setCryptoAssetsStoreGetter } from "../../cryptoAssetsStore";
42
-
43
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
44
- const USD_COIN_TOKEN = usdCoinTokenData as unknown as TokenCurrency;
45
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
46
- const WETH_TOKEN = wethTokenData as unknown as TokenCurrency;
47
36
 
48
37
  jest.mock("../../config");
49
38
  const mockGetConfig = jest.mocked(getCoinConfig);
@@ -361,12 +350,12 @@ describe("EVM Family", () => {
361
350
  describe("mergeSubAccounts", () => {
362
351
  it("should merge 2 different sub accounts", () => {
363
352
  const tokenAccount1 = {
364
- ...makeTokenAccount("0xkvn", USD_COIN_TOKEN),
353
+ ...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
365
354
  balance: new BigNumber(1),
366
355
  operations: [],
367
356
  };
368
357
  const tokenAccount2 = {
369
- ...makeTokenAccount("0xkvn", WETH_TOKEN),
358
+ ...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/weth")),
370
359
  balance: new BigNumber(2),
371
360
  operations: [],
372
361
  };
@@ -381,7 +370,7 @@ describe("EVM Family", () => {
381
370
 
382
371
  it("should merge 2 different sub accounts and update the first one", () => {
383
372
  const tokenAccount1 = {
384
- ...makeTokenAccount("0xkvn", USD_COIN_TOKEN),
373
+ ...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
385
374
  balance: new BigNumber(1),
386
375
  operations: [],
387
376
  };
@@ -407,7 +396,7 @@ describe("EVM Family", () => {
407
396
  operations: [],
408
397
  };
409
398
  const tokenAccount2 = {
410
- ...makeTokenAccount("0xkvn", WETH_TOKEN),
399
+ ...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/weth")),
411
400
  balance: new BigNumber(2),
412
401
  operations: [],
413
402
  };
@@ -429,7 +418,7 @@ describe("EVM Family", () => {
429
418
  hash: "0xAgAinAnotHeRH4sh",
430
419
  });
431
420
  const tokenAccount1 = {
432
- ...makeTokenAccount("0xkvn", USD_COIN_TOKEN),
421
+ ...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
433
422
  balance: new BigNumber(1),
434
423
  operations: [op1, op2],
435
424
  operationsCount: 2,
@@ -452,7 +441,7 @@ describe("EVM Family", () => {
452
441
 
453
442
  it("should return only new sub accounts", () => {
454
443
  const tokenAccount = {
455
- ...makeTokenAccount("0xkvn", USD_COIN_TOKEN),
444
+ ...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
456
445
  balance: new BigNumber(1),
457
446
  };
458
447
  const account = {
@@ -467,7 +456,7 @@ describe("EVM Family", () => {
467
456
 
468
457
  it("should dedup sub accounts", () => {
469
458
  const tokenAccount = {
470
- ...makeTokenAccount("0xkvn", USD_COIN_TOKEN),
459
+ ...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
471
460
  balance: new BigNumber(1),
472
461
  };
473
462
  const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"), [tokenAccount]);
@@ -494,7 +483,7 @@ describe("EVM Family", () => {
494
483
 
495
484
  it("maps TokenAccounts to their swapHistory", () => {
496
485
  const tokenAccount1 = {
497
- ...makeTokenAccount("0xCrema1", USD_COIN_TOKEN),
486
+ ...makeTokenAccount("0xCrema1", getTokenById("ethereum/erc20/usd__coin")),
498
487
  swapHistory: [
499
488
  {
500
489
  status: "pending",
@@ -508,7 +497,7 @@ describe("EVM Family", () => {
508
497
  ],
509
498
  };
510
499
  const tokenAccount2 = {
511
- ...makeTokenAccount("0xCrema2", WETH_TOKEN),
500
+ ...makeTokenAccount("0xCrema2", getTokenById("ethereum/erc20/weth")),
512
501
  swapHistory: [
513
502
  {
514
503
  status: "pending",
@@ -534,7 +523,7 @@ describe("EVM Family", () => {
534
523
  });
535
524
  it("should include correct swapHistory for a token account", () => {
536
525
  const tokenAccount = {
537
- ...makeTokenAccount("0xCrema", USD_COIN_TOKEN),
526
+ ...makeTokenAccount("0xCrema", getTokenById("ethereum/erc20/usd__coin")),
538
527
  swapHistory: [
539
528
  {
540
529
  status: "pending",
@@ -641,26 +630,24 @@ describe("EVM Family", () => {
641
630
  });
642
631
 
643
632
  it("should provide a new hash if a token is added to the blacklistedTokenIds", () => {
644
- expect(getSyncHash(currency)).not.toEqual(getSyncHash(currency, [USD_COIN_TOKEN.id]));
633
+ const token = getTokenById("ethereum/erc20/usd__coin");
634
+ expect(getSyncHash(currency)).not.toEqual(getSyncHash(currency, [token.id]));
645
635
  });
646
636
  });
647
637
 
648
638
  describe("attachOperations", () => {
649
639
  it("should attach token & nft operations to coin operations and create 'NONE' coin operations in case of orphans child operations", () => {
650
- setCryptoAssetsStoreGetter(
651
- () =>
652
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
653
- ({
654
- findTokenById: (id: string) => {
655
- if (id === "ethereum/erc20/usd__coin") {
656
- return USD_COIN_TOKEN;
657
- }
658
-
659
- return undefined;
660
- },
661
- findTokenByAddressInCurrency: (_: string, __: string) => undefined,
662
- }) as CryptoAssetsStore,
663
- );
640
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
641
+ setCryptoAssetsStore({
642
+ findTokenById: (id: string) => {
643
+ if (id === "ethereum/erc20/usd__coin") {
644
+ return usdCoinTokenData;
645
+ }
646
+
647
+ return undefined;
648
+ },
649
+ findTokenByAddressInCurrency: (_: string, __: string) => undefined,
650
+ } as CryptoAssetsStore);
664
651
  const coinOperation = makeOperation({
665
652
  hash: "0xCoinOp3Hash",
666
653
  });
@@ -792,6 +779,7 @@ describe("EVM Family", () => {
792
779
  });
793
780
 
794
781
  it("should filter blacklisted tokens", () => {
782
+ const token = getTokenById("ethereum/erc20/usd__coin");
795
783
  const coinOperation = makeOperation({
796
784
  hash: "0xCoinOp3Hash",
797
785
  });
@@ -851,7 +839,7 @@ describe("EVM Family", () => {
851
839
 
852
840
  expect(
853
841
  attachOperations([coinOperation], tokenOperations, nftOperations, internalOperations, {
854
- blacklistedTokenIds: [USD_COIN_TOKEN.id],
842
+ blacklistedTokenIds: [token.id],
855
843
  }),
856
844
  ).toEqual([
857
845
  {
@@ -1,25 +1,21 @@
1
1
  import BigNumber from "bignumber.js";
2
- import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index";
2
+ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets/index";
3
3
  import { genAccount, genOperation, genTokenAccount } from "@ledgerhq/coin-framework/mocks/account";
4
4
  import { Operation } from "@ledgerhq/types-live";
5
5
  import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
6
6
  import Prando from "prando";
7
7
  import { getStuckAccountAndOperation, isEditableOperation } from "../../operation";
8
8
  import { getCoinConfig } from "../../config";
9
- import usdCoinTokenData from "../../__fixtures__/ethereum-erc20-usd__coin.json";
10
- import lobsterTokenData from "../../__fixtures__/cardano-native-8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552.json";
11
9
 
12
10
  jest.mock("../../config");
13
11
  const mockGetConfig = jest.mocked(getCoinConfig);
14
12
 
15
13
  const ethereum = getCryptoCurrencyById("ethereum");
16
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
17
- const usdc = usdCoinTokenData as TokenCurrency;
18
-
14
+ const usdc = getTokenById("ethereum/erc20/usd__coin");
19
15
  const cardano = getCryptoCurrencyById("cardano");
20
-
21
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
22
- const lobster = lobsterTokenData as TokenCurrency;
16
+ const lobster = getTokenById(
17
+ "cardano/native/8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552",
18
+ );
23
19
 
24
20
  describe("EVM Family", () => {
25
21
  beforeEach(() => {
@@ -1,7 +1,7 @@
1
1
  import { ethers } from "ethers";
2
2
  import BigNumber from "bignumber.js";
3
3
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
4
- import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
4
+ import { addTokens, convertERC20, getTokenById } from "@ledgerhq/cryptoassets/tokens";
5
5
  import { prepareForSignOperation, prepareTransaction } from "../../bridge/prepareTransaction";
6
6
  import { makeAccount, makeTokenAccount } from "../fixtures/common.fixtures";
7
7
  import { createTransaction } from "../../bridge/createTransaction";
@@ -18,7 +18,6 @@ import { GasOptions, Transaction as EvmTransaction, EvmNftTransaction } from "..
18
18
  import * as nftAPI from "../../network/nft";
19
19
  import { getCoinConfig } from "../../config";
20
20
  import { DEFAULT_NONCE, getEstimatedFees } from "../../utils";
21
- import usdCoinTokenData from "../../__fixtures__/optimism-erc20-usd_coin.json";
22
21
 
23
22
  jest.mock("../../config");
24
23
  const mockGetConfig = jest.mocked(getCoinConfig);
@@ -334,6 +333,22 @@ describe("EVM Family", () => {
334
333
  });
335
334
 
336
335
  describe("Tokens", () => {
336
+ beforeAll(() => {
337
+ addTokens([
338
+ convertERC20([
339
+ "optimism",
340
+ "usd_coin",
341
+ "USDC",
342
+ 6,
343
+ "USD Coin",
344
+ "30440220597e4a9911df217d680aa240ca96f7e8fca24c24e7c673c43820c94b08ef69e402206e975e27e82b3370eca40041fca772bd6c4ca7dd087d2bfcc8aa146cb8e1de53",
345
+ "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
346
+ false,
347
+ false,
348
+ ]),
349
+ ]);
350
+ });
351
+
337
352
  it("should have a gasLimit = 0 and no data when recipient has an error", async () => {
338
353
  jest.spyOn(nodeApi, "getGasEstimation").mockImplementation(async () => {
339
354
  throw new Error();
@@ -513,8 +528,7 @@ describe("EVM Family", () => {
513
528
  const tokenAccountWithBalance = {
514
529
  ...makeTokenAccount(
515
530
  "0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d",
516
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
517
- usdCoinTokenData as TokenCurrency,
531
+ getTokenById("optimism/erc20/usd_coin"),
518
532
  ),
519
533
  balance: new BigNumber(200),
520
534
  };