@metamask/assets-controllers 38.0.0 → 38.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -1
- package/dist/AccountTrackerController.cjs +245 -0
- package/dist/AccountTrackerController.cjs.map +1 -0
- package/dist/{types/AccountTrackerController.d.ts → AccountTrackerController.d.cts} +6 -6
- package/dist/AccountTrackerController.d.cts.map +1 -0
- package/dist/AccountTrackerController.d.mts +112 -0
- package/dist/AccountTrackerController.d.mts.map +1 -0
- package/dist/AccountTrackerController.mjs +244 -8
- package/dist/AccountTrackerController.mjs.map +1 -1
- package/dist/AssetsContractController.cjs +389 -0
- package/dist/AssetsContractController.cjs.map +1 -0
- package/dist/{types/AssetsContractController.d.ts → AssetsContractController.d.cts} +9 -9
- package/dist/AssetsContractController.d.cts.map +1 -0
- package/dist/AssetsContractController.d.mts +277 -0
- package/dist/AssetsContractController.d.mts.map +1 -0
- package/dist/AssetsContractController.mjs +387 -16
- package/dist/AssetsContractController.mjs.map +1 -1
- package/dist/CurrencyRateController.cjs +156 -0
- package/dist/CurrencyRateController.cjs.map +1 -0
- package/dist/{types/CurrencyRateController.d.ts → CurrencyRateController.d.cts} +5 -5
- package/dist/CurrencyRateController.d.cts.map +1 -0
- package/dist/CurrencyRateController.d.mts +80 -0
- package/dist/CurrencyRateController.d.mts.map +1 -0
- package/dist/CurrencyRateController.mjs +150 -10
- package/dist/CurrencyRateController.mjs.map +1 -1
- package/dist/NftController.cjs +1159 -0
- package/dist/NftController.cjs.map +1 -0
- package/dist/{types/NftController.d.ts → NftController.d.cts} +11 -11
- package/dist/NftController.d.cts.map +1 -0
- package/dist/NftController.d.mts +424 -0
- package/dist/NftController.d.mts.map +1 -0
- package/dist/NftController.mjs +1156 -12
- package/dist/NftController.mjs.map +1 -1
- package/dist/NftDetectionController.cjs +237 -0
- package/dist/NftDetectionController.cjs.map +1 -0
- package/dist/{types/NftDetectionController.d.ts → NftDetectionController.d.cts} +9 -9
- package/dist/NftDetectionController.d.cts.map +1 -0
- package/dist/NftDetectionController.d.mts +368 -0
- package/dist/NftDetectionController.d.mts.map +1 -0
- package/dist/NftDetectionController.mjs +231 -14
- package/dist/NftDetectionController.mjs.map +1 -1
- package/dist/RatesController/RatesController.cjs +189 -0
- package/dist/RatesController/RatesController.cjs.map +1 -0
- package/dist/{types/RatesController/RatesController.d.ts → RatesController/RatesController.d.cts} +3 -3
- package/dist/RatesController/RatesController.d.cts.map +1 -0
- package/dist/RatesController/RatesController.d.mts +44 -0
- package/dist/RatesController/RatesController.d.mts.map +1 -0
- package/dist/RatesController/RatesController.mjs +183 -12
- package/dist/RatesController/RatesController.mjs.map +1 -1
- package/dist/RatesController/index.cjs +7 -0
- package/dist/RatesController/index.cjs.map +1 -0
- package/dist/{types/RatesController/index.d.ts → RatesController/index.d.cts} +3 -3
- package/dist/RatesController/index.d.cts.map +1 -0
- package/dist/RatesController/index.d.mts +3 -0
- package/dist/RatesController/index.d.mts.map +1 -0
- package/dist/RatesController/index.mjs +1 -12
- package/dist/RatesController/index.mjs.map +1 -1
- package/dist/RatesController/types.cjs +3 -0
- package/dist/RatesController/types.cjs.map +1 -0
- package/dist/{types/RatesController/types.d.ts → RatesController/types.d.cts} +4 -4
- package/dist/RatesController/types.d.cts.map +1 -0
- package/dist/RatesController/types.d.mts +100 -0
- package/dist/RatesController/types.d.mts.map +1 -0
- package/dist/RatesController/types.mjs +1 -0
- package/dist/RatesController/types.mjs.map +1 -1
- package/dist/Standards/ERC20Standard.cjs +124 -0
- package/dist/Standards/ERC20Standard.cjs.map +1 -0
- package/dist/{types/Standards/ERC20Standard.d.ts → Standards/ERC20Standard.d.cts} +3 -3
- package/dist/Standards/ERC20Standard.d.cts.map +1 -0
- package/dist/Standards/ERC20Standard.d.mts +49 -0
- package/dist/Standards/ERC20Standard.d.mts.map +1 -0
- package/dist/Standards/ERC20Standard.mjs +121 -8
- package/dist/Standards/ERC20Standard.mjs.map +1 -1
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.cjs +189 -0
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.cjs.map +1 -0
- package/dist/{types/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts → Standards/NftStandards/ERC1155/ERC1155Standard.d.cts} +3 -3
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.cts.map +1 -0
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.mts +95 -0
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.mts.map +1 -0
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.mjs +184 -8
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.mjs.map +1 -1
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.cjs +167 -0
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.cjs.map +1 -0
- package/dist/{types/Standards/NftStandards/ERC721/ERC721Standard.d.ts → Standards/NftStandards/ERC721/ERC721Standard.d.cts} +2 -2
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.cts.map +1 -0
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.mts +89 -0
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.mts.map +1 -0
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.mjs +162 -8
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.mjs.map +1 -1
- package/dist/TokenBalancesController.cjs +136 -0
- package/dist/TokenBalancesController.cjs.map +1 -0
- package/dist/{types/TokenBalancesController.d.ts → TokenBalancesController.d.cts} +7 -7
- package/dist/TokenBalancesController.d.cts.map +1 -0
- package/dist/TokenBalancesController.d.mts +82 -0
- package/dist/TokenBalancesController.d.mts.map +1 -0
- package/dist/TokenBalancesController.mjs +129 -10
- package/dist/TokenBalancesController.mjs.map +1 -1
- package/dist/TokenDetectionController.cjs +369 -0
- package/dist/TokenDetectionController.cjs.map +1 -0
- package/dist/{types/TokenDetectionController.d.ts → TokenDetectionController.d.cts} +10 -10
- package/dist/TokenDetectionController.d.cts.map +1 -0
- package/dist/TokenDetectionController.d.mts +109 -0
- package/dist/TokenDetectionController.d.mts.map +1 -0
- package/dist/TokenDetectionController.mjs +366 -15
- package/dist/TokenDetectionController.mjs.map +1 -1
- package/dist/TokenListController.cjs +274 -0
- package/dist/TokenListController.cjs.map +1 -0
- package/dist/{types/TokenListController.d.ts → TokenListController.d.cts} +5 -5
- package/dist/TokenListController.d.cts.map +1 -0
- package/dist/TokenListController.d.mts +117 -0
- package/dist/TokenListController.d.mts.map +1 -0
- package/dist/TokenListController.mjs +267 -12
- package/dist/TokenListController.mjs.map +1 -1
- package/dist/TokenRatesController.cjs +452 -0
- package/dist/TokenRatesController.cjs.map +1 -0
- package/dist/{types/TokenRatesController.d.ts → TokenRatesController.d.cts} +8 -8
- package/dist/TokenRatesController.d.cts.map +1 -0
- package/dist/TokenRatesController.d.mts +170 -0
- package/dist/TokenRatesController.d.mts.map +1 -0
- package/dist/TokenRatesController.mjs +446 -16
- package/dist/TokenRatesController.mjs.map +1 -1
- package/dist/TokensController.cjs +678 -0
- package/dist/TokensController.cjs.map +1 -0
- package/dist/{types/TokensController.d.ts → TokensController.d.cts} +9 -9
- package/dist/TokensController.d.cts.map +1 -0
- package/dist/TokensController.d.mts +165 -0
- package/dist/TokensController.d.mts.map +1 -0
- package/dist/TokensController.mjs +675 -14
- package/dist/TokensController.mjs.map +1 -1
- package/dist/assetsUtil.cjs +358 -0
- package/dist/assetsUtil.cjs.map +1 -0
- package/dist/{types/assetsUtil.d.ts → assetsUtil.d.cts} +7 -7
- package/dist/assetsUtil.d.cts.map +1 -0
- package/dist/assetsUtil.d.mts +177 -0
- package/dist/assetsUtil.d.mts.map +1 -0
- package/dist/assetsUtil.mjs +343 -36
- package/dist/assetsUtil.mjs.map +1 -1
- package/dist/constants.cjs +10 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{types/constants.d.ts → constants.d.cts} +1 -1
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +6 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +6 -7
- package/dist/constants.mjs.map +1 -1
- package/dist/crypto-compare-service/crypto-compare.cjs +119 -0
- package/dist/crypto-compare-service/crypto-compare.cjs.map +1 -0
- package/dist/{types/crypto-compare-service/crypto-compare.d.ts → crypto-compare-service/crypto-compare.d.cts} +1 -1
- package/dist/crypto-compare-service/crypto-compare.d.cts.map +1 -0
- package/dist/crypto-compare-service/crypto-compare.d.mts +22 -0
- package/dist/crypto-compare-service/crypto-compare.d.mts.map +1 -0
- package/dist/crypto-compare-service/crypto-compare.mjs +113 -9
- package/dist/crypto-compare-service/crypto-compare.mjs.map +1 -1
- package/dist/crypto-compare-service/index.cjs +7 -0
- package/dist/crypto-compare-service/index.cjs.map +1 -0
- package/dist/crypto-compare-service/index.d.cts +2 -0
- package/dist/crypto-compare-service/index.d.cts.map +1 -0
- package/dist/crypto-compare-service/index.d.mts +2 -0
- package/dist/crypto-compare-service/index.d.mts.map +1 -0
- package/dist/crypto-compare-service/index.mjs +1 -10
- package/dist/crypto-compare-service/index.mjs.map +1 -1
- package/dist/index.cjs +51 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{types/index.d.ts → index.d.cts} +24 -24
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +13 -80
- package/dist/index.mjs.map +1 -1
- package/dist/token-prices-service/abstract-token-prices-service.cjs +3 -0
- package/dist/token-prices-service/abstract-token-prices-service.cjs.map +1 -0
- package/dist/{types/token-prices-service/abstract-token-prices-service.d.ts → token-prices-service/abstract-token-prices-service.d.cts} +2 -2
- package/dist/token-prices-service/abstract-token-prices-service.d.cts.map +1 -0
- package/dist/token-prices-service/abstract-token-prices-service.d.mts +79 -0
- package/dist/token-prices-service/abstract-token-prices-service.d.mts.map +1 -0
- package/dist/token-prices-service/abstract-token-prices-service.mjs +1 -0
- package/dist/token-prices-service/abstract-token-prices-service.mjs.map +1 -1
- package/dist/token-prices-service/codefi-v2.cjs +352 -0
- package/dist/token-prices-service/codefi-v2.cjs.map +1 -0
- package/dist/{types/token-prices-service/codefi-v2.d.ts → token-prices-service/codefi-v2.d.cts} +3 -3
- package/dist/token-prices-service/codefi-v2.d.cts.map +1 -0
- package/dist/token-prices-service/codefi-v2.d.mts +97 -0
- package/dist/token-prices-service/codefi-v2.d.mts.map +1 -0
- package/dist/token-prices-service/codefi-v2.mjs +347 -12
- package/dist/token-prices-service/codefi-v2.mjs.map +1 -1
- package/dist/token-prices-service/index.cjs +7 -0
- package/dist/token-prices-service/index.cjs.map +1 -0
- package/dist/token-prices-service/index.d.cts +3 -0
- package/dist/token-prices-service/index.d.cts.map +1 -0
- package/dist/token-prices-service/index.d.mts +3 -0
- package/dist/token-prices-service/index.d.mts.map +1 -0
- package/dist/token-prices-service/index.mjs +1 -10
- package/dist/token-prices-service/index.mjs.map +1 -1
- package/dist/token-service.cjs +130 -0
- package/dist/token-service.cjs.map +1 -0
- package/dist/{types/token-service.d.ts → token-service.d.cts} +2 -2
- package/dist/token-service.d.cts.map +1 -0
- package/dist/token-service.d.mts +31 -0
- package/dist/token-service.d.mts.map +1 -0
- package/dist/token-service.mjs +124 -14
- package/dist/token-service.mjs.map +1 -1
- package/package.json +20 -15
- package/dist/AccountTrackerController.js +0 -10
- package/dist/AccountTrackerController.js.map +0 -1
- package/dist/AssetsContractController.js +0 -18
- package/dist/AssetsContractController.js.map +0 -1
- package/dist/CurrencyRateController.js +0 -12
- package/dist/CurrencyRateController.js.map +0 -1
- package/dist/NftController.js +0 -14
- package/dist/NftController.js.map +0 -1
- package/dist/NftDetectionController.js +0 -16
- package/dist/NftDetectionController.js.map +0 -1
- package/dist/RatesController/RatesController.js +0 -14
- package/dist/RatesController/RatesController.js.map +0 -1
- package/dist/RatesController/index.js +0 -13
- package/dist/RatesController/index.js.map +0 -1
- package/dist/RatesController/types.js +0 -1
- package/dist/RatesController/types.js.map +0 -1
- package/dist/Standards/ERC20Standard.js +0 -9
- package/dist/Standards/ERC20Standard.js.map +0 -1
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js +0 -9
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js.map +0 -1
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.js +0 -9
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.js.map +0 -1
- package/dist/TokenBalancesController.js +0 -12
- package/dist/TokenBalancesController.js.map +0 -1
- package/dist/TokenDetectionController.js +0 -17
- package/dist/TokenDetectionController.js.map +0 -1
- package/dist/TokenListController.js +0 -14
- package/dist/TokenListController.js.map +0 -1
- package/dist/TokenRatesController.js +0 -18
- package/dist/TokenRatesController.js.map +0 -1
- package/dist/TokensController.js +0 -16
- package/dist/TokensController.js.map +0 -1
- package/dist/assetsUtil.js +0 -38
- package/dist/assetsUtil.js.map +0 -1
- package/dist/chunk-27KOXCQK.mjs +0 -1
- package/dist/chunk-27KOXCQK.mjs.map +0 -1
- package/dist/chunk-2TZK6YZA.js +0 -1405
- package/dist/chunk-2TZK6YZA.js.map +0 -1
- package/dist/chunk-3LPQTUGG.js +0 -434
- package/dist/chunk-3LPQTUGG.js.map +0 -1
- package/dist/chunk-3QDXAE2D.mjs +0 -178
- package/dist/chunk-3QDXAE2D.mjs.map +0 -1
- package/dist/chunk-46KUC5FH.mjs +0 -434
- package/dist/chunk-46KUC5FH.mjs.map +0 -1
- package/dist/chunk-4QZESU46.mjs +0 -530
- package/dist/chunk-4QZESU46.mjs.map +0 -1
- package/dist/chunk-5QLC2MHV.js +0 -215
- package/dist/chunk-5QLC2MHV.js.map +0 -1
- package/dist/chunk-7K6PSEAA.js +0 -1
- package/dist/chunk-7K6PSEAA.js.map +0 -1
- package/dist/chunk-AX522TDL.mjs +0 -85
- package/dist/chunk-AX522TDL.mjs.map +0 -1
- package/dist/chunk-AZSIKIMK.mjs +0 -429
- package/dist/chunk-AZSIKIMK.mjs.map +0 -1
- package/dist/chunk-BBCZM5P4.js +0 -300
- package/dist/chunk-BBCZM5P4.js.map +0 -1
- package/dist/chunk-BZEAPSD5.mjs +0 -215
- package/dist/chunk-BZEAPSD5.mjs.map +0 -1
- package/dist/chunk-C7LNCQXM.mjs +0 -300
- package/dist/chunk-C7LNCQXM.mjs.map +0 -1
- package/dist/chunk-CP3HC7AQ.mjs +0 -12
- package/dist/chunk-CP3HC7AQ.mjs.map +0 -1
- package/dist/chunk-FWKV5FGP.mjs +0 -71
- package/dist/chunk-FWKV5FGP.mjs.map +0 -1
- package/dist/chunk-GDFLKKDY.js +0 -71
- package/dist/chunk-GDFLKKDY.js.map +0 -1
- package/dist/chunk-GW6RE66P.mjs +0 -210
- package/dist/chunk-GW6RE66P.mjs.map +0 -1
- package/dist/chunk-HVOIBGYN.js +0 -282
- package/dist/chunk-HVOIBGYN.js.map +0 -1
- package/dist/chunk-ISK2VSBB.js +0 -178
- package/dist/chunk-ISK2VSBB.js.map +0 -1
- package/dist/chunk-JCR4H6YL.js +0 -115
- package/dist/chunk-JCR4H6YL.js.map +0 -1
- package/dist/chunk-JJX7TMH5.mjs +0 -135
- package/dist/chunk-JJX7TMH5.mjs.map +0 -1
- package/dist/chunk-JMZ7KWJS.js +0 -157
- package/dist/chunk-JMZ7KWJS.js.map +0 -1
- package/dist/chunk-JYHAAA6W.mjs +0 -1
- package/dist/chunk-JYHAAA6W.mjs.map +0 -1
- package/dist/chunk-K7A3EOIM.js +0 -85
- package/dist/chunk-K7A3EOIM.js.map +0 -1
- package/dist/chunk-KPBNX6GP.mjs +0 -215
- package/dist/chunk-KPBNX6GP.mjs.map +0 -1
- package/dist/chunk-LKVWPNXY.js +0 -429
- package/dist/chunk-LKVWPNXY.js.map +0 -1
- package/dist/chunk-MZI3SDQN.js +0 -215
- package/dist/chunk-MZI3SDQN.js.map +0 -1
- package/dist/chunk-NDUMUEE6.js +0 -812
- package/dist/chunk-NDUMUEE6.js.map +0 -1
- package/dist/chunk-OBUR4TXH.js +0 -1
- package/dist/chunk-OBUR4TXH.js.map +0 -1
- package/dist/chunk-RGHTNZQ6.js +0 -12
- package/dist/chunk-RGHTNZQ6.js.map +0 -1
- package/dist/chunk-S5CFNNOM.mjs +0 -115
- package/dist/chunk-S5CFNNOM.mjs.map +0 -1
- package/dist/chunk-SK2B36Q4.mjs +0 -1405
- package/dist/chunk-SK2B36Q4.mjs.map +0 -1
- package/dist/chunk-TFLYM4PY.mjs +0 -291
- package/dist/chunk-TFLYM4PY.mjs.map +0 -1
- package/dist/chunk-TIFLP53R.js +0 -210
- package/dist/chunk-TIFLP53R.js.map +0 -1
- package/dist/chunk-TTH3ES66.mjs +0 -1
- package/dist/chunk-TTH3ES66.mjs.map +0 -1
- package/dist/chunk-UKXD6WUT.mjs +0 -157
- package/dist/chunk-UKXD6WUT.mjs.map +0 -1
- package/dist/chunk-UUF4E7OG.js +0 -530
- package/dist/chunk-UUF4E7OG.js.map +0 -1
- package/dist/chunk-V6DNVROD.js +0 -348
- package/dist/chunk-V6DNVROD.js.map +0 -1
- package/dist/chunk-XC3SOOGC.js +0 -1
- package/dist/chunk-XC3SOOGC.js.map +0 -1
- package/dist/chunk-XMQA5NLX.mjs +0 -812
- package/dist/chunk-XMQA5NLX.mjs.map +0 -1
- package/dist/chunk-XQO3EG4J.mjs +0 -348
- package/dist/chunk-XQO3EG4J.mjs.map +0 -1
- package/dist/chunk-XUI43LEZ.mjs +0 -30
- package/dist/chunk-XUI43LEZ.mjs.map +0 -1
- package/dist/chunk-YGGUAMHV.js +0 -135
- package/dist/chunk-YGGUAMHV.js.map +0 -1
- package/dist/chunk-Z4BLTVTB.js +0 -30
- package/dist/chunk-Z4BLTVTB.js.map +0 -1
- package/dist/chunk-Z7RMCHD4.mjs +0 -282
- package/dist/chunk-Z7RMCHD4.mjs.map +0 -1
- package/dist/chunk-ZAR4BIOC.js +0 -291
- package/dist/chunk-ZAR4BIOC.js.map +0 -1
- package/dist/constants.js +0 -8
- package/dist/constants.js.map +0 -1
- package/dist/crypto-compare-service/crypto-compare.js +0 -10
- package/dist/crypto-compare-service/crypto-compare.js.map +0 -1
- package/dist/crypto-compare-service/index.js +0 -11
- package/dist/crypto-compare-service/index.js.map +0 -1
- package/dist/index.js +0 -81
- package/dist/index.js.map +0 -1
- package/dist/token-prices-service/abstract-token-prices-service.js +0 -1
- package/dist/token-prices-service/abstract-token-prices-service.js.map +0 -1
- package/dist/token-prices-service/codefi-v2.js +0 -14
- package/dist/token-prices-service/codefi-v2.js.map +0 -1
- package/dist/token-prices-service/index.js +0 -11
- package/dist/token-prices-service/index.js.map +0 -1
- package/dist/token-service.js +0 -15
- package/dist/token-service.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/AccountTrackerController.d.ts.map +0 -1
- package/dist/types/AssetsContractController.d.ts.map +0 -1
- package/dist/types/CurrencyRateController.d.ts.map +0 -1
- package/dist/types/NftController.d.ts.map +0 -1
- package/dist/types/NftDetectionController.d.ts.map +0 -1
- package/dist/types/RatesController/RatesController.d.ts.map +0 -1
- package/dist/types/RatesController/index.d.ts.map +0 -1
- package/dist/types/RatesController/types.d.ts.map +0 -1
- package/dist/types/Standards/ERC20Standard.d.ts.map +0 -1
- package/dist/types/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts.map +0 -1
- package/dist/types/Standards/NftStandards/ERC721/ERC721Standard.d.ts.map +0 -1
- package/dist/types/TokenBalancesController.d.ts.map +0 -1
- package/dist/types/TokenDetectionController.d.ts.map +0 -1
- package/dist/types/TokenListController.d.ts.map +0 -1
- package/dist/types/TokenRatesController.d.ts.map +0 -1
- package/dist/types/TokensController.d.ts.map +0 -1
- package/dist/types/assetsUtil.d.ts.map +0 -1
- package/dist/types/constants.d.ts.map +0 -1
- package/dist/types/crypto-compare-service/crypto-compare.d.ts.map +0 -1
- package/dist/types/crypto-compare-service/index.d.ts +0 -2
- package/dist/types/crypto-compare-service/index.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/token-prices-service/abstract-token-prices-service.d.ts.map +0 -1
- package/dist/types/token-prices-service/codefi-v2.d.ts.map +0 -1
- package/dist/types/token-prices-service/index.d.ts +0 -3
- package/dist/types/token-prices-service/index.d.ts.map +0 -1
- package/dist/types/token-service.d.ts.map +0 -1
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import type { AccountsControllerGetSelectedAccountAction } from "@metamask/accounts-controller";
|
|
2
|
+
import type { AddApprovalRequest } from "@metamask/approval-controller";
|
|
3
|
+
import type { RestrictedControllerMessenger } from "@metamask/base-controller";
|
|
4
|
+
import { BaseController } from "@metamask/base-controller";
|
|
5
|
+
import type { NetworkClientId, NetworkClient, NetworkControllerGetNetworkClientByIdAction, NetworkControllerStateChangeEvent, NetworkControllerGetStateAction } from "@metamask/network-controller";
|
|
6
|
+
import type { PreferencesControllerGetStateAction, PreferencesControllerStateChangeEvent } from "@metamask/preferences-controller";
|
|
7
|
+
import { Source } from "./constants.mjs";
|
|
8
|
+
import { type NftController, type NftControllerState } from "./NftController.mjs";
|
|
9
|
+
declare const controllerName = "NftDetectionController";
|
|
10
|
+
export type NFTDetectionControllerState = Record<never, never>;
|
|
11
|
+
export type AllowedActions = AddApprovalRequest | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | PreferencesControllerGetStateAction | AccountsControllerGetSelectedAccountAction;
|
|
12
|
+
export type AllowedEvents = PreferencesControllerStateChangeEvent | NetworkControllerStateChangeEvent;
|
|
13
|
+
export type NftDetectionControllerMessenger = RestrictedControllerMessenger<typeof controllerName, AllowedActions, AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
14
|
+
/**
|
|
15
|
+
* @type ApiNft
|
|
16
|
+
*
|
|
17
|
+
* NFT object coming from OpenSea api
|
|
18
|
+
* @property token_id - The NFT identifier
|
|
19
|
+
* @property num_sales - Number of sales
|
|
20
|
+
* @property background_color - The background color to be displayed with the item
|
|
21
|
+
* @property image_url - URI of an image associated with this NFT
|
|
22
|
+
* @property image_preview_url - URI of a smaller image associated with this NFT
|
|
23
|
+
* @property image_thumbnail_url - URI of a thumbnail image associated with this NFT
|
|
24
|
+
* @property image_original_url - URI of the original image associated with this NFT
|
|
25
|
+
* @property animation_url - URI of a animation associated with this NFT
|
|
26
|
+
* @property animation_original_url - URI of the original animation associated with this NFT
|
|
27
|
+
* @property name - The NFT name
|
|
28
|
+
* @property description - The NFT description
|
|
29
|
+
* @property external_link - External link containing additional information
|
|
30
|
+
* @property assetContract - The NFT contract information object
|
|
31
|
+
* @property creator - The NFT owner information object
|
|
32
|
+
* @property lastSale - When this item was last sold
|
|
33
|
+
*/
|
|
34
|
+
export type ApiNft = {
|
|
35
|
+
token_id: string;
|
|
36
|
+
num_sales: number | null;
|
|
37
|
+
background_color: string | null;
|
|
38
|
+
image_url: string | null;
|
|
39
|
+
image_preview_url: string | null;
|
|
40
|
+
image_thumbnail_url: string | null;
|
|
41
|
+
image_original_url: string | null;
|
|
42
|
+
animation_url: string | null;
|
|
43
|
+
animation_original_url: string | null;
|
|
44
|
+
name: string | null;
|
|
45
|
+
description: string | null;
|
|
46
|
+
external_link: string | null;
|
|
47
|
+
asset_contract: ApiNftContract;
|
|
48
|
+
creator: ApiNftCreator;
|
|
49
|
+
last_sale: ApiNftLastSale | null;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* @type ApiNftContract
|
|
53
|
+
*
|
|
54
|
+
* NFT contract object coming from OpenSea api
|
|
55
|
+
* @property address - Address of the NFT contract
|
|
56
|
+
* @property asset_contract_type - The NFT type, it could be `semi-fungible` or `non-fungible`
|
|
57
|
+
* @property created_date - Creation date
|
|
58
|
+
* @property collection - Object containing the contract name and URI of an image associated
|
|
59
|
+
* @property schema_name - The schema followed by the contract, it could be `ERC721` or `ERC1155`
|
|
60
|
+
* @property symbol - The NFT contract symbol
|
|
61
|
+
* @property total_supply - Total supply of NFTs
|
|
62
|
+
* @property description - The NFT contract description
|
|
63
|
+
* @property external_link - External link containing additional information
|
|
64
|
+
*/
|
|
65
|
+
export type ApiNftContract = {
|
|
66
|
+
address: string;
|
|
67
|
+
asset_contract_type: string | null;
|
|
68
|
+
created_date: string | null;
|
|
69
|
+
schema_name: string | null;
|
|
70
|
+
symbol: string | null;
|
|
71
|
+
total_supply: string | null;
|
|
72
|
+
description: string | null;
|
|
73
|
+
external_link: string | null;
|
|
74
|
+
collection: {
|
|
75
|
+
name: string | null;
|
|
76
|
+
image_url?: string | null;
|
|
77
|
+
tokenCount?: string | null;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* @type ApiNftLastSale
|
|
82
|
+
*
|
|
83
|
+
* NFT sale object coming from OpenSea api
|
|
84
|
+
* @property event_timestamp - Object containing a `username`
|
|
85
|
+
* @property total_price - URI of NFT image associated with this owner
|
|
86
|
+
* @property transaction - Object containing transaction_hash and block_hash
|
|
87
|
+
*/
|
|
88
|
+
export type ApiNftLastSale = {
|
|
89
|
+
event_timestamp: string;
|
|
90
|
+
total_price: string;
|
|
91
|
+
transaction: {
|
|
92
|
+
transaction_hash: string;
|
|
93
|
+
block_hash: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* @type ApiNftCreator
|
|
98
|
+
*
|
|
99
|
+
* NFT creator object coming from OpenSea api
|
|
100
|
+
* @property user - Object containing a `username`
|
|
101
|
+
* @property profile_img_url - URI of NFT image associated with this owner
|
|
102
|
+
* @property address - The owner address
|
|
103
|
+
*/
|
|
104
|
+
export type ApiNftCreator = {
|
|
105
|
+
user: {
|
|
106
|
+
username: string;
|
|
107
|
+
};
|
|
108
|
+
profile_img_url: string;
|
|
109
|
+
address: string;
|
|
110
|
+
};
|
|
111
|
+
export type ReservoirResponse = {
|
|
112
|
+
tokens: TokensResponse[];
|
|
113
|
+
continuation?: string;
|
|
114
|
+
};
|
|
115
|
+
export type TokensResponse = {
|
|
116
|
+
token: TokenResponse;
|
|
117
|
+
ownership: Ownership;
|
|
118
|
+
market?: Market;
|
|
119
|
+
blockaidResult?: Blockaid;
|
|
120
|
+
};
|
|
121
|
+
export declare enum BlockaidResultType {
|
|
122
|
+
Benign = "Benign",
|
|
123
|
+
Spam = "Spam",
|
|
124
|
+
Warning = "Warning",
|
|
125
|
+
Malicious = "Malicious"
|
|
126
|
+
}
|
|
127
|
+
export type Blockaid = {
|
|
128
|
+
contract: string;
|
|
129
|
+
chainId: number;
|
|
130
|
+
result_type: BlockaidResultType;
|
|
131
|
+
malicious_score: string;
|
|
132
|
+
attack_types: object;
|
|
133
|
+
};
|
|
134
|
+
export type Market = {
|
|
135
|
+
floorAsk?: FloorAsk;
|
|
136
|
+
topBid?: TopBid;
|
|
137
|
+
};
|
|
138
|
+
export type TokenResponse = {
|
|
139
|
+
chainId: number;
|
|
140
|
+
contract: string;
|
|
141
|
+
tokenId: string;
|
|
142
|
+
kind?: string;
|
|
143
|
+
name?: string;
|
|
144
|
+
image?: string;
|
|
145
|
+
imageSmall?: string;
|
|
146
|
+
imageLarge?: string;
|
|
147
|
+
metadata?: Metadata;
|
|
148
|
+
description?: string;
|
|
149
|
+
supply?: number;
|
|
150
|
+
remainingSupply?: number;
|
|
151
|
+
rarityScore?: number;
|
|
152
|
+
rarity?: number;
|
|
153
|
+
rarityRank?: number;
|
|
154
|
+
media?: string;
|
|
155
|
+
isFlagged?: boolean;
|
|
156
|
+
isSpam?: boolean;
|
|
157
|
+
isNsfw?: boolean;
|
|
158
|
+
metadataDisabled?: boolean;
|
|
159
|
+
lastFlagUpdate?: string;
|
|
160
|
+
lastFlagChange?: string;
|
|
161
|
+
collection?: Collection;
|
|
162
|
+
lastSale?: LastSale;
|
|
163
|
+
topBid?: TopBid;
|
|
164
|
+
lastAppraisalValue?: number;
|
|
165
|
+
attributes?: Attributes[];
|
|
166
|
+
};
|
|
167
|
+
export type TopBid = {
|
|
168
|
+
id?: string;
|
|
169
|
+
price?: Price;
|
|
170
|
+
source?: {
|
|
171
|
+
id?: string;
|
|
172
|
+
domain?: string;
|
|
173
|
+
name?: string;
|
|
174
|
+
icon?: string;
|
|
175
|
+
url?: string;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export type LastSale = {
|
|
179
|
+
saleId?: string;
|
|
180
|
+
token?: {
|
|
181
|
+
contract?: string;
|
|
182
|
+
tokenId?: string;
|
|
183
|
+
name?: string;
|
|
184
|
+
image?: string;
|
|
185
|
+
collection?: {
|
|
186
|
+
id?: string;
|
|
187
|
+
name?: string;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
orderSource?: string;
|
|
191
|
+
orderSide?: 'ask' | 'bid';
|
|
192
|
+
orderKind?: string;
|
|
193
|
+
orderId?: string;
|
|
194
|
+
from?: string;
|
|
195
|
+
to?: string;
|
|
196
|
+
amount?: string;
|
|
197
|
+
fillSource?: string;
|
|
198
|
+
block?: number;
|
|
199
|
+
txHash?: string;
|
|
200
|
+
logIndex?: number;
|
|
201
|
+
batchIndex?: number;
|
|
202
|
+
timestamp?: number;
|
|
203
|
+
price?: Price;
|
|
204
|
+
washTradingScore?: number;
|
|
205
|
+
royaltyFeeBps?: number;
|
|
206
|
+
marketplaceFeeBps?: number;
|
|
207
|
+
paidFullRoyalty?: boolean;
|
|
208
|
+
feeBreakdown?: FeeBreakdown[];
|
|
209
|
+
isDeleted?: boolean;
|
|
210
|
+
createdAt?: string;
|
|
211
|
+
updatedAt?: string;
|
|
212
|
+
};
|
|
213
|
+
export type FeeBreakdown = {
|
|
214
|
+
kind?: string;
|
|
215
|
+
bps?: number;
|
|
216
|
+
recipient?: string;
|
|
217
|
+
source?: string;
|
|
218
|
+
rawAmount?: string;
|
|
219
|
+
};
|
|
220
|
+
export type Attributes = {
|
|
221
|
+
key?: string;
|
|
222
|
+
kind?: string;
|
|
223
|
+
value: string;
|
|
224
|
+
tokenCount?: number;
|
|
225
|
+
onSaleCount?: number;
|
|
226
|
+
floorAskPrice?: Price | null;
|
|
227
|
+
topBidValue?: number | null;
|
|
228
|
+
createdAt?: string;
|
|
229
|
+
};
|
|
230
|
+
export type GetCollectionsResponse = {
|
|
231
|
+
collections: CollectionResponse[];
|
|
232
|
+
};
|
|
233
|
+
export type CollectionResponse = {
|
|
234
|
+
id?: string;
|
|
235
|
+
openseaVerificationStatus?: string;
|
|
236
|
+
contractDeployedAt?: string;
|
|
237
|
+
creator?: string;
|
|
238
|
+
ownerCount?: string;
|
|
239
|
+
topBid?: TopBid & {
|
|
240
|
+
sourceDomain?: string;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
export type FloorAskCollection = {
|
|
244
|
+
id?: string;
|
|
245
|
+
price?: Price;
|
|
246
|
+
maker?: string;
|
|
247
|
+
kind?: string;
|
|
248
|
+
validFrom?: number;
|
|
249
|
+
validUntil?: number;
|
|
250
|
+
source?: SourceCollection;
|
|
251
|
+
rawData?: Metadata;
|
|
252
|
+
isNativeOffChainCancellable?: boolean;
|
|
253
|
+
};
|
|
254
|
+
export type SourceCollection = {
|
|
255
|
+
id: string;
|
|
256
|
+
domain: string;
|
|
257
|
+
name: string;
|
|
258
|
+
icon: string;
|
|
259
|
+
url: string;
|
|
260
|
+
};
|
|
261
|
+
export type TokenCollection = {
|
|
262
|
+
id?: string;
|
|
263
|
+
name?: string;
|
|
264
|
+
slug?: string;
|
|
265
|
+
symbol?: string;
|
|
266
|
+
imageUrl?: string;
|
|
267
|
+
image?: string;
|
|
268
|
+
isSpam?: boolean;
|
|
269
|
+
isNsfw?: boolean;
|
|
270
|
+
creator?: string;
|
|
271
|
+
tokenCount?: string;
|
|
272
|
+
metadataDisabled?: boolean;
|
|
273
|
+
openseaVerificationStatus?: string;
|
|
274
|
+
floorAskPrice?: Price;
|
|
275
|
+
royaltiesBps?: number;
|
|
276
|
+
royalties?: Royalties[];
|
|
277
|
+
floorAsk?: FloorAskCollection;
|
|
278
|
+
};
|
|
279
|
+
export type Collection = TokenCollection & CollectionResponse;
|
|
280
|
+
export type Royalties = {
|
|
281
|
+
bps?: number;
|
|
282
|
+
recipient?: string;
|
|
283
|
+
};
|
|
284
|
+
export type Ownership = {
|
|
285
|
+
tokenCount?: string;
|
|
286
|
+
onSaleCount?: string;
|
|
287
|
+
floorAsk?: FloorAsk;
|
|
288
|
+
acquiredAt?: string;
|
|
289
|
+
};
|
|
290
|
+
export type FloorAsk = {
|
|
291
|
+
id?: string;
|
|
292
|
+
price?: Price;
|
|
293
|
+
maker?: string;
|
|
294
|
+
kind?: string;
|
|
295
|
+
validFrom?: number;
|
|
296
|
+
validUntil?: number;
|
|
297
|
+
source?: Source;
|
|
298
|
+
rawData?: Metadata;
|
|
299
|
+
isNativeOffChainCancellable?: boolean;
|
|
300
|
+
};
|
|
301
|
+
export type Price = {
|
|
302
|
+
currency?: {
|
|
303
|
+
contract?: string;
|
|
304
|
+
name?: string;
|
|
305
|
+
symbol?: string;
|
|
306
|
+
decimals?: number;
|
|
307
|
+
chainId?: number;
|
|
308
|
+
};
|
|
309
|
+
amount?: {
|
|
310
|
+
raw?: string;
|
|
311
|
+
decimal?: number;
|
|
312
|
+
usd?: number;
|
|
313
|
+
native?: number;
|
|
314
|
+
};
|
|
315
|
+
netAmount?: {
|
|
316
|
+
raw?: string;
|
|
317
|
+
decimal?: number;
|
|
318
|
+
usd?: number;
|
|
319
|
+
native?: number;
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
export type Metadata = {
|
|
323
|
+
imageOriginal?: string;
|
|
324
|
+
tokenURI?: string;
|
|
325
|
+
};
|
|
326
|
+
export declare const MAX_GET_COLLECTION_BATCH_SIZE = 20;
|
|
327
|
+
/**
|
|
328
|
+
* Controller that passively detects nfts for a user address
|
|
329
|
+
*/
|
|
330
|
+
export declare class NftDetectionController extends BaseController<typeof controllerName, NFTDetectionControllerState, NftDetectionControllerMessenger> {
|
|
331
|
+
#private;
|
|
332
|
+
/**
|
|
333
|
+
* The controller options
|
|
334
|
+
*
|
|
335
|
+
* @param options - The controller options.
|
|
336
|
+
* @param options.messenger - A reference to the messaging system.
|
|
337
|
+
* @param options.disabled - Represents previous value of useNftDetection. Used to detect changes of useNftDetection. Default value is true.
|
|
338
|
+
* @param options.addNft - Add an NFT.
|
|
339
|
+
* @param options.getNftState - Gets the current state of the Assets controller.
|
|
340
|
+
*/
|
|
341
|
+
constructor({ messenger, disabled, addNft, getNftState, }: {
|
|
342
|
+
messenger: NftDetectionControllerMessenger;
|
|
343
|
+
disabled: boolean;
|
|
344
|
+
addNft: NftController['addNft'];
|
|
345
|
+
getNftState: () => NftControllerState;
|
|
346
|
+
});
|
|
347
|
+
/**
|
|
348
|
+
* Checks whether network is mainnet or not.
|
|
349
|
+
*
|
|
350
|
+
* @returns Whether current network is mainnet.
|
|
351
|
+
*/
|
|
352
|
+
isMainnet(): boolean;
|
|
353
|
+
isMainnetByNetworkClientId(networkClient: NetworkClient): boolean;
|
|
354
|
+
/**
|
|
355
|
+
* Triggers asset ERC721 token auto detection on mainnet. Any newly detected NFTs are
|
|
356
|
+
* added.
|
|
357
|
+
*
|
|
358
|
+
* @param options - Options bag.
|
|
359
|
+
* @param options.networkClientId - The network client ID to detect NFTs on.
|
|
360
|
+
* @param options.userAddress - The address to detect NFTs for.
|
|
361
|
+
*/
|
|
362
|
+
detectNfts(options?: {
|
|
363
|
+
networkClientId?: NetworkClientId;
|
|
364
|
+
userAddress?: string;
|
|
365
|
+
}): Promise<void>;
|
|
366
|
+
}
|
|
367
|
+
export default NftDetectionController;
|
|
368
|
+
//# sourceMappingURL=NftDetectionController.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NftDetectionController.d.mts","sourceRoot":"","sources":["../src/NftDetectionController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0CAA0C,EAAE,sCAAsC;AAChG,OAAO,KAAK,EAAE,kBAAkB,EAAE,sCAAsC;AACxE,OAAO,KAAK,EAAE,6BAA6B,EAAE,kCAAkC;AAC/E,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAW3D,OAAO,KAAK,EACV,eAAe,E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1,233 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./chunk-C7LNCQXM.mjs";
|
|
7
|
-
import "./chunk-CP3HC7AQ.mjs";
|
|
8
|
-
import "./chunk-BZEAPSD5.mjs";
|
|
9
|
-
import "./chunk-XUI43LEZ.mjs";
|
|
10
|
-
export {
|
|
11
|
-
BlockaidResultType,
|
|
12
|
-
MAX_GET_COLLECTION_BATCH_SIZE,
|
|
13
|
-
NftDetectionController,
|
|
14
|
-
NftDetectionController_default as default
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
6
|
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _NftDetectionController_instances, _NftDetectionController_disabled, _NftDetectionController_addNft, _NftDetectionController_getNftState, _NftDetectionController_inProcessNftFetchingUpdates, _NftDetectionController_onPreferencesControllerStateChange, _NftDetectionController_getOwnerNftApi, _NftDetectionController_getOwnerNfts;
|
|
13
|
+
import { BaseController } from "@metamask/base-controller";
|
|
14
|
+
import { toChecksumHexAddress, ChainId, NFT_API_BASE_URL, NFT_API_VERSION, convertHexToDecimal, handleFetch, fetchWithErrorHandling, NFT_API_TIMEOUT } from "@metamask/controller-utils";
|
|
15
|
+
import { createDeferredPromise } from "@metamask/utils";
|
|
16
|
+
import { reduceInBatchesSerially } from "./assetsUtil.mjs";
|
|
17
|
+
import { Source } from "./constants.mjs";
|
|
18
|
+
const controllerName = 'NftDetectionController';
|
|
19
|
+
const supportedNftDetectionNetworks = [
|
|
20
|
+
ChainId.mainnet,
|
|
21
|
+
ChainId['linea-mainnet'],
|
|
22
|
+
];
|
|
23
|
+
export var BlockaidResultType;
|
|
24
|
+
(function (BlockaidResultType) {
|
|
25
|
+
BlockaidResultType["Benign"] = "Benign";
|
|
26
|
+
BlockaidResultType["Spam"] = "Spam";
|
|
27
|
+
BlockaidResultType["Warning"] = "Warning";
|
|
28
|
+
BlockaidResultType["Malicious"] = "Malicious";
|
|
29
|
+
})(BlockaidResultType || (BlockaidResultType = {}));
|
|
30
|
+
export const MAX_GET_COLLECTION_BATCH_SIZE = 20;
|
|
31
|
+
/**
|
|
32
|
+
* Controller that passively detects nfts for a user address
|
|
33
|
+
*/
|
|
34
|
+
export class NftDetectionController extends BaseController {
|
|
35
|
+
/**
|
|
36
|
+
* The controller options
|
|
37
|
+
*
|
|
38
|
+
* @param options - The controller options.
|
|
39
|
+
* @param options.messenger - A reference to the messaging system.
|
|
40
|
+
* @param options.disabled - Represents previous value of useNftDetection. Used to detect changes of useNftDetection. Default value is true.
|
|
41
|
+
* @param options.addNft - Add an NFT.
|
|
42
|
+
* @param options.getNftState - Gets the current state of the Assets controller.
|
|
43
|
+
*/
|
|
44
|
+
constructor({ messenger, disabled = false, addNft, getNftState, }) {
|
|
45
|
+
super({
|
|
46
|
+
name: controllerName,
|
|
47
|
+
messenger,
|
|
48
|
+
metadata: {},
|
|
49
|
+
state: {},
|
|
50
|
+
});
|
|
51
|
+
_NftDetectionController_instances.add(this);
|
|
52
|
+
_NftDetectionController_disabled.set(this, void 0);
|
|
53
|
+
_NftDetectionController_addNft.set(this, void 0);
|
|
54
|
+
_NftDetectionController_getNftState.set(this, void 0);
|
|
55
|
+
_NftDetectionController_inProcessNftFetchingUpdates.set(this, void 0);
|
|
56
|
+
__classPrivateFieldSet(this, _NftDetectionController_disabled, disabled, "f");
|
|
57
|
+
__classPrivateFieldSet(this, _NftDetectionController_inProcessNftFetchingUpdates, {}, "f");
|
|
58
|
+
__classPrivateFieldSet(this, _NftDetectionController_getNftState, getNftState, "f");
|
|
59
|
+
__classPrivateFieldSet(this, _NftDetectionController_addNft, addNft, "f");
|
|
60
|
+
this.messagingSystem.subscribe('PreferencesController:stateChange', __classPrivateFieldGet(this, _NftDetectionController_instances, "m", _NftDetectionController_onPreferencesControllerStateChange).bind(this));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Checks whether network is mainnet or not.
|
|
64
|
+
*
|
|
65
|
+
* @returns Whether current network is mainnet.
|
|
66
|
+
*/
|
|
67
|
+
isMainnet() {
|
|
68
|
+
const { selectedNetworkClientId } = this.messagingSystem.call('NetworkController:getState');
|
|
69
|
+
const { configuration: { chainId }, } = this.messagingSystem.call('NetworkController:getNetworkClientById', selectedNetworkClientId);
|
|
70
|
+
return chainId === ChainId.mainnet;
|
|
71
|
+
}
|
|
72
|
+
isMainnetByNetworkClientId(networkClient) {
|
|
73
|
+
return networkClient.configuration.chainId === ChainId.mainnet;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Triggers asset ERC721 token auto detection on mainnet. Any newly detected NFTs are
|
|
77
|
+
* added.
|
|
78
|
+
*
|
|
79
|
+
* @param options - Options bag.
|
|
80
|
+
* @param options.networkClientId - The network client ID to detect NFTs on.
|
|
81
|
+
* @param options.userAddress - The address to detect NFTs for.
|
|
82
|
+
*/
|
|
83
|
+
async detectNfts(options) {
|
|
84
|
+
const userAddress = options?.userAddress ??
|
|
85
|
+
this.messagingSystem.call('AccountsController:getSelectedAccount')
|
|
86
|
+
.address;
|
|
87
|
+
const { selectedNetworkClientId } = this.messagingSystem.call('NetworkController:getState');
|
|
88
|
+
const { configuration: { chainId }, } = this.messagingSystem.call('NetworkController:getNetworkClientById', selectedNetworkClientId);
|
|
89
|
+
/* istanbul ignore if */
|
|
90
|
+
if (!supportedNftDetectionNetworks.includes(chainId) || __classPrivateFieldGet(this, _NftDetectionController_disabled, "f")) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
/* istanbul ignore else */
|
|
94
|
+
if (!userAddress) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
98
|
+
const updateKey = `${chainId}:${userAddress}`;
|
|
99
|
+
if (updateKey in __classPrivateFieldGet(this, _NftDetectionController_inProcessNftFetchingUpdates, "f")) {
|
|
100
|
+
// This prevents redundant updates
|
|
101
|
+
// This promise is resolved after the in-progress update has finished,
|
|
102
|
+
// and state has been updated.
|
|
103
|
+
await __classPrivateFieldGet(this, _NftDetectionController_inProcessNftFetchingUpdates, "f")[updateKey];
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const { promise: inProgressUpdate, resolve: updateSucceeded, reject: updateFailed, } = createDeferredPromise({ suppressUnhandledRejection: true });
|
|
107
|
+
__classPrivateFieldGet(this, _NftDetectionController_inProcessNftFetchingUpdates, "f")[updateKey] = inProgressUpdate;
|
|
108
|
+
let next;
|
|
109
|
+
let apiNfts = [];
|
|
110
|
+
let resultNftApi;
|
|
111
|
+
try {
|
|
112
|
+
do {
|
|
113
|
+
resultNftApi = await __classPrivateFieldGet(this, _NftDetectionController_instances, "m", _NftDetectionController_getOwnerNfts).call(this, userAddress, chainId, next);
|
|
114
|
+
apiNfts = resultNftApi.tokens.filter((elm) => elm.token.isSpam === false &&
|
|
115
|
+
(elm.blockaidResult?.result_type
|
|
116
|
+
? elm.blockaidResult?.result_type === BlockaidResultType.Benign
|
|
117
|
+
: true));
|
|
118
|
+
// Retrieve collections from apiNfts
|
|
119
|
+
// contract and collection.id are equal for simple contract addresses; this is to exclude cases for shared contracts
|
|
120
|
+
const collections = apiNfts.reduce((acc, currValue) => {
|
|
121
|
+
if (!acc.includes(currValue.token.contract) &&
|
|
122
|
+
currValue.token.contract === currValue?.token?.collection?.id) {
|
|
123
|
+
acc.push(currValue.token.contract);
|
|
124
|
+
}
|
|
125
|
+
return acc;
|
|
126
|
+
}, []);
|
|
127
|
+
if (collections.length !== 0) {
|
|
128
|
+
// Call API to retrive collections infos
|
|
129
|
+
// The api accept a max of 20 contracts
|
|
130
|
+
const collectionResponse = await reduceInBatchesSerially({
|
|
131
|
+
values: collections,
|
|
132
|
+
batchSize: MAX_GET_COLLECTION_BATCH_SIZE,
|
|
133
|
+
eachBatch: async (allResponses, batch) => {
|
|
134
|
+
const params = new URLSearchParams(batch.map((s) => ['contract', s]));
|
|
135
|
+
params.append('chainId', '1'); // Adding chainId 1 because we are only detecting for mainnet
|
|
136
|
+
const collectionResponseForBatch = await fetchWithErrorHandling({
|
|
137
|
+
url: `${NFT_API_BASE_URL}/collections?${params.toString()}`,
|
|
138
|
+
options: {
|
|
139
|
+
headers: {
|
|
140
|
+
Version: NFT_API_VERSION,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
timeout: NFT_API_TIMEOUT,
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
...allResponses,
|
|
147
|
+
...collectionResponseForBatch,
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
initialResult: {},
|
|
151
|
+
});
|
|
152
|
+
// Add collections response fields to newnfts
|
|
153
|
+
if (collectionResponse.collections?.length) {
|
|
154
|
+
apiNfts.forEach((singleNFT) => {
|
|
155
|
+
const found = collectionResponse.collections.find((elm) => elm.id?.toLowerCase() ===
|
|
156
|
+
singleNFT.token.contract.toLowerCase());
|
|
157
|
+
if (found) {
|
|
158
|
+
singleNFT.token = {
|
|
159
|
+
...singleNFT.token,
|
|
160
|
+
collection: {
|
|
161
|
+
...(singleNFT.token.collection ?? {}),
|
|
162
|
+
creator: found?.creator,
|
|
163
|
+
openseaVerificationStatus: found?.openseaVerificationStatus,
|
|
164
|
+
contractDeployedAt: found.contractDeployedAt,
|
|
165
|
+
ownerCount: found.ownerCount,
|
|
166
|
+
topBid: found.topBid,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Proceed to add NFTs
|
|
174
|
+
const addNftPromises = apiNfts.map(async (nft) => {
|
|
175
|
+
const { tokenId, contract, kind, image: imageUrl, imageSmall: imageThumbnailUrl, metadata: { imageOriginal: imageOriginalUrl } = {}, name, description, attributes, topBid, lastSale, rarityRank, rarityScore, collection, } = nft.token;
|
|
176
|
+
let ignored;
|
|
177
|
+
/* istanbul ignore else */
|
|
178
|
+
const { ignoredNfts } = __classPrivateFieldGet(this, _NftDetectionController_getNftState, "f").call(this);
|
|
179
|
+
if (ignoredNfts.length) {
|
|
180
|
+
ignored = ignoredNfts.find((c) => {
|
|
181
|
+
/* istanbul ignore next */
|
|
182
|
+
return (c.address === toChecksumHexAddress(contract) &&
|
|
183
|
+
c.tokenId === tokenId);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/* istanbul ignore else */
|
|
187
|
+
if (!ignored) {
|
|
188
|
+
/* istanbul ignore next */
|
|
189
|
+
const nftMetadata = Object.assign({}, { name }, description && { description }, imageUrl && { image: imageUrl }, imageThumbnailUrl && { imageThumbnail: imageThumbnailUrl }, imageOriginalUrl && { imageOriginal: imageOriginalUrl }, kind && { standard: kind.toUpperCase() }, lastSale && { lastSale }, attributes && { attributes }, topBid && { topBid }, rarityRank && { rarityRank }, rarityScore && { rarityScore }, collection && { collection });
|
|
190
|
+
await __classPrivateFieldGet(this, _NftDetectionController_addNft, "f").call(this, contract, tokenId, {
|
|
191
|
+
nftMetadata,
|
|
192
|
+
userAddress,
|
|
193
|
+
source: Source.Detected,
|
|
194
|
+
networkClientId: options?.networkClientId,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
await Promise.all(addNftPromises);
|
|
199
|
+
} while ((next = resultNftApi.continuation));
|
|
200
|
+
updateSucceeded();
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
updateFailed(error);
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
delete __classPrivateFieldGet(this, _NftDetectionController_inProcessNftFetchingUpdates, "f")[updateKey];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
_NftDetectionController_disabled = new WeakMap(), _NftDetectionController_addNft = new WeakMap(), _NftDetectionController_getNftState = new WeakMap(), _NftDetectionController_inProcessNftFetchingUpdates = new WeakMap(), _NftDetectionController_instances = new WeakSet(), _NftDetectionController_onPreferencesControllerStateChange = function _NftDetectionController_onPreferencesControllerStateChange({ useNftDetection }) {
|
|
212
|
+
if (!useNftDetection !== __classPrivateFieldGet(this, _NftDetectionController_disabled, "f")) {
|
|
213
|
+
__classPrivateFieldSet(this, _NftDetectionController_disabled, !useNftDetection, "f");
|
|
214
|
+
}
|
|
215
|
+
}, _NftDetectionController_getOwnerNftApi = function _NftDetectionController_getOwnerNftApi({ chainId, address, next, }) {
|
|
216
|
+
return `${NFT_API_BASE_URL}/users/${address}/tokens?chainIds=${chainId}&limit=50&includeTopBid=true&continuation=${next ?? ''}`;
|
|
217
|
+
}, _NftDetectionController_getOwnerNfts = async function _NftDetectionController_getOwnerNfts(address, chainId, cursor) {
|
|
218
|
+
// Convert hex chainId to number
|
|
219
|
+
const convertedChainId = convertHexToDecimal(chainId).toString();
|
|
220
|
+
const url = __classPrivateFieldGet(this, _NftDetectionController_instances, "m", _NftDetectionController_getOwnerNftApi).call(this, {
|
|
221
|
+
chainId: convertedChainId,
|
|
222
|
+
address,
|
|
223
|
+
next: cursor,
|
|
224
|
+
});
|
|
225
|
+
const nftApiResponse = await handleFetch(url, {
|
|
226
|
+
headers: {
|
|
227
|
+
Version: NFT_API_VERSION,
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
return nftApiResponse;
|
|
231
|
+
};
|
|
232
|
+
export default NftDetectionController;
|
|
16
233
|
//# sourceMappingURL=NftDetectionController.mjs.map
|