Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: NFT details new design #25524

Merged
merged 45 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
68d912c
feat: NFT detail new design
sahar-fehri Jun 25, 2024
2b3967d
fix: add real values
sahar-fehri Jun 26, 2024
26201a8
fix: add storybooks
sahar-fehri Jun 26, 2024
9ed2b98
fix: design updates
sahar-fehri Jun 27, 2024
601f566
fix: lint
sahar-fehri Jun 27, 2024
b88b124
fix: fix
sahar-fehri Jun 27, 2024
f8fbdf2
fix: fix design
sahar-fehri Jun 27, 2024
cd1c81e
fix: fix design
sahar-fehri Jun 27, 2024
e551de3
fix: fix conflicts
sahar-fehri Jun 27, 2024
588985c
fix: add patch
sahar-fehri Jun 27, 2024
a1417c7
fix: fix tests
sahar-fehri Jun 27, 2024
c2a56cd
fix: fix locales
sahar-fehri Jun 27, 2024
6faee86
fix: fix tests
sahar-fehri Jun 28, 2024
3e3c749
fix: fix tests
sahar-fehri Jun 28, 2024
14b3062
fix: fix tests
sahar-fehri Jun 28, 2024
44800b3
Revert "fix: add patch"
sahar-fehri Jun 28, 2024
676f670
fix: update patch
sahar-fehri Jun 28, 2024
1fb5fb4
fix: make contract and creator address clickable
sahar-fehri Jun 30, 2024
35fa004
fix: fix
sahar-fehri Jul 1, 2024
b5827ab
fix: fix showMore css
sahar-fehri Jul 1, 2024
24d691d
fix: merge conflicts
sahar-fehri Jul 2, 2024
a7c45cf
fix: update patch
sahar-fehri Jul 2, 2024
0bc7edd
fix: delete unused patch
sahar-fehri Jul 2, 2024
fb9922a
fix: add showLess button
sahar-fehri Jul 2, 2024
ab336d4
fix: add storybook for nft detail description
sahar-fehri Jul 2, 2024
baae025
fix: fix
sahar-fehri Jul 2, 2024
557559f
fix: fix css
sahar-fehri Jul 2, 2024
892f613
fix: fix snapshot
sahar-fehri Jul 2, 2024
2859211
fix: fix css
sahar-fehri Jul 3, 2024
03190db
fix: add full image component
sahar-fehri Jul 3, 2024
bff239c
fix: add transition to full image
sahar-fehri Jul 4, 2024
875a85d
Merge branch 'develop' into feat/NFT-details-new-design
sahar-fehri Jul 9, 2024
8d1f67a
fix: fix
sahar-fehri Jul 9, 2024
a51096b
fix: feedback fix
sahar-fehri Jul 12, 2024
8378a26
fix: feedback fix
sahar-fehri Jul 12, 2024
904cc5d
fix: convert new components to tsx
sahar-fehri Jul 12, 2024
7ac5dde
fix: convert to tsx
sahar-fehri Jul 13, 2024
3682682
Revert "fix: convert to tsx"
sahar-fehri Jul 13, 2024
50644e4
Revert "fix: update patch"
sahar-fehri Jul 15, 2024
bd13218
fix: update patch and convert file to tsx
sahar-fehri Jul 15, 2024
4f413ba
Update LavaMoat policies
metamaskbot Jul 15, 2024
1a00cc1
fix: update date format
sahar-fehri Jul 15, 2024
8c7eb89
fix: fix value display
sahar-fehri Jul 15, 2024
eba470b
fix: fix lint
sahar-fehri Jul 16, 2024
9d75a7f
Merge branch 'develop' into feat/NFT-details-new-design
sahar-fehri Jul 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
diff --git a/dist/chunk-354SINOH.js b/dist/chunk-354SINOH.js
pedronfigueiredo marked this conversation as resolved.
Show resolved Hide resolved
index 7f87776370b755bf04765b8a0ae0145bf3a0b5e6..e0b47123b31b3c7779e903180afc6c692953b6c2 100644
--- a/dist/chunk-354SINOH.js
+++ b/dist/chunk-354SINOH.js
@@ -12,7 +12,8 @@ var _basecontroller = require('@metamask/base-controller');



