@metamask/assets-controllers 38.0.0 → 38.1.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 (372) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/dist/AccountTrackerController.cjs +245 -0
  3. package/dist/AccountTrackerController.cjs.map +1 -0
  4. package/dist/{types/AccountTrackerController.d.ts → AccountTrackerController.d.cts} +6 -6
  5. package/dist/AccountTrackerController.d.cts.map +1 -0
  6. package/dist/AccountTrackerController.d.mts +112 -0
  7. package/dist/AccountTrackerController.d.mts.map +1 -0
  8. package/dist/AccountTrackerController.mjs +244 -8
  9. package/dist/AccountTrackerController.mjs.map +1 -1
  10. package/dist/AssetsContractController.cjs +389 -0
  11. package/dist/AssetsContractController.cjs.map +1 -0
  12. package/dist/{types/AssetsContractController.d.ts → AssetsContractController.d.cts} +9 -9
  13. package/dist/AssetsContractController.d.cts.map +1 -0
  14. package/dist/AssetsContractController.d.mts +277 -0
  15. package/dist/AssetsContractController.d.mts.map +1 -0
  16. package/dist/AssetsContractController.mjs +387 -16
  17. package/dist/AssetsContractController.mjs.map +1 -1
  18. package/dist/CurrencyRateController.cjs +156 -0
  19. package/dist/CurrencyRateController.cjs.map +1 -0
  20. package/dist/{types/CurrencyRateController.d.ts → CurrencyRateController.d.cts} +5 -5
  21. package/dist/CurrencyRateController.d.cts.map +1 -0
  22. package/dist/CurrencyRateController.d.mts +80 -0
  23. package/dist/CurrencyRateController.d.mts.map +1 -0
  24. package/dist/CurrencyRateController.mjs +150 -10
  25. package/dist/CurrencyRateController.mjs.map +1 -1
  26. package/dist/NftController.cjs +1159 -0
  27. package/dist/NftController.cjs.map +1 -0
  28. package/dist/{types/NftController.d.ts → NftController.d.cts} +11 -11
  29. package/dist/NftController.d.cts.map +1 -0
  30. package/dist/NftController.d.mts +424 -0
  31. package/dist/NftController.d.mts.map +1 -0
  32. package/dist/NftController.mjs +1156 -12
  33. package/dist/NftController.mjs.map +1 -1
  34. package/dist/NftDetectionController.cjs +237 -0
  35. package/dist/NftDetectionController.cjs.map +1 -0
  36. package/dist/{types/NftDetectionController.d.ts → NftDetectionController.d.cts} +9 -9
  37. package/dist/NftDetectionController.d.cts.map +1 -0
  38. package/dist/NftDetectionController.d.mts +368 -0
  39. package/dist/NftDetectionController.d.mts.map +1 -0
  40. package/dist/NftDetectionController.mjs +231 -14
  41. package/dist/NftDetectionController.mjs.map +1 -1
  42. package/dist/RatesController/RatesController.cjs +189 -0
  43. package/dist/RatesController/RatesController.cjs.map +1 -0
  44. package/dist/{types/RatesController/RatesController.d.ts → RatesController/RatesController.d.cts} +3 -3
  45. package/dist/RatesController/RatesController.d.cts.map +1 -0
  46. package/dist/RatesController/RatesController.d.mts +44 -0
  47. package/dist/RatesController/RatesController.d.mts.map +1 -0
  48. package/dist/RatesController/RatesController.mjs +183 -12
  49. package/dist/RatesController/RatesController.mjs.map +1 -1
  50. package/dist/RatesController/index.cjs +7 -0
  51. package/dist/RatesController/index.cjs.map +1 -0
  52. package/dist/{types/RatesController/index.d.ts → RatesController/index.d.cts} +3 -3
  53. package/dist/RatesController/index.d.cts.map +1 -0
  54. package/dist/RatesController/index.d.mts +3 -0
  55. package/dist/RatesController/index.d.mts.map +1 -0
  56. package/dist/RatesController/index.mjs +1 -12
  57. package/dist/RatesController/index.mjs.map +1 -1
  58. package/dist/RatesController/types.cjs +3 -0
  59. package/dist/RatesController/types.cjs.map +1 -0
  60. package/dist/{types/RatesController/types.d.ts → RatesController/types.d.cts} +4 -4
  61. package/dist/RatesController/types.d.cts.map +1 -0
  62. package/dist/RatesController/types.d.mts +100 -0
  63. package/dist/RatesController/types.d.mts.map +1 -0
  64. package/dist/RatesController/types.mjs +1 -0
  65. package/dist/RatesController/types.mjs.map +1 -1
  66. package/dist/Standards/ERC20Standard.cjs +124 -0
  67. package/dist/Standards/ERC20Standard.cjs.map +1 -0
  68. package/dist/{types/Standards/ERC20Standard.d.ts → Standards/ERC20Standard.d.cts} +3 -3
  69. package/dist/Standards/ERC20Standard.d.cts.map +1 -0
  70. package/dist/Standards/ERC20Standard.d.mts +49 -0
  71. package/dist/Standards/ERC20Standard.d.mts.map +1 -0
  72. package/dist/Standards/ERC20Standard.mjs +121 -8
  73. package/dist/Standards/ERC20Standard.mjs.map +1 -1
  74. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.cjs +189 -0
  75. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.cjs.map +1 -0
  76. package/dist/{types/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts → Standards/NftStandards/ERC1155/ERC1155Standard.d.cts} +3 -3
  77. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.cts.map +1 -0
  78. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.mts +95 -0
  79. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.mts.map +1 -0
  80. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.mjs +184 -8
  81. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.mjs.map +1 -1
  82. package/dist/Standards/NftStandards/ERC721/ERC721Standard.cjs +167 -0
  83. package/dist/Standards/NftStandards/ERC721/ERC721Standard.cjs.map +1 -0
  84. package/dist/{types/Standards/NftStandards/ERC721/ERC721Standard.d.ts → Standards/NftStandards/ERC721/ERC721Standard.d.cts} +2 -2
  85. package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.cts.map +1 -0
  86. package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.mts +89 -0
  87. package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.mts.map +1 -0
  88. package/dist/Standards/NftStandards/ERC721/ERC721Standard.mjs +162 -8
  89. package/dist/Standards/NftStandards/ERC721/ERC721Standard.mjs.map +1 -1
  90. package/dist/TokenBalancesController.cjs +136 -0
  91. package/dist/TokenBalancesController.cjs.map +1 -0
  92. package/dist/{types/TokenBalancesController.d.ts → TokenBalancesController.d.cts} +7 -7
  93. package/dist/TokenBalancesController.d.cts.map +1 -0
  94. package/dist/TokenBalancesController.d.mts +82 -0
  95. package/dist/TokenBalancesController.d.mts.map +1 -0
  96. package/dist/TokenBalancesController.mjs +129 -10
  97. package/dist/TokenBalancesController.mjs.map +1 -1
  98. package/dist/TokenDetectionController.cjs +368 -0
  99. package/dist/TokenDetectionController.cjs.map +1 -0
  100. package/dist/{types/TokenDetectionController.d.ts → TokenDetectionController.d.cts} +10 -10
  101. package/dist/TokenDetectionController.d.cts.map +1 -0
  102. package/dist/TokenDetectionController.d.mts +109 -0
  103. package/dist/TokenDetectionController.d.mts.map +1 -0
  104. package/dist/TokenDetectionController.mjs +365 -15
  105. package/dist/TokenDetectionController.mjs.map +1 -1
  106. package/dist/TokenListController.cjs +274 -0
  107. package/dist/TokenListController.cjs.map +1 -0
  108. package/dist/{types/TokenListController.d.ts → TokenListController.d.cts} +5 -5
  109. package/dist/TokenListController.d.cts.map +1 -0
  110. package/dist/TokenListController.d.mts +117 -0
  111. package/dist/TokenListController.d.mts.map +1 -0
  112. package/dist/TokenListController.mjs +267 -12
  113. package/dist/TokenListController.mjs.map +1 -1
  114. package/dist/TokenRatesController.cjs +452 -0
  115. package/dist/TokenRatesController.cjs.map +1 -0
  116. package/dist/{types/TokenRatesController.d.ts → TokenRatesController.d.cts} +8 -8
  117. package/dist/TokenRatesController.d.cts.map +1 -0
  118. package/dist/TokenRatesController.d.mts +170 -0
  119. package/dist/TokenRatesController.d.mts.map +1 -0
  120. package/dist/TokenRatesController.mjs +446 -16
  121. package/dist/TokenRatesController.mjs.map +1 -1
  122. package/dist/TokensController.cjs +678 -0
  123. package/dist/TokensController.cjs.map +1 -0
  124. package/dist/{types/TokensController.d.ts → TokensController.d.cts} +9 -9
  125. package/dist/TokensController.d.cts.map +1 -0
  126. package/dist/TokensController.d.mts +165 -0
  127. package/dist/TokensController.d.mts.map +1 -0
  128. package/dist/TokensController.mjs +675 -14
  129. package/dist/TokensController.mjs.map +1 -1
  130. package/dist/assetsUtil.cjs +358 -0
  131. package/dist/assetsUtil.cjs.map +1 -0
  132. package/dist/{types/assetsUtil.d.ts → assetsUtil.d.cts} +7 -7
  133. package/dist/assetsUtil.d.cts.map +1 -0
  134. package/dist/assetsUtil.d.mts +177 -0
  135. package/dist/assetsUtil.d.mts.map +1 -0
  136. package/dist/assetsUtil.mjs +343 -36
  137. package/dist/assetsUtil.mjs.map +1 -1
  138. package/dist/constants.cjs +10 -0
  139. package/dist/constants.cjs.map +1 -0
  140. package/dist/{types/constants.d.ts → constants.d.cts} +1 -1
  141. package/dist/constants.d.cts.map +1 -0
  142. package/dist/constants.d.mts +6 -0
  143. package/dist/constants.d.mts.map +1 -0
  144. package/dist/constants.mjs +6 -7
  145. package/dist/constants.mjs.map +1 -1
  146. package/dist/crypto-compare-service/crypto-compare.cjs +119 -0
  147. package/dist/crypto-compare-service/crypto-compare.cjs.map +1 -0
  148. package/dist/{types/crypto-compare-service/crypto-compare.d.ts → crypto-compare-service/crypto-compare.d.cts} +1 -1
  149. package/dist/crypto-compare-service/crypto-compare.d.cts.map +1 -0
  150. package/dist/crypto-compare-service/crypto-compare.d.mts +22 -0
  151. package/dist/crypto-compare-service/crypto-compare.d.mts.map +1 -0
  152. package/dist/crypto-compare-service/crypto-compare.mjs +113 -9
  153. package/dist/crypto-compare-service/crypto-compare.mjs.map +1 -1
  154. package/dist/crypto-compare-service/index.cjs +7 -0
  155. package/dist/crypto-compare-service/index.cjs.map +1 -0
  156. package/dist/crypto-compare-service/index.d.cts +2 -0
  157. package/dist/crypto-compare-service/index.d.cts.map +1 -0
  158. package/dist/crypto-compare-service/index.d.mts +2 -0
  159. package/dist/crypto-compare-service/index.d.mts.map +1 -0
  160. package/dist/crypto-compare-service/index.mjs +1 -10
  161. package/dist/crypto-compare-service/index.mjs.map +1 -1
  162. package/dist/index.cjs +51 -0
  163. package/dist/index.cjs.map +1 -0
  164. package/dist/{types/index.d.ts → index.d.cts} +24 -24
  165. package/dist/index.d.cts.map +1 -0
  166. package/dist/index.d.mts +24 -0
  167. package/dist/index.d.mts.map +1 -0
  168. package/dist/index.mjs +13 -80
  169. package/dist/index.mjs.map +1 -1
  170. package/dist/token-prices-service/abstract-token-prices-service.cjs +3 -0
  171. package/dist/token-prices-service/abstract-token-prices-service.cjs.map +1 -0
  172. package/dist/{types/token-prices-service/abstract-token-prices-service.d.ts → token-prices-service/abstract-token-prices-service.d.cts} +2 -2
  173. package/dist/token-prices-service/abstract-token-prices-service.d.cts.map +1 -0
  174. package/dist/token-prices-service/abstract-token-prices-service.d.mts +79 -0
  175. package/dist/token-prices-service/abstract-token-prices-service.d.mts.map +1 -0
  176. package/dist/token-prices-service/abstract-token-prices-service.mjs +1 -0
  177. package/dist/token-prices-service/abstract-token-prices-service.mjs.map +1 -1
  178. package/dist/token-prices-service/codefi-v2.cjs +352 -0
  179. package/dist/token-prices-service/codefi-v2.cjs.map +1 -0
  180. package/dist/{types/token-prices-service/codefi-v2.d.ts → token-prices-service/codefi-v2.d.cts} +3 -3
  181. package/dist/token-prices-service/codefi-v2.d.cts.map +1 -0
  182. package/dist/token-prices-service/codefi-v2.d.mts +97 -0
  183. package/dist/token-prices-service/codefi-v2.d.mts.map +1 -0
  184. package/dist/token-prices-service/codefi-v2.mjs +347 -12
  185. package/dist/token-prices-service/codefi-v2.mjs.map +1 -1
  186. package/dist/token-prices-service/index.cjs +7 -0
  187. package/dist/token-prices-service/index.cjs.map +1 -0
  188. package/dist/token-prices-service/index.d.cts +3 -0
  189. package/dist/token-prices-service/index.d.cts.map +1 -0
  190. package/dist/token-prices-service/index.d.mts +3 -0
  191. package/dist/token-prices-service/index.d.mts.map +1 -0
  192. package/dist/token-prices-service/index.mjs +1 -10
  193. package/dist/token-prices-service/index.mjs.map +1 -1
  194. package/dist/token-service.cjs +130 -0
  195. package/dist/token-service.cjs.map +1 -0
  196. package/dist/{types/token-service.d.ts → token-service.d.cts} +2 -2
  197. package/dist/token-service.d.cts.map +1 -0
  198. package/dist/token-service.d.mts +31 -0
  199. package/dist/token-service.d.mts.map +1 -0
  200. package/dist/token-service.mjs +124 -14
  201. package/dist/token-service.mjs.map +1 -1
  202. package/package.json +21 -16
  203. package/dist/AccountTrackerController.js +0 -10
  204. package/dist/AccountTrackerController.js.map +0 -1
  205. package/dist/AssetsContractController.js +0 -18
  206. package/dist/AssetsContractController.js.map +0 -1
  207. package/dist/CurrencyRateController.js +0 -12
  208. package/dist/CurrencyRateController.js.map +0 -1
  209. package/dist/NftController.js +0 -14
  210. package/dist/NftController.js.map +0 -1
  211. package/dist/NftDetectionController.js +0 -16
  212. package/dist/NftDetectionController.js.map +0 -1
  213. package/dist/RatesController/RatesController.js +0 -14
  214. package/dist/RatesController/RatesController.js.map +0 -1
  215. package/dist/RatesController/index.js +0 -13
  216. package/dist/RatesController/index.js.map +0 -1
  217. package/dist/RatesController/types.js +0 -1
  218. package/dist/RatesController/types.js.map +0 -1
  219. package/dist/Standards/ERC20Standard.js +0 -9
  220. package/dist/Standards/ERC20Standard.js.map +0 -1
  221. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js +0 -9
  222. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js.map +0 -1
  223. package/dist/Standards/NftStandards/ERC721/ERC721Standard.js +0 -9
  224. package/dist/Standards/NftStandards/ERC721/ERC721Standard.js.map +0 -1
  225. package/dist/TokenBalancesController.js +0 -12
  226. package/dist/TokenBalancesController.js.map +0 -1
  227. package/dist/TokenDetectionController.js +0 -17
  228. package/dist/TokenDetectionController.js.map +0 -1
  229. package/dist/TokenListController.js +0 -14
  230. package/dist/TokenListController.js.map +0 -1
  231. package/dist/TokenRatesController.js +0 -18
  232. package/dist/TokenRatesController.js.map +0 -1
  233. package/dist/TokensController.js +0 -16
  234. package/dist/TokensController.js.map +0 -1
  235. package/dist/assetsUtil.js +0 -38
  236. package/dist/assetsUtil.js.map +0 -1
  237. package/dist/chunk-27KOXCQK.mjs +0 -1
  238. package/dist/chunk-27KOXCQK.mjs.map +0 -1
  239. package/dist/chunk-2TZK6YZA.js +0 -1405
  240. package/dist/chunk-2TZK6YZA.js.map +0 -1
  241. package/dist/chunk-3LPQTUGG.js +0 -434
  242. package/dist/chunk-3LPQTUGG.js.map +0 -1
  243. package/dist/chunk-3QDXAE2D.mjs +0 -178
  244. package/dist/chunk-3QDXAE2D.mjs.map +0 -1
  245. package/dist/chunk-46KUC5FH.mjs +0 -434
  246. package/dist/chunk-46KUC5FH.mjs.map +0 -1
  247. package/dist/chunk-4QZESU46.mjs +0 -530
  248. package/dist/chunk-4QZESU46.mjs.map +0 -1
  249. package/dist/chunk-5QLC2MHV.js +0 -215
  250. package/dist/chunk-5QLC2MHV.js.map +0 -1
  251. package/dist/chunk-7K6PSEAA.js +0 -1
  252. package/dist/chunk-7K6PSEAA.js.map +0 -1
  253. package/dist/chunk-AX522TDL.mjs +0 -85
  254. package/dist/chunk-AX522TDL.mjs.map +0 -1
  255. package/dist/chunk-AZSIKIMK.mjs +0 -429
  256. package/dist/chunk-AZSIKIMK.mjs.map +0 -1
  257. package/dist/chunk-BBCZM5P4.js +0 -300
  258. package/dist/chunk-BBCZM5P4.js.map +0 -1
  259. package/dist/chunk-BZEAPSD5.mjs +0 -215
  260. package/dist/chunk-BZEAPSD5.mjs.map +0 -1
  261. package/dist/chunk-C7LNCQXM.mjs +0 -300
  262. package/dist/chunk-C7LNCQXM.mjs.map +0 -1
  263. package/dist/chunk-CP3HC7AQ.mjs +0 -12
  264. package/dist/chunk-CP3HC7AQ.mjs.map +0 -1
  265. package/dist/chunk-FWKV5FGP.mjs +0 -71
  266. package/dist/chunk-FWKV5FGP.mjs.map +0 -1
  267. package/dist/chunk-GDFLKKDY.js +0 -71
  268. package/dist/chunk-GDFLKKDY.js.map +0 -1
  269. package/dist/chunk-GW6RE66P.mjs +0 -210
  270. package/dist/chunk-GW6RE66P.mjs.map +0 -1
  271. package/dist/chunk-HVOIBGYN.js +0 -282
  272. package/dist/chunk-HVOIBGYN.js.map +0 -1
  273. package/dist/chunk-ISK2VSBB.js +0 -178
  274. package/dist/chunk-ISK2VSBB.js.map +0 -1
  275. package/dist/chunk-JCR4H6YL.js +0 -115
  276. package/dist/chunk-JCR4H6YL.js.map +0 -1
  277. package/dist/chunk-JJX7TMH5.mjs +0 -135
  278. package/dist/chunk-JJX7TMH5.mjs.map +0 -1
  279. package/dist/chunk-JMZ7KWJS.js +0 -157
  280. package/dist/chunk-JMZ7KWJS.js.map +0 -1
  281. package/dist/chunk-JYHAAA6W.mjs +0 -1
  282. package/dist/chunk-JYHAAA6W.mjs.map +0 -1
  283. package/dist/chunk-K7A3EOIM.js +0 -85
  284. package/dist/chunk-K7A3EOIM.js.map +0 -1
  285. package/dist/chunk-KPBNX6GP.mjs +0 -215
  286. package/dist/chunk-KPBNX6GP.mjs.map +0 -1
  287. package/dist/chunk-LKVWPNXY.js +0 -429
  288. package/dist/chunk-LKVWPNXY.js.map +0 -1
  289. package/dist/chunk-MZI3SDQN.js +0 -215
  290. package/dist/chunk-MZI3SDQN.js.map +0 -1
  291. package/dist/chunk-NDUMUEE6.js +0 -812
  292. package/dist/chunk-NDUMUEE6.js.map +0 -1
  293. package/dist/chunk-OBUR4TXH.js +0 -1
  294. package/dist/chunk-OBUR4TXH.js.map +0 -1
  295. package/dist/chunk-RGHTNZQ6.js +0 -12
  296. package/dist/chunk-RGHTNZQ6.js.map +0 -1
  297. package/dist/chunk-S5CFNNOM.mjs +0 -115
  298. package/dist/chunk-S5CFNNOM.mjs.map +0 -1
  299. package/dist/chunk-SK2B36Q4.mjs +0 -1405
  300. package/dist/chunk-SK2B36Q4.mjs.map +0 -1
  301. package/dist/chunk-TFLYM4PY.mjs +0 -291
  302. package/dist/chunk-TFLYM4PY.mjs.map +0 -1
  303. package/dist/chunk-TIFLP53R.js +0 -210
  304. package/dist/chunk-TIFLP53R.js.map +0 -1
  305. package/dist/chunk-TTH3ES66.mjs +0 -1
  306. package/dist/chunk-TTH3ES66.mjs.map +0 -1
  307. package/dist/chunk-UKXD6WUT.mjs +0 -157
  308. package/dist/chunk-UKXD6WUT.mjs.map +0 -1
  309. package/dist/chunk-UUF4E7OG.js +0 -530
  310. package/dist/chunk-UUF4E7OG.js.map +0 -1
  311. package/dist/chunk-V6DNVROD.js +0 -348
  312. package/dist/chunk-V6DNVROD.js.map +0 -1
  313. package/dist/chunk-XC3SOOGC.js +0 -1
  314. package/dist/chunk-XC3SOOGC.js.map +0 -1
  315. package/dist/chunk-XMQA5NLX.mjs +0 -812
  316. package/dist/chunk-XMQA5NLX.mjs.map +0 -1
  317. package/dist/chunk-XQO3EG4J.mjs +0 -348
  318. package/dist/chunk-XQO3EG4J.mjs.map +0 -1
  319. package/dist/chunk-XUI43LEZ.mjs +0 -30
  320. package/dist/chunk-XUI43LEZ.mjs.map +0 -1
  321. package/dist/chunk-YGGUAMHV.js +0 -135
  322. package/dist/chunk-YGGUAMHV.js.map +0 -1
  323. package/dist/chunk-Z4BLTVTB.js +0 -30
  324. package/dist/chunk-Z4BLTVTB.js.map +0 -1
  325. package/dist/chunk-Z7RMCHD4.mjs +0 -282
  326. package/dist/chunk-Z7RMCHD4.mjs.map +0 -1
  327. package/dist/chunk-ZAR4BIOC.js +0 -291
  328. package/dist/chunk-ZAR4BIOC.js.map +0 -1
  329. package/dist/constants.js +0 -8
  330. package/dist/constants.js.map +0 -1
  331. package/dist/crypto-compare-service/crypto-compare.js +0 -10
  332. package/dist/crypto-compare-service/crypto-compare.js.map +0 -1
  333. package/dist/crypto-compare-service/index.js +0 -11
  334. package/dist/crypto-compare-service/index.js.map +0 -1
  335. package/dist/index.js +0 -81
  336. package/dist/index.js.map +0 -1
  337. package/dist/token-prices-service/abstract-token-prices-service.js +0 -1
  338. package/dist/token-prices-service/abstract-token-prices-service.js.map +0 -1
  339. package/dist/token-prices-service/codefi-v2.js +0 -14
  340. package/dist/token-prices-service/codefi-v2.js.map +0 -1
  341. package/dist/token-prices-service/index.js +0 -11
  342. package/dist/token-prices-service/index.js.map +0 -1
  343. package/dist/token-service.js +0 -15
  344. package/dist/token-service.js.map +0 -1
  345. package/dist/tsconfig.build.tsbuildinfo +0 -1
  346. package/dist/types/AccountTrackerController.d.ts.map +0 -1
  347. package/dist/types/AssetsContractController.d.ts.map +0 -1
  348. package/dist/types/CurrencyRateController.d.ts.map +0 -1
  349. package/dist/types/NftController.d.ts.map +0 -1
  350. package/dist/types/NftDetectionController.d.ts.map +0 -1
  351. package/dist/types/RatesController/RatesController.d.ts.map +0 -1
  352. package/dist/types/RatesController/index.d.ts.map +0 -1
  353. package/dist/types/RatesController/types.d.ts.map +0 -1
  354. package/dist/types/Standards/ERC20Standard.d.ts.map +0 -1
  355. package/dist/types/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts.map +0 -1
  356. package/dist/types/Standards/NftStandards/ERC721/ERC721Standard.d.ts.map +0 -1
  357. package/dist/types/TokenBalancesController.d.ts.map +0 -1
  358. package/dist/types/TokenDetectionController.d.ts.map +0 -1
  359. package/dist/types/TokenListController.d.ts.map +0 -1
  360. package/dist/types/TokenRatesController.d.ts.map +0 -1
  361. package/dist/types/TokensController.d.ts.map +0 -1
  362. package/dist/types/assetsUtil.d.ts.map +0 -1
  363. package/dist/types/constants.d.ts.map +0 -1
  364. package/dist/types/crypto-compare-service/crypto-compare.d.ts.map +0 -1
  365. package/dist/types/crypto-compare-service/index.d.ts +0 -2
  366. package/dist/types/crypto-compare-service/index.d.ts.map +0 -1
  367. package/dist/types/index.d.ts.map +0 -1
  368. package/dist/types/token-prices-service/abstract-token-prices-service.d.ts.map +0 -1
  369. package/dist/types/token-prices-service/codefi-v2.d.ts.map +0 -1
  370. package/dist/types/token-prices-service/index.d.ts +0 -3
  371. package/dist/types/token-prices-service/index.d.ts.map +0 -1
  372. package/dist/types/token-service.d.ts.map +0 -1
@@ -1,215 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/assetsUtil.ts
2
-
3
-
4
-
5
- var _controllerutils = require('@metamask/controller-utils');
6
- var _utils = require('@metamask/utils');
7
- var _bnjs = require('bn.js'); var _bnjs2 = _interopRequireDefault(_bnjs);
8
- var TOKEN_PRICES_BATCH_SIZE = 30;
9
- function compareNftMetadata(newNftMetadata, nft) {
10
- const keys = [
11
- "image",
12
- "backgroundColor",
13
- "imagePreview",
14
- "imageThumbnail",
15
- "imageOriginal",
16
- "animation",
17
- "animationOriginal",
18
- "externalLink",
19
- "tokenURI"
20
- ];
21
- const differentValues = keys.reduce((value, key) => {
22
- if (newNftMetadata[key] && newNftMetadata[key] !== nft[key]) {
23
- return value + 1;
24
- }
25
- return value;
26
- }, 0);
27
- return differentValues > 0;
28
- }
29
- function hasNewCollectionFields(newNftMetadata, nft) {
30
- const keysNewNftMetadata = Object.keys(newNftMetadata.collection ?? {});
31
- const keysExistingNft = new Set(Object.keys(nft.collection ?? {}));
32
- return keysNewNftMetadata.some((key) => !keysExistingNft.has(key));
33
- }
34
- var aggregatorNameByKey = {
35
- aave: "Aave",
36
- bancor: "Bancor",
37
- cmc: "CMC",
38
- cryptocom: "Crypto.com",
39
- coinGecko: "CoinGecko",
40
- oneInch: "1inch",
41
- paraswap: "Paraswap",
42
- pmm: "PMM",
43
- zapper: "Zapper",
44
- zerion: "Zerion",
45
- zeroEx: "0x",
46
- synthetix: "Synthetix",
47
- yearn: "Yearn",
48
- apeswap: "ApeSwap",
49
- binanceDex: "BinanceDex",
50
- pancakeTop100: "PancakeTop100",
51
- pancakeExtended: "PancakeExtended",
52
- balancer: "Balancer",
53
- quickswap: "QuickSwap",
54
- matcha: "Matcha",
55
- pangolinDex: "PangolinDex",
56
- pangolinDexStableCoin: "PangolinDexStableCoin",
57
- pangolinDexAvaxBridge: "PangolinDexAvaxBridge",
58
- traderJoe: "TraderJoe",
59
- airswapLight: "AirswapLight",
60
- kleros: "Kleros"
61
- };
62
- var formatAggregatorNames = (aggregators) => {
63
- return aggregators.map(
64
- (key) => aggregatorNameByKey[key] || `${key[0].toUpperCase()}${key.substring(1, key.length)}`
65
- );
66
- };
67
- var formatIconUrlWithProxy = ({
68
- chainId,
69
- tokenAddress
70
- }) => {
71
- const chainIdDecimal = _controllerutils.convertHexToDecimal.call(void 0, chainId).toString();
72
- return `https://static.cx.metamask.io/api/v1/tokenIcons/${chainIdDecimal}/${tokenAddress.toLowerCase()}.png`;
73
- };
74
- var SupportedTokenDetectionNetworks = /* @__PURE__ */ ((SupportedTokenDetectionNetworks2) => {
75
- SupportedTokenDetectionNetworks2["mainnet"] = "0x1";
76
- SupportedTokenDetectionNetworks2["bsc"] = "0x38";
77
- SupportedTokenDetectionNetworks2["polygon"] = "0x89";
78
- SupportedTokenDetectionNetworks2["avax"] = "0xa86a";
79
- SupportedTokenDetectionNetworks2["aurora"] = "0x4e454152";
80
- SupportedTokenDetectionNetworks2["linea_goerli"] = "0xe704";
81
- SupportedTokenDetectionNetworks2["linea_mainnet"] = "0xe708";
82
- SupportedTokenDetectionNetworks2["arbitrum"] = "0xa4b1";
83
- SupportedTokenDetectionNetworks2["optimism"] = "0xa";
84
- SupportedTokenDetectionNetworks2["base"] = "0x2105";
85
- SupportedTokenDetectionNetworks2["zksync"] = "0x144";
86
- SupportedTokenDetectionNetworks2["cronos"] = "0x19";
87
- SupportedTokenDetectionNetworks2["celo"] = "0xa4ec";
88
- SupportedTokenDetectionNetworks2["gnosis"] = "0x64";
89
- SupportedTokenDetectionNetworks2["fantom"] = "0xfa";
90
- SupportedTokenDetectionNetworks2["polygon_zkevm"] = "0x44d";
91
- SupportedTokenDetectionNetworks2["moonbeam"] = "0x504";
92
- SupportedTokenDetectionNetworks2["moonriver"] = "0x505";
93
- return SupportedTokenDetectionNetworks2;
94
- })(SupportedTokenDetectionNetworks || {});
95
- function isTokenDetectionSupportedForNetwork(chainId) {
96
- return Object.values(SupportedTokenDetectionNetworks).includes(chainId);
97
- }
98
- function isTokenListSupportedForNetwork(chainId) {
99
- return isTokenDetectionSupportedForNetwork(chainId);
100
- }
101
- function removeIpfsProtocolPrefix(ipfsUrl) {
102
- if (ipfsUrl.startsWith("ipfs://ipfs/")) {
103
- return ipfsUrl.replace("ipfs://ipfs/", "");
104
- } else if (ipfsUrl.startsWith("ipfs://")) {
105
- return ipfsUrl.replace("ipfs://", "");
106
- }
107
- throw new Error("this method should not be used with non ipfs urls");
108
- }
109
- async function getIpfsCIDv1AndPath(ipfsUrl) {
110
- const url = removeIpfsProtocolPrefix(ipfsUrl);
111
- const index = url.indexOf("/");
112
- const cid = index !== -1 ? url.substring(0, index) : url;
113
- const path = index !== -1 ? url.substring(index) : void 0;
114
- const { CID } = await Promise.resolve().then(() => _interopRequireWildcard(require("multiformats")));
115
- return {
116
- cid: CID.parse(cid).toV1().toString(),
117
- path
118
- };
119
- }
120
- async function getFormattedIpfsUrl(ipfsGateway, ipfsUrl, subdomainSupported) {
121
- const { host, protocol, origin } = new URL(addUrlProtocolPrefix(ipfsGateway));
122
- if (subdomainSupported) {
123
- const { cid, path } = await getIpfsCIDv1AndPath(ipfsUrl);
124
- return `${protocol}//${cid}.ipfs.${host}${path ?? ""}`;
125
- }
126
- const cidAndPath = removeIpfsProtocolPrefix(ipfsUrl);
127
- return `${origin}/ipfs/${cidAndPath}`;
128
- }
129
- function addUrlProtocolPrefix(urlString) {
130
- if (!urlString.match(/(^http:\/\/)|(^https:\/\/)/u)) {
131
- return `https://${urlString}`;
132
- }
133
- return urlString;
134
- }
135
- function ethersBigNumberToBN(bigNumber) {
136
- return new (0, _bnjs2.default)(_utils.remove0x.call(void 0, bigNumber.toHexString()), "hex");
137
- }
138
- function divideIntoBatches(values, { batchSize }) {
139
- const batches = [];
140
- for (let i = 0; i < values.length; i += batchSize) {
141
- batches.push(values.slice(i, i + batchSize));
142
- }
143
- return batches;
144
- }
145
- async function reduceInBatchesSerially({
146
- values,
147
- batchSize,
148
- eachBatch,
149
- initialResult
150
- }) {
151
- const batches = divideIntoBatches(values, { batchSize });
152
- let workingResult = initialResult;
153
- for (const [index, batch] of batches.entries()) {
154
- workingResult = await eachBatch(workingResult, batch, index);
155
- }
156
- const finalResult = workingResult;
157
- return finalResult;
158
- }
159
- async function fetchTokenContractExchangeRates({
160
- tokenPricesService,
161
- nativeCurrency,
162
- tokenAddresses,
163
- chainId
164
- }) {
165
- const isChainIdSupported = tokenPricesService.validateChainIdSupported(chainId);
166
- const isCurrencySupported = tokenPricesService.validateCurrencySupported(nativeCurrency);
167
- if (!isChainIdSupported || !isCurrencySupported) {
168
- return {};
169
- }
170
- const tokenPricesByTokenAddress = await reduceInBatchesSerially({
171
- values: [...tokenAddresses].sort(),
172
- batchSize: TOKEN_PRICES_BATCH_SIZE,
173
- eachBatch: async (allTokenPricesByTokenAddress, batch) => {
174
- const tokenPricesByTokenAddressForBatch = await tokenPricesService.fetchTokenPrices({
175
- tokenAddresses: batch,
176
- chainId,
177
- currency: nativeCurrency
178
- });
179
- return {
180
- ...allTokenPricesByTokenAddress,
181
- ...tokenPricesByTokenAddressForBatch
182
- };
183
- },
184
- initialResult: {}
185
- });
186
- return Object.entries(tokenPricesByTokenAddress).reduce(
187
- (obj, [tokenAddress, tokenPrice]) => {
188
- return {
189
- ...obj,
190
- [_controllerutils.toChecksumHexAddress.call(void 0, tokenAddress)]: tokenPrice?.price
191
- };
192
- },
193
- {}
194
- );
195
- }
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
- exports.TOKEN_PRICES_BATCH_SIZE = TOKEN_PRICES_BATCH_SIZE; exports.compareNftMetadata = compareNftMetadata; exports.hasNewCollectionFields = hasNewCollectionFields; exports.formatAggregatorNames = formatAggregatorNames; exports.formatIconUrlWithProxy = formatIconUrlWithProxy; exports.SupportedTokenDetectionNetworks = SupportedTokenDetectionNetworks; exports.isTokenDetectionSupportedForNetwork = isTokenDetectionSupportedForNetwork; exports.isTokenListSupportedForNetwork = isTokenListSupportedForNetwork; exports.removeIpfsProtocolPrefix = removeIpfsProtocolPrefix; exports.getIpfsCIDv1AndPath = getIpfsCIDv1AndPath; exports.getFormattedIpfsUrl = getFormattedIpfsUrl; exports.addUrlProtocolPrefix = addUrlProtocolPrefix; exports.ethersBigNumberToBN = ethersBigNumberToBN; exports.divideIntoBatches = divideIntoBatches; exports.reduceInBatchesSerially = reduceInBatchesSerially; exports.fetchTokenContractExchangeRates = fetchTokenContractExchangeRates;
215
- //# sourceMappingURL=chunk-MZI3SDQN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/assetsUtil.ts"],"names":["SupportedTokenDetectionNetworks"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,gBAAgB;AACzB,OAAO,QAAQ;AAUR,IAAM,0BAA0B;AAWhC,SAAS,mBAAmB,gBAA6B,KAAU;AACxE,QAAM,OAA8B;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,kBAAkB,KAAK,OAAO,CAAC,OAAO,QAAQ;AAClD,QAAI,eAAe,GAAG,KAAK,eAAe,GAAG,MAAM,IAAI,GAAG,GAAG;AAC3D,aAAO,QAAQ;AAAA,IACjB;AACA,WAAO;AAAA,EACT,GAAG,CAAC;AACJ,SAAO,kBAAkB;AAC3B;AAQO,SAAS,uBACd,gBACA,KACS;AACT,QAAM,qBAAqB,OAAO,KAAK,eAAe,cAAc,CAAC,CAAC;AACtE,QAAM,kBAAkB,IAAI,IAAI,OAAO,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC;AAEjE,SAAO,mBAAmB,KAAK,CAAC,QAAQ,CAAC,gBAAgB,IAAI,GAAG,CAAC;AACnE;AAEA,IAAM,sBAA8C;AAA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QACH,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,eAAe,CAAC;AAAA,EAClB,CAAC;AAED,SAAO,OAAO,QAAQ,yBAAyB,EAAE;AAAA,IAC/C,CAAC,KAAK,CAAC,cAAc,UAAU,MAAM;AACnC,aAAO;AAAA,QACL,GAAG;AAAA,QACH,CAAC,qBAAqB,YAAY,CAAC,GAAG,YAAY;AAAA,MACpD;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACF","sourcesContent":["import type { BigNumber } from '@ethersproject/bignumber';\nimport {\n convertHexToDecimal,\n toChecksumHexAddress,\n} from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { remove0x } from '@metamask/utils';\nimport BN from 'bn.js';\n\nimport type { Nft, NftMetadata } from './NftController';\nimport type { AbstractTokenPricesService } from './token-prices-service';\nimport { type ContractExchangeRates } from './TokenRatesController';\n\n/**\n * The maximum number of token addresses that should be sent to the Price API in\n * a single request.\n */\nexport const TOKEN_PRICES_BATCH_SIZE = 30;\n\n/**\n * Compares nft metadata entries to any nft entry.\n * We need this method when comparing a new fetched nft metadata, in case a entry changed to a defined value,\n * there's a need to update the nft in state.\n *\n * @param newNftMetadata - Nft metadata object.\n * @param nft - Nft object to compare with.\n * @returns Whether there are differences.\n */\nexport function compareNftMetadata(newNftMetadata: NftMetadata, nft: Nft) {\n const keys: (keyof NftMetadata)[] = [\n 'image',\n 'backgroundColor',\n 'imagePreview',\n 'imageThumbnail',\n 'imageOriginal',\n 'animation',\n 'animationOriginal',\n 'externalLink',\n 'tokenURI',\n ];\n const differentValues = keys.reduce((value, key) => {\n if (newNftMetadata[key] && newNftMetadata[key] !== nft[key]) {\n return value + 1;\n }\n return value;\n }, 0);\n return differentValues > 0;\n}\n\n/**\n * Checks whether the existing nft object has all the keys of the new incoming nft metadata object\n * @param newNftMetadata - New nft metadata object\n * @param nft - Existing nft object to compare with\n * @returns Whether the existing nft object has all the new keys from the new Nft metadata object\n */\nexport function hasNewCollectionFields(\n newNftMetadata: NftMetadata,\n nft: Nft,\n): boolean {\n const keysNewNftMetadata = Object.keys(newNftMetadata.collection ?? {});\n const keysExistingNft = new Set(Object.keys(nft.collection ?? {}));\n\n return keysNewNftMetadata.some((key) => !keysExistingNft.has(key));\n}\n\nconst aggregatorNameByKey: Record<string, string> = {\n aave: 'Aave',\n bancor: 'Bancor',\n cmc: 'CMC',\n cryptocom: 'Crypto.com',\n coinGecko: 'CoinGecko',\n oneInch: '1inch',\n paraswap: 'Paraswap',\n pmm: 'PMM',\n zapper: 'Zapper',\n zerion: 'Zerion',\n zeroEx: '0x',\n synthetix: 'Synthetix',\n yearn: 'Yearn',\n apeswap: 'ApeSwap',\n binanceDex: 'BinanceDex',\n pancakeTop100: 'PancakeTop100',\n pancakeExtended: 'PancakeExtended',\n balancer: 'Balancer',\n quickswap: 'QuickSwap',\n matcha: 'Matcha',\n pangolinDex: 'PangolinDex',\n pangolinDexStableCoin: 'PangolinDexStableCoin',\n pangolinDexAvaxBridge: 'PangolinDexAvaxBridge',\n traderJoe: 'TraderJoe',\n airswapLight: 'AirswapLight',\n kleros: 'Kleros',\n};\n\n/**\n * Formats aggregator names to presentable format.\n *\n * @param aggregators - List of token list names in camelcase.\n * @returns Formatted aggregator names.\n */\nexport const formatAggregatorNames = (aggregators: string[]) => {\n return aggregators.map(\n (key) =>\n aggregatorNameByKey[key] ||\n `${key[0].toUpperCase()}${key.substring(1, key.length)}`,\n );\n};\n\n/**\n * Format token list assets to use image proxy from Codefi.\n *\n * @param params - Object that contains chainID and tokenAddress.\n * @param params.chainId - ChainID of network in 0x-prefixed hexadecimal format.\n * @param params.tokenAddress - Address of token in mixed or lowercase.\n * @returns Formatted image url\n */\nexport const formatIconUrlWithProxy = ({\n chainId,\n tokenAddress,\n}: {\n chainId: Hex;\n tokenAddress: string;\n}) => {\n const chainIdDecimal = convertHexToDecimal(chainId).toString();\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `https://static.cx.metamask.io/api/v1/tokenIcons/${chainIdDecimal}/${tokenAddress.toLowerCase()}.png`;\n};\n\n/**\n * Networks where token detection is supported - Values are in hex format\n */\nexport enum SupportedTokenDetectionNetworks {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n mainnet = '0x1', // decimal: 1\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n bsc = '0x38', // decimal: 56\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n polygon = '0x89', // decimal: 137\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n avax = '0xa86a', // decimal: 43114\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n aurora = '0x4e454152', // decimal: 1313161554\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n linea_goerli = '0xe704', // decimal: 59140\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n linea_mainnet = '0xe708', // decimal: 59144\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n arbitrum = '0xa4b1', // decimal: 42161\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n optimism = '0xa', // decimal: 10\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n base = '0x2105', // decimal: 8453\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n zksync = '0x144', // decimal: 324\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n cronos = '0x19', // decimal: 25\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n celo = '0xa4ec', // decimal: 42220\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n gnosis = '0x64', // decimal: 100\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n fantom = '0xfa', // decimal: 250\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n polygon_zkevm = '0x44d', // decimal: 1101\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n moonbeam = '0x504', // decimal: 1284\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n moonriver = '0x505', // decimal: 1285\n}\n\n/**\n * Check if token detection is enabled for certain networks.\n *\n * @param chainId - ChainID of network\n * @returns Whether the current network supports token detection\n */\nexport function isTokenDetectionSupportedForNetwork(chainId: Hex): boolean {\n return Object.values<Hex>(SupportedTokenDetectionNetworks).includes(chainId);\n}\n\n/**\n * Check if token list polling is enabled for a given network.\n * Currently this method is used to support e2e testing for consumers of this package.\n *\n * @param chainId - ChainID of network\n * @returns Whether the current network supports tokenlists\n */\nexport function isTokenListSupportedForNetwork(chainId: Hex): boolean {\n return isTokenDetectionSupportedForNetwork(chainId);\n}\n\n/**\n * Removes IPFS protocol prefix from input string.\n *\n * @param ipfsUrl - An IPFS url (e.g. ipfs://{content id})\n * @returns IPFS content identifier and (possibly) path in a string\n * @throws Will throw if the url passed is not IPFS.\n */\nexport function removeIpfsProtocolPrefix(ipfsUrl: string) {\n if (ipfsUrl.startsWith('ipfs://ipfs/')) {\n return ipfsUrl.replace('ipfs://ipfs/', '');\n } else if (ipfsUrl.startsWith('ipfs://')) {\n return ipfsUrl.replace('ipfs://', '');\n }\n // this method should not be used with non-ipfs urls (i.e. startsWith('ipfs://') === true)\n throw new Error('this method should not be used with non ipfs urls');\n}\n\n/**\n * Extracts content identifier and path from an input string.\n *\n * @param ipfsUrl - An IPFS URL minus the IPFS protocol prefix\n * @returns IFPS content identifier (cid) and sub path as string.\n * @throws Will throw if the url passed is not ipfs.\n */\nexport async function getIpfsCIDv1AndPath(ipfsUrl: string): Promise<{\n cid: string;\n path?: string;\n}> {\n const url = removeIpfsProtocolPrefix(ipfsUrl);\n\n // check if there is a path\n // (CID is everything preceding first forward slash, path is everything after)\n const index = url.indexOf('/');\n const cid = index !== -1 ? url.substring(0, index) : url;\n const path = index !== -1 ? url.substring(index) : undefined;\n\n const { CID } = await import('multiformats');\n // We want to ensure that the CID is v1 (https://docs.ipfs.io/concepts/content-addressing/#identifier-formats)\n // because most cid v0s appear to be incompatible with IPFS subdomains\n return {\n cid: CID.parse(cid).toV1().toString(),\n path,\n };\n}\n\n/**\n * Formats URL correctly for use retrieving assets hosted on IPFS.\n *\n * @param ipfsGateway - The users preferred IPFS gateway (full URL or just host).\n * @param ipfsUrl - The IFPS URL pointed at the asset.\n * @param subdomainSupported - Boolean indicating whether the URL should be formatted with subdomains or not.\n * @returns A formatted URL, with the user's preferred IPFS gateway and format (subdomain or not), pointing to an asset hosted on IPFS.\n */\nexport async function getFormattedIpfsUrl(\n ipfsGateway: string,\n ipfsUrl: string,\n subdomainSupported: boolean,\n): Promise<string> {\n const { host, protocol, origin } = new URL(addUrlProtocolPrefix(ipfsGateway));\n if (subdomainSupported) {\n const { cid, path } = await getIpfsCIDv1AndPath(ipfsUrl);\n return `${protocol}//${cid}.ipfs.${host}${path ?? ''}`;\n }\n const cidAndPath = removeIpfsProtocolPrefix(ipfsUrl);\n return `${origin}/ipfs/${cidAndPath}`;\n}\n\n/**\n * Adds URL protocol prefix to input URL string if missing.\n *\n * @param urlString - An IPFS URL.\n * @returns A URL with a https:// prepended.\n */\nexport function addUrlProtocolPrefix(urlString: string): string {\n if (!urlString.match(/(^http:\\/\\/)|(^https:\\/\\/)/u)) {\n return `https://${urlString}`;\n }\n return urlString;\n}\n\n/**\n * Converts an Ethers BigNumber to a BN.\n *\n * @param bigNumber - An Ethers BigNumber instance.\n * @returns A BN object.\n */\nexport function ethersBigNumberToBN(bigNumber: BigNumber): BN {\n return new BN(remove0x(bigNumber.toHexString()), 'hex');\n}\n\n/**\n * Partitions a list of values into groups that are at most `batchSize` in\n * length.\n *\n * @param values - The list of values.\n * @param args - The remaining arguments.\n * @param args.batchSize - The desired maximum number of values per batch.\n * @returns The list of batches.\n */\nexport function divideIntoBatches<Value>(\n values: Value[],\n { batchSize }: { batchSize: number },\n): Value[][] {\n const batches = [];\n for (let i = 0; i < values.length; i += batchSize) {\n batches.push(values.slice(i, i + batchSize));\n }\n return batches;\n}\n\n/**\n * Constructs an object from processing batches of the given values\n * sequentially.\n *\n * @param args - The arguments to this function.\n * @param args.values - A list of values to iterate over.\n * @param args.batchSize - The maximum number of values in each batch.\n * @param args.eachBatch - A function to call for each batch. This function is\n * similar to the function that `Array.prototype.reduce` takes, in that it\n * receives the object that is being built, each batch in the list of batches\n * and the index, and should return an updated version of the object.\n * @param args.initialResult - The initial value of the final data structure,\n * i.e., the value that will be fed into the first call of `eachBatch`.\n * @returns The built object.\n */\nexport async function reduceInBatchesSerially<\n Value,\n Result extends Record<PropertyKey, unknown>,\n>({\n values,\n batchSize,\n eachBatch,\n initialResult,\n}: {\n values: Value[];\n batchSize: number;\n eachBatch: (\n workingResult: Partial<Result>,\n batch: Value[],\n index: number,\n ) => Partial<Result> | Promise<Partial<Result>>;\n initialResult: Partial<Result>;\n}): Promise<Result> {\n const batches = divideIntoBatches(values, { batchSize });\n let workingResult = initialResult;\n for (const [index, batch] of batches.entries()) {\n workingResult = await eachBatch(workingResult, batch, index);\n }\n // There's no way around this — we have to assume that in the end, the result\n // matches the intended type.\n const finalResult = workingResult as Result;\n return finalResult;\n}\n\n/**\n * Retrieves token prices for a set of contract addresses in a specific currency and chainId.\n *\n * @param args - The arguments to function.\n * @param args.tokenPricesService - An object in charge of retrieving token prices.\n * @param args.nativeCurrency - The native currency to request price in.\n * @param args.tokenAddresses - The list of contract addresses.\n * @param args.chainId - The chainId of the tokens.\n * @returns The prices for the requested tokens.\n */\nexport async function fetchTokenContractExchangeRates({\n tokenPricesService,\n nativeCurrency,\n tokenAddresses,\n chainId,\n}: {\n tokenPricesService: AbstractTokenPricesService;\n nativeCurrency: string;\n tokenAddresses: Hex[];\n chainId: Hex;\n}): Promise<ContractExchangeRates> {\n const isChainIdSupported =\n tokenPricesService.validateChainIdSupported(chainId);\n const isCurrencySupported =\n tokenPricesService.validateCurrencySupported(nativeCurrency);\n\n if (!isChainIdSupported || !isCurrencySupported) {\n return {};\n }\n\n const tokenPricesByTokenAddress = await reduceInBatchesSerially<\n Hex,\n Awaited<ReturnType<AbstractTokenPricesService['fetchTokenPrices']>>\n >({\n values: [...tokenAddresses].sort(),\n batchSize: TOKEN_PRICES_BATCH_SIZE,\n eachBatch: async (allTokenPricesByTokenAddress, batch) => {\n const tokenPricesByTokenAddressForBatch =\n await tokenPricesService.fetchTokenPrices({\n tokenAddresses: batch,\n chainId,\n currency: nativeCurrency,\n });\n\n return {\n ...allTokenPricesByTokenAddress,\n ...tokenPricesByTokenAddressForBatch,\n };\n },\n initialResult: {},\n });\n\n return Object.entries(tokenPricesByTokenAddress).reduce(\n (obj, [tokenAddress, tokenPrice]) => {\n return {\n ...obj,\n [toChecksumHexAddress(tokenAddress)]: tokenPrice?.price,\n };\n },\n {},\n );\n}\n"]}