@metamask/assets-controllers 27.2.0 → 29.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 +39 -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-VHCPQS4X.js → chunk-3ZHN4GFT.js} +5 -5
- package/dist/{chunk-KCUSDOIE.mjs → chunk-5MRF7YPD.mjs} +12 -5
- package/dist/chunk-5MRF7YPD.mjs.map +1 -0
- package/dist/{chunk-76KGJJJV.mjs → chunk-6XOM7KOQ.mjs} +5 -5
- package/dist/{chunk-GLZ66IRX.mjs → chunk-ASFD56OL.mjs} +48 -58
- package/dist/chunk-ASFD56OL.mjs.map +1 -0
- package/dist/{chunk-355MWUUQ.js → chunk-BO2WZDUM.js} +3 -3
- package/dist/{chunk-ZKJSG4TA.mjs → chunk-D3PCUDTX.mjs} +4 -4
- package/dist/chunk-D3PCUDTX.mjs.map +1 -0
- package/dist/{chunk-KSGMD24G.js → chunk-DEQZ35QE.js} +7 -7
- package/dist/{chunk-C4PQK53K.js → chunk-DYH5P3VY.js} +5 -2
- package/dist/chunk-DYH5P3VY.js.map +1 -0
- package/dist/{chunk-XEZJ5XMV.js → chunk-I53XGBU3.js} +7 -7
- package/dist/chunk-I53XGBU3.js.map +1 -0
- package/dist/{chunk-PD624ZNK.js → chunk-IOQX3VTD.js} +6 -6
- package/dist/{chunk-AQIXUBTK.js → chunk-KM3J4DO6.js} +93 -132
- package/dist/chunk-KM3J4DO6.js.map +1 -0
- package/dist/{chunk-MQ7TIWBK.mjs → chunk-LLYYJY7H.mjs} +2 -2
- package/dist/{chunk-H6TOSWUM.js → chunk-LRKDZWS6.js} +3 -3
- package/dist/{chunk-RELRWIJN.js → chunk-LS6R3HQL.js} +9 -68
- package/dist/chunk-LS6R3HQL.js.map +1 -0
- package/dist/{chunk-KRTEFV4Q.mjs → chunk-NXGX7LZJ.mjs} +2 -2
- package/dist/{chunk-6NO7Z5DL.js → chunk-OBOWNEJU.js} +5 -5
- package/dist/chunk-OBOWNEJU.js.map +1 -0
- package/dist/{chunk-VY7TUOK2.js → chunk-OHSQRYVL.js} +3 -3
- package/dist/{chunk-2IZUMKMY.mjs → chunk-OWTCG2N3.mjs} +3 -3
- package/dist/{chunk-TCO22VIO.mjs → chunk-PWZE6KJV.mjs} +5 -2
- package/dist/chunk-PWZE6KJV.mjs.map +1 -0
- package/dist/{chunk-4YU7CT4O.js → chunk-QHU4H6HP.js} +15 -8
- package/dist/chunk-QHU4H6HP.js.map +1 -0
- package/dist/{chunk-23F5W3A2.mjs → chunk-QWACHXRH.mjs} +2 -2
- package/dist/{chunk-523YP4Z3.mjs → chunk-RUE635TV.mjs} +3 -3
- package/dist/{chunk-IFJWX5RY.mjs → chunk-S6CZP74C.mjs} +93 -132
- package/dist/chunk-S6CZP74C.mjs.map +1 -0
- package/dist/{chunk-CEENXWOB.mjs → chunk-S7UA2DU7.mjs} +2 -2
- package/dist/{chunk-NUBQRDKI.js → chunk-SOK5YX7I.js} +11 -11
- package/dist/{chunk-WIVSZVF4.mjs → chunk-V46CHMOU.mjs} +3 -3
- package/dist/chunk-V46CHMOU.mjs.map +1 -0
- package/dist/{chunk-WSOHBBCO.js → chunk-X2MMIBYW.js} +49 -59
- package/dist/chunk-X2MMIBYW.js.map +1 -0
- package/dist/{chunk-E5PIGGYR.mjs → chunk-X5PLVMOQ.mjs} +8 -67
- package/dist/chunk-X5PLVMOQ.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/AssetsContractController.d.ts.map +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 +189 -1
- 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 +10 -23
- 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 +15 -15
- package/dist/chunk-4YU7CT4O.js.map +0 -1
- 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-KCUSDOIE.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-VHCPQS4X.js.map → chunk-3ZHN4GFT.js.map} +0 -0
- /package/dist/{chunk-76KGJJJV.mjs.map → chunk-6XOM7KOQ.mjs.map} +0 -0
- /package/dist/{chunk-355MWUUQ.js.map → chunk-BO2WZDUM.js.map} +0 -0
- /package/dist/{chunk-KSGMD24G.js.map → chunk-DEQZ35QE.js.map} +0 -0
- /package/dist/{chunk-PD624ZNK.js.map → chunk-IOQX3VTD.js.map} +0 -0
- /package/dist/{chunk-MQ7TIWBK.mjs.map → chunk-LLYYJY7H.mjs.map} +0 -0
- /package/dist/{chunk-H6TOSWUM.js.map → chunk-LRKDZWS6.js.map} +0 -0
- /package/dist/{chunk-KRTEFV4Q.mjs.map → chunk-NXGX7LZJ.mjs.map} +0 -0
- /package/dist/{chunk-VY7TUOK2.js.map → chunk-OHSQRYVL.js.map} +0 -0
- /package/dist/{chunk-2IZUMKMY.mjs.map → chunk-OWTCG2N3.mjs.map} +0 -0
- /package/dist/{chunk-23F5W3A2.mjs.map → chunk-QWACHXRH.mjs.map} +0 -0
- /package/dist/{chunk-523YP4Z3.mjs.map → chunk-RUE635TV.mjs.map} +0 -0
- /package/dist/{chunk-CEENXWOB.mjs.map → chunk-S7UA2DU7.mjs.map} +0 -0
- /package/dist/{chunk-NUBQRDKI.js.map → chunk-SOK5YX7I.js.map} +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
compareNftMetadata,
|
|
3
|
-
getFormattedIpfsUrl
|
|
4
|
-
|
|
5
|
-
mapOpenSeaDetailedNftV2ToV1
|
|
6
|
-
} from "./chunk-E5PIGGYR.mjs";
|
|
3
|
+
getFormattedIpfsUrl
|
|
4
|
+
} from "./chunk-X5PLVMOQ.mjs";
|
|
7
5
|
|
|
8
6
|
// src/NftController.ts
|
|
9
7
|
import { isAddress } from "@ethersproject/address";
|
|
@@ -17,8 +15,8 @@ import {
|
|
|
17
15
|
IPFS_DEFAULT_GATEWAY_URL,
|
|
18
16
|
ERC721,
|
|
19
17
|
ERC1155,
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
ApprovalType,
|
|
19
|
+
NFT_API_BASE_URL
|
|
22
20
|
} from "@metamask/controller-utils";
|
|
23
21
|
import { rpcErrors } from "@metamask/rpc-errors";
|
|
24
22
|
import { remove0x } from "@metamask/utils";
|
|
@@ -26,10 +24,6 @@ import { Mutex } from "async-mutex";
|
|
|
26
24
|
import BN from "bn.js";
|
|
27
25
|
import { EventEmitter } from "events";
|
|
28
26
|
import { v4 as random } from "uuid";
|
|
29
|
-
var OpenSeaV2ChainIds = /* @__PURE__ */ ((OpenSeaV2ChainIds2) => {
|
|
30
|
-
OpenSeaV2ChainIds2["ethereum"] = "ethereum";
|
|
31
|
-
return OpenSeaV2ChainIds2;
|
|
32
|
-
})(OpenSeaV2ChainIds || {});
|
|
33
27
|
var ALL_NFTS_STATE_KEY = "allNfts";
|
|
34
28
|
var ALL_NFTS_CONTRACTS_STATE_KEY = "allNftContracts";
|
|
35
29
|
var getDefaultNftState = () => {
|
|
@@ -104,7 +98,7 @@ var NftController = class extends BaseControllerV1 {
|
|
|
104
98
|
this.onNftAdded = onNftAdded;
|
|
105
99
|
this.messagingSystem = messenger;
|
|
106
100
|
onPreferencesStateChange(
|
|
107
|
-
({
|
|
101
|
+
async ({
|
|
108
102
|
selectedAddress,
|
|
109
103
|
ipfsGateway,
|
|
110
104
|
openSeaEnabled,
|
|
@@ -116,6 +110,20 @@ var NftController = class extends BaseControllerV1 {
|
|
|
116
110
|
openSeaEnabled,
|
|
117
111
|
isIpfsGatewayEnabled
|
|
118
112
|
});
|
|
113
|
+
const needsUpdateNftMetadata = isIpfsGatewayEnabled && ipfsGateway !== "" || openSeaEnabled;
|
|
114
|
+
if (needsUpdateNftMetadata) {
|
|
115
|
+
const { chainId } = this.config;
|
|
116
|
+
const nfts = this.state.allNfts[selectedAddress]?.[chainId] ?? [];
|
|
117
|
+
const nftsToUpdate = nfts.filter(
|
|
118
|
+
(singleNft) => !singleNft.name && !singleNft.description && !singleNft.image
|
|
119
|
+
);
|
|
120
|
+
if (nftsToUpdate.length !== 0) {
|
|
121
|
+
await this.updateNftMetadata({
|
|
122
|
+
nfts: nftsToUpdate,
|
|
123
|
+
userAddress: selectedAddress
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
119
127
|
}
|
|
120
128
|
);
|
|
121
129
|
onNetworkStateChange(({ providerConfig }) => {
|
|
@@ -123,21 +131,8 @@ var NftController = class extends BaseControllerV1 {
|
|
|
123
131
|
this.configure({ chainId });
|
|
124
132
|
});
|
|
125
133
|
}
|
|
126
|
-
getNftApi({
|
|
127
|
-
|
|
128
|
-
tokenId
|
|
129
|
-
}) {
|
|
130
|
-
return `${OPENSEA_PROXY_URL}/chain/${"ethereum" /* ethereum */}/contract/${contractAddress}/nfts/${tokenId}`;
|
|
131
|
-
}
|
|
132
|
-
getNftContractInformationApi({
|
|
133
|
-
contractAddress
|
|
134
|
-
}) {
|
|
135
|
-
return `${OPENSEA_PROXY_URL}/chain/${"ethereum" /* ethereum */}/contract/${contractAddress}`;
|
|
136
|
-
}
|
|
137
|
-
getNftCollectionInformationApi({
|
|
138
|
-
collectionSlug
|
|
139
|
-
}) {
|
|
140
|
-
return `${OPENSEA_PROXY_URL}/collections/${collectionSlug}`;
|
|
134
|
+
getNftApi() {
|
|
135
|
+
return `${NFT_API_BASE_URL}/tokens`;
|
|
141
136
|
}
|
|
142
137
|
/**
|
|
143
138
|
* Helper method to update nested state for allNfts and allNftContracts.
|
|
@@ -164,20 +159,29 @@ var NftController = class extends BaseControllerV1 {
|
|
|
164
159
|
});
|
|
165
160
|
}
|
|
166
161
|
/**
|
|
167
|
-
* Request individual NFT information from
|
|
162
|
+
* Request individual NFT information from NFT API.
|
|
168
163
|
*
|
|
169
164
|
* @param contractAddress - Hex address of the NFT contract.
|
|
170
165
|
* @param tokenId - The NFT identifier.
|
|
171
166
|
* @returns Promise resolving to the current NFT name and image.
|
|
172
167
|
*/
|
|
173
168
|
async getNftInformationFromApi(contractAddress, tokenId) {
|
|
169
|
+
const urlParams = new URLSearchParams({
|
|
170
|
+
chainIds: "1",
|
|
171
|
+
tokens: `${contractAddress}:${tokenId}`,
|
|
172
|
+
includeTopBid: "true",
|
|
173
|
+
includeAttributes: "true",
|
|
174
|
+
includeLastSale: "true"
|
|
175
|
+
}).toString();
|
|
174
176
|
const nftInformation = await fetchWithErrorHandling({
|
|
175
|
-
url: this.getNftApi({
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
url: `${this.getNftApi()}?${urlParams}`,
|
|
178
|
+
options: {
|
|
179
|
+
headers: {
|
|
180
|
+
Version: "1"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
179
183
|
});
|
|
180
|
-
if (!nftInformation?.
|
|
184
|
+
if (!nftInformation?.tokens?.[0]?.token) {
|
|
181
185
|
return {
|
|
182
186
|
name: null,
|
|
183
187
|
description: null,
|
|
@@ -186,39 +190,35 @@ var NftController = class extends BaseControllerV1 {
|
|
|
186
190
|
};
|
|
187
191
|
}
|
|
188
192
|
const {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
image_url,
|
|
192
|
-
image_preview_url,
|
|
193
|
-
image_thumbnail_url,
|
|
194
|
-
image_original_url,
|
|
195
|
-
animation_url,
|
|
196
|
-
animation_original_url,
|
|
193
|
+
image,
|
|
194
|
+
metadata: { imageOriginal } = {},
|
|
197
195
|
name,
|
|
198
196
|
description,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
197
|
+
collection,
|
|
198
|
+
kind,
|
|
199
|
+
rarityRank,
|
|
200
|
+
rarity,
|
|
201
|
+
attributes,
|
|
202
|
+
lastSale,
|
|
203
|
+
imageSmall
|
|
204
|
+
} = nftInformation.tokens[0].token;
|
|
204
205
|
const nftMetadata = Object.assign(
|
|
205
206
|
{},
|
|
206
207
|
{ name: name || null },
|
|
207
208
|
{ description: description || null },
|
|
208
|
-
{ image:
|
|
209
|
-
creator && { creator },
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
animationOriginal: animation_original_url
|
|
209
|
+
{ image: image || null },
|
|
210
|
+
collection?.creator && { creator: collection.creator },
|
|
211
|
+
imageOriginal && { imageOriginal },
|
|
212
|
+
imageSmall && { imageThumbnail: imageSmall },
|
|
213
|
+
kind && { standard: kind.toUpperCase() },
|
|
214
|
+
lastSale && { lastSale },
|
|
215
|
+
attributes && { attributes },
|
|
216
|
+
nftInformation.tokens[0].market?.topBid && {
|
|
217
|
+
topBid: nftInformation.tokens[0].market?.topBid
|
|
218
218
|
},
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
rarityRank && { rarityRank },
|
|
220
|
+
rarity && { rarity },
|
|
221
|
+
collection && { collection }
|
|
222
222
|
);
|
|
223
223
|
return nftMetadata;
|
|
224
224
|
}
|
|
@@ -334,7 +334,7 @@ var NftController = class extends BaseControllerV1 {
|
|
|
334
334
|
const chainId = this.getCorrectChainId({
|
|
335
335
|
networkClientId
|
|
336
336
|
});
|
|
337
|
-
const [blockchainMetadata,
|
|
337
|
+
const [blockchainMetadata, nftApiMetadata] = await Promise.all([
|
|
338
338
|
safelyExecute(
|
|
339
339
|
() => this.getNftInformationFromTokenURI(
|
|
340
340
|
contractAddress,
|
|
@@ -347,49 +347,14 @@ var NftController = class extends BaseControllerV1 {
|
|
|
347
347
|
) : void 0
|
|
348
348
|
]);
|
|
349
349
|
return {
|
|
350
|
-
...
|
|
351
|
-
name: blockchainMetadata?.name ??
|
|
352
|
-
description: blockchainMetadata?.description ??
|
|
353
|
-
image: blockchainMetadata?.image ??
|
|
354
|
-
standard: blockchainMetadata?.standard ??
|
|
350
|
+
...nftApiMetadata,
|
|
351
|
+
name: blockchainMetadata?.name ?? nftApiMetadata?.name ?? null,
|
|
352
|
+
description: blockchainMetadata?.description ?? nftApiMetadata?.description ?? null,
|
|
353
|
+
image: blockchainMetadata?.image ?? nftApiMetadata?.image ?? null,
|
|
354
|
+
standard: blockchainMetadata?.standard ?? nftApiMetadata?.standard ?? null,
|
|
355
355
|
tokenURI: blockchainMetadata?.tokenURI ?? null
|
|
356
356
|
};
|
|
357
357
|
}
|
|
358
|
-
/**
|
|
359
|
-
* Request NFT contract information from OpenSea API.
|
|
360
|
-
*
|
|
361
|
-
* @param contractAddress - Hex address of the NFT contract.
|
|
362
|
-
* @returns Promise resolving to the current NFT name and image.
|
|
363
|
-
*/
|
|
364
|
-
async getNftContractInformationFromApi(contractAddress) {
|
|
365
|
-
const apiNftContractObject = await fetchWithErrorHandling({
|
|
366
|
-
url: this.getNftContractInformationApi({
|
|
367
|
-
contractAddress
|
|
368
|
-
})
|
|
369
|
-
});
|
|
370
|
-
if (apiNftContractObject) {
|
|
371
|
-
const collection = await fetchWithErrorHandling({
|
|
372
|
-
url: this.getNftCollectionInformationApi({
|
|
373
|
-
collectionSlug: apiNftContractObject.collection
|
|
374
|
-
})
|
|
375
|
-
});
|
|
376
|
-
return mapOpenSeaContractV2ToV1(apiNftContractObject, collection);
|
|
377
|
-
}
|
|
378
|
-
return {
|
|
379
|
-
address: contractAddress,
|
|
380
|
-
asset_contract_type: null,
|
|
381
|
-
created_date: null,
|
|
382
|
-
schema_name: null,
|
|
383
|
-
symbol: null,
|
|
384
|
-
total_supply: null,
|
|
385
|
-
description: null,
|
|
386
|
-
external_link: null,
|
|
387
|
-
collection: {
|
|
388
|
-
name: null,
|
|
389
|
-
image_url: null
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
358
|
/**
|
|
394
359
|
* Request NFT contract information from the contract itself.
|
|
395
360
|
*
|
|
@@ -409,36 +374,30 @@ var NftController = class extends BaseControllerV1 {
|
|
|
409
374
|
};
|
|
410
375
|
}
|
|
411
376
|
/**
|
|
412
|
-
* Request NFT contract information from
|
|
377
|
+
* Request NFT contract information from Blockchain and aggregate with received data from NFTMetadata.
|
|
413
378
|
*
|
|
414
379
|
* @param contractAddress - Hex address of the NFT contract.
|
|
380
|
+
* @param nftMetadataFromApi - Received NFT information to be aggregated with blockchain contract information.
|
|
415
381
|
* @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.
|
|
416
382
|
* @returns Promise resolving to the NFT contract name, image and description.
|
|
417
383
|
*/
|
|
418
|
-
async getNftContractInformation(contractAddress, networkClientId) {
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
networkClientId
|
|
427
|
-
)
|
|
428
|
-
),
|
|
429
|
-
this.config.openSeaEnabled && chainId === "0x1" ? safelyExecute(
|
|
430
|
-
() => this.getNftContractInformationFromApi(contractAddress)
|
|
431
|
-
) : void 0
|
|
432
|
-
]);
|
|
433
|
-
if (blockchainContractData || openSeaContractData) {
|
|
384
|
+
async getNftContractInformation(contractAddress, nftMetadataFromApi, networkClientId) {
|
|
385
|
+
const blockchainContractData = await safelyExecute(
|
|
386
|
+
() => this.getNftContractInformationFromContract(
|
|
387
|
+
contractAddress,
|
|
388
|
+
networkClientId
|
|
389
|
+
)
|
|
390
|
+
);
|
|
391
|
+
if (blockchainContractData || !Object.values(nftMetadataFromApi).every((value) => value === null)) {
|
|
434
392
|
return {
|
|
435
393
|
address: contractAddress,
|
|
436
|
-
...openSeaContractData,
|
|
437
394
|
...blockchainContractData,
|
|
395
|
+
schema_name: nftMetadataFromApi?.standard ?? null,
|
|
438
396
|
collection: {
|
|
439
397
|
name: null,
|
|
440
|
-
image_url: null,
|
|
441
|
-
|
|
398
|
+
image_url: nftMetadataFromApi?.collection?.image ?? nftMetadataFromApi?.collection?.imageUrl ?? null,
|
|
399
|
+
tokenCount: nftMetadataFromApi?.collection?.tokenCount ?? null,
|
|
400
|
+
...nftMetadataFromApi?.collection,
|
|
442
401
|
...blockchainContractData?.collection
|
|
443
402
|
}
|
|
444
403
|
};
|
|
@@ -524,6 +483,7 @@ var NftController = class extends BaseControllerV1 {
|
|
|
524
483
|
* @param options - options.
|
|
525
484
|
* @param options.tokenAddress - Hex address of the NFT contract.
|
|
526
485
|
* @param options.userAddress - The address of the account where the NFT is being added.
|
|
486
|
+
* @param options.nftMetadata - The retrieved NFTMetadata from API.
|
|
527
487
|
* @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.
|
|
528
488
|
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.
|
|
529
489
|
* @returns Promise resolving to the current NFT contracts list.
|
|
@@ -532,7 +492,8 @@ var NftController = class extends BaseControllerV1 {
|
|
|
532
492
|
tokenAddress,
|
|
533
493
|
userAddress,
|
|
534
494
|
networkClientId,
|
|
535
|
-
source
|
|
495
|
+
source,
|
|
496
|
+
nftMetadata
|
|
536
497
|
}) {
|
|
537
498
|
const releaseLock = await this.mutex.acquire();
|
|
538
499
|
try {
|
|
@@ -550,17 +511,17 @@ var NftController = class extends BaseControllerV1 {
|
|
|
550
511
|
}
|
|
551
512
|
const contractInformation = await this.getNftContractInformation(
|
|
552
513
|
tokenAddress,
|
|
514
|
+
nftMetadata,
|
|
553
515
|
networkClientId
|
|
554
516
|
);
|
|
555
517
|
const {
|
|
556
518
|
asset_contract_type,
|
|
557
519
|
created_date,
|
|
558
|
-
schema_name,
|
|
559
520
|
symbol,
|
|
560
|
-
total_supply,
|
|
561
521
|
description,
|
|
562
522
|
external_link,
|
|
563
|
-
|
|
523
|
+
schema_name,
|
|
524
|
+
collection: { name, image_url, tokenCount }
|
|
564
525
|
} = contractInformation;
|
|
565
526
|
if (source === "detected" /* Detected */ && "address" in contractInformation && typeof contractInformation.address === "string" && "collection" in contractInformation && contractInformation.collection.name === null && "image_url" in contractInformation.collection && contractInformation.collection.image_url === null && Object.entries(contractInformation).every(([key, value]) => {
|
|
566
527
|
return key === "address" || key === "collection" || !value;
|
|
@@ -574,7 +535,7 @@ var NftController = class extends BaseControllerV1 {
|
|
|
574
535
|
name && { name },
|
|
575
536
|
image_url && { logo: image_url },
|
|
576
537
|
symbol && { symbol },
|
|
577
|
-
|
|
538
|
+
tokenCount !== null && typeof tokenCount !== "undefined" && { totalSupply: tokenCount },
|
|
578
539
|
asset_contract_type && { assetContractType: asset_contract_type },
|
|
579
540
|
created_date && { createdDate: created_date },
|
|
580
541
|
schema_name && { schemaName: schema_name },
|
|
@@ -863,13 +824,14 @@ var NftController = class extends BaseControllerV1 {
|
|
|
863
824
|
} = { userAddress: this.config.selectedAddress }) {
|
|
864
825
|
tokenAddress = toChecksumHexAddress(tokenAddress);
|
|
865
826
|
const chainId = this.getCorrectChainId({ networkClientId });
|
|
827
|
+
nftMetadata = nftMetadata || await this.getNftInformation(tokenAddress, tokenId, networkClientId);
|
|
866
828
|
const newNftContracts = await this.addNftContract({
|
|
867
829
|
tokenAddress,
|
|
868
830
|
userAddress,
|
|
869
831
|
networkClientId,
|
|
870
|
-
source
|
|
832
|
+
source,
|
|
833
|
+
nftMetadata
|
|
871
834
|
});
|
|
872
|
-
nftMetadata = nftMetadata || await this.getNftInformation(tokenAddress, tokenId, networkClientId);
|
|
873
835
|
const nftContract = newNftContracts.find(
|
|
874
836
|
(contract) => contract.address.toLowerCase() === tokenAddress.toLowerCase()
|
|
875
837
|
);
|
|
@@ -889,14 +851,14 @@ var NftController = class extends BaseControllerV1 {
|
|
|
889
851
|
* Refetches NFT metadata and updates the state
|
|
890
852
|
*
|
|
891
853
|
* @param options - Options for refetching NFT metadata
|
|
892
|
-
* @param options.nfts -
|
|
893
|
-
* @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.
|
|
854
|
+
* @param options.nfts - nfts to update metadata for.
|
|
894
855
|
* @param options.userAddress - The current user address
|
|
856
|
+
* @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.
|
|
895
857
|
*/
|
|
896
858
|
async updateNftMetadata({
|
|
897
859
|
nfts,
|
|
898
|
-
|
|
899
|
-
|
|
860
|
+
userAddress = this.config.selectedAddress,
|
|
861
|
+
networkClientId
|
|
900
862
|
}) {
|
|
901
863
|
const chainId = this.getCorrectChainId({ networkClientId });
|
|
902
864
|
const nftsWithChecksumAdr = nfts.map((nft) => {
|
|
@@ -1213,9 +1175,8 @@ var NftController = class extends BaseControllerV1 {
|
|
|
1213
1175
|
var NftController_default = NftController;
|
|
1214
1176
|
|
|
1215
1177
|
export {
|
|
1216
|
-
OpenSeaV2ChainIds,
|
|
1217
1178
|
getDefaultNftState,
|
|
1218
1179
|
NftController,
|
|
1219
1180
|
NftController_default
|
|
1220
1181
|
};
|
|
1221
|
-
//# sourceMappingURL=chunk-
|
|
1182
|
+
//# sourceMappingURL=chunk-S6CZP74C.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/NftController.ts"],"sourcesContent":["import { isAddress } from '@ethersproject/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 ApprovalType,\n NFT_API_BASE_URL,\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 { compareNftMetadata, getFormattedIpfsUrl } from './assetsUtil';\nimport { Source } from './constants';\nimport type {\n ApiNftContract,\n ReservoirResponse,\n Collection,\n Attributes,\n LastSale,\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\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?: string;\n transactionId?: string;\n tokenURI?: string | null;\n collection?: Collection;\n address?: string;\n attributes?: Attributes;\n lastSale?: LastSale;\n rarityRank?: string;\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 return `${NFT_API_BASE_URL}/tokens`;\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 this.update({\n [baseStateKey]: newState,\n });\n }\n\n /**\n * Request individual NFT information from NFT 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 nft-api\n const urlParams = new URLSearchParams({\n chainIds: '1',\n tokens: `${contractAddress}:${tokenId}`,\n includeTopBid: 'true',\n includeAttributes: 'true',\n includeLastSale: 'true',\n }).toString();\n const nftInformation: ReservoirResponse | undefined =\n await fetchWithErrorHandling({\n url: `${this.getNftApi()}?${urlParams}`,\n options: {\n headers: {\n Version: '1',\n },\n },\n });\n // if we were still unable to fetch the data we return out the default/null of `NftMetadata`\n if (!nftInformation?.tokens?.[0]?.token) {\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\n const {\n image,\n metadata: { imageOriginal } = {},\n name,\n description,\n collection,\n kind,\n rarityRank,\n rarity,\n attributes,\n lastSale,\n imageSmall,\n } = nftInformation.tokens[0].token;\n\n /* istanbul ignore next */\n const nftMetadata: NftMetadata = Object.assign(\n {},\n { name: name || null },\n { description: description || null },\n { image: image || null },\n collection?.creator && { creator: collection.creator },\n imageOriginal && { imageOriginal },\n imageSmall && { imageThumbnail: imageSmall },\n kind && { standard: kind.toUpperCase() },\n lastSale && { lastSale },\n attributes && { attributes },\n nftInformation.tokens[0].market?.topBid && {\n topBid: nftInformation.tokens[0].market?.topBid,\n },\n rarityRank && { rarityRank },\n rarity && { rarity },\n collection && { collection },\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 const [blockchainMetadata, nftApiMetadata] = 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 return {\n ...nftApiMetadata,\n name: blockchainMetadata?.name ?? nftApiMetadata?.name ?? null,\n description:\n blockchainMetadata?.description ?? nftApiMetadata?.description ?? null,\n image: blockchainMetadata?.image ?? nftApiMetadata?.image ?? null,\n standard:\n blockchainMetadata?.standard ?? nftApiMetadata?.standard ?? null,\n tokenURI: blockchainMetadata?.tokenURI ?? null,\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 Blockchain and aggregate with received data from NFTMetadata.\n *\n * @param contractAddress - Hex address of the NFT contract.\n * @param nftMetadataFromApi - Received NFT information to be aggregated with blockchain contract information.\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 nftMetadataFromApi: NftMetadata,\n networkClientId?: NetworkClientId,\n ): Promise<\n Partial<ApiNftContract> &\n Pick<ApiNftContract, 'address'> &\n Pick<ApiNftContract, 'collection'>\n > {\n const blockchainContractData = await safelyExecute(() =>\n this.getNftContractInformationFromContract(\n contractAddress,\n networkClientId,\n ),\n );\n\n if (\n blockchainContractData ||\n !Object.values(nftMetadataFromApi).every((value) => value === null)\n ) {\n return {\n address: contractAddress,\n ...blockchainContractData,\n schema_name: nftMetadataFromApi?.standard ?? null,\n collection: {\n name: null,\n image_url:\n nftMetadataFromApi?.collection?.image ??\n nftMetadataFromApi?.collection?.imageUrl ??\n null,\n tokenCount: nftMetadataFromApi?.collection?.tokenCount ?? null,\n ...nftMetadataFromApi?.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.nftMetadata - The retrieved NFTMetadata from API.\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 nftMetadata,\n }: {\n tokenAddress: string;\n userAddress: string;\n nftMetadata: NftMetadata;\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 // get name and symbol if ERC721 then put together the metadata\n const contractInformation = await this.getNftContractInformation(\n tokenAddress,\n nftMetadata,\n networkClientId,\n );\n const {\n asset_contract_type,\n created_date,\n symbol,\n description,\n external_link,\n schema_name,\n collection: { name, image_url, tokenCount },\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 tokenCount !== null &&\n typeof tokenCount !== 'undefined' && { totalSupply: tokenCount },\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 async ({\n selectedAddress,\n ipfsGateway,\n openSeaEnabled,\n isIpfsGatewayEnabled,\n }) => {\n this.configure({\n selectedAddress,\n ipfsGateway,\n openSeaEnabled,\n isIpfsGatewayEnabled,\n });\n\n const needsUpdateNftMetadata =\n (isIpfsGatewayEnabled && ipfsGateway !== '') || openSeaEnabled;\n\n if (needsUpdateNftMetadata) {\n const { chainId } = this.config;\n const nfts: Nft[] =\n this.state.allNfts[selectedAddress]?.[chainId] ?? [];\n // filter only nfts\n const nftsToUpdate = nfts.filter(\n (singleNft) =>\n !singleNft.name && !singleNft.description && !singleNft.image,\n );\n if (nftsToUpdate.length !== 0) {\n await this.updateNftMetadata({\n nfts: nftsToUpdate,\n userAddress: selectedAddress,\n });\n }\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\n nftMetadata =\n nftMetadata ||\n (await this.getNftInformation(tokenAddress, tokenId, networkClientId));\n\n const newNftContracts = await this.addNftContract({\n tokenAddress,\n userAddress,\n networkClientId,\n source,\n nftMetadata,\n });\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 - nfts to update metadata for.\n * @param options.userAddress - The current user address\n * @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.\n */\n async updateNftMetadata({\n nfts,\n userAddress = this.config.selectedAddress,\n networkClientId,\n }: {\n nfts: Nft[];\n userAddress?: string;\n networkClientId?: NetworkClientId;\n }) {\n const chainId = this.getCorrectChainId({ networkClientId });\n\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 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"],"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;AA4K7B,IAAM,qBAAqB;AAC3B,IAAM,+BAA+B;AA+B9B,IAAM,qBAAqB,MAAgB;AAChD,SAAO;AAAA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
|
|
4
|
+
} from "./chunk-X5PLVMOQ.mjs";
|
|
5
5
|
|
|
6
6
|
// src/Standards/NftStandards/ERC1155/ERC1155Standard.ts
|
|
7
7
|
import { Contract } from "@ethersproject/contracts";
|
|
@@ -212,4 +212,4 @@ var ERC1155Standard = class {
|
|
|
212
212
|
export {
|
|
213
213
|
ERC1155Standard
|
|
214
214
|
};
|
|
215
|
-
//# sourceMappingURL=chunk-
|
|
215
|
+
//# sourceMappingURL=chunk-S7UA2DU7.mjs.map
|