Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 14 additions & 6 deletions app/components/UI/CollectibleContracts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
} from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds';
import Logger from '../../../util/Logger';
import { useMetrics } from '../../../components/hooks/useMetrics';
import { CHAIN_IDS } from '@metamask/transaction-controller/dist/constants';

const createStyles = (colors) =>
StyleSheet.create({
Expand Down Expand Up @@ -191,12 +192,19 @@ const CollectibleContracts = ({

useEffect(() => {
// TO DO: Move this fix to the controllers layer
collectibles.forEach((collectible) => {
if (shouldUpdateCollectibleMetadata(collectible)) {
updateCollectibleMetadata(collectible);
}
});
}, [collectibles, updateCollectibleMetadata]);
// The nft autodetection is enabled on mainnet (only as of today), there is no need to run this if we are on mainnet
// because the detectNfts fct will refetch the data.
// I see that the reason we have this if when we are on other networks !==Eth and the user tries to refresh, then we should be able
// to refetch for all NFTs
// We should avoid running for networks where we support NFT autodetection.
if (chainId !== CHAIN_IDS.MAINNET) {
collectibles.forEach((collectible) => {
if (shouldUpdateCollectibleMetadata(collectible)) {
updateCollectibleMetadata(collectible);
}
});
}
}, [collectibles, updateCollectibleMetadata, chainId]);

const memoizedCollectibles = useMemo(() => collectibles, [collectibles]);

Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/CollectibleMedia/CollectibleMedia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ const CollectibleMedia: React.FC<CollectibleMediaProps> = ({
const fallback = useCallback(() => setSourceUri(null), []);

useEffect(() => {
const { image, imagePreview, address } = collectible;
const { image, imageOriginal, imagePreview, address } = collectible;
if (address) {
if (small && imagePreview && imagePreview !== '')
setSourceUri(imagePreview);
else setSourceUri(image);
else setSourceUri((image || imageOriginal) ?? null);
}
}, [collectible, small, big, setSourceUri]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Collectible {
tokenURI: string;
contractName?: string;
standard: string;
imageOriginal?: string;
error: string | undefined;
}

Expand Down
18,208 changes: 17,253 additions & 955 deletions patches/@metamask+assets-controllers+12.0.0.patch

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions patches/@metamask+controller-utils+4.3.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ index dd0be20..56cfc46 100644
/**
* Approval request types for various operations.
diff --git a/node_modules/@metamask/controller-utils/dist/constants.js b/node_modules/@metamask/controller-utils/dist/constants.js
index 90ede0b..d5f7202 100644
index 90ede0b..e30ca89 100644
--- a/node_modules/@metamask/controller-utils/dist/constants.js
+++ b/node_modules/@metamask/controller-utils/dist/constants.js
@@ -38,6 +38,7 @@ exports.TESTNET_TICKER_SYMBOLS = {
Expand All @@ -54,18 +54,19 @@ index 90ede0b..d5f7202 100644
[types_1.NetworkType['linea-mainnet']]: {
chainId: types_1.ChainId['linea-mainnet'],
ticker: types_1.NetworksTicker['linea-mainnet'],
@@ -85,9 +93,7 @@ exports.BUILT_IN_NETWORKS = {
@@ -85,9 +93,8 @@ exports.BUILT_IN_NETWORKS = {
},
};
// APIs
-exports.OPENSEA_PROXY_URL = 'https://proxy.metafi.codefi.network/opensea/v1/api/v1';
-exports.OPENSEA_API_URL = 'https://api.opensea.io/api/v1';
-exports.OPENSEA_TEST_API_URL = 'https://testnets-api.opensea.io/api/v1';
+exports.OPENSEA_PROXY_URL = 'https://proxy.metafi.codefi.network/opensea/v1/api/v2';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps these could be made configurable, instead of harcoded constants, in the upstream package? Would simplify this, remove the need for a patch, and these could be treated like any build config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @legobeat !
Are there examples of how we can make the url configurable? also do you think it can be done on a separate PR?
I will close this PR and create a new one because the assets-controller version on mobile has been upgraded and i will be using a different core branch to create the patch 🙏

+exports.NFT_API_BASE_URL = 'https://nft.api.cx.metamask.io';
// Default origin for controllers
exports.ORIGIN_METAMASK = 'metamask';
/**
@@ -121,6 +127,7 @@ exports.NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP = {
@@ -121,6 +128,7 @@ exports.NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP = {
[types_1.NetworkId.sepolia]: types_1.NetworkType.sepolia,
[types_1.NetworkId.mainnet]: types_1.NetworkType.mainnet,
[types_1.NetworkId['linea-goerli']]: types_1.NetworkType['linea-goerli'],
Expand Down