@metamask/assets-controllers 27.2.0 → 28.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/dist/AssetsContractController.js +6 -6
- package/dist/AssetsContractController.mjs +5 -5
- package/dist/CurrencyRateController.js +3 -3
- package/dist/CurrencyRateController.mjs +2 -2
- package/dist/NftController.js +3 -5
- package/dist/NftController.mjs +2 -4
- package/dist/NftDetectionController.js +4 -4
- package/dist/NftDetectionController.mjs +3 -3
- package/dist/Standards/ERC20Standard.js +3 -3
- package/dist/Standards/ERC20Standard.mjs +2 -2
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js +3 -3
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.mjs +2 -2
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.js +3 -3
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.mjs +2 -2
- package/dist/TokenDetectionController.js +3 -3
- package/dist/TokenDetectionController.mjs +2 -2
- package/dist/TokenListController.js +4 -4
- package/dist/TokenListController.mjs +3 -3
- package/dist/TokenRatesController.js +4 -4
- package/dist/TokenRatesController.mjs +3 -3
- package/dist/TokensController.js +6 -6
- package/dist/TokensController.mjs +5 -5
- package/dist/assetsUtil.js +2 -8
- package/dist/assetsUtil.mjs +1 -7
- package/dist/{chunk-IFJWX5RY.mjs → chunk-4PAJC7WC.mjs} +93 -132
- package/dist/chunk-4PAJC7WC.mjs.map +1 -0
- package/dist/{chunk-WIVSZVF4.mjs → chunk-AC5HGIHS.mjs} +3 -3
- package/dist/chunk-AC5HGIHS.mjs.map +1 -0
- package/dist/{chunk-355MWUUQ.js → chunk-BM7EPTR6.js} +3 -3
- package/dist/{chunk-4YU7CT4O.js → chunk-C4JDCQG2.js} +7 -7
- package/dist/{chunk-ZKJSG4TA.mjs → chunk-CNICDMRI.mjs} +4 -4
- package/dist/chunk-CNICDMRI.mjs.map +1 -0
- package/dist/{chunk-VY7TUOK2.js → chunk-D3N35ABH.js} +3 -3
- package/dist/{chunk-RELRWIJN.js → chunk-D6BDJYSK.js} +2 -68
- package/dist/chunk-D6BDJYSK.js.map +1 -0
- package/dist/{chunk-C4PQK53K.js → chunk-DYH5P3VY.js} +5 -2
- package/dist/chunk-DYH5P3VY.js.map +1 -0
- package/dist/{chunk-NUBQRDKI.js → chunk-E2SLNUD4.js} +11 -11
- package/dist/{chunk-VHCPQS4X.js → chunk-GCWWC4X3.js} +5 -5
- package/dist/{chunk-KRTEFV4Q.mjs → chunk-IURNPMBB.mjs} +2 -2
- package/dist/{chunk-WSOHBBCO.js → chunk-JEGLHDNA.js} +42 -56
- package/dist/chunk-JEGLHDNA.js.map +1 -0
- package/dist/{chunk-GLZ66IRX.mjs → chunk-KDMDWUVX.mjs} +41 -55
- package/dist/chunk-KDMDWUVX.mjs.map +1 -0
- package/dist/{chunk-MQ7TIWBK.mjs → chunk-KS4MOA2T.mjs} +2 -2
- package/dist/{chunk-H6TOSWUM.js → chunk-LRKDZWS6.js} +3 -3
- package/dist/{chunk-CEENXWOB.mjs → chunk-N5H5KDJZ.mjs} +2 -2
- package/dist/{chunk-2IZUMKMY.mjs → chunk-NHX4QGOD.mjs} +3 -3
- package/dist/{chunk-TCO22VIO.mjs → chunk-PWZE6KJV.mjs} +5 -2
- package/dist/chunk-PWZE6KJV.mjs.map +1 -0
- package/dist/{chunk-KSGMD24G.js → chunk-Q6TLNHYC.js} +7 -7
- package/dist/{chunk-523YP4Z3.mjs → chunk-QQAG6ECS.mjs} +3 -3
- package/dist/{chunk-XEZJ5XMV.js → chunk-QVSSEGA5.js} +7 -7
- package/dist/chunk-QVSSEGA5.js.map +1 -0
- package/dist/{chunk-23F5W3A2.mjs → chunk-QWACHXRH.mjs} +2 -2
- package/dist/{chunk-KCUSDOIE.mjs → chunk-RDWXY4OF.mjs} +4 -4
- package/dist/{chunk-PD624ZNK.js → chunk-RUPB4ELK.js} +6 -6
- package/dist/{chunk-6NO7Z5DL.js → chunk-TGKUZNML.js} +5 -5
- package/dist/chunk-TGKUZNML.js.map +1 -0
- package/dist/{chunk-AQIXUBTK.js → chunk-UNKIHWZH.js} +93 -132
- package/dist/chunk-UNKIHWZH.js.map +1 -0
- package/dist/{chunk-76KGJJJV.mjs → chunk-ZM42FNAQ.mjs} +5 -5
- package/dist/{chunk-E5PIGGYR.mjs → chunk-ZPAX2HLQ.mjs} +1 -67
- package/dist/chunk-ZPAX2HLQ.mjs.map +1 -0
- package/dist/crypto-compare.js +2 -2
- package/dist/crypto-compare.mjs +1 -1
- package/dist/index.js +15 -15
- package/dist/index.mjs +18 -18
- package/dist/token-service.js +3 -3
- package/dist/token-service.mjs +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/CurrencyRateController.d.ts +7 -7
- package/dist/types/CurrencyRateController.d.ts.map +1 -1
- package/dist/types/NftController.d.ts +20 -95
- package/dist/types/NftController.d.ts.map +1 -1
- package/dist/types/NftDetectionController.d.ts +184 -0
- package/dist/types/NftDetectionController.d.ts.map +1 -1
- package/dist/types/Standards/NftStandards/ERC721/ERC721Standard.d.ts.map +1 -1
- package/dist/types/TokenBalancesController.d.ts +10 -10
- package/dist/types/TokenBalancesController.d.ts.map +1 -1
- package/dist/types/TokenDetectionController.d.ts +9 -9
- package/dist/types/TokenDetectionController.d.ts.map +1 -1
- package/dist/types/TokenListController.d.ts +12 -12
- package/dist/types/TokenListController.d.ts.map +1 -1
- package/dist/types/TokensController.d.ts +10 -10
- package/dist/types/TokensController.d.ts.map +1 -1
- package/dist/types/assetsUtil.d.ts +1 -21
- package/dist/types/assetsUtil.d.ts.map +1 -1
- package/dist/types/crypto-compare.d.ts.map +1 -1
- package/dist/types/token-prices-service/abstract-token-prices-service.d.ts +3 -3
- package/dist/types/token-prices-service/abstract-token-prices-service.d.ts.map +1 -1
- package/dist/types/token-prices-service/codefi-v2.d.ts +2 -2
- package/dist/types/token-prices-service/codefi-v2.d.ts.map +1 -1
- package/package.json +12 -12
- package/dist/chunk-6NO7Z5DL.js.map +0 -1
- package/dist/chunk-AQIXUBTK.js.map +0 -1
- package/dist/chunk-C4PQK53K.js.map +0 -1
- package/dist/chunk-E5PIGGYR.mjs.map +0 -1
- package/dist/chunk-GLZ66IRX.mjs.map +0 -1
- package/dist/chunk-IFJWX5RY.mjs.map +0 -1
- package/dist/chunk-RELRWIJN.js.map +0 -1
- package/dist/chunk-TCO22VIO.mjs.map +0 -1
- package/dist/chunk-WIVSZVF4.mjs.map +0 -1
- package/dist/chunk-WSOHBBCO.js.map +0 -1
- package/dist/chunk-XEZJ5XMV.js.map +0 -1
- package/dist/chunk-ZKJSG4TA.mjs.map +0 -1
- /package/dist/{chunk-355MWUUQ.js.map → chunk-BM7EPTR6.js.map} +0 -0
- /package/dist/{chunk-4YU7CT4O.js.map → chunk-C4JDCQG2.js.map} +0 -0
- /package/dist/{chunk-VY7TUOK2.js.map → chunk-D3N35ABH.js.map} +0 -0
- /package/dist/{chunk-NUBQRDKI.js.map → chunk-E2SLNUD4.js.map} +0 -0
- /package/dist/{chunk-VHCPQS4X.js.map → chunk-GCWWC4X3.js.map} +0 -0
- /package/dist/{chunk-KRTEFV4Q.mjs.map → chunk-IURNPMBB.mjs.map} +0 -0
- /package/dist/{chunk-MQ7TIWBK.mjs.map → chunk-KS4MOA2T.mjs.map} +0 -0
- /package/dist/{chunk-H6TOSWUM.js.map → chunk-LRKDZWS6.js.map} +0 -0
- /package/dist/{chunk-CEENXWOB.mjs.map → chunk-N5H5KDJZ.mjs.map} +0 -0
- /package/dist/{chunk-2IZUMKMY.mjs.map → chunk-NHX4QGOD.mjs.map} +0 -0
- /package/dist/{chunk-KSGMD24G.js.map → chunk-Q6TLNHYC.js.map} +0 -0
- /package/dist/{chunk-523YP4Z3.mjs.map → chunk-QQAG6ECS.mjs.map} +0 -0
- /package/dist/{chunk-23F5W3A2.mjs.map → chunk-QWACHXRH.mjs.map} +0 -0
- /package/dist/{chunk-KCUSDOIE.mjs.map → chunk-RDWXY4OF.mjs.map} +0 -0
- /package/dist/{chunk-PD624ZNK.js.map → chunk-RUPB4ELK.js.map} +0 -0
- /package/dist/{chunk-76KGJJJV.mjs.map → chunk-ZM42FNAQ.mjs.map} +0 -0
|
@@ -3,7 +3,7 @@ import type { NetworkClientId, NetworkControllerStateChangeEvent, NetworkState,
|
|
|
3
3
|
import { StaticIntervalPollingController } from '@metamask/polling-controller';
|
|
4
4
|
import type { Hex } from '@metamask/utils';
|
|
5
5
|
declare const name = "TokenListController";
|
|
6
|
-
export
|
|
6
|
+
export type TokenListToken = {
|
|
7
7
|
name: string;
|
|
8
8
|
symbol: string;
|
|
9
9
|
decimals: number;
|
|
@@ -12,26 +12,26 @@ export declare type TokenListToken = {
|
|
|
12
12
|
aggregators: string[];
|
|
13
13
|
iconUrl: string;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
|
|
15
|
+
export type TokenListMap = Record<string, TokenListToken>;
|
|
16
|
+
type DataCache = {
|
|
17
17
|
timestamp: number;
|
|
18
18
|
data: TokenListMap;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type TokensChainsCache = {
|
|
21
21
|
[chainId: Hex]: DataCache;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type TokenListState = {
|
|
24
24
|
tokenList: TokenListMap;
|
|
25
25
|
tokensChainsCache: TokensChainsCache;
|
|
26
26
|
preventPollingOnNetworkRestart: boolean;
|
|
27
27
|
};
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export
|
|
28
|
+
export type TokenListStateChange = ControllerStateChangeEvent<typeof name, TokenListState>;
|
|
29
|
+
export type TokenListControllerEvents = TokenListStateChange;
|
|
30
|
+
export type GetTokenListState = ControllerGetStateAction<typeof name, TokenListState>;
|
|
31
|
+
export type TokenListControllerActions = GetTokenListState;
|
|
32
|
+
type AllowedActions = NetworkControllerGetNetworkClientByIdAction;
|
|
33
|
+
type AllowedEvents = NetworkControllerStateChangeEvent;
|
|
34
|
+
export type TokenListControllerMessenger = RestrictedControllerMessenger<typeof name, TokenListControllerActions | AllowedActions, TokenListControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
35
35
|
export declare const getDefaultTokenListState: () => TokenListState;
|
|
36
36
|
/**
|
|
37
37
|
* Controller that passively polls on a set interval for the list of tokens from metaswaps api
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenListController.d.ts","sourceRoot":"","sources":["../../src/TokenListController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EACV,eAAe,EACf,iCAAiC,EACjC,YAAY,EACZ,2CAA2C,EAC5C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAa3C,QAAA,MAAM,IAAI,wBAAwB,CAAC;AAEnC,
|
|
1
|
+
{"version":3,"file":"TokenListController.d.ts","sourceRoot":"","sources":["../../src/TokenListController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EACV,eAAe,EACf,iCAAiC,EACjC,YAAY,EACZ,2CAA2C,EAC5C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAa3C,QAAA,MAAM,IAAI,wBAAwB,CAAC;AAEnC,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CA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|
* @property asset - Asset suggested object
|
|
33
33
|
* @property interactingAddress - Account address that requested watch asset
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
type SuggestedAssetMeta = {
|
|
36
36
|
id: string;
|
|
37
37
|
time: number;
|
|
38
38
|
type: string;
|
|
@@ -50,7 +50,7 @@ declare type SuggestedAssetMeta = {
|
|
|
50
50
|
* @property allIgnoredTokens - Object containing hidden/ignored tokens by network and account
|
|
51
51
|
* @property allDetectedTokens - Object containing tokens detected with non-zero balances
|
|
52
52
|
*/
|
|
53
|
-
export
|
|
53
|
+
export type TokensState = {
|
|
54
54
|
tokens: Token[];
|
|
55
55
|
ignoredTokens: string[];
|
|
56
56
|
detectedTokens: Token[];
|
|
@@ -74,29 +74,29 @@ export declare type TokensState = {
|
|
|
74
74
|
* The name of the {@link TokensController}.
|
|
75
75
|
*/
|
|
76
76
|
declare const controllerName = "TokensController";
|
|
77
|
-
export
|
|
78
|
-
export
|
|
77
|
+
export type TokensControllerActions = TokensControllerGetStateAction | TokensControllerAddDetectedTokensAction;
|
|
78
|
+
export type TokensControllerGetStateAction = {
|
|
79
79
|
type: `${typeof controllerName}:getState`;
|
|
80
80
|
handler: () => TokensState;
|
|
81
81
|
};
|
|
82
|
-
export
|
|
82
|
+
export type TokensControllerAddDetectedTokensAction = {
|
|
83
83
|
type: `${typeof controllerName}:addDetectedTokens`;
|
|
84
84
|
handler: TokensController['addDetectedTokens'];
|
|
85
85
|
};
|
|
86
86
|
/**
|
|
87
87
|
* The external actions available to the {@link TokensController}.
|
|
88
88
|
*/
|
|
89
|
-
export
|
|
90
|
-
export
|
|
89
|
+
export type AllowedActions = AddApprovalRequest | NetworkControllerGetNetworkClientByIdAction;
|
|
90
|
+
export type TokensControllerStateChangeEvent = {
|
|
91
91
|
type: `${typeof controllerName}:stateChange`;
|
|
92
92
|
payload: [TokensState, Patch[]];
|
|
93
93
|
};
|
|
94
|
-
export
|
|
95
|
-
export
|
|
94
|
+
export type TokensControllerEvents = TokensControllerStateChangeEvent;
|
|
95
|
+
export type AllowedEvents = NetworkControllerNetworkDidChangeEvent | PreferencesControllerStateChangeEvent | TokenListStateChange;
|
|
96
96
|
/**
|
|
97
97
|
* The messenger of the {@link TokensController}.
|
|
98
98
|
*/
|
|
99
|
-
export
|
|
99
|
+
export type TokensControllerMessenger = RestrictedControllerMessenger<typeof controllerName, TokensControllerActions | AllowedActions, TokensControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
100
100
|
export declare const getDefaultTokensState: () => TokensState;
|
|
101
101
|
/**
|
|
102
102
|
* Controller that stores assets and exposes convenience methods
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokensController.d.ts","sourceRoot":"","sources":["../../src/TokensController.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAc7D,OAAO,KAAK,EACV,eAAe,EACf,2CAA2C,EAC3C,sCAAsC,EACtC,QAAQ,EACT,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,kCAAkC,CAAC;AAE9F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAU9C,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;;;;G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,EAAE;QAC5B,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;QACpB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5B,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC;QAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,GAAG,CAAC;KAC1B;;;;;;;;;;;;;;;;;IAyED;;OAEG;IACH,kBAAkB;IAIZ,gBAAgB,CAAC,kBAAkB,EAAE,kBAAkB;CAqB9D;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { BigNumber } from '@ethersproject/bignumber';
|
|
2
2
|
import type { Hex } from '@metamask/utils';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
|
-
import type { Nft, NftMetadata
|
|
5
|
-
import type { ApiNft, ApiNftContract } from './NftDetectionController';
|
|
4
|
+
import type { Nft, NftMetadata } from './NftController';
|
|
6
5
|
import type { AbstractTokenPricesService } from './token-prices-service';
|
|
7
6
|
import { type ContractExchangeRates } from './TokenRatesController';
|
|
8
7
|
/**
|
|
@@ -145,25 +144,6 @@ export declare function reduceInBatchesSerially<Value, Result extends Record<Pro
|
|
|
145
144
|
eachBatch: (workingResult: Partial<Result>, batch: Value[], index: number) => Partial<Result> | Promise<Partial<Result>>;
|
|
146
145
|
initialResult: Partial<Result>;
|
|
147
146
|
}): Promise<Result>;
|
|
148
|
-
/**
|
|
149
|
-
* Maps an OpenSea V2 NFT to the V1 schema.
|
|
150
|
-
* @param nft - The V2 NFT to map.
|
|
151
|
-
* @returns The NFT in the V1 schema.
|
|
152
|
-
*/
|
|
153
|
-
export declare function mapOpenSeaNftV2ToV1(nft: OpenSeaV2Nft): ApiNft;
|
|
154
|
-
/**
|
|
155
|
-
* Maps an OpenSea V2 detailed NFT to the V1 schema.
|
|
156
|
-
* @param nft - The V2 detailed NFT to map.
|
|
157
|
-
* @returns The NFT in the V1 schema.
|
|
158
|
-
*/
|
|
159
|
-
export declare function mapOpenSeaDetailedNftV2ToV1(nft: OpenSeaV2DetailedNft): ApiNft;
|
|
160
|
-
/**
|
|
161
|
-
* Maps an OpenSea V2 contract to the V1 schema.
|
|
162
|
-
* @param contract - The v2 contract data.
|
|
163
|
-
* @param collection - The v2 collection data.
|
|
164
|
-
* @returns The contract in the v1 schema.
|
|
165
|
-
*/
|
|
166
|
-
export declare function mapOpenSeaContractV2ToV1(contract: OpenSeaV2Contract, collection?: OpenSeaV2Collection): ApiNftContract;
|
|
167
147
|
/**
|
|
168
148
|
* Retrieves token prices for a set of contract addresses in a specific currency and chainId.
|
|
169
149
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetsUtil.d.ts","sourceRoot":"","sources":["../../src/assetsUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,MAAM,OAAO,CAAC;AAGvB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"assetsUtil.d.ts","sourceRoot":"","sources":["../../src/assetsUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,MAAM,OAAO,CAAC;AAGvB,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,WAAW,EAAE,G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CAAA;CAAE,GACnC,KAAK,EAAE,EAAE,CAMX;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EACL,MAAM,SAAS,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EAC3C,EACA,MAAM,EACN,SAAS,EACT,SAAS,EACT,aAAa,GACd,EAAE;IACD,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CACT,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,EAC9B,KAAK,EAAE,KAAK,EAAE,EACd,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlB;AAED;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,OAAO,GACR,EAAE;IACD,kBAAkB,EAAE,0BAA0B,CAAC;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,GAAG,EAAE,CAAC;IACtB,OAAO,EAAE,GAAG,CAAC;CACd,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAyCjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-compare.d.ts","sourceRoot":"","sources":["../../src/crypto-compare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto-compare.d.ts","sourceRoot":"","sources":["../../src/crypto-compare.ts"],"names":[],"mappings":"AAiCA;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,CAAC;IACT,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC,CAoCD"}
|
|
@@ -2,7 +2,7 @@ import type { Hex } from '@metamask/utils';
|
|
|
2
2
|
/**
|
|
3
3
|
* Represents the price of a token in a currency.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type TokenPrice<TokenAddress extends Hex, Currency extends string> = {
|
|
6
6
|
tokenAddress: TokenAddress;
|
|
7
7
|
value: number;
|
|
8
8
|
currency: Currency;
|
|
@@ -10,7 +10,7 @@ export declare type TokenPrice<TokenAddress extends Hex, Currency extends string
|
|
|
10
10
|
/**
|
|
11
11
|
* A map of token address to its price.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type TokenPricesByTokenAddress<TokenAddress extends Hex, Currency extends string> = {
|
|
14
14
|
[A in TokenAddress]: TokenPrice<A, Currency>;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
@@ -26,7 +26,7 @@ export declare type TokenPricesByTokenAddress<TokenAddress extends Hex, Currency
|
|
|
26
26
|
* @template Currency - A type union of valid arguments for the `currency`
|
|
27
27
|
* argument to `fetchTokenPrices`.
|
|
28
28
|
*/
|
|
29
|
-
export
|
|
29
|
+
export type AbstractTokenPricesService<ChainId extends Hex = Hex, TokenAddress extends Hex = Hex, Currency extends string = string> = {
|
|
30
30
|
/**
|
|
31
31
|
* Retrieves prices in the given currency for the tokens identified by the
|
|
32
32
|
* given addresses which are expected to live on the given chain.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-token-prices-service.d.ts","sourceRoot":"","sources":["../../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"abstract-token-prices-service.d.ts","sourceRoot":"","sources":["../../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,YAAY,SAAS,GAAG,EAAE,QAAQ,SAAS,MAAM,IAAI;IAC1E,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,CACnC,YAAY,SAAS,GAAG,EACxB,QAAQ,SAAS,MAAM,IACrB;KACD,CAAC,IAAI,YAAY,GAAG,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC;CAC7C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,GAAG,GAAG,GAAG,EACzB,YAAY,SAAS,GAAG,GAAG,GAAG,EAC9B,QAAQ,SAAS,MAAM,GAAG,MAAM,IAC9B;IACF;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EACf,OAAO,EACP,cAAc,EACd,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,OAAO,CAAC;QACjB,cAAc,EAAE,YAAY,EAAE,CAAC;QAC/B,QAAQ,EAAE,QAAQ,CAAC;KACpB,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC;IAE/D;;;;;;OAMG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC;CACpE,CAAC"}
|
|
@@ -9,7 +9,7 @@ export declare const SUPPORTED_CURRENCIES: readonly ["btc", "eth", "ltc", "bch",
|
|
|
9
9
|
* A currency that can be supplied as the `vsCurrency` parameter to
|
|
10
10
|
* the `/spot-prices` endpoint. Covers both uppercase and lowercase versions.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number] | Uppercase<(typeof SUPPORTED_CURRENCIES)[number]>;
|
|
13
13
|
/**
|
|
14
14
|
* The list of chain IDs that can be supplied in the URL for the `/spot-prices`
|
|
15
15
|
* endpoint, but in hexadecimal form (for consistency with how we represent
|
|
@@ -22,7 +22,7 @@ export declare const SUPPORTED_CHAIN_IDS: readonly ["0x1", "0xa", "0x19", "0x38"
|
|
|
22
22
|
* but in hexadecimal form (for consistency with how we represent chain IDs in
|
|
23
23
|
* other places).
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
type SupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
26
26
|
/**
|
|
27
27
|
* This version of the token prices service uses V2 of the Codefi Price API to
|
|
28
28
|
* fetch token prices.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codefi-v2.d.ts","sourceRoot":"","sources":["../../../src/token-prices-service/codefi-v2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAa3C,OAAO,KAAK,EACV,0BAA0B,EAE1B,yBAAyB,EAC1B,MAAM,iCAAiC,CAAC;AAUzC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,ybA2HvB,CAAC;AAEX;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"codefi-v2.d.ts","sourceRoot":"","sources":["../../../src/token-prices-service/codefi-v2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAa3C,OAAO,KAAK,EACV,0BAA0B,EAE1B,yBAAyB,EAC1B,MAAM,iCAAiC,CAAC;AAUzC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,ybA2HvB,CAAC;AAEX;;;GAGG;AACH,KAAK,iBAAiB,GAClB,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,GACrC,SAAS,CAAC,CAAC,OAAO,oBAAoB,CAAC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",
|
|
4
4
|
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"@ethersproject/contracts": "^5.7.0",
|
|
48
48
|
"@ethersproject/providers": "^5.7.0",
|
|
49
49
|
"@metamask/abi-utils": "^2.0.2",
|
|
50
|
-
"@metamask/accounts-controller": "^
|
|
50
|
+
"@metamask/accounts-controller": "^13.0.0",
|
|
51
51
|
"@metamask/approval-controller": "^6.0.1",
|
|
52
52
|
"@metamask/base-controller": "^5.0.1",
|
|
53
53
|
"@metamask/contract-metadata": "^2.4.0",
|
|
54
|
-
"@metamask/controller-utils": "^9.0
|
|
54
|
+
"@metamask/controller-utils": "^9.1.0",
|
|
55
55
|
"@metamask/eth-query": "^4.0.0",
|
|
56
|
-
"@metamask/keyring-controller": "^
|
|
57
|
-
"@metamask/metamask-eth-abis": "3.
|
|
58
|
-
"@metamask/network-controller": "^18.0
|
|
56
|
+
"@metamask/keyring-controller": "^15.0.0",
|
|
57
|
+
"@metamask/metamask-eth-abis": "^3.1.1",
|
|
58
|
+
"@metamask/network-controller": "^18.1.0",
|
|
59
59
|
"@metamask/polling-controller": "^6.0.1",
|
|
60
|
-
"@metamask/preferences-controller": "^
|
|
60
|
+
"@metamask/preferences-controller": "^10.0.0",
|
|
61
61
|
"@metamask/rpc-errors": "^6.2.1",
|
|
62
62
|
"@metamask/utils": "^8.3.0",
|
|
63
63
|
"@types/bn.js": "^5.1.5",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@metamask/auto-changelog": "^3.4.4",
|
|
75
75
|
"@metamask/ethjs-provider-http": "^0.3.0",
|
|
76
|
-
"@metamask/keyring-api": "^
|
|
76
|
+
"@metamask/keyring-api": "^5.1.0",
|
|
77
77
|
"@types/jest": "^27.4.1",
|
|
78
78
|
"@types/lodash": "^4.14.191",
|
|
79
79
|
"@types/node": "^16.18.54",
|
|
@@ -85,14 +85,14 @@
|
|
|
85
85
|
"ts-jest": "^27.1.4",
|
|
86
86
|
"typedoc": "^0.24.8",
|
|
87
87
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
88
|
-
"typescript": "~4.
|
|
88
|
+
"typescript": "~4.9.5"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
|
-
"@metamask/accounts-controller": "^
|
|
91
|
+
"@metamask/accounts-controller": "^13.0.0",
|
|
92
92
|
"@metamask/approval-controller": "^6.0.0",
|
|
93
|
-
"@metamask/keyring-controller": "^
|
|
93
|
+
"@metamask/keyring-controller": "^15.0.0",
|
|
94
94
|
"@metamask/network-controller": "^18.0.0",
|
|
95
|
-
"@metamask/preferences-controller": "^
|
|
95
|
+
"@metamask/preferences-controller": "^10.0.0"
|
|
96
96
|
},
|
|
97
97
|
"engines": {
|
|
98
98
|
"node": ">=16.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Standards/NftStandards/ERC721/ERC721Standard.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAEzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAInB,IAAM,iBAAN,MAAqB;AAAA,EAG1B,YAAY,UAAwB;AAUpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6CAAoC,OAClC,YACqB;AACrB,aAAO,KAAK;AAAA,QACV;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+CAAsC,OACpC,YACqB;AACrB,aAAO,KAAK;AAAA,QACV;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4CAAmC,OACjC,YACqB;AACrB,aAAO,KAAK,0BAA0B,SAAS,mBAAmB;AAAA,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WAAW,MAAM,KAAK,iCAAiC,OAAO;AACpE,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,MAAM,oCAAoC;AAAA,MACtD;AAEA,YAAM,CAAC,QAAQ,MAAM,QAAQ,IAAI,MAAM,QAAQ,IAAI;AAAA,QACjD,cAAc,MAAM,KAAK,eAAe,OAAO,CAAC;AAAA,QAChD,cAAc,MAAM,KAAK,aAAa,OAAO,CAAC;AAAA,QAC9C,UACI;AAAA,UAAc,MACZ,KAAK,YAAY,SAAS,OAAO,EAAE;AAAA,YAAK,CAAC,QACvC,IAAI,WAAW,SAAS,IACpB,oBAAoB,aAAa,KAAK,IAAI,IAC1C;AAAA,UACN;AAAA,QACF,IACA;AAAA,MACN,CAAC;AAED,UAAI;AACJ,UAAI,UAAU;AACZ,YAAI;AACF,gBAAM,WAAW,MAAM,aAAa,QAAQ;AAC5C,gBAAM,SAAS,MAAM,SAAS,KAAK;AACnC,kBAAQ,QAAQ;AAChB,cAAI,OAAO,WAAW,SAAS,GAAG;AAChC,oBAAQ,oBAAoB,aAAa,OAAO,IAAI;AAAA,UACtD;AAAA,QACF,QAAQ;AAAA,QAER;AAAA,MACF;AAEA,aAAO;AAAA,QACL,UAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAvME,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4GA,MAAM,WAAW,SAAiB,SAAkC;AAClE,UAAM,WAAW,IAAI,SAAS,SAAS,WAAW,KAAK,QAAQ;AAC/D,WAAO,SAAS,QAAQ,OAAO;AAAA,EACjC;AAwFF","sourcesContent":["import { Contract } from '@ethersproject/contracts';\nimport type { Web3Provider } from '@ethersproject/providers';\nimport {\n timeoutFetch,\n ERC721_INTERFACE_ID,\n ERC721_METADATA_INTERFACE_ID,\n ERC721_ENUMERABLE_INTERFACE_ID,\n ERC721,\n safelyExecute,\n} from '@metamask/controller-utils';\nimport { abiERC721 } from '@metamask/metamask-eth-abis';\n\nimport { getFormattedIpfsUrl } from '../../../assetsUtil';\n\nexport class ERC721Standard {\n private readonly provider: Web3Provider;\n\n constructor(provider: Web3Provider) {\n this.provider = provider;\n }\n\n /**\n * Query if contract implements ERC721Metadata interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721Metadata interface.\n */\n contractSupportsMetadataInterface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(\n address,\n ERC721_METADATA_INTERFACE_ID,\n );\n };\n\n /**\n * Query if contract implements ERC721Enumerable interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721Enumerable interface.\n */\n contractSupportsEnumerableInterface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(\n address,\n ERC721_ENUMERABLE_INTERFACE_ID,\n );\n };\n\n /**\n * Query if contract implements ERC721 interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721 interface.\n */\n contractSupportsBase721Interface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(address, ERC721_INTERFACE_ID);\n };\n\n /**\n * Enumerate assets assigned to an owner.\n *\n * @param address - ERC721 asset contract address.\n * @param selectedAddress - Current account public address.\n * @param index - An NFT counter less than `balanceOf(selectedAddress)`.\n * @returns Promise resolving to token identifier for the 'index'th asset assigned to 'selectedAddress'.\n */\n getNftTokenId = async (\n address: string,\n selectedAddress: string,\n index: number,\n ): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.tokenOfOwnerByIndex(selectedAddress, index);\n };\n\n /**\n * Query for tokenURI for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @param tokenId - ERC721 asset identifier.\n * @returns Promise resolving to the 'tokenURI'.\n */\n getTokenURI = async (address: string, tokenId: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n const supportsMetadata = await this.contractSupportsMetadataInterface(\n address,\n );\n if (!supportsMetadata) {\n throw new Error('Contract does not support ERC721 metadata interface.');\n }\n return contract.tokenURI(tokenId);\n };\n\n /**\n * Query for name for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to the 'name'.\n */\n getAssetName = async (address: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.name();\n };\n\n /**\n * Query for symbol for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to the 'symbol'.\n */\n getAssetSymbol = async (address: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.symbol();\n };\n\n /**\n * Query for owner for a given ERC721 asset.\n *\n * @param address - ERC721 asset contract address.\n * @param tokenId - ERC721 asset identifier.\n * @returns Promise resolving to the owner address.\n */\n async getOwnerOf(address: string, tokenId: string): Promise<string> {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.ownerOf(tokenId);\n }\n\n /**\n * Query if a contract implements an interface.\n *\n * @param address - Asset contract address.\n * @param interfaceId - Interface identifier.\n * @returns Promise resolving to whether the contract implements `interfaceID`.\n */\n private readonly contractSupportsInterface = async (\n address: string,\n interfaceId: string,\n ): Promise<boolean> => {\n const contract = new Contract(address, abiERC721, this.provider);\n try {\n return await contract.supportsInterface(interfaceId);\n } catch (err) {\n // Mirror previous implementation\n if (\n err instanceof Error &&\n err.message.includes('call revert exception')\n ) {\n return false;\n }\n throw err;\n }\n };\n\n /**\n * Query if a contract implements an interface.\n *\n * @param address - Asset contract address.\n * @param ipfsGateway - The user's preferred IPFS gateway.\n * @param tokenId - tokenId of a given token in the contract.\n * @returns Promise resolving an object containing the standard, tokenURI, symbol and name of the given contract/tokenId pair.\n */\n getDetails = async (\n address: string,\n ipfsGateway: string,\n tokenId?: string,\n ): Promise<{\n standard: string;\n tokenURI: string | undefined;\n symbol: string | undefined;\n name: string | undefined;\n image: string | undefined;\n }> => {\n const isERC721 = await this.contractSupportsBase721Interface(address);\n if (!isERC721) {\n throw new Error(\"This isn't a valid ERC721 contract\");\n }\n\n const [symbol, name, tokenURI] = await Promise.all([\n safelyExecute(() => this.getAssetSymbol(address)),\n safelyExecute(() => this.getAssetName(address)),\n tokenId\n ? safelyExecute(() =>\n this.getTokenURI(address, tokenId).then((uri) =>\n uri.startsWith('ipfs://')\n ? getFormattedIpfsUrl(ipfsGateway, uri, true)\n : uri,\n ),\n )\n : undefined,\n ]);\n\n let image;\n if (tokenURI) {\n try {\n const response = await timeoutFetch(tokenURI);\n const object = await response.json();\n image = object?.image;\n if (image?.startsWith('ipfs://')) {\n image = getFormattedIpfsUrl(ipfsGateway, image, true);\n }\n } catch {\n // ignore\n }\n }\n\n return {\n standard: ERC721,\n tokenURI,\n symbol,\n name,\n image,\n };\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/NftController.ts"],"names":["OpenSeaV2ChainIds"],"mappings":";;;;;;;;AAAA,SAAS,iBAAiB;AAO1B,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,SAAS,iBAAiB;AAE1B,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,OAAO,QAAQ;AACf,SAAS,oBAAoB;AAC7B,SAAS,MAAM,cAAc;AA2BtB,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,mBAAA,cAAW;AADD,SAAAA;AAAA,GAAA;AAwNZ,IAAM,qBAAqB;AAC3B,IAAM,+BAA+B;AA+B9B,IAAM,qBAAqB,MAAgB;AAChD,SAAO;AAAA,IACL,iBAAiB,CAAC;AAAA,IAClB,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,EAChB;AACF;AAKO,IAAM,gBAAN,cAA4B,iBAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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project/address';\nimport type { AddApprovalRequest } from '@metamask/approval-controller';\nimport type {\n BaseConfig,\n BaseState,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { BaseControllerV1 } from '@metamask/base-controller';\nimport {\n safelyExecute,\n handleFetch,\n toChecksumHexAddress,\n BNToHex,\n fetchWithErrorHandling,\n IPFS_DEFAULT_GATEWAY_URL,\n ERC721,\n ERC1155,\n OPENSEA_PROXY_URL,\n ApprovalType,\n} from '@metamask/controller-utils';\nimport type {\n NetworkClientId,\n NetworkController,\n NetworkState,\n} from '@metamask/network-controller';\nimport type { PreferencesState } from '@metamask/preferences-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { Hex } from '@metamask/utils';\nimport { remove0x } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport BN from 'bn.js';\nimport { EventEmitter } from 'events';\nimport { v4 as random } from 'uuid';\n\nimport type { AssetsContractController } from './AssetsContractController';\nimport {\n compareNftMetadata,\n getFormattedIpfsUrl,\n mapOpenSeaContractV2ToV1,\n mapOpenSeaDetailedNftV2ToV1,\n} from './assetsUtil';\nimport { Source } from './constants';\nimport type {\n ApiNftCreator,\n ApiNftContract,\n ApiNftLastSale,\n} from './NftDetectionController';\n\ntype NFTStandardType = 'ERC721' | 'ERC1155';\n\ntype SuggestedNftMeta = {\n asset: { address: string; tokenId: string } & NftMetadata;\n id: string;\n time: number;\n type: NFTStandardType;\n interactingAddress: string;\n origin: string;\n};\n\nexport enum OpenSeaV2ChainIds {\n ethereum = 'ethereum',\n}\n\nexport type OpenSeaV2GetNftResponse = { nft: OpenSeaV2DetailedNft };\n\nexport type OpenSeaV2Nft = {\n identifier: string;\n collection: string;\n contract: string;\n token_standard: string;\n name: string;\n description: string;\n image_url?: string;\n metadata_url?: string;\n updated_at: string;\n is_disabled: boolean;\n is_nsfw: boolean;\n};\n\nexport type OpenSeaV2DetailedNft = OpenSeaV2Nft & {\n animation_url?: string;\n is_suspicious: boolean;\n creator: string;\n traits: {\n trait_type: string;\n display_type?: string;\n max_value: string;\n trait_count?: number;\n value: number | string;\n }[];\n owners: {\n address: string;\n quantity: number;\n }[];\n rarity: { rank: number };\n};\n\nexport type OpenSeaV2ListNftsResponse = {\n nfts: OpenSeaV2Nft[];\n next?: string;\n};\n\nexport type OpenSeaV2Contract = {\n address: string;\n chain: string;\n collection: string;\n contract_standard: string;\n name: string;\n total_supply?: number;\n};\n\nexport type OpenSeaV2Collection = {\n collection: string;\n name: string;\n description?: string;\n image_url?: string;\n owner: string;\n category: string;\n is_disabled: boolean;\n is_nsfw: boolean;\n trait_offers_enabled: boolean;\n opensea_url: string;\n project_url?: string;\n wiki_url?: string;\n discord_url?: string;\n telegram_url?: string;\n twitter_username?: string;\n instagram_username?: string;\n total_supply?: number;\n};\n\n/**\n * @type Nft\n *\n * NFT representation\n * @property address - Hex address of a ERC721 contract\n * @property description - The NFT description\n * @property image - URI of custom NFT image associated with this tokenId\n * @property name - Name associated with this tokenId and contract address\n * @property tokenId - The NFT identifier\n * @property numberOfSales - Number of sales\n * @property backgroundColor - The background color to be displayed with the item\n * @property imagePreview - URI of a smaller image associated with this NFT\n * @property imageThumbnail - URI of a thumbnail image associated with this NFT\n * @property imageOriginal - URI of the original image associated with this NFT\n * @property animation - URI of a animation associated with this NFT\n * @property animationOriginal - URI of the original animation associated with this NFT\n * @property externalLink - External link containing additional information\n * @property creator - The NFT owner information object\n * @property isCurrentlyOwned - Boolean indicating whether the address/chainId combination where it's currently stored currently owns this NFT\n * @property transactionId - Transaction Id associated with the NFT\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface Nft extends NftMetadata {\n tokenId: string;\n address: string;\n isCurrentlyOwned?: boolean;\n}\n\ntype NftUpdate = {\n nft: Nft;\n newMetadata: NftMetadata;\n};\n\n/**\n * @type NftContract\n *\n * NFT contract information representation\n * @property name - Contract name\n * @property logo - Contract logo\n * @property address - Contract address\n * @property symbol - Contract symbol\n * @property description - Contract description\n * @property totalSupply - Total supply of NFTs\n * @property assetContractType - The NFT type, it could be `semi-fungible` or `non-fungible`\n * @property createdDate - Creation date\n * @property schemaName - The schema followed by the contract, it could be `ERC721` or `ERC1155`\n * @property externalLink - External link containing additional information\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface NftContract {\n name?: string;\n logo?: string;\n address: string;\n symbol?: string;\n description?: string;\n totalSupply?: string;\n assetContractType?: string;\n createdDate?: string;\n schemaName?: string;\n externalLink?: string;\n}\n\n/**\n * @type NftMetadata\n *\n * NFT custom information\n * @property name - NFT custom name\n * @property description - The NFT description\n * @property numberOfSales - Number of sales\n * @property backgroundColor - The background color to be displayed with the item\n * @property image - Image custom image URI\n * @property imagePreview - URI of a smaller image associated with this NFT\n * @property imageThumbnail - URI of a thumbnail image associated with this NFT\n * @property imageOriginal - URI of the original image associated with this NFT\n * @property animation - URI of a animation associated with this NFT\n * @property animationOriginal - URI of the original animation associated with this NFT\n * @property externalLink - External link containing additional information\n * @property creator - The NFT owner information object\n * @property standard - NFT standard name for the NFT, e.g., ERC-721 or ERC-1155\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface NftMetadata {\n name: string | null;\n description: string | null;\n image: string | null;\n standard: string | null;\n favorite?: boolean;\n numberOfSales?: number;\n backgroundColor?: string;\n imagePreview?: string;\n imageThumbnail?: string;\n imageOriginal?: string;\n animation?: string;\n animationOriginal?: string;\n externalLink?: string;\n creator?: ApiNftCreator;\n lastSale?: ApiNftLastSale;\n transactionId?: string;\n tokenURI?: string | null;\n}\n\n/**\n * @type NftConfig\n *\n * NFT controller configuration\n * @property selectedAddress - Vault selected address\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface NftConfig extends BaseConfig {\n selectedAddress: string;\n chainId: Hex;\n ipfsGateway: string;\n openSeaEnabled: boolean;\n useIPFSSubdomains: boolean;\n isIpfsGatewayEnabled: boolean;\n}\n\n/**\n * @type NftState\n *\n * NFT controller state\n * @property allNftContracts - Object containing NFT contract information\n * @property allNfts - Object containing NFTs per account and network\n * @property ignoredNfts - List of NFTs that should be ignored\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface NftState extends BaseState {\n allNftContracts: {\n [key: string]: { [chainId: Hex]: NftContract[] };\n };\n allNfts: { [key: string]: { [chainId: Hex]: Nft[] } };\n ignoredNfts: Nft[];\n}\n\nconst ALL_NFTS_STATE_KEY = 'allNfts';\nconst ALL_NFTS_CONTRACTS_STATE_KEY = 'allNftContracts';\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ninterface NftAsset {\n address: string;\n tokenId: string;\n}\n\n/**\n * The name of the {@link NftController}.\n */\nconst controllerName = 'NftController';\n\n/**\n * The external actions available to the {@link NftController}.\n */\ntype AllowedActions = AddApprovalRequest;\n\n/**\n * The messenger of the {@link NftController}.\n */\nexport type NftControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n AllowedActions,\n never,\n AllowedActions['type'],\n never\n>;\n\nexport const getDefaultNftState = (): NftState => {\n return {\n allNftContracts: {},\n allNfts: {},\n ignoredNfts: [],\n };\n};\n\n/**\n * Controller that stores assets and exposes convenience methods\n */\nexport class NftController extends BaseControllerV1<NftConfig, NftState> {\n private readonly mutex = new Mutex();\n\n private readonly messagingSystem: NftControllerMessenger;\n\n getNftApi({\n contractAddress,\n tokenId,\n }: {\n contractAddress: string;\n tokenId: string;\n }) {\n return `${OPENSEA_PROXY_URL}/chain/${OpenSeaV2ChainIds.ethereum}/contract/${contractAddress}/nfts/${tokenId}`;\n }\n\n private getNftContractInformationApi({\n contractAddress,\n }: {\n contractAddress: string;\n }) {\n return `${OPENSEA_PROXY_URL}/chain/${OpenSeaV2ChainIds.ethereum}/contract/${contractAddress}`;\n }\n\n private getNftCollectionInformationApi({\n collectionSlug,\n }: {\n collectionSlug: string;\n }) {\n return `${OPENSEA_PROXY_URL}/collections/${collectionSlug}`;\n }\n\n /**\n * Helper method to update nested state for allNfts and allNftContracts.\n *\n * @param newCollection - the modified piece of state to update in the controller's store\n * @param baseStateKey - The root key in the store to update.\n * @param passedConfig - An object containing the selectedAddress and chainId that are passed through the auto-detection flow.\n * @param passedConfig.userAddress - the address passed through the NFT detection flow to ensure assets are stored to the correct account\n * @param passedConfig.chainId - the chainId passed through the NFT detection flow to ensure assets are stored to the correct account\n */\n private updateNestedNftState(\n newCollection: Nft[] | NftContract[],\n baseStateKey: 'allNfts' | 'allNftContracts',\n { userAddress, chainId }: { userAddress: string; chainId: Hex },\n ) {\n const { [baseStateKey]: oldState } = this.state;\n\n const addressState = oldState[userAddress];\n const newAddressState = {\n ...addressState,\n ...{ [chainId]: newCollection },\n };\n const newState = {\n ...oldState,\n ...{ [userAddress]: newAddressState },\n };\n\n this.update({\n [baseStateKey]: newState,\n });\n }\n\n /**\n * Request individual NFT information from OpenSea API.\n *\n * @param contractAddress - Hex address of the NFT contract.\n * @param tokenId - The NFT identifier.\n * @returns Promise resolving to the current NFT name and image.\n */\n private async getNftInformationFromApi(\n contractAddress: string,\n tokenId: string,\n ): Promise<NftMetadata> {\n // TODO Parameterize this by chainId for non-mainnet token detection\n // Attempt to fetch the data with the proxy\n const nftInformation: OpenSeaV2GetNftResponse | undefined =\n await fetchWithErrorHandling({\n url: this.getNftApi({\n contractAddress,\n tokenId,\n }),\n });\n\n // if we were still unable to fetch the data we return out the default/null of `NftMetadata`\n if (!nftInformation?.nft) {\n return {\n name: null,\n description: null,\n image: null,\n standard: null,\n };\n }\n\n // if we've reached this point, we have successfully fetched some data for nftInformation\n // now we reconfigure the data to conform to the `NftMetadata` type for storage.\n const {\n num_sales,\n background_color,\n image_url,\n image_preview_url,\n image_thumbnail_url,\n image_original_url,\n animation_url,\n animation_original_url,\n name,\n description,\n external_link,\n creator,\n last_sale,\n asset_contract: { schema_name },\n } = mapOpenSeaDetailedNftV2ToV1(nftInformation.nft);\n\n /* istanbul ignore next */\n const nftMetadata: NftMetadata = Object.assign(\n {},\n { name: name || null },\n { description: description || null },\n { image: image_url || null },\n creator && { creator },\n num_sales && { numberOfSales: num_sales },\n background_color && { backgroundColor: background_color },\n image_preview_url && { imagePreview: image_preview_url },\n image_thumbnail_url && { imageThumbnail: image_thumbnail_url },\n image_original_url && { imageOriginal: image_original_url },\n animation_url && { animation: animation_url },\n animation_original_url && {\n animationOriginal: animation_original_url,\n },\n external_link && { externalLink: external_link },\n last_sale && { lastSale: last_sale },\n schema_name && { standard: schema_name },\n );\n\n return nftMetadata;\n }\n\n /**\n * Request individual NFT information from contracts that follows Metadata Interface.\n *\n * @param contractAddress - Hex address of the NFT contract.\n * @param tokenId - The NFT identifier.\n * @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @returns Promise resolving to the current NFT name and image.\n */\n private async getNftInformationFromTokenURI(\n contractAddress: string,\n tokenId: string,\n networkClientId?: NetworkClientId,\n ): Promise<NftMetadata> {\n const { ipfsGateway, useIPFSSubdomains, isIpfsGatewayEnabled } =\n this.config;\n const result = await this.getNftURIAndStandard(\n contractAddress,\n tokenId,\n networkClientId,\n );\n let tokenURI = result[0];\n const standard = result[1];\n\n const hasIpfsTokenURI = tokenURI.startsWith('ipfs://');\n\n if (hasIpfsTokenURI && !isIpfsGatewayEnabled) {\n return {\n image: null,\n name: null,\n description: null,\n standard: standard || null,\n favorite: false,\n tokenURI: tokenURI ?? null,\n };\n }\n\n const isDisplayNFTMediaToggleEnabled = this.config.openSeaEnabled;\n if (!hasIpfsTokenURI && !isDisplayNFTMediaToggleEnabled) {\n return {\n image: null,\n name: null,\n description: null,\n standard: standard || null,\n favorite: false,\n tokenURI: tokenURI ?? null,\n };\n }\n\n if (hasIpfsTokenURI) {\n tokenURI = getFormattedIpfsUrl(ipfsGateway, tokenURI, useIPFSSubdomains);\n }\n\n try {\n const object = await handleFetch(tokenURI);\n // TODO: Check image_url existence. This is not part of EIP721 nor EIP1155\n const image = Object.prototype.hasOwnProperty.call(object, 'image')\n ? 'image'\n : /* istanbul ignore next */ 'image_url';\n\n return {\n image: object[image],\n name: object.name,\n description: object.description,\n standard,\n favorite: false,\n tokenURI: tokenURI ?? null,\n };\n } catch {\n return {\n image: null,\n name: null,\n description: null,\n standard: standard || null,\n favorite: false,\n tokenURI: tokenURI ?? null,\n };\n }\n }\n\n /**\n * Retrieve NFT uri with metadata. TODO Update method to use IPFS.\n *\n * @param contractAddress - NFT contract address.\n * @param tokenId - NFT token id.\n * @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @returns Promise resolving NFT uri and token standard.\n */\n private async getNftURIAndStandard(\n contractAddress: string,\n tokenId: string,\n networkClientId?: NetworkClientId,\n ): Promise<[string, string]> {\n // try ERC721 uri\n try {\n const uri = await this.getERC721TokenURI(\n contractAddress,\n tokenId,\n networkClientId,\n );\n return [uri, ERC721];\n } catch {\n // Ignore error\n }\n\n // try ERC1155 uri\n try {\n const tokenURI = await this.getERC1155TokenURI(\n contractAddress,\n tokenId,\n networkClientId,\n );\n\n /**\n * According to EIP1155 the URI value allows for ID substitution\n * in case the string `{id}` exists.\n * https://eips.ethereum.org/EIPS/eip-1155#metadata\n */\n\n if (!tokenURI.includes('{id}')) {\n return [tokenURI, ERC1155];\n }\n\n const hexTokenId = remove0x(BNToHex(new BN(tokenId)))\n .padStart(64, '0')\n .toLowerCase();\n return [tokenURI.replace('{id}', hexTokenId), ERC1155];\n } catch {\n // Ignore error\n }\n\n return ['', ''];\n }\n\n /**\n * Request individual NFT information (name, image url and description).\n *\n * @param contractAddress - Hex address of the NFT contract.\n * @param tokenId - The NFT identifier.\n * @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @returns Promise resolving to the current NFT name and image.\n */\n private async getNftInformation(\n contractAddress: string,\n tokenId: string,\n networkClientId?: NetworkClientId,\n ): Promise<NftMetadata> {\n const chainId = this.getCorrectChainId({\n networkClientId,\n });\n\n const [blockchainMetadata, openSeaMetadata] = await Promise.all([\n safelyExecute(() =>\n this.getNftInformationFromTokenURI(\n contractAddress,\n tokenId,\n networkClientId,\n ),\n ),\n this.config.openSeaEnabled && chainId === '0x1'\n ? safelyExecute(() =>\n this.getNftInformationFromApi(contractAddress, tokenId),\n )\n : undefined,\n ]);\n\n return {\n ...openSeaMetadata,\n name: blockchainMetadata?.name ?? openSeaMetadata?.name ?? null,\n description:\n blockchainMetadata?.description ?? openSeaMetadata?.description ?? null,\n image: blockchainMetadata?.image ?? openSeaMetadata?.image ?? null,\n standard:\n blockchainMetadata?.standard ?? openSeaMetadata?.standard ?? null,\n tokenURI: blockchainMetadata?.tokenURI ?? null,\n };\n }\n\n /**\n * Request NFT contract information from OpenSea API.\n *\n * @param contractAddress - Hex address of the NFT contract.\n * @returns Promise resolving to the current NFT name and image.\n */\n private async getNftContractInformationFromApi(\n contractAddress: string,\n ): Promise<ApiNftContract> {\n /* istanbul ignore if */\n const apiNftContractObject: OpenSeaV2Contract | undefined =\n await fetchWithErrorHandling({\n url: this.getNftContractInformationApi({\n contractAddress,\n }),\n });\n\n // If we successfully fetched the contract\n if (apiNftContractObject) {\n // Then fetch some additional details from the collection\n const collection: OpenSeaV2Collection | undefined =\n await fetchWithErrorHandling({\n url: this.getNftCollectionInformationApi({\n collectionSlug: apiNftContractObject.collection,\n }),\n });\n\n return mapOpenSeaContractV2ToV1(apiNftContractObject, collection);\n }\n\n // If we've reached this point we were unable to fetch data from either the proxy or opensea so we return\n // the default/null of ApiNftContract\n return {\n address: contractAddress,\n asset_contract_type: null,\n created_date: null,\n schema_name: null,\n symbol: null,\n total_supply: null,\n description: null,\n external_link: null,\n collection: {\n name: null,\n image_url: null,\n },\n };\n }\n\n /**\n * Request NFT contract information from the contract itself.\n *\n * @param contractAddress - Hex address of the NFT contract.\n * @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @returns Promise resolving to the current NFT name and image.\n */\n private async getNftContractInformationFromContract(\n contractAddress: string,\n networkClientId?: NetworkClientId,\n ): Promise<\n Partial<ApiNftContract> &\n Pick<ApiNftContract, 'address'> &\n Pick<ApiNftContract, 'collection'>\n > {\n const [name, symbol] = await Promise.all([\n this.getERC721AssetName(contractAddress, networkClientId),\n this.getERC721AssetSymbol(contractAddress, networkClientId),\n ]);\n\n return {\n collection: { name },\n symbol,\n address: contractAddress,\n };\n }\n\n /**\n * Request NFT contract information from OpenSea API.\n *\n * @param contractAddress - Hex address of the NFT contract.\n * @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @returns Promise resolving to the NFT contract name, image and description.\n */\n private async getNftContractInformation(\n contractAddress: string,\n networkClientId?: NetworkClientId,\n ): Promise<\n Partial<ApiNftContract> &\n Pick<ApiNftContract, 'address'> &\n Pick<ApiNftContract, 'collection'>\n > {\n const chainId = this.getCorrectChainId({\n networkClientId,\n });\n\n const [blockchainContractData, openSeaContractData] = await Promise.all([\n safelyExecute(() =>\n this.getNftContractInformationFromContract(\n contractAddress,\n networkClientId,\n ),\n ),\n this.config.openSeaEnabled && chainId === '0x1'\n ? safelyExecute(() =>\n this.getNftContractInformationFromApi(contractAddress),\n )\n : undefined,\n ]);\n\n if (blockchainContractData || openSeaContractData) {\n return {\n address: contractAddress,\n ...openSeaContractData,\n ...blockchainContractData,\n collection: {\n name: null,\n image_url: null,\n ...openSeaContractData?.collection,\n ...blockchainContractData?.collection,\n },\n };\n }\n\n /* istanbul ignore next */\n return {\n address: contractAddress,\n asset_contract_type: null,\n created_date: null,\n schema_name: null,\n symbol: null,\n total_supply: null,\n description: null,\n external_link: null,\n collection: { name: null, image_url: null },\n };\n }\n\n /**\n * Adds an individual NFT to the stored NFT list.\n *\n * @param tokenAddress - Hex address of the NFT contract.\n * @param tokenId - The NFT identifier.\n * @param nftMetadata - NFT optional information (name, image and description).\n * @param nftContract - An object containing contract data of the NFT being added.\n * @param chainId - The chainId of the network where the NFT is being added.\n * @param userAddress - The address of the account where the NFT is being added.\n * @param source - Whether the NFT was detected, added manually or suggested by a dapp.\n * @returns Promise resolving to the current NFT list.\n */\n private async addIndividualNft(\n tokenAddress: string,\n tokenId: string,\n nftMetadata: NftMetadata,\n nftContract: NftContract,\n chainId: Hex,\n userAddress: string,\n source: Source,\n ): Promise<Nft[]> {\n // TODO: Remove unused return\n const releaseLock = await this.mutex.acquire();\n try {\n tokenAddress = toChecksumHexAddress(tokenAddress);\n const { allNfts } = this.state;\n\n const nfts = allNfts[userAddress]?.[chainId] || [];\n\n const existingEntry: Nft | undefined = nfts.find(\n (nft) =>\n nft.address.toLowerCase() === tokenAddress.toLowerCase() &&\n nft.tokenId === tokenId,\n );\n\n if (existingEntry) {\n const differentMetadata = compareNftMetadata(\n nftMetadata,\n existingEntry,\n );\n if (differentMetadata || !existingEntry.isCurrentlyOwned) {\n // TODO: Switch to indexToUpdate\n const indexToRemove = nfts.findIndex(\n (nft) =>\n nft.address.toLowerCase() === tokenAddress.toLowerCase() &&\n nft.tokenId === tokenId,\n );\n /* istanbul ignore next */\n if (indexToRemove !== -1) {\n nfts.splice(indexToRemove, 1);\n }\n } else {\n return nfts;\n }\n }\n\n const newEntry: Nft = {\n address: tokenAddress,\n tokenId,\n favorite: existingEntry?.favorite || false,\n isCurrentlyOwned: true,\n ...nftMetadata,\n };\n\n const newNfts = [...nfts, newEntry];\n this.updateNestedNftState(newNfts, ALL_NFTS_STATE_KEY, {\n chainId,\n userAddress,\n });\n\n if (this.onNftAdded) {\n this.onNftAdded({\n address: tokenAddress,\n symbol: nftContract.symbol,\n tokenId: tokenId.toString(),\n standard: nftMetadata.standard,\n source,\n });\n }\n return newNfts;\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Adds an NFT contract to the stored NFT contracts list.\n *\n * @param options - options.\n * @param options.tokenAddress - Hex address of the NFT contract.\n * @param options.userAddress - The address of the account where the NFT is being added.\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.\n * @returns Promise resolving to the current NFT contracts list.\n */\n private async addNftContract({\n tokenAddress,\n userAddress,\n networkClientId,\n source,\n }: {\n tokenAddress: string;\n userAddress: string;\n networkClientId?: NetworkClientId;\n source?: Source;\n }): Promise<NftContract[]> {\n const releaseLock = await this.mutex.acquire();\n try {\n tokenAddress = toChecksumHexAddress(tokenAddress);\n const { allNftContracts } = this.state;\n const chainId = this.getCorrectChainId({\n networkClientId,\n });\n\n const nftContracts = allNftContracts[userAddress]?.[chainId] || [];\n\n const existingEntry = nftContracts.find(\n (nftContract) =>\n nftContract.address.toLowerCase() === tokenAddress.toLowerCase(),\n );\n if (existingEntry) {\n return nftContracts;\n }\n\n // this doesn't work currently for detection if the user switches networks while the detection is processing\n // will be fixed once detection uses networkClientIds\n const contractInformation = await this.getNftContractInformation(\n tokenAddress,\n networkClientId,\n );\n const {\n asset_contract_type,\n created_date,\n schema_name,\n symbol,\n total_supply,\n description,\n external_link,\n collection: { name, image_url },\n } = contractInformation;\n\n // If the nft is auto-detected we want some valid metadata to be present\n if (\n source === Source.Detected &&\n 'address' in contractInformation &&\n typeof contractInformation.address === 'string' &&\n 'collection' in contractInformation &&\n contractInformation.collection.name === null &&\n 'image_url' in contractInformation.collection &&\n contractInformation.collection.image_url === null &&\n Object.entries(contractInformation).every(([key, value]) => {\n return key === 'address' || key === 'collection' || !value;\n })\n ) {\n return nftContracts;\n }\n\n /* istanbul ignore next */\n const newEntry: NftContract = Object.assign(\n {},\n { address: tokenAddress },\n description && { description },\n name && { name },\n image_url && { logo: image_url },\n symbol && { symbol },\n total_supply !== null &&\n typeof total_supply !== 'undefined' && { totalSupply: total_supply },\n asset_contract_type && { assetContractType: asset_contract_type },\n created_date && { createdDate: created_date },\n schema_name && { schemaName: schema_name },\n external_link && { externalLink: external_link },\n );\n const newNftContracts = [...nftContracts, newEntry];\n this.updateNestedNftState(newNftContracts, ALL_NFTS_CONTRACTS_STATE_KEY, {\n chainId,\n userAddress,\n });\n\n return newNftContracts;\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Removes an individual NFT from the stored token list and saves it in ignored NFTs list.\n *\n * @param address - Hex address of the NFT contract.\n * @param tokenId - Token identifier of the NFT.\n * @param options - options.\n * @param options.chainId - The chainId of the network where the NFT is being removed.\n * @param options.userAddress - The address of the account where the NFT is being removed.\n */\n private removeAndIgnoreIndividualNft(\n address: string,\n tokenId: string,\n {\n chainId,\n userAddress,\n }: {\n chainId: Hex;\n userAddress: string;\n },\n ) {\n address = toChecksumHexAddress(address);\n const { allNfts, ignoredNfts } = this.state;\n const newIgnoredNfts = [...ignoredNfts];\n const nfts = allNfts[userAddress]?.[chainId] || [];\n const newNfts = nfts.filter((nft) => {\n if (\n nft.address.toLowerCase() === address.toLowerCase() &&\n nft.tokenId === tokenId\n ) {\n const alreadyIgnored = newIgnoredNfts.find(\n (c) => c.address === address && c.tokenId === tokenId,\n );\n !alreadyIgnored && newIgnoredNfts.push(nft);\n return false;\n }\n return true;\n });\n\n this.updateNestedNftState(newNfts, ALL_NFTS_STATE_KEY, {\n userAddress,\n chainId,\n });\n\n this.update({\n ignoredNfts: newIgnoredNfts,\n });\n }\n\n /**\n * Removes an individual NFT from the stored token list.\n *\n * @param address - Hex address of the NFT contract.\n * @param tokenId - Token identifier of the NFT.\n * @param options - options.\n * @param options.chainId - The chainId of the network where the NFT is being removed.\n * @param options.userAddress - The address of the account where the NFT is being removed.\n */\n private removeIndividualNft(\n address: string,\n tokenId: string,\n { chainId, userAddress }: { chainId: Hex; userAddress: string },\n ) {\n address = toChecksumHexAddress(address);\n const { allNfts } = this.state;\n const nfts = allNfts[userAddress]?.[chainId] || [];\n const newNfts = nfts.filter(\n (nft) =>\n !(\n nft.address.toLowerCase() === address.toLowerCase() &&\n nft.tokenId === tokenId\n ),\n );\n this.updateNestedNftState(newNfts, ALL_NFTS_STATE_KEY, {\n userAddress,\n chainId,\n });\n }\n\n /**\n * Removes an NFT contract to the stored NFT contracts list.\n *\n * @param address - Hex address of the NFT contract.\n * @param options - options.\n * @param options.chainId - The chainId of the network where the NFT is being removed.\n * @param options.userAddress - The address of the account where the NFT is being removed.\n * @returns Promise resolving to the current NFT contracts list.\n */\n private removeNftContract(\n address: string,\n { chainId, userAddress }: { chainId: Hex; userAddress: string },\n ): NftContract[] {\n address = toChecksumHexAddress(address);\n const { allNftContracts } = this.state;\n const nftContracts = allNftContracts[userAddress]?.[chainId] || [];\n\n const newNftContracts = nftContracts.filter(\n (nftContract) =>\n !(nftContract.address.toLowerCase() === address.toLowerCase()),\n );\n this.updateNestedNftState(newNftContracts, ALL_NFTS_CONTRACTS_STATE_KEY, {\n chainId,\n userAddress,\n });\n\n return newNftContracts;\n }\n\n /**\n * EventEmitter instance used to listen to specific EIP747 events\n */\n hub = new EventEmitter();\n\n /**\n * Optional API key to use with opensea\n */\n openSeaApiKey?: string;\n\n /**\n * Name of this controller used during composition\n */\n override name = 'NftController';\n\n private readonly getERC721AssetName: AssetsContractController['getERC721AssetName'];\n\n private readonly getERC721AssetSymbol: AssetsContractController['getERC721AssetSymbol'];\n\n private readonly getERC721TokenURI: AssetsContractController['getERC721TokenURI'];\n\n private readonly getERC721OwnerOf: AssetsContractController['getERC721OwnerOf'];\n\n private readonly getERC1155BalanceOf: AssetsContractController['getERC1155BalanceOf'];\n\n private readonly getERC1155TokenURI: AssetsContractController['getERC1155TokenURI'];\n\n private readonly getNetworkClientById: NetworkController['getNetworkClientById'];\n\n private readonly onNftAdded?: (data: {\n address: string;\n symbol: string | undefined;\n tokenId: string;\n standard: string | null;\n source: Source;\n }) => void;\n\n /**\n * Creates an NftController instance.\n *\n * @param options - The controller options.\n * @param options.chainId - The chain ID of the current network.\n * @param options.onPreferencesStateChange - Allows subscribing to preference controller state changes.\n * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.\n * @param options.getERC721AssetName - Gets the name of the asset at the given address.\n * @param options.getERC721AssetSymbol - Gets the symbol of the asset at the given address.\n * @param options.getERC721TokenURI - Gets the URI of the ERC721 token at the given address, with the given ID.\n * @param options.getERC721OwnerOf - Get the owner of a ERC-721 NFT.\n * @param options.getERC1155BalanceOf - Gets balance of a ERC-1155 NFT.\n * @param options.getERC1155TokenURI - Gets the URI of the ERC1155 token at the given address, with the given ID.\n * @param options.getNetworkClientById - Gets the network client for the given networkClientId.\n * @param options.onNftAdded - Callback that is called when an NFT is added. Currently used pass data\n * for tracking the NFT added event.\n * @param options.messenger - The controller messenger.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n chainId: initialChainId,\n onPreferencesStateChange,\n onNetworkStateChange,\n getERC721AssetName,\n getERC721AssetSymbol,\n getERC721TokenURI,\n getERC721OwnerOf,\n getERC1155BalanceOf,\n getERC1155TokenURI,\n getNetworkClientById,\n onNftAdded,\n messenger,\n }: {\n chainId: Hex;\n onPreferencesStateChange: (\n listener: (preferencesState: PreferencesState) => void,\n ) => void;\n onNetworkStateChange: (\n listener: (networkState: NetworkState) => void,\n ) => void;\n getERC721AssetName: AssetsContractController['getERC721AssetName'];\n getERC721AssetSymbol: AssetsContractController['getERC721AssetSymbol'];\n getERC721TokenURI: AssetsContractController['getERC721TokenURI'];\n getERC721OwnerOf: AssetsContractController['getERC721OwnerOf'];\n getERC1155BalanceOf: AssetsContractController['getERC1155BalanceOf'];\n getERC1155TokenURI: AssetsContractController['getERC1155TokenURI'];\n getNetworkClientById: NetworkController['getNetworkClientById'];\n onNftAdded?: (data: {\n address: string;\n symbol: string | undefined;\n tokenId: string;\n standard: string | null;\n source: string;\n }) => void;\n messenger: NftControllerMessenger;\n },\n config?: Partial<BaseConfig>,\n state?: Partial<NftState>,\n ) {\n super(config, state);\n this.defaultConfig = {\n selectedAddress: '',\n chainId: initialChainId,\n ipfsGateway: IPFS_DEFAULT_GATEWAY_URL,\n openSeaEnabled: false,\n useIPFSSubdomains: true,\n isIpfsGatewayEnabled: true,\n };\n\n this.defaultState = getDefaultNftState();\n this.initialize();\n this.getERC721AssetName = getERC721AssetName;\n this.getERC721AssetSymbol = getERC721AssetSymbol;\n this.getERC721TokenURI = getERC721TokenURI;\n this.getERC721OwnerOf = getERC721OwnerOf;\n this.getERC1155BalanceOf = getERC1155BalanceOf;\n this.getERC1155TokenURI = getERC1155TokenURI;\n this.getNetworkClientById = getNetworkClientById;\n this.onNftAdded = onNftAdded;\n this.messagingSystem = messenger;\n\n onPreferencesStateChange(\n ({\n selectedAddress,\n ipfsGateway,\n openSeaEnabled,\n isIpfsGatewayEnabled,\n }) => {\n this.configure({\n selectedAddress,\n ipfsGateway,\n openSeaEnabled,\n isIpfsGatewayEnabled,\n });\n },\n );\n\n onNetworkStateChange(({ providerConfig }) => {\n const { chainId } = providerConfig;\n this.configure({ chainId });\n });\n }\n\n private async validateWatchNft(\n asset: NftAsset,\n type: NFTStandardType,\n userAddress: string,\n { networkClientId }: { networkClientId?: NetworkClientId } = {},\n ) {\n const { address: contractAddress, tokenId } = asset;\n\n // Validate parameters\n if (!type) {\n throw rpcErrors.invalidParams('Asset type is required');\n }\n\n if (type !== ERC721 && type !== ERC1155) {\n throw rpcErrors.invalidParams(\n `Non NFT asset type ${type} not supported by watchNft`,\n );\n }\n\n if (!contractAddress || !tokenId) {\n throw rpcErrors.invalidParams('Both address and tokenId are required');\n }\n\n if (!isAddress(contractAddress)) {\n throw rpcErrors.invalidParams('Invalid address');\n }\n\n if (!/^\\d+$/u.test(tokenId)) {\n throw rpcErrors.invalidParams('Invalid tokenId');\n }\n\n // Check if the user owns the suggested NFT\n try {\n const isOwner = await this.isNftOwner(\n userAddress,\n contractAddress,\n tokenId,\n { networkClientId },\n );\n if (!isOwner) {\n throw rpcErrors.invalidInput(\n 'Suggested NFT is not owned by the selected account',\n );\n }\n } catch (error) {\n // error thrown here: \"Unable to verify ownership. Possibly because the standard is not supported or the user's currently selected network does not match the chain of the asset in question.\"\n if (error instanceof Error) {\n throw rpcErrors.resourceUnavailable(error.message);\n }\n throw error;\n }\n }\n\n // temporary method to get the correct chainId until we remove chainId from the config & the chainId arg from the detection logic\n // Just a helper method to prefer the networkClient chainId first then the chainId argument and then finally the config chainId\n private getCorrectChainId({\n networkClientId,\n }: {\n networkClientId?: NetworkClientId;\n }) {\n if (networkClientId) {\n return this.getNetworkClientById(networkClientId).configuration.chainId;\n }\n return this.config.chainId;\n }\n\n /**\n * Adds a new suggestedAsset to state. Parameters will be validated according to\n * asset type being watched. A `<suggestedNftMeta.id>:pending` hub event will be emitted once added.\n *\n * @param asset - The asset to be watched. For now ERC721 and ERC1155 tokens are accepted.\n * @param asset.address - The address of the asset contract.\n * @param asset.tokenId - The ID of the asset.\n * @param type - The asset type.\n * @param origin - Domain origin to register the asset from.\n * @param options - Options bag.\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @param options.userAddress - The address of the account where the NFT is being added.\n * @returns Object containing a Promise resolving to the suggestedAsset address if accepted.\n */\n async watchNft(\n asset: NftAsset,\n type: NFTStandardType,\n origin: string,\n {\n networkClientId,\n userAddress = this.config.selectedAddress,\n }: {\n networkClientId?: NetworkClientId;\n userAddress?: string;\n } = {\n userAddress: this.config.selectedAddress,\n },\n ) {\n await this.validateWatchNft(asset, type, userAddress);\n\n const nftMetadata = await this.getNftInformation(\n asset.address,\n asset.tokenId,\n networkClientId,\n );\n\n if (nftMetadata.standard && nftMetadata.standard !== type) {\n throw rpcErrors.invalidInput(\n `Suggested NFT of type ${nftMetadata.standard} does not match received type ${type}`,\n );\n }\n\n const suggestedNftMeta: SuggestedNftMeta = {\n asset: { ...asset, ...nftMetadata },\n type,\n id: random(),\n time: Date.now(),\n interactingAddress: userAddress,\n origin,\n };\n await this._requestApproval(suggestedNftMeta);\n const { address, tokenId } = asset;\n const { name, standard, description, image } = nftMetadata;\n\n await this.addNft(address, tokenId, {\n nftMetadata: {\n name: name ?? null,\n description: description ?? null,\n image: image ?? null,\n standard: standard ?? null,\n },\n userAddress,\n source: Source.Dapp,\n networkClientId,\n });\n }\n\n /**\n * Sets an OpenSea API key to retrieve NFT information.\n *\n * @param openSeaApiKey - OpenSea API key.\n */\n setApiKey(openSeaApiKey: string) {\n this.openSeaApiKey = openSeaApiKey;\n }\n\n /**\n * Checks the ownership of a ERC-721 or ERC-1155 NFT for a given address.\n *\n * @param ownerAddress - User public address.\n * @param nftAddress - NFT contract address.\n * @param tokenId - NFT token ID.\n * @param options - Options bag.\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @returns Promise resolving the NFT ownership.\n */\n async isNftOwner(\n ownerAddress: string,\n nftAddress: string,\n tokenId: string,\n {\n networkClientId,\n }: {\n networkClientId?: NetworkClientId;\n } = {},\n ): Promise<boolean> {\n // Checks the ownership for ERC-721.\n try {\n const owner = await this.getERC721OwnerOf(\n nftAddress,\n tokenId,\n networkClientId,\n );\n return ownerAddress.toLowerCase() === owner.toLowerCase();\n // eslint-disable-next-line no-empty\n } catch {\n // Ignore ERC-721 contract error\n }\n\n // Checks the ownership for ERC-1155.\n try {\n const balance = await this.getERC1155BalanceOf(\n ownerAddress,\n nftAddress,\n tokenId,\n networkClientId,\n );\n return !balance.isZero();\n // eslint-disable-next-line no-empty\n } catch {\n // Ignore ERC-1155 contract error\n }\n\n throw new Error(\n `Unable to verify ownership. Possibly because the standard is not supported or the user's currently selected network does not match the chain of the asset in question.`,\n );\n }\n\n /**\n * Verifies currently selected address owns entered NFT address/tokenId combo and\n * adds the NFT and respective NFT contract to the stored NFT and NFT contracts lists.\n *\n * @param address - Hex address of the NFT contract.\n * @param tokenId - The NFT identifier.\n * @param options - an object of arguments\n * @param options.userAddress - The address of the current user.\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.\n */\n async addNftVerifyOwnership(\n address: string,\n tokenId: string,\n {\n userAddress = this.config.selectedAddress,\n networkClientId,\n source,\n }: {\n userAddress?: string;\n networkClientId?: NetworkClientId;\n source?: Source;\n } = {\n userAddress: this.config.selectedAddress,\n },\n ) {\n if (\n !(await this.isNftOwner(userAddress, address, tokenId, {\n networkClientId,\n }))\n ) {\n throw new Error('This NFT is not owned by the user');\n }\n await this.addNft(address, tokenId, {\n networkClientId,\n userAddress,\n source,\n });\n }\n\n /**\n * Adds an NFT and respective NFT contract to the stored NFT and NFT contracts lists.\n *\n * @param tokenAddress - Hex address of the NFT contract.\n * @param tokenId - The NFT identifier.\n * @param options - an object of arguments\n * @param options.nftMetadata - NFT optional metadata.\n * @param options.userAddress - The address of the current user.\n * @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @returns Promise resolving to the current NFT list.\n */\n async addNft(\n tokenAddress: string,\n tokenId: string,\n {\n nftMetadata,\n userAddress = this.config.selectedAddress,\n source = Source.Custom,\n networkClientId,\n }: {\n nftMetadata?: NftMetadata;\n userAddress?: string;\n source?: Source;\n networkClientId?: NetworkClientId;\n } = { userAddress: this.config.selectedAddress },\n ) {\n tokenAddress = toChecksumHexAddress(tokenAddress);\n\n const chainId = this.getCorrectChainId({ networkClientId });\n const newNftContracts = await this.addNftContract({\n tokenAddress,\n userAddress,\n networkClientId,\n source,\n });\n\n nftMetadata =\n nftMetadata ||\n (await this.getNftInformation(tokenAddress, tokenId, networkClientId));\n\n // If NFT contract was not added, do not add individual NFT\n const nftContract = newNftContracts.find(\n (contract) =>\n contract.address.toLowerCase() === tokenAddress.toLowerCase(),\n );\n\n // If NFT contract information, add individual NFT\n if (nftContract) {\n await this.addIndividualNft(\n tokenAddress,\n tokenId,\n nftMetadata,\n nftContract,\n chainId,\n userAddress,\n source,\n );\n }\n }\n\n /**\n * Refetches NFT metadata and updates the state\n *\n * @param options - Options for refetching NFT metadata\n * @param options.nfts - Array of nfts\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @param options.userAddress - The current user address\n */\n async updateNftMetadata({\n nfts,\n networkClientId,\n userAddress = this.config.selectedAddress,\n }: {\n nfts: Nft[];\n networkClientId?: NetworkClientId;\n userAddress?: string;\n }) {\n const chainId = this.getCorrectChainId({ networkClientId });\n const nftsWithChecksumAdr = nfts.map((nft) => {\n return {\n ...nft,\n address: toChecksumHexAddress(nft.address),\n };\n });\n const nftMetadataResults = await Promise.allSettled(\n nftsWithChecksumAdr.map(async (nft) => {\n const resMetadata = await this.getNftInformation(\n nft.address,\n nft.tokenId,\n networkClientId,\n );\n return {\n nft,\n newMetadata: resMetadata,\n };\n }),\n );\n\n nftMetadataResults\n .filter(\n (result): result is PromiseFulfilledResult<NftUpdate> =>\n result.status === 'fulfilled',\n )\n .forEach((elm) =>\n this.updateNft(\n elm.value.nft,\n elm.value.newMetadata,\n userAddress,\n chainId,\n ),\n );\n }\n\n /**\n * Removes an NFT from the stored token list.\n *\n * @param address - Hex address of the NFT contract.\n * @param tokenId - Token identifier of the NFT.\n * @param options - an object of arguments\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @param options.userAddress - The address of the account where the NFT is being removed.\n */\n removeNft(\n address: string,\n tokenId: string,\n {\n networkClientId,\n userAddress = this.config.selectedAddress,\n }: { networkClientId?: NetworkClientId; userAddress?: string } = {\n userAddress: this.config.selectedAddress,\n },\n ) {\n const chainId = this.getCorrectChainId({ networkClientId });\n address = toChecksumHexAddress(address);\n this.removeIndividualNft(address, tokenId, { chainId, userAddress });\n const { allNfts } = this.state;\n const nfts = allNfts[userAddress]?.[chainId] || [];\n const remainingNft = nfts.find(\n (nft) => nft.address.toLowerCase() === address.toLowerCase(),\n );\n\n if (!remainingNft) {\n this.removeNftContract(address, { chainId, userAddress });\n }\n }\n\n /**\n * Removes an NFT from the stored token list and saves it in ignored NFTs list.\n *\n * @param address - Hex address of the NFT contract.\n * @param tokenId - Token identifier of the NFT.\n * @param options - an object of arguments\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @param options.userAddress - The address of the account where the NFT is being removed.\n */\n removeAndIgnoreNft(\n address: string,\n tokenId: string,\n {\n networkClientId,\n userAddress = this.config.selectedAddress,\n }: { networkClientId?: NetworkClientId; userAddress?: string } = {\n userAddress: this.config.selectedAddress,\n },\n ) {\n const chainId = this.getCorrectChainId({ networkClientId });\n address = toChecksumHexAddress(address);\n this.removeAndIgnoreIndividualNft(address, tokenId, {\n chainId,\n userAddress,\n });\n const { allNfts } = this.state;\n const nfts = allNfts[userAddress]?.[chainId] || [];\n const remainingNft = nfts.find(\n (nft) => nft.address.toLowerCase() === address.toLowerCase(),\n );\n if (!remainingNft) {\n this.removeNftContract(address, { chainId, userAddress });\n }\n }\n\n /**\n * Removes all NFTs from the ignored list.\n */\n clearIgnoredNfts() {\n this.update({ ignoredNfts: [] });\n }\n\n /**\n * Checks whether input NFT is still owned by the user\n * And updates the isCurrentlyOwned value on the NFT object accordingly.\n *\n * @param nft - The NFT object to check and update.\n * @param batch - A boolean indicating whether this method is being called as part of a batch or single update.\n * @param accountParams - The userAddress and chainId to check ownership against\n * @param accountParams.userAddress - the address passed through the confirmed transaction flow to ensure assets are stored to the correct account\n * @param accountParams.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @returns the NFT with the updated isCurrentlyOwned value\n */\n async checkAndUpdateSingleNftOwnershipStatus(\n nft: Nft,\n batch: boolean,\n {\n userAddress = this.config.selectedAddress,\n networkClientId,\n }: { networkClientId?: NetworkClientId; userAddress?: string } = {\n userAddress: this.config.selectedAddress,\n },\n ) {\n const chainId = this.getCorrectChainId({ networkClientId });\n const { address, tokenId } = nft;\n let isOwned = nft.isCurrentlyOwned;\n try {\n isOwned = await this.isNftOwner(userAddress, address, tokenId, {\n networkClientId,\n });\n } catch {\n // ignore error\n // this will only throw an error 'Unable to verify ownership' in which case\n // we want to keep the current value of isCurrentlyOwned for this flow.\n }\n\n nft.isCurrentlyOwned = isOwned;\n\n if (batch) {\n return nft;\n }\n\n // if this is not part of a batched update we update this one NFT in state\n const { allNfts } = this.state;\n const nfts = allNfts[userAddress]?.[chainId] || [];\n const nftToUpdate = nfts.find(\n (item) =>\n item.tokenId === tokenId &&\n item.address.toLowerCase() === address.toLowerCase(),\n );\n if (nftToUpdate) {\n nftToUpdate.isCurrentlyOwned = isOwned;\n this.updateNestedNftState(nfts, ALL_NFTS_STATE_KEY, {\n userAddress,\n chainId,\n });\n }\n return nft;\n }\n\n /**\n * Checks whether NFTs associated with current selectedAddress/chainId combination are still owned by the user\n * And updates the isCurrentlyOwned value on each accordingly.\n * @param options - an object of arguments\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @param options.userAddress - The address of the account where the NFT ownership status is checked/updated.\n */\n async checkAndUpdateAllNftsOwnershipStatus(\n {\n networkClientId,\n userAddress = this.config.selectedAddress,\n }: { networkClientId?: NetworkClientId; userAddress?: string } = {\n userAddress: this.config.selectedAddress,\n },\n ) {\n const chainId = this.getCorrectChainId({ networkClientId });\n const { allNfts } = this.state;\n const nfts = allNfts[userAddress]?.[chainId] || [];\n const updatedNfts = await Promise.all(\n nfts.map(async (nft) => {\n return (\n (await this.checkAndUpdateSingleNftOwnershipStatus(nft, true, {\n networkClientId,\n userAddress,\n })) ?? nft\n );\n }),\n );\n\n this.updateNestedNftState(updatedNfts, ALL_NFTS_STATE_KEY, {\n userAddress,\n chainId,\n });\n }\n\n /**\n * Update NFT favorite status.\n *\n * @param address - Hex address of the NFT contract.\n * @param tokenId - Hex address of the NFT contract.\n * @param favorite - NFT new favorite status.\n * @param options - an object of arguments\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n * @param options.userAddress - The address of the account where the NFT is being removed.\n */\n updateNftFavoriteStatus(\n address: string,\n tokenId: string,\n favorite: boolean,\n {\n networkClientId,\n userAddress = this.config.selectedAddress,\n }: {\n networkClientId?: NetworkClientId;\n userAddress?: string;\n } = {\n userAddress: this.config.selectedAddress,\n },\n ) {\n const chainId = this.getCorrectChainId({ networkClientId });\n const { allNfts } = this.state;\n const nfts = allNfts[userAddress]?.[chainId] || [];\n const index: number = nfts.findIndex(\n (nft) => nft.address === address && nft.tokenId === tokenId,\n );\n\n if (index === -1) {\n return;\n }\n\n const updatedNft: Nft = {\n ...nfts[index],\n favorite,\n };\n\n // Update Nfts array\n nfts[index] = updatedNft;\n\n this.updateNestedNftState(nfts, ALL_NFTS_STATE_KEY, {\n chainId,\n userAddress,\n });\n }\n\n /**\n * Returns an NFT by the address and token id.\n *\n * @param address - Hex address of the NFT contract.\n * @param tokenId - Number that represents the id of the token.\n * @param selectedAddress - Hex address of the user account.\n * @param chainId - Id of the current network.\n * @returns Object containing the NFT and its position in the array\n */\n findNftByAddressAndTokenId(\n address: string,\n tokenId: string,\n selectedAddress: string,\n chainId: Hex,\n ): { nft: Nft; index: number } | null {\n const { allNfts } = this.state;\n const nfts = allNfts[selectedAddress]?.[chainId] || [];\n const index: number = nfts.findIndex(\n (nft) =>\n nft.address.toLowerCase() === address.toLowerCase() &&\n nft.tokenId === tokenId,\n );\n\n if (index === -1) {\n return null;\n }\n\n return { nft: nfts[index], index };\n }\n\n /**\n * Update NFT data.\n *\n * @param nft - NFT object to find the right NFT to updates.\n * @param updates - NFT partial object to update properties of the NFT.\n * @param selectedAddress - Hex address of the user account.\n * @param chainId - Id of the current network.\n */\n updateNft(\n nft: Nft,\n updates: Partial<Nft>,\n selectedAddress: string,\n chainId: Hex,\n ) {\n const { allNfts } = this.state;\n const nfts = allNfts[selectedAddress]?.[chainId] || [];\n const nftInfo = this.findNftByAddressAndTokenId(\n nft.address,\n nft.tokenId,\n selectedAddress,\n chainId,\n );\n\n if (!nftInfo) {\n return;\n }\n\n const updatedNft: Nft = {\n ...nft,\n ...updates,\n };\n\n const newNfts = [\n ...nfts.slice(0, nftInfo.index),\n updatedNft,\n ...nfts.slice(nftInfo.index + 1),\n ];\n\n this.updateNestedNftState(newNfts, ALL_NFTS_STATE_KEY, {\n chainId,\n userAddress: selectedAddress,\n });\n }\n\n /**\n * Resets the transaction status of an NFT.\n *\n * @param transactionId - NFT transaction id.\n * @param selectedAddress - Hex address of the user account.\n * @param chainId - Id of the current network.\n * @returns a boolean indicating if the reset was well succeeded or not\n */\n resetNftTransactionStatusByTransactionId(\n transactionId: string,\n selectedAddress: string,\n chainId: Hex,\n ): boolean {\n const { allNfts } = this.state;\n const nfts = allNfts[selectedAddress]?.[chainId] || [];\n const index: number = nfts.findIndex(\n (nft) => nft.transactionId === transactionId,\n );\n\n if (index === -1) {\n return false;\n }\n const updatedNft: Nft = {\n ...nfts[index],\n transactionId: undefined,\n };\n\n const newNfts = [\n ...nfts.slice(0, index),\n updatedNft,\n ...nfts.slice(index + 1),\n ];\n\n this.updateNestedNftState(newNfts, ALL_NFTS_STATE_KEY, {\n chainId,\n userAddress: selectedAddress,\n });\n\n return true;\n }\n\n async _requestApproval(suggestedNftMeta: SuggestedNftMeta) {\n return this.messagingSystem.call(\n 'ApprovalController:addRequest',\n {\n id: suggestedNftMeta.id,\n origin: suggestedNftMeta.origin,\n type: ApprovalType.WatchAsset,\n requestData: {\n id: suggestedNftMeta.id,\n interactingAddress: suggestedNftMeta.interactingAddress,\n asset: {\n address: suggestedNftMeta.asset.address,\n tokenId: suggestedNftMeta.asset.tokenId,\n name: suggestedNftMeta.asset.name,\n description: suggestedNftMeta.asset.description,\n image: suggestedNftMeta.asset.image,\n standard: suggestedNftMeta.asset.standard,\n },\n },\n },\n true,\n );\n }\n}\n\nexport default NftController;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/crypto-compare.ts"],"names":[],"mappings":";AAAA,SAAS,mBAAmB;AAa5B,SAAS,cACP,iBACA,gBACA,gBACA;AACA,SACE,qDACG,eAAe,YAAY,CAAC,UAAU,gBAAgB,YAAY,CAAC,GACnE,kBAAkB,gBAAgB,YAAY,MAAM,QAAQ,SAAS,EAAE;AAE9E;AAUA,eAAsB,kBACpB,UACA,gBACA,gBAIC;AACD,QAAM,OAAO,MAAM;AAAA,IACjB,cAAc,UAAU,gBAAgB,cAAc;AAAA,EACxD;AAUA,MAAI,KAAK,aAAa,SAAS;AAC7B,UAAM,IAAI,MAAM,KAAK,OAAO;AAAA,EAC9B;AAEA,QAAM,iBAAiB,OAAO,KAAK,SAAS,YAAY,CAAC,CAAC;AAE1D,QAAM,oBAAoB,OAAO,KAAK,GAAG;AACzC,MAAI,CAAC,OAAO,SAAS,cAAc,GAAG;AACpC,UAAM,IAAI;AAAA,MACR,wBAAwB,SAAS,YAAY,CAAC,KAC5C,KAAK,SAAS,YAAY,CAAC,CAC7B;AAAA,IACF;AAAA,EACF;AAEA,MAAI,kBAAkB,CAAC,OAAO,SAAS,iBAAiB,GAAG;AACzD,UAAM,IAAI,MAAM,2CAA2C,KAAK,GAAG,EAAE;AAAA,EACvE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\n\n/**\n * Get the CryptoCompare API URL for getting the conversion rate from the given native currency to\n * the given currency. Optionally, the conversion rate from the native currency to USD can also be\n * included in the response.\n *\n * @param currentCurrency - The currency to get a conversion rate for.\n * @param nativeCurrency - The native currency to convert from.\n * @param includeUSDRate - Whether or not the native currency to USD conversion rate should be\n * included in the response as well.\n * @returns The API URL for getting the conversion rate.\n */\nfunction getPricingURL(\n currentCurrency: string,\n nativeCurrency: string,\n includeUSDRate?: boolean,\n) {\n return (\n `https://min-api.cryptocompare.com/data/price?fsym=` +\n `${nativeCurrency.toUpperCase()}&tsyms=${currentCurrency.toUpperCase()}` +\n `${includeUSDRate && currentCurrency.toUpperCase() !== 'USD' ? ',USD' : ''}`\n );\n}\n\n/**\n * Fetches the exchange rate for a given currency.\n *\n * @param currency - ISO 4217 currency code.\n * @param nativeCurrency - Symbol for base asset.\n * @param includeUSDRate - Whether to add the USD rate to the fetch.\n * @returns Promise resolving to exchange rate for given currency.\n */\nexport async function fetchExchangeRate(\n currency: string,\n nativeCurrency: string,\n includeUSDRate?: boolean,\n): Promise<{\n conversionRate: number;\n usdConversionRate: number;\n}> {\n const json = await handleFetch(\n getPricingURL(currency, nativeCurrency, includeUSDRate),\n );\n\n /*\n Example expected error response (if pair is not found)\n {\n Response: \"Error\",\n Message: \"cccagg_or_exchange market does not exist for this coin pair (ETH-<NON_EXISTENT_TOKEN>)\",\n HasWarning: false,\n }\n */\n if (json.Response === 'Error') {\n throw new Error(json.Message);\n }\n\n const conversionRate = Number(json[currency.toUpperCase()]);\n\n const usdConversionRate = Number(json.USD);\n if (!Number.isFinite(conversionRate)) {\n throw new Error(\n `Invalid response for ${currency.toUpperCase()}: ${\n json[currency.toUpperCase()]\n }`,\n );\n }\n\n if (includeUSDRate && !Number.isFinite(usdConversionRate)) {\n throw new Error(`Invalid response for usdConversionRate: ${json.USD}`);\n }\n\n return {\n conversionRate,\n usdConversionRate,\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/assetsUtil.ts"],"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';\nimport { CID } from 'multiformats/cid';\n\nimport type {\n Nft,\n NftMetadata,\n OpenSeaV2Collection,\n OpenSeaV2Contract,\n OpenSeaV2DetailedNft,\n OpenSeaV2Nft,\n} from './NftController';\nimport type { ApiNft, ApiNftContract } from './NftDetectionController';\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\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 return `https://static.metafi.codefi.network/api/v1/tokenIcons/${chainIdDecimal}/${tokenAddress.toLowerCase()}.png`;\n};\n\n/**\n * Networks where token detection is supported - Values are in decimal format\n */\nexport enum SupportedTokenDetectionNetworks {\n mainnet = '0x1', // decimal: 1\n bsc = '0x38', // decimal: 56\n polygon = '0x89', // decimal: 137\n avax = '0xa86a', // decimal: 43114\n aurora = '0x4e454152', // decimal: 1313161554\n linea_goerli = '0xe704', // decimal: 59140\n linea_mainnet = '0xe708', // decimal: 59144\n arbitrum = '0xa4b1', // decimal: 42161\n optimism = '0xa', // decimal: 10\n base = '0x2105', // decimal: 8453\n zksync = '0x144', // decimal: 324\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 function getIpfsCIDv1AndPath(ipfsUrl: string): {\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 // 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 function getFormattedIpfsUrl(\n ipfsGateway: string,\n ipfsUrl: string,\n subdomainSupported: boolean,\n): string {\n const { host, protocol, origin } = new URL(addUrlProtocolPrefix(ipfsGateway));\n if (subdomainSupported) {\n const { cid, path } = 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 * Maps an OpenSea V2 NFT to the V1 schema.\n * @param nft - The V2 NFT to map.\n * @returns The NFT in the V1 schema.\n */\nexport function mapOpenSeaNftV2ToV1(nft: OpenSeaV2Nft): ApiNft {\n return {\n token_id: nft.identifier,\n num_sales: null,\n background_color: null,\n image_url: nft.image_url ?? null,\n image_preview_url: null,\n image_thumbnail_url: null,\n image_original_url: null,\n animation_url: null,\n animation_original_url: null,\n name: nft.name,\n description: nft.description,\n external_link: null,\n asset_contract: {\n address: nft.contract,\n asset_contract_type: null,\n created_date: null,\n schema_name: nft.token_standard.toUpperCase(),\n symbol: null,\n total_supply: null,\n description: nft.description,\n external_link: null,\n collection: {\n name: nft.collection,\n image_url: null,\n },\n },\n creator: {\n user: { username: '' },\n profile_img_url: '',\n address: '',\n },\n last_sale: null,\n };\n}\n\n/**\n * Maps an OpenSea V2 detailed NFT to the V1 schema.\n * @param nft - The V2 detailed NFT to map.\n * @returns The NFT in the V1 schema.\n */\nexport function mapOpenSeaDetailedNftV2ToV1(nft: OpenSeaV2DetailedNft): ApiNft {\n const mapped = mapOpenSeaNftV2ToV1(nft);\n return {\n ...mapped,\n animation_url: nft.animation_url ?? null,\n creator: {\n ...mapped.creator,\n address: nft.creator,\n },\n };\n}\n\n/**\n * Maps an OpenSea V2 contract to the V1 schema.\n * @param contract - The v2 contract data.\n * @param collection - The v2 collection data.\n * @returns The contract in the v1 schema.\n */\nexport function mapOpenSeaContractV2ToV1(\n contract: OpenSeaV2Contract,\n collection?: OpenSeaV2Collection,\n): ApiNftContract {\n return {\n address: contract.address,\n asset_contract_type: null,\n created_date: null,\n schema_name: contract.contract_standard.toUpperCase(),\n symbol: null,\n total_supply:\n collection?.total_supply?.toString() ??\n contract.total_supply?.toString() ??\n null,\n description: collection?.description ?? null,\n external_link: collection?.project_url ?? null,\n collection: {\n name: collection?.name ?? contract.name,\n image_url: collection?.image_url,\n },\n };\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?.value,\n };\n },\n {},\n );\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,gBAAgB;AACzB,OAAO,QAAQ;AACf,SAAS,WAAW;AAkBb,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;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