mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix broken NFT import and auto-detect flows (#17384)
* Fix broken NFT import and auto-detect flows
This commit is contained in:
parent
073718d965
commit
3d87f65d9b
@ -342,6 +342,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
...networkState,
|
...networkState,
|
||||||
providerConfig: {
|
providerConfig: {
|
||||||
...networkState.provider,
|
...networkState.provider,
|
||||||
|
chainId: hexToDecimal(networkState.provider.chainId),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return cb(modifiedNetworkState);
|
return cb(modifiedNetworkState);
|
||||||
@ -972,8 +973,11 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
getTokenValueParam(transactionData);
|
getTokenValueParam(transactionData);
|
||||||
const { allNfts } = this.nftController.state;
|
const { allNfts } = this.nftController.state;
|
||||||
|
|
||||||
|
const chainIdAsDecimal = hexToDecimal(chainId);
|
||||||
// check if its a known collectible
|
// check if its a known collectible
|
||||||
const knownCollectible = allNfts?.[userAddress]?.[chainId].find(
|
const knownCollectible = allNfts?.[userAddress]?.[
|
||||||
|
chainIdAsDecimal
|
||||||
|
]?.find(
|
||||||
({ address, tokenId }) =>
|
({ address, tokenId }) =>
|
||||||
isEqualCaseInsensitive(address, contractAddress) &&
|
isEqualCaseInsensitive(address, contractAddress) &&
|
||||||
tokenId === transactionDataTokenId,
|
tokenId === transactionDataTokenId,
|
||||||
@ -984,7 +988,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
this.nftController.checkAndUpdateSingleNftOwnershipStatus(
|
this.nftController.checkAndUpdateSingleNftOwnershipStatus(
|
||||||
knownCollectible,
|
knownCollectible,
|
||||||
false,
|
false,
|
||||||
{ userAddress, chainId },
|
{ userAddress, chainId: chainIdAsDecimal },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import configureStore from '../../../store/store';
|
|||||||
import { renderWithProvider } from '../../../../test/jest/rendering';
|
import { renderWithProvider } from '../../../../test/jest/rendering';
|
||||||
import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes';
|
import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes';
|
||||||
import { setBackgroundConnection } from '../../../../test/jest';
|
import { setBackgroundConnection } from '../../../../test/jest';
|
||||||
|
import { hexToDecimal } from '../../../../shared/modules/conversion.utils';
|
||||||
import CollectiblesTab from '.';
|
import CollectiblesTab from '.';
|
||||||
|
|
||||||
const COLLECTIBLES = [
|
const COLLECTIBLES = [
|
||||||
@ -153,16 +154,17 @@ const render = ({
|
|||||||
useNftDetection,
|
useNftDetection,
|
||||||
onAddNFT = jest.fn(),
|
onAddNFT = jest.fn(),
|
||||||
}) => {
|
}) => {
|
||||||
|
const chainIdAsDecimal = hexToDecimal(chainId);
|
||||||
const store = configureStore({
|
const store = configureStore({
|
||||||
metamask: {
|
metamask: {
|
||||||
allNfts: {
|
allNfts: {
|
||||||
[ACCOUNT_1]: {
|
[ACCOUNT_1]: {
|
||||||
[chainId]: collectibles,
|
[chainIdAsDecimal]: collectibles,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
allNftContracts: {
|
allNftContracts: {
|
||||||
[ACCOUNT_1]: {
|
[ACCOUNT_1]: {
|
||||||
[chainId]: collectibleContracts,
|
[chainIdAsDecimal]: collectibleContracts,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
provider: { chainId },
|
provider: { chainId },
|
||||||
|
@ -17,7 +17,10 @@ import { setCustomGasLimit, setCustomGasPrice } from '../gas/gas.duck';
|
|||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
||||||
import { isEqualCaseInsensitive } from '../../../shared/modules/string-utils';
|
import { isEqualCaseInsensitive } from '../../../shared/modules/string-utils';
|
||||||
import { stripHexPrefix } from '../../../shared/modules/hexstring-utils';
|
import { stripHexPrefix } from '../../../shared/modules/hexstring-utils';
|
||||||
import { decGWEIToHexWEI } from '../../../shared/modules/conversion.utils';
|
import {
|
||||||
|
decGWEIToHexWEI,
|
||||||
|
hexToDecimal,
|
||||||
|
} from '../../../shared/modules/conversion.utils';
|
||||||
|
|
||||||
export default function reduceMetamask(state = {}, action) {
|
export default function reduceMetamask(state = {}, action) {
|
||||||
const metamaskState = {
|
const metamaskState = {
|
||||||
@ -280,7 +283,9 @@ export const getCollectibles = (state) => {
|
|||||||
},
|
},
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
return allNfts?.[selectedAddress]?.[chainId] ?? [];
|
const chainIdAsDecimal = hexToDecimal(chainId);
|
||||||
|
|
||||||
|
return allNfts?.[selectedAddress]?.[chainIdAsDecimal] ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCollectibleContracts = (state) => {
|
export const getCollectibleContracts = (state) => {
|
||||||
@ -292,7 +297,9 @@ export const getCollectibleContracts = (state) => {
|
|||||||
},
|
},
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
return allNftContracts?.[selectedAddress]?.[chainId] ?? [];
|
const chainIdAsDecimal = hexToDecimal(chainId);
|
||||||
|
|
||||||
|
return allNftContracts?.[selectedAddress]?.[chainIdAsDecimal] ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getBlockGasLimit(state) {
|
export function getBlockGasLimit(state) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user