-
+var MAX_GET_COLLECTION_BATCH_SIZE = 20;
+var _chunkNYVA7ZTQjs = require('./chunk-NYVA7ZTQ.js');

var _controllerutils = require('@metamask/controller-utils');
var _utils = require('@metamask/utils');
@@ -134,6 +135,60 @@ var NftDetectionController = class extends _basecontroller.BaseController {
apiNfts = resultNftApi.tokens.filter(
(elm) => elm.token.isSpam === false && (elm.blockaidResult?.result_type ? elm.blockaidResult?.result_type === "Benign" /* Benign */ : true)
);
+ const collections = apiNfts.reduce((acc, currValue) => {
+ if (!acc.includes(currValue.token.contract) && currValue.token.contract === currValue?.token?.collection?.id) {
+ acc.push(currValue.token.contract);
+ }
+ return acc;
+ }, []);
+ if (collections.length !== 0) {
+ const collectionResponse = await _chunkNYVA7ZTQjs.reduceInBatchesSerially.call(void 0, {
+ values: collections,
+ batchSize: MAX_GET_COLLECTION_BATCH_SIZE,
+ eachBatch: async (allResponses, batch) => {
+ const params = new URLSearchParams(
+ batch.map((s) => ["contract", s])
+ );
+ params.append("chainId", "1");
+ const collectionResponseForBatch = await _controllerutils.fetchWithErrorHandling.call(void 0,
+ {
+ url: `${_controllerutils.NFT_API_BASE_URL}/collections?${params.toString()}`,
+ options: {
+ headers: {
+ Version: _controllerutils.NFT_API_VERSION
+ }
+ },
+ timeout: _controllerutils.NFT_API_TIMEOUT
+ }
+ );
+ return {
+ ...allResponses,
+ ...collectionResponseForBatch
+ };
+ },
+ initialResult: {}
+ });
+ if (collectionResponse.collections?.length) {
+ apiNfts.forEach((singleNFT) => {
+ const found = collectionResponse.collections.find(
+ (elm) => elm.id?.toLowerCase() === singleNFT.token.contract.toLowerCase()
+ );
+ if (found) {
+ singleNFT.token = {
+ ...singleNFT.token,
+ collection: {
+ ...singleNFT.token.collection ? singleNFT.token.collection : {},
+ creator: found?.creator,
+ openseaVerificationStatus: found?.openseaVerificationStatus,
+ contractDeployedAt: found.contractDeployedAt,
+ ownerCount: found.ownerCount,
+ topBid: found.topBid
+ }
+ };
+ }
+ });
+ }
+ }
const addNftPromises = apiNfts.map(async (nft) => {
const {
tokenId,
diff --git a/dist/chunk-7JWDWDXT.js b/dist/chunk-7JWDWDXT.js
index af5d78416658763da52305f9e08b286733310898..5f1d7268ed8b102e0aab9f09c3896ea6fba6a0a8 100644
--- a/dist/chunk-7JWDWDXT.js
+++ b/dist/chunk-7JWDWDXT.js
@@ -881,6 +881,18 @@ getNftInformationFromApi_fn = async function(contractAddress, tokenId) {
}
}
});
+ const getCollectionParams = new URLSearchParams({
+ chainId: "1",
+ id: `${nftInformation?.tokens[0]?.token?.collection?.id}`
+ }).toString();
+ const collectionInformation = await _controllerutils.fetchWithErrorHandling.call(void 0, {
+ url: `${_controllerutils.NFT_API_BASE_URL}/collections?${getCollectionParams}`,
+ options: {
+ headers: {
+ Version: _controllerutils.NFT_API_VERSION
+ }
+ }
+ });
if (!nftInformation?.tokens?.[0]?.token) {
return {
name: null,
@@ -918,7 +930,16 @@ getNftInformationFromApi_fn = async function(contractAddress, tokenId) {
},
rarityRank && { rarityRank },
rarity && { rarity },
- collection && { collection }
+ (collection || collectionInformation) && {
+ collection: {
+ ...collection || {},
+ creator: collection?.creator || collectionInformation?.collections[0].creator,
+ openseaVerificationStatus: collectionInformation?.collections[0].openseaVerificationStatus,
+ contractDeployedAt: collectionInformation?.collections[0].contractDeployedAt,
+ ownerCount: collectionInformation?.collections[0].ownerCount,
+ topBid: collectionInformation?.collections[0].topBid
+ }
+ }
);
return nftMetadata;
};
@@ -1095,7 +1116,8 @@ addIndividualNft_fn = async function(tokenAddress, tokenId, nftMetadata, nftCont
nftMetadata,
existingEntry
);
- if (!differentMetadata && existingEntry.isCurrentlyOwned) {
+ const hasNewFields = hasNewCollectionFields(nftMetadata, existingEntry);
+ if (!differentMetadata && existingEntry.isCurrentlyOwned && !hasNewFields) {
return;
}
const indexToUpdate = nfts.findIndex(
diff --git a/dist/chunk-NYVA7ZTQ.js b/dist/chunk-NYVA7ZTQ.js
index f31fdabedc067227407a6320e57a670f86b972f4..c0ff7ece56dc5f3e68149d114ff16f7d10eb1741 100644
--- a/dist/chunk-NYVA7ZTQ.js
+++ b/dist/chunk-NYVA7ZTQ.js
@@ -27,6 +27,11 @@ function compareNftMetadata(newNftMetadata, nft) {
}, 0);
return differentValues > 0;
}
+function hasNewCollectionFields(newNftMetadata, nft) {
+ const keysNewNftMetadata = Object.keys(newNftMetadata.collection || {});
+ const keysExistingNft = new Set(Object.keys(nft.collection || {}));
+ return keysNewNftMetadata.some((key) => !keysExistingNft.has(key));
+}
var aggregatorNameByKey = {
aave: "Aave",
bancor: "Bancor",
@@ -205,5 +210,5 @@ async function fetchTokenContractExchangeRates({



-exports.TOKEN_PRICES_BATCH_SIZE = TOKEN_PRICES_BATCH_SIZE; exports.compareNftMetadata = compareNftMetadata; exports.formatAggregatorNames = formatAggregatorNames; exports.formatIconUrlWithProxy = formatIconUrlWithProxy; exports.SupportedTokenDetectionNetworks = SupportedTokenDetectionNetworks; exports.isTokenDetectionSupportedForNetwork = isTokenDetectionSupportedForNetwork; exports.isTokenListSupportedForNetwork = isTokenListSupportedForNetwork; exports.removeIpfsProtocolPrefix = removeIpfsProtocolPrefix; exports.getIpfsCIDv1AndPath = getIpfsCIDv1AndPath; exports.getFormattedIpfsUrl = getFormattedIpfsUrl; exports.addUrlProtocolPrefix = addUrlProtocolPrefix; exports.ethersBigNumberToBN = ethersBigNumberToBN; exports.divideIntoBatches = divideIntoBatches; exports.reduceInBatchesSerially = reduceInBatchesSerially; exports.fetchTokenContractExchangeRates = fetchTokenContractExchangeRates;
+exports.TOKEN_PRICES_BATCH_SIZE = TOKEN_PRICES_BATCH_SIZE; exports.compareNftMetadata = compareNftMetadata; exports.hasNewCollectionFields = hasNewCollectionFields; exports.formatAggregatorNames = formatAggregatorNames; exports.formatIconUrlWithProxy = formatIconUrlWithProxy; exports.SupportedTokenDetectionNetworks = SupportedTokenDetectionNetworks; exports.isTokenDetectionSupportedForNetwork = isTokenDetectionSupportedForNetwork; exports.isTokenListSupportedForNetwork = isTokenListSupportedForNetwork; exports.removeIpfsProtocolPrefix = removeIpfsProtocolPrefix; exports.getIpfsCIDv1AndPath = getIpfsCIDv1AndPath; exports.getFormattedIpfsUrl = getFormattedIpfsUrl; exports.addUrlProtocolPrefix = addUrlProtocolPrefix; exports.ethersBigNumberToBN = ethersBigNumberToBN; exports.divideIntoBatches = divideIntoBatches; exports.reduceInBatchesSerially = reduceInBatchesSerially; exports.fetchTokenContractExchangeRates = fetchTokenContractExchangeRates;
//# sourceMappingURL=chunk-NYVA7ZTQ.js.map
\ No newline at end of file
diff --git a/dist/types/NftController.d.ts b/dist/types/NftController.d.ts
index b663e265475fee486f1e570736a08f2c06ce5479..0252b138bb4f1cbcbfab7c6eadc8ba28fe5af674 100644
--- a/dist/types/NftController.d.ts
+++ b/dist/types/NftController.d.ts
@@ -7,7 +7,7 @@ import type { PreferencesControllerStateChangeEvent } from '@metamask/preference
import type { Hex } from '@metamask/utils';
import type { AssetsContractController } from './AssetsContractController';
import { Source } from './constants';
-import type { Collection, Attributes, LastSale } from './NftDetectionController';
+import type { Collection, Attributes, LastSale, TopBid } from './NftDetectionController';
type NFTStandardType = 'ERC721' | 'ERC1155';
type SuggestedNftMeta = {
asset: {
@@ -110,9 +110,10 @@ export type NftMetadata = {
tokenURI?: string | null;
collection?: Collection;
address?: string;
- attributes?: Attributes;
+ attributes?: Attributes[];
lastSale?: LastSale;
rarityRank?: string;
+ topBid?: TopBid;
};
/**
* @type NftControllerState
diff --git a/dist/types/NftDetectionController.d.ts b/dist/types/NftDetectionController.d.ts
index c645b3ada1ad9dd862428e94adb788f7892c99ad..ad2df53b8225c105b67245f6498702920f882f95 100644
--- a/dist/types/NftDetectionController.d.ts
+++ b/dist/types/NftDetectionController.d.ts
@@ -227,7 +227,43 @@ export type Attributes = {
topBidValue?: number | null;
createdAt?: string;
};
-export type Collection = {
+
+export type GetCollectionsResponse = {
+ collections: CollectionResponse[];
+ };
+
+export type CollectionResponse = {
+ id?: string;
+ openseaVerificationStatus?: string;
+ contractDeployedAt?: string;
+ creator?: string;
+ ownerCount?: string;
+ topBid?: TopBid & {
+ sourceDomain?: string;
+ };
+};
+
+export type FloorAskCollection = {
+ id?: string;
+ price?: Price;
+ maker?: string;
+ kind?: string;
+ validFrom?: number;
+ validUntil?: number;
+ source?: SourceCollection;
+ rawData?: Metadata;
+ isNativeOffChainCancellable?: boolean;
+};
+
+export type SourceCollection = {
+ id: string;
+ domain: string;
+ name: string;
+ icon: string;
+ url: string;
+};
+
+export type TokenCollection = {
id?: string;
name?: string;
slug?: string;
@@ -243,7 +279,10 @@ export type Collection = {
floorAskPrice?: Price;
royaltiesBps?: number;
royalties?: Royalties[];
-};
+ floorAsk?: FloorAskCollection;
+ };
+
+export type Collection = TokenCollection & CollectionResponse;
export type Royalties = {
bps?: number;
recipient?: string;
3 changes: 0 additions & 3 deletions app/_locales/de/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/el/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 45 additions & 3 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading