mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Update @metamask/controllers
to v33 (#16493)
The controllers package has been updated to v33. The only breaking change in this release was to rename the term "collectible" to "NFT" wherever it appeared in the API. Changes in this PR have been kept minimal; additional renaming can be done in separate PRs. This PR only updates the controller names, controller state, controller methods, and any direct references to these things. NFTs are still called "collectibles" in most places.
This commit is contained in:
parent
b898115bad
commit
4f66dc948f
@ -1454,7 +1454,7 @@ export const MOCK_TRANSACTION_BY_TYPE = {
|
|||||||
dappSuggestedGasFees: null,
|
dappSuggestedGasFees: null,
|
||||||
sendFlowHistory: [
|
sendFlowHistory: [
|
||||||
{
|
{
|
||||||
entry: 'sendFlow - user set asset type to COLLECTIBLE',
|
entry: 'sendFlow - user set asset type to NFT',
|
||||||
timestamp: 1653457317999,
|
timestamp: 1653457317999,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1504,7 +1504,7 @@ export const MOCK_TRANSACTION_BY_TYPE = {
|
|||||||
dappSuggestedGasFees: null,
|
dappSuggestedGasFees: null,
|
||||||
sendFlowHistory: [
|
sendFlowHistory: [
|
||||||
{
|
{
|
||||||
entry: 'sendFlow - user set asset type to COLLECTIBLE',
|
entry: 'sendFlow - user set asset type to NFT',
|
||||||
timestamp: 1653457317999,
|
timestamp: 1653457317999,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -706,15 +706,14 @@ export default class MetaMetricsController {
|
|||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
[TRAITS.NFT_AUTODETECTION_ENABLED]: metamaskState.useCollectibleDetection,
|
[TRAITS.NFT_AUTODETECTION_ENABLED]: metamaskState.useNftDetection,
|
||||||
[TRAITS.NUMBER_OF_ACCOUNTS]: Object.values(metamaskState.identities)
|
[TRAITS.NUMBER_OF_ACCOUNTS]: Object.values(metamaskState.identities)
|
||||||
.length,
|
.length,
|
||||||
[TRAITS.NUMBER_OF_NFT_COLLECTIONS]: this._getAllUniqueNFTAddressesLength(
|
[TRAITS.NUMBER_OF_NFT_COLLECTIONS]: this._getAllUniqueNFTAddressesLength(
|
||||||
metamaskState.allCollectibles,
|
metamaskState.allNfts,
|
||||||
),
|
),
|
||||||
[TRAITS.NUMBER_OF_NFTS]: this._getAllNFTsFlattened(
|
[TRAITS.NUMBER_OF_NFTS]: this._getAllNFTsFlattened(metamaskState.allNfts)
|
||||||
metamaskState.allCollectibles,
|
.length,
|
||||||
).length,
|
|
||||||
[TRAITS.NUMBER_OF_TOKENS]: this._getNumberOfTokens(metamaskState),
|
[TRAITS.NUMBER_OF_TOKENS]: this._getNumberOfTokens(metamaskState),
|
||||||
[TRAITS.OPENSEA_API_ENABLED]: metamaskState.openSeaEnabled,
|
[TRAITS.OPENSEA_API_ENABLED]: metamaskState.openSeaEnabled,
|
||||||
[TRAITS.THREE_BOX_ENABLED]: false, // deprecated, hard-coded as false
|
[TRAITS.THREE_BOX_ENABLED]: false, // deprecated, hard-coded as false
|
||||||
@ -765,11 +764,11 @@ export default class MetaMetricsController {
|
|||||||
* Returns an array of all of the collectibles/NFTs the user
|
* Returns an array of all of the collectibles/NFTs the user
|
||||||
* possesses across all networks and accounts.
|
* possesses across all networks and accounts.
|
||||||
*
|
*
|
||||||
* @param {object} allCollectibles
|
* @param {object} allNfts
|
||||||
* @returns {[]}
|
* @returns {[]}
|
||||||
*/
|
*/
|
||||||
_getAllNFTsFlattened = memoize((allCollectibles = {}) => {
|
_getAllNFTsFlattened = memoize((allNfts = {}) => {
|
||||||
return Object.values(allCollectibles).reduce((result, chainNFTs) => {
|
return Object.values(allNfts).reduce((result, chainNFTs) => {
|
||||||
return result.concat(...Object.values(chainNFTs));
|
return result.concat(...Object.values(chainNFTs));
|
||||||
}, []);
|
}, []);
|
||||||
});
|
});
|
||||||
@ -778,11 +777,11 @@ export default class MetaMetricsController {
|
|||||||
* Returns the number of unique collectible/NFT addresses the user
|
* Returns the number of unique collectible/NFT addresses the user
|
||||||
* possesses across all networks and accounts.
|
* possesses across all networks and accounts.
|
||||||
*
|
*
|
||||||
* @param {object} allCollectibles
|
* @param {object} allNfts
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
_getAllUniqueNFTAddressesLength(allCollectibles = {}) {
|
_getAllUniqueNFTAddressesLength(allNfts = {}) {
|
||||||
const allNFTAddresses = this._getAllNFTsFlattened(allCollectibles).map(
|
const allNFTAddresses = this._getAllNFTsFlattened(allNfts).map(
|
||||||
(nft) => nft.address,
|
(nft) => nft.address,
|
||||||
);
|
);
|
||||||
const uniqueAddresses = new Set(allNFTAddresses);
|
const uniqueAddresses = new Set(allNFTAddresses);
|
||||||
|
@ -717,7 +717,7 @@ describe('MetaMetricsController', function () {
|
|||||||
[CHAIN_IDS.MAINNET]: [{ address: '0x' }],
|
[CHAIN_IDS.MAINNET]: [{ address: '0x' }],
|
||||||
[CHAIN_IDS.GOERLI]: [{ address: '0x' }, { address: '0x0' }],
|
[CHAIN_IDS.GOERLI]: [{ address: '0x' }, { address: '0x0' }],
|
||||||
},
|
},
|
||||||
allCollectibles: {
|
allNfts: {
|
||||||
'0xac706cE8A9BF27Afecf080fB298d0ee13cfb978A': {
|
'0xac706cE8A9BF27Afecf080fB298d0ee13cfb978A': {
|
||||||
56: [
|
56: [
|
||||||
{
|
{
|
||||||
@ -752,7 +752,7 @@ describe('MetaMetricsController', function () {
|
|||||||
identities: [{}, {}],
|
identities: [{}, {}],
|
||||||
ledgerTransportType: 'web-hid',
|
ledgerTransportType: 'web-hid',
|
||||||
openSeaEnabled: true,
|
openSeaEnabled: true,
|
||||||
useCollectibleDetection: false,
|
useNftDetection: false,
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
useTokenDetection: true,
|
useTokenDetection: true,
|
||||||
});
|
});
|
||||||
@ -790,7 +790,7 @@ describe('MetaMetricsController', function () {
|
|||||||
ledgerTransportType: 'web-hid',
|
ledgerTransportType: 'web-hid',
|
||||||
openSeaEnabled: true,
|
openSeaEnabled: true,
|
||||||
identities: [{}, {}],
|
identities: [{}, {}],
|
||||||
useCollectibleDetection: false,
|
useNftDetection: false,
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
useTokenDetection: true,
|
useTokenDetection: true,
|
||||||
});
|
});
|
||||||
@ -810,7 +810,7 @@ describe('MetaMetricsController', function () {
|
|||||||
ledgerTransportType: 'web-hid',
|
ledgerTransportType: 'web-hid',
|
||||||
openSeaEnabled: false,
|
openSeaEnabled: false,
|
||||||
identities: [{}, {}, {}],
|
identities: [{}, {}, {}],
|
||||||
useCollectibleDetection: false,
|
useNftDetection: false,
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
useTokenDetection: true,
|
useTokenDetection: true,
|
||||||
});
|
});
|
||||||
@ -838,7 +838,7 @@ describe('MetaMetricsController', function () {
|
|||||||
ledgerTransportType: 'web-hid',
|
ledgerTransportType: 'web-hid',
|
||||||
openSeaEnabled: true,
|
openSeaEnabled: true,
|
||||||
identities: [{}, {}],
|
identities: [{}, {}],
|
||||||
useCollectibleDetection: true,
|
useNftDetection: true,
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
useTokenDetection: true,
|
useTokenDetection: true,
|
||||||
});
|
});
|
||||||
@ -856,7 +856,7 @@ describe('MetaMetricsController', function () {
|
|||||||
ledgerTransportType: 'web-hid',
|
ledgerTransportType: 'web-hid',
|
||||||
openSeaEnabled: true,
|
openSeaEnabled: true,
|
||||||
identities: [{}, {}],
|
identities: [{}, {}],
|
||||||
useCollectibleDetection: true,
|
useNftDetection: true,
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
useTokenDetection: true,
|
useTokenDetection: true,
|
||||||
});
|
});
|
||||||
|
@ -39,7 +39,7 @@ export default class PreferencesController {
|
|||||||
// set to true means the dynamic list from the API is being used
|
// set to true means the dynamic list from the API is being used
|
||||||
// set to false will be using the static list from contract-metadata
|
// set to false will be using the static list from contract-metadata
|
||||||
useTokenDetection: false,
|
useTokenDetection: false,
|
||||||
useCollectibleDetection: false,
|
useNftDetection: false,
|
||||||
openSeaEnabled: false,
|
openSeaEnabled: false,
|
||||||
advancedGasFee: null,
|
advancedGasFee: null,
|
||||||
|
|
||||||
@ -142,12 +142,12 @@ export default class PreferencesController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the `useCollectibleDetection` property
|
* Setter for the `useNftDetection` property
|
||||||
*
|
*
|
||||||
* @param {boolean} useCollectibleDetection - Whether or not the user prefers to autodetect collectibles.
|
* @param {boolean} useNftDetection - Whether or not the user prefers to autodetect collectibles.
|
||||||
*/
|
*/
|
||||||
setUseCollectibleDetection(useCollectibleDetection) {
|
setUseNftDetection(useNftDetection) {
|
||||||
this.store.updateState({ useCollectibleDetection });
|
this.store.updateState({ useNftDetection });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -308,21 +308,21 @@ describe('preferences controller', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setUseCollectibleDetection', function () {
|
describe('setUseNftDetection', function () {
|
||||||
it('should default to false', function () {
|
it('should default to false', function () {
|
||||||
const state = preferencesController.store.getState();
|
const state = preferencesController.store.getState();
|
||||||
assert.equal(state.useCollectibleDetection, false);
|
assert.equal(state.useNftDetection, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the useCollectibleDetection property in state', function () {
|
it('should set the useNftDetection property in state', function () {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
preferencesController.store.getState().useCollectibleDetection,
|
preferencesController.store.getState().useNftDetection,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
preferencesController.setOpenSeaEnabled(true);
|
preferencesController.setOpenSeaEnabled(true);
|
||||||
preferencesController.setUseCollectibleDetection(true);
|
preferencesController.setUseNftDetection(true);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
preferencesController.store.getState().useCollectibleDetection,
|
preferencesController.store.getState().useNftDetection,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -34,9 +34,9 @@ import {
|
|||||||
TokenListController,
|
TokenListController,
|
||||||
TokensController,
|
TokensController,
|
||||||
TokenRatesController,
|
TokenRatesController,
|
||||||
CollectiblesController,
|
NftController,
|
||||||
AssetsContractController,
|
AssetsContractController,
|
||||||
CollectibleDetectionController,
|
NftDetectionController,
|
||||||
PermissionController,
|
PermissionController,
|
||||||
SubjectMetadataController,
|
SubjectMetadataController,
|
||||||
PermissionsRequestNotFoundError,
|
PermissionsRequestNotFoundError,
|
||||||
@ -314,7 +314,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
initState.AssetsContractController,
|
initState.AssetsContractController,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.collectiblesController = new CollectiblesController(
|
this.nftController = new NftController(
|
||||||
{
|
{
|
||||||
onPreferencesStateChange:
|
onPreferencesStateChange:
|
||||||
this.preferencesController.store.subscribe.bind(
|
this.preferencesController.store.subscribe.bind(
|
||||||
@ -345,14 +345,14 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
this.assetsContractController.getERC1155TokenURI.bind(
|
this.assetsContractController.getERC1155TokenURI.bind(
|
||||||
this.assetsContractController,
|
this.assetsContractController,
|
||||||
),
|
),
|
||||||
onCollectibleAdded: ({ address, symbol, tokenId, standard, source }) =>
|
onNftAdded: ({ address, symbol, tokenId, standard, source }) =>
|
||||||
this.metaMetricsController.trackEvent({
|
this.metaMetricsController.trackEvent({
|
||||||
event: EVENT_NAMES.NFT_ADDED,
|
event: EVENT_NAMES.NFT_ADDED,
|
||||||
category: EVENT.CATEGORIES.WALLET,
|
category: EVENT.CATEGORIES.WALLET,
|
||||||
properties: {
|
properties: {
|
||||||
token_contract_address: address,
|
token_contract_address: address,
|
||||||
token_symbol: symbol,
|
token_symbol: symbol,
|
||||||
asset_type: ASSET_TYPES.COLLECTIBLE,
|
asset_type: ASSET_TYPES.NFT,
|
||||||
token_standard: standard,
|
token_standard: standard,
|
||||||
source,
|
source,
|
||||||
},
|
},
|
||||||
@ -362,34 +362,29 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
initState.CollectiblesController,
|
initState.NftController,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.collectiblesController.setApiKey(process.env.OPENSEA_KEY);
|
this.nftController.setApiKey(process.env.OPENSEA_KEY);
|
||||||
|
|
||||||
process.env.COLLECTIBLES_V1 &&
|
process.env.COLLECTIBLES_V1 &&
|
||||||
(this.collectibleDetectionController = new CollectibleDetectionController(
|
(this.nftDetectionController = new NftDetectionController({
|
||||||
{
|
onNftsStateChange: (listener) => this.nftController.subscribe(listener),
|
||||||
onCollectiblesStateChange: (listener) =>
|
onPreferencesStateChange:
|
||||||
this.collectiblesController.subscribe(listener),
|
this.preferencesController.store.subscribe.bind(
|
||||||
onPreferencesStateChange:
|
this.preferencesController.store,
|
||||||
this.preferencesController.store.subscribe.bind(
|
|
||||||
this.preferencesController.store,
|
|
||||||
),
|
|
||||||
onNetworkStateChange: this.networkController.store.subscribe.bind(
|
|
||||||
this.networkController.store,
|
|
||||||
),
|
),
|
||||||
getOpenSeaApiKey: () => this.collectiblesController.openSeaApiKey,
|
onNetworkStateChange: this.networkController.store.subscribe.bind(
|
||||||
getBalancesInSingleCall:
|
this.networkController.store,
|
||||||
this.assetsContractController.getBalancesInSingleCall.bind(
|
),
|
||||||
this.assetsContractController,
|
getOpenSeaApiKey: () => this.nftController.openSeaApiKey,
|
||||||
),
|
getBalancesInSingleCall:
|
||||||
addCollectible: this.collectiblesController.addCollectible.bind(
|
this.assetsContractController.getBalancesInSingleCall.bind(
|
||||||
this.collectiblesController,
|
this.assetsContractController,
|
||||||
),
|
),
|
||||||
getCollectiblesState: () => this.collectiblesController.state,
|
addNft: this.nftController.addNft.bind(this.nftController),
|
||||||
},
|
getNftState: () => this.nftController.state,
|
||||||
));
|
}));
|
||||||
|
|
||||||
this.metaMetricsController = new MetaMetricsController({
|
this.metaMetricsController = new MetaMetricsController({
|
||||||
segment,
|
segment,
|
||||||
@ -897,12 +892,10 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
const transactionDataTokenId =
|
const transactionDataTokenId =
|
||||||
getTokenIdParam(transactionData) ??
|
getTokenIdParam(transactionData) ??
|
||||||
getTokenValueParam(transactionData);
|
getTokenValueParam(transactionData);
|
||||||
const { allCollectibles } = this.collectiblesController.state;
|
const { allNfts } = this.nftController.state;
|
||||||
|
|
||||||
// check if its a known collectible
|
// check if its a known collectible
|
||||||
const knownCollectible = allCollectibles?.[userAddress]?.[
|
const knownCollectible = allNfts?.[userAddress]?.[chainId].find(
|
||||||
chainId
|
|
||||||
].find(
|
|
||||||
({ address, tokenId }) =>
|
({ address, tokenId }) =>
|
||||||
isEqualCaseInsensitive(address, contractAddress) &&
|
isEqualCaseInsensitive(address, contractAddress) &&
|
||||||
tokenId === transactionDataTokenId,
|
tokenId === transactionDataTokenId,
|
||||||
@ -910,7 +903,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
|
|
||||||
// if it is we check and update ownership status.
|
// if it is we check and update ownership status.
|
||||||
if (knownCollectible) {
|
if (knownCollectible) {
|
||||||
this.collectiblesController.checkAndUpdateSingleCollectibleOwnershipStatus(
|
this.nftController.checkAndUpdateSingleNftOwnershipStatus(
|
||||||
knownCollectible,
|
knownCollectible,
|
||||||
false,
|
false,
|
||||||
{ userAddress, chainId },
|
{ userAddress, chainId },
|
||||||
@ -1058,7 +1051,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
TokenListController: this.tokenListController,
|
TokenListController: this.tokenListController,
|
||||||
TokensController: this.tokensController,
|
TokensController: this.tokensController,
|
||||||
SmartTransactionsController: this.smartTransactionsController,
|
SmartTransactionsController: this.smartTransactionsController,
|
||||||
CollectiblesController: this.collectiblesController,
|
NftController: this.nftController,
|
||||||
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
||||||
SnapController: this.snapController,
|
SnapController: this.snapController,
|
||||||
CronjobController: this.cronjobController,
|
CronjobController: this.cronjobController,
|
||||||
@ -1100,7 +1093,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
TokenListController: this.tokenListController,
|
TokenListController: this.tokenListController,
|
||||||
TokensController: this.tokensController,
|
TokensController: this.tokensController,
|
||||||
SmartTransactionsController: this.smartTransactionsController,
|
SmartTransactionsController: this.smartTransactionsController,
|
||||||
CollectiblesController: this.collectiblesController,
|
NftController: this.nftController,
|
||||||
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
||||||
SnapController: this.snapController,
|
SnapController: this.snapController,
|
||||||
CronjobController: this.cronjobController,
|
CronjobController: this.cronjobController,
|
||||||
@ -1504,8 +1497,8 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
addressBookController,
|
addressBookController,
|
||||||
alertController,
|
alertController,
|
||||||
appStateController,
|
appStateController,
|
||||||
collectiblesController,
|
nftController,
|
||||||
collectibleDetectionController,
|
nftDetectionController,
|
||||||
currencyRateController,
|
currencyRateController,
|
||||||
detectTokensController,
|
detectTokensController,
|
||||||
ensController,
|
ensController,
|
||||||
@ -1544,10 +1537,9 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
setUseTokenDetection: preferencesController.setUseTokenDetection.bind(
|
setUseTokenDetection: preferencesController.setUseTokenDetection.bind(
|
||||||
preferencesController,
|
preferencesController,
|
||||||
),
|
),
|
||||||
setUseCollectibleDetection:
|
setUseNftDetection: preferencesController.setUseNftDetection.bind(
|
||||||
preferencesController.setUseCollectibleDetection.bind(
|
preferencesController,
|
||||||
preferencesController,
|
),
|
||||||
),
|
|
||||||
setOpenSeaEnabled: preferencesController.setOpenSeaEnabled.bind(
|
setOpenSeaEnabled: preferencesController.setOpenSeaEnabled.bind(
|
||||||
preferencesController,
|
preferencesController,
|
||||||
),
|
),
|
||||||
@ -1657,38 +1649,25 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
// AssetsContractController
|
// AssetsContractController
|
||||||
getTokenStandardAndDetails: this.getTokenStandardAndDetails.bind(this),
|
getTokenStandardAndDetails: this.getTokenStandardAndDetails.bind(this),
|
||||||
|
|
||||||
// CollectiblesController
|
// NftController
|
||||||
addCollectible: collectiblesController.addCollectible.bind(
|
addNft: nftController.addNft.bind(nftController),
|
||||||
collectiblesController,
|
|
||||||
),
|
|
||||||
|
|
||||||
addCollectibleVerifyOwnership:
|
addNftVerifyOwnership:
|
||||||
collectiblesController.addCollectibleVerifyOwnership.bind(
|
nftController.addNftVerifyOwnership.bind(nftController),
|
||||||
collectiblesController,
|
|
||||||
|
removeAndIgnoreNft: nftController.removeAndIgnoreNft.bind(nftController),
|
||||||
|
|
||||||
|
removeNft: nftController.removeNft.bind(nftController),
|
||||||
|
|
||||||
|
checkAndUpdateAllNftsOwnershipStatus:
|
||||||
|
nftController.checkAndUpdateAllNftsOwnershipStatus.bind(nftController),
|
||||||
|
|
||||||
|
checkAndUpdateSingleNftOwnershipStatus:
|
||||||
|
nftController.checkAndUpdateSingleNftOwnershipStatus.bind(
|
||||||
|
nftController,
|
||||||
),
|
),
|
||||||
|
|
||||||
removeAndIgnoreCollectible:
|
isNftOwner: nftController.isNftOwner.bind(nftController),
|
||||||
collectiblesController.removeAndIgnoreCollectible.bind(
|
|
||||||
collectiblesController,
|
|
||||||
),
|
|
||||||
|
|
||||||
removeCollectible: collectiblesController.removeCollectible.bind(
|
|
||||||
collectiblesController,
|
|
||||||
),
|
|
||||||
|
|
||||||
checkAndUpdateAllCollectiblesOwnershipStatus:
|
|
||||||
collectiblesController.checkAndUpdateAllCollectiblesOwnershipStatus.bind(
|
|
||||||
collectiblesController,
|
|
||||||
),
|
|
||||||
|
|
||||||
checkAndUpdateSingleCollectibleOwnershipStatus:
|
|
||||||
collectiblesController.checkAndUpdateSingleCollectibleOwnershipStatus.bind(
|
|
||||||
collectiblesController,
|
|
||||||
),
|
|
||||||
|
|
||||||
isCollectibleOwner: collectiblesController.isCollectibleOwner.bind(
|
|
||||||
collectiblesController,
|
|
||||||
),
|
|
||||||
|
|
||||||
// AddressController
|
// AddressController
|
||||||
setAddressBook: addressBookController.set.bind(addressBookController),
|
setAddressBook: addressBookController.set.bind(addressBookController),
|
||||||
@ -1968,10 +1947,8 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
),
|
),
|
||||||
|
|
||||||
// DetectCollectibleController
|
// DetectCollectibleController
|
||||||
detectCollectibles: process.env.COLLECTIBLES_V1
|
detectNfts: process.env.COLLECTIBLES_V1
|
||||||
? collectibleDetectionController.detectCollectibles.bind(
|
? nftDetectionController.detectNfts.bind(nftDetectionController)
|
||||||
collectibleDetectionController,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
|
|
||||||
/** Token Detection V2 */
|
/** Token Detection V2 */
|
||||||
|
46
app/scripts/migrations/076.js
Normal file
46
app/scripts/migrations/076.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { cloneDeep } from 'lodash';
|
||||||
|
|
||||||
|
const version = 76;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update to `@metamask/controllers@33.0.0` (rename "Collectible" to "NFT").
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
version,
|
||||||
|
async migrate(originalVersionedData) {
|
||||||
|
const versionedData = cloneDeep(originalVersionedData);
|
||||||
|
versionedData.meta.version = version;
|
||||||
|
const state = versionedData.data;
|
||||||
|
const newState = transformState(state);
|
||||||
|
versionedData.data = newState;
|
||||||
|
return versionedData;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
function transformState(state) {
|
||||||
|
if (state.CollectiblesController) {
|
||||||
|
const {
|
||||||
|
allCollectibleContracts,
|
||||||
|
allCollectibles,
|
||||||
|
ignoredCollectibles,
|
||||||
|
...remainingState
|
||||||
|
} = state.CollectiblesController;
|
||||||
|
state.NftController = {
|
||||||
|
...(allCollectibleContracts
|
||||||
|
? { allNftContracts: allCollectibleContracts }
|
||||||
|
: {}),
|
||||||
|
...(allCollectibles ? { allNfts: allCollectibles } : {}),
|
||||||
|
...(ignoredCollectibles ? { ignoredNfts: ignoredCollectibles } : {}),
|
||||||
|
...remainingState,
|
||||||
|
};
|
||||||
|
delete state.CollectiblesController;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.PreferencesController?.useCollectibleDetection) {
|
||||||
|
state.PreferencesController.useNftDetection =
|
||||||
|
state.PreferencesController.useCollectibleDetection;
|
||||||
|
delete state.PreferencesController.useCollectibleDetection;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
143
app/scripts/migrations/076.test.js
Normal file
143
app/scripts/migrations/076.test.js
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
import migration76 from './076';
|
||||||
|
|
||||||
|
describe('migration #76', () => {
|
||||||
|
it('should update the version metadata', async () => {
|
||||||
|
const oldStorage = {
|
||||||
|
meta: {
|
||||||
|
version: 75,
|
||||||
|
},
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
const newStorage = await migration76.migrate(oldStorage);
|
||||||
|
expect(newStorage.meta).toStrictEqual({
|
||||||
|
version: 76,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should migrate known controller state properties', async () => {
|
||||||
|
const oldStorage = {
|
||||||
|
meta: {
|
||||||
|
version: 75,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
CollectiblesController: {
|
||||||
|
allCollectibleContracts: 'foo',
|
||||||
|
allCollectibles: 'bar',
|
||||||
|
ignoredCollectibles: 'baz',
|
||||||
|
},
|
||||||
|
PreferencesController: {
|
||||||
|
useCollectibleDetection: 'foobar',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const newStorage = await migration76.migrate(oldStorage);
|
||||||
|
expect(newStorage).toStrictEqual({
|
||||||
|
meta: {
|
||||||
|
version: 76,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
NftController: {
|
||||||
|
allNftContracts: 'foo',
|
||||||
|
allNfts: 'bar',
|
||||||
|
ignoredNfts: 'baz',
|
||||||
|
},
|
||||||
|
PreferencesController: {
|
||||||
|
useNftDetection: 'foobar',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should migrate unknown controller state properties', async () => {
|
||||||
|
const oldStorage = {
|
||||||
|
meta: {
|
||||||
|
version: 75,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
CollectiblesController: {
|
||||||
|
allCollectibleContracts: 'foo',
|
||||||
|
allCollectibles: 'bar',
|
||||||
|
ignoredCollectibles: 'baz',
|
||||||
|
extra: 'extra',
|
||||||
|
},
|
||||||
|
PreferencesController: {
|
||||||
|
extra: 'extra',
|
||||||
|
useCollectibleDetection: 'foobar',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const newStorage = await migration76.migrate(oldStorage);
|
||||||
|
expect(newStorage).toStrictEqual({
|
||||||
|
meta: {
|
||||||
|
version: 76,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
NftController: {
|
||||||
|
allNftContracts: 'foo',
|
||||||
|
allNfts: 'bar',
|
||||||
|
ignoredNfts: 'baz',
|
||||||
|
extra: 'extra',
|
||||||
|
},
|
||||||
|
PreferencesController: {
|
||||||
|
extra: 'extra',
|
||||||
|
useNftDetection: 'foobar',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle missing controller state', async () => {
|
||||||
|
const oldStorage = {
|
||||||
|
meta: {
|
||||||
|
version: 75,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
CollectiblesController: {
|
||||||
|
extra: 'extra',
|
||||||
|
},
|
||||||
|
PreferencesController: {
|
||||||
|
extra: 'extra',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const newStorage = await migration76.migrate(oldStorage);
|
||||||
|
expect(newStorage).toStrictEqual({
|
||||||
|
meta: {
|
||||||
|
version: 76,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
NftController: {
|
||||||
|
extra: 'extra',
|
||||||
|
},
|
||||||
|
PreferencesController: {
|
||||||
|
extra: 'extra',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle missing CollectiblesController and PreferencesController', async () => {
|
||||||
|
const oldStorage = {
|
||||||
|
meta: {
|
||||||
|
version: 75,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
FooController: { a: 'b' },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const newStorage = await migration76.migrate(oldStorage);
|
||||||
|
expect(newStorage).toStrictEqual({
|
||||||
|
meta: {
|
||||||
|
version: 76,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
FooController: { a: 'b' },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -79,6 +79,7 @@ import m072 from './072';
|
|||||||
import m073 from './073';
|
import m073 from './073';
|
||||||
import m074 from './074';
|
import m074 from './074';
|
||||||
import m075 from './075';
|
import m075 from './075';
|
||||||
|
import m076 from './076';
|
||||||
|
|
||||||
const migrations = [
|
const migrations = [
|
||||||
m002,
|
m002,
|
||||||
@ -155,6 +156,7 @@ const migrations = [
|
|||||||
m073,
|
m073,
|
||||||
m074,
|
m074,
|
||||||
m075,
|
m075,
|
||||||
|
m076,
|
||||||
];
|
];
|
||||||
|
|
||||||
export default migrations;
|
export default migrations;
|
||||||
|
@ -1430,7 +1430,7 @@
|
|||||||
"console.warn": true
|
"console.warn": true
|
||||||
},
|
},
|
||||||
"packages": {
|
"packages": {
|
||||||
"@metamask/controllers": true,
|
"@metamask/rpc-methods>@metamask/controllers": true,
|
||||||
"@metamask/rpc-methods>@metamask/key-tree": true,
|
"@metamask/rpc-methods>@metamask/key-tree": true,
|
||||||
"@metamask/rpc-methods>nanoid": true,
|
"@metamask/rpc-methods>nanoid": true,
|
||||||
"@metamask/snap-utils": true,
|
"@metamask/snap-utils": true,
|
||||||
@ -1439,6 +1439,137 @@
|
|||||||
"eth-rpc-errors": true
|
"eth-rpc-errors": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers": {
|
||||||
|
"globals": {
|
||||||
|
"Headers": true,
|
||||||
|
"URL": true,
|
||||||
|
"clearInterval": true,
|
||||||
|
"clearTimeout": true,
|
||||||
|
"console.error": true,
|
||||||
|
"console.log": true,
|
||||||
|
"fetch": true,
|
||||||
|
"setInterval": true,
|
||||||
|
"setTimeout": true
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@ethereumjs/common": true,
|
||||||
|
"@ethereumjs/tx": true,
|
||||||
|
"@metamask/contract-metadata": true,
|
||||||
|
"@metamask/controllers>@ethersproject/abi": true,
|
||||||
|
"@metamask/controllers>@ethersproject/contracts": true,
|
||||||
|
"@metamask/controllers>@ethersproject/providers": true,
|
||||||
|
"@metamask/controllers>abort-controller": true,
|
||||||
|
"@metamask/controllers>async-mutex": true,
|
||||||
|
"@metamask/controllers>eth-json-rpc-infura": true,
|
||||||
|
"@metamask/controllers>eth-phishing-detect": true,
|
||||||
|
"@metamask/controllers>isomorphic-fetch": true,
|
||||||
|
"@metamask/controllers>multiformats": true,
|
||||||
|
"@metamask/controllers>web3": true,
|
||||||
|
"@metamask/controllers>web3-provider-engine": true,
|
||||||
|
"@metamask/metamask-eth-abis": true,
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry": true,
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>ethereumjs-wallet": true,
|
||||||
|
"@metamask/rpc-methods>nanoid": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"browserify>events": true,
|
||||||
|
"deep-freeze-strict": true,
|
||||||
|
"eslint>fast-deep-equal": true,
|
||||||
|
"eth-ens-namehash": true,
|
||||||
|
"eth-keyring-controller": true,
|
||||||
|
"eth-query": true,
|
||||||
|
"eth-rpc-errors": true,
|
||||||
|
"eth-sig-util": true,
|
||||||
|
"ethereumjs-util": true,
|
||||||
|
"ethjs>ethjs-unit": true,
|
||||||
|
"immer": true,
|
||||||
|
"json-rpc-engine": true,
|
||||||
|
"jsonschema": true,
|
||||||
|
"punycode": true,
|
||||||
|
"single-call-balance-checker-abi": true,
|
||||||
|
"uuid": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs": {
|
||||||
|
"globals": {
|
||||||
|
"clearInterval": true,
|
||||||
|
"setInterval": true
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": true,
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": true,
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"ethjs>ethjs-filter": true,
|
||||||
|
"ethjs>ethjs-provider-http": true,
|
||||||
|
"ethjs>ethjs-unit": true,
|
||||||
|
"ethjs>ethjs-util": true,
|
||||||
|
"ethjs>js-sha3": true,
|
||||||
|
"ethjs>number-to-bn": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"ethjs>js-sha3": true,
|
||||||
|
"ethjs>number-to-bn": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": true,
|
||||||
|
"ethjs-query>babel-runtime": true,
|
||||||
|
"ethjs>ethjs-filter": true,
|
||||||
|
"ethjs>ethjs-util": true,
|
||||||
|
"ethjs>js-sha3": true,
|
||||||
|
"promise-to-callback": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"ethjs>js-sha3": true,
|
||||||
|
"ethjs>number-to-bn": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": {
|
||||||
|
"globals": {
|
||||||
|
"console": true
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"ethjs-query>babel-runtime": true,
|
||||||
|
"ethjs-query>ethjs-format": true,
|
||||||
|
"ethjs-query>ethjs-rpc": true,
|
||||||
|
"promise-to-callback": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>ethereumjs-wallet": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>ethereumjs-wallet>uuid": true,
|
||||||
|
"@truffle/codec>utf8": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"browserify>crypto-browserify": true,
|
||||||
|
"ethereumjs-util": true,
|
||||||
|
"ethereumjs-util>ethereum-cryptography": true,
|
||||||
|
"ethereumjs-wallet>aes-js": true,
|
||||||
|
"ethereumjs-wallet>bs58check": true,
|
||||||
|
"ethereumjs-wallet>randombytes": true,
|
||||||
|
"ethers>@ethersproject/json-wallets>scrypt-js": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/rpc-methods>@metamask/controllers>ethereumjs-wallet>uuid": {
|
||||||
|
"globals": {
|
||||||
|
"crypto": true,
|
||||||
|
"msCrypto": true
|
||||||
|
}
|
||||||
|
},
|
||||||
"@metamask/rpc-methods>@metamask/key-tree": {
|
"@metamask/rpc-methods>@metamask/key-tree": {
|
||||||
"packages": {
|
"packages": {
|
||||||
"@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": true,
|
"@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": true,
|
||||||
@ -1659,11 +1790,11 @@
|
|||||||
"setTimeout": true
|
"setTimeout": true
|
||||||
},
|
},
|
||||||
"packages": {
|
"packages": {
|
||||||
"@metamask/controllers": true,
|
|
||||||
"@metamask/post-message-stream": true,
|
"@metamask/post-message-stream": true,
|
||||||
"@metamask/providers>@metamask/object-multiplex": true,
|
"@metamask/providers>@metamask/object-multiplex": true,
|
||||||
"@metamask/rpc-methods": true,
|
"@metamask/rpc-methods": true,
|
||||||
"@metamask/snap-controllers>@metamask/browser-passworder": true,
|
"@metamask/snap-controllers>@metamask/browser-passworder": true,
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers": true,
|
||||||
"@metamask/snap-controllers>@xstate/fsm": true,
|
"@metamask/snap-controllers>@xstate/fsm": true,
|
||||||
"@metamask/snap-controllers>concat-stream": true,
|
"@metamask/snap-controllers>concat-stream": true,
|
||||||
"@metamask/snap-controllers>gunzip-maybe": true,
|
"@metamask/snap-controllers>gunzip-maybe": true,
|
||||||
@ -1691,6 +1822,137 @@
|
|||||||
"browserify>buffer": true
|
"browserify>buffer": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers": {
|
||||||
|
"globals": {
|
||||||
|
"Headers": true,
|
||||||
|
"URL": true,
|
||||||
|
"clearInterval": true,
|
||||||
|
"clearTimeout": true,
|
||||||
|
"console.error": true,
|
||||||
|
"console.log": true,
|
||||||
|
"fetch": true,
|
||||||
|
"setInterval": true,
|
||||||
|
"setTimeout": true
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@ethereumjs/common": true,
|
||||||
|
"@ethereumjs/tx": true,
|
||||||
|
"@metamask/contract-metadata": true,
|
||||||
|
"@metamask/controllers>@ethersproject/abi": true,
|
||||||
|
"@metamask/controllers>@ethersproject/contracts": true,
|
||||||
|
"@metamask/controllers>@ethersproject/providers": true,
|
||||||
|
"@metamask/controllers>abort-controller": true,
|
||||||
|
"@metamask/controllers>async-mutex": true,
|
||||||
|
"@metamask/controllers>eth-json-rpc-infura": true,
|
||||||
|
"@metamask/controllers>eth-phishing-detect": true,
|
||||||
|
"@metamask/controllers>isomorphic-fetch": true,
|
||||||
|
"@metamask/controllers>multiformats": true,
|
||||||
|
"@metamask/controllers>web3": true,
|
||||||
|
"@metamask/controllers>web3-provider-engine": true,
|
||||||
|
"@metamask/metamask-eth-abis": true,
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry": true,
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>ethereumjs-wallet": true,
|
||||||
|
"@metamask/snap-controllers>nanoid": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"browserify>events": true,
|
||||||
|
"deep-freeze-strict": true,
|
||||||
|
"eslint>fast-deep-equal": true,
|
||||||
|
"eth-ens-namehash": true,
|
||||||
|
"eth-keyring-controller": true,
|
||||||
|
"eth-query": true,
|
||||||
|
"eth-rpc-errors": true,
|
||||||
|
"eth-sig-util": true,
|
||||||
|
"ethereumjs-util": true,
|
||||||
|
"ethjs>ethjs-unit": true,
|
||||||
|
"immer": true,
|
||||||
|
"json-rpc-engine": true,
|
||||||
|
"jsonschema": true,
|
||||||
|
"punycode": true,
|
||||||
|
"single-call-balance-checker-abi": true,
|
||||||
|
"uuid": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs": {
|
||||||
|
"globals": {
|
||||||
|
"clearInterval": true,
|
||||||
|
"setInterval": true
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": true,
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": true,
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"ethjs>ethjs-filter": true,
|
||||||
|
"ethjs>ethjs-provider-http": true,
|
||||||
|
"ethjs>ethjs-unit": true,
|
||||||
|
"ethjs>ethjs-util": true,
|
||||||
|
"ethjs>js-sha3": true,
|
||||||
|
"ethjs>number-to-bn": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"ethjs>js-sha3": true,
|
||||||
|
"ethjs>number-to-bn": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": true,
|
||||||
|
"ethjs-query>babel-runtime": true,
|
||||||
|
"ethjs>ethjs-filter": true,
|
||||||
|
"ethjs>ethjs-util": true,
|
||||||
|
"ethjs>js-sha3": true,
|
||||||
|
"promise-to-callback": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"ethjs>js-sha3": true,
|
||||||
|
"ethjs>number-to-bn": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": {
|
||||||
|
"globals": {
|
||||||
|
"console": true
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"ethjs-query>babel-runtime": true,
|
||||||
|
"ethjs-query>ethjs-format": true,
|
||||||
|
"ethjs-query>ethjs-rpc": true,
|
||||||
|
"promise-to-callback": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>ethereumjs-wallet": {
|
||||||
|
"packages": {
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>ethereumjs-wallet>uuid": true,
|
||||||
|
"@truffle/codec>utf8": true,
|
||||||
|
"browserify>buffer": true,
|
||||||
|
"browserify>crypto-browserify": true,
|
||||||
|
"ethereumjs-util": true,
|
||||||
|
"ethereumjs-util>ethereum-cryptography": true,
|
||||||
|
"ethereumjs-wallet>aes-js": true,
|
||||||
|
"ethereumjs-wallet>bs58check": true,
|
||||||
|
"ethereumjs-wallet>randombytes": true,
|
||||||
|
"ethers>@ethersproject/json-wallets>scrypt-js": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@metamask/snap-controllers>@metamask/controllers>ethereumjs-wallet>uuid": {
|
||||||
|
"globals": {
|
||||||
|
"crypto": true,
|
||||||
|
"msCrypto": true
|
||||||
|
}
|
||||||
|
},
|
||||||
"@metamask/snap-controllers>concat-stream": {
|
"@metamask/snap-controllers>concat-stream": {
|
||||||
"packages": {
|
"packages": {
|
||||||
"@metamask/snap-controllers>concat-stream>readable-stream": true,
|
"@metamask/snap-controllers>concat-stream>readable-stream": true,
|
||||||
|
@ -111,7 +111,7 @@
|
|||||||
"@keystonehq/metamask-airgapped-keyring": "^0.6.1",
|
"@keystonehq/metamask-airgapped-keyring": "^0.6.1",
|
||||||
"@material-ui/core": "^4.11.0",
|
"@material-ui/core": "^4.11.0",
|
||||||
"@metamask/contract-metadata": "^1.31.0",
|
"@metamask/contract-metadata": "^1.31.0",
|
||||||
"@metamask/controllers": "^32.0.2",
|
"@metamask/controllers": "^33.0.0",
|
||||||
"@metamask/design-tokens": "^1.9.0",
|
"@metamask/design-tokens": "^1.9.0",
|
||||||
"@metamask/eth-json-rpc-infura": "^7.0.0",
|
"@metamask/eth-json-rpc-infura": "^7.0.0",
|
||||||
"@metamask/eth-ledger-bridge-keyring": "^0.13.0",
|
"@metamask/eth-ledger-bridge-keyring": "^0.13.0",
|
||||||
|
@ -12,11 +12,11 @@ export const LISTED_CONTRACT_ADDRESSES = Object.keys(contractMap).map(
|
|||||||
/**
|
/**
|
||||||
* @typedef {object} TokenDetails
|
* @typedef {object} TokenDetails
|
||||||
* @property {string} address - The address of the selected 'TOKEN' or
|
* @property {string} address - The address of the selected 'TOKEN' or
|
||||||
* 'COLLECTIBLE' contract.
|
* 'NFT' contract.
|
||||||
* @property {string} [symbol] - The symbol of the token.
|
* @property {string} [symbol] - The symbol of the token.
|
||||||
* @property {number} [decimals] - The number of decimals of the selected
|
* @property {number} [decimals] - The number of decimals of the selected
|
||||||
* 'ERC20' asset.
|
* 'ERC20' asset.
|
||||||
* @property {number} [tokenId] - The id of the selected 'COLLECTIBLE' asset.
|
* @property {number} [tokenId] - The id of the selected 'NFT' asset.
|
||||||
* @property {TokenStandardStrings} [standard] - The standard of the selected
|
* @property {TokenStandardStrings} [standard] - The standard of the selected
|
||||||
* asset.
|
* asset.
|
||||||
* @property {boolean} [isERC721] - True when the asset is a ERC721 token.
|
* @property {boolean} [isERC721] - True when the asset is a ERC721 token.
|
||||||
|
@ -364,7 +364,7 @@ export const TRANSACTION_EVENTS = {
|
|||||||
* @property {'NATIVE'} NATIVE - The native asset for the current network, such
|
* @property {'NATIVE'} NATIVE - The native asset for the current network, such
|
||||||
* as ETH
|
* as ETH
|
||||||
* @property {'TOKEN'} TOKEN - An ERC20 token.
|
* @property {'TOKEN'} TOKEN - An ERC20 token.
|
||||||
* @property {'COLLECTIBLE'} COLLECTIBLE - An ERC721 or ERC1155 token.
|
* @property {'NFT'} NFT - An ERC721 or ERC1155 token.
|
||||||
* @property {'UNKNOWN'} UNKNOWN - A transaction interacting with a contract
|
* @property {'UNKNOWN'} UNKNOWN - A transaction interacting with a contract
|
||||||
* that isn't a token method interaction will be marked as dealing with an
|
* that isn't a token method interaction will be marked as dealing with an
|
||||||
* unknown asset type.
|
* unknown asset type.
|
||||||
@ -385,7 +385,7 @@ export const TRANSACTION_EVENTS = {
|
|||||||
export const ASSET_TYPES = {
|
export const ASSET_TYPES = {
|
||||||
NATIVE: 'NATIVE',
|
NATIVE: 'NATIVE',
|
||||||
TOKEN: 'TOKEN',
|
TOKEN: 'TOKEN',
|
||||||
COLLECTIBLE: 'COLLECTIBLE',
|
NFT: 'NFT',
|
||||||
UNKNOWN: 'UNKNOWN',
|
UNKNOWN: 'UNKNOWN',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ export async function determineTransactionAssetType(
|
|||||||
assetType:
|
assetType:
|
||||||
details.standard === TOKEN_STANDARDS.ERC20
|
details.standard === TOKEN_STANDARDS.ERC20
|
||||||
? ASSET_TYPES.TOKEN
|
? ASSET_TYPES.TOKEN
|
||||||
: ASSET_TYPES.COLLECTIBLE,
|
: ASSET_TYPES.NFT,
|
||||||
tokenStandard: details.standard,
|
tokenStandard: details.standard,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ function defaultFixture() {
|
|||||||
selectedAddress: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
selectedAddress: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
useBlockie: false,
|
useBlockie: false,
|
||||||
useCollectibleDetection: false,
|
useNftDetection: false,
|
||||||
useNonceField: false,
|
useNonceField: false,
|
||||||
usePhishDetect: true,
|
usePhishDetect: true,
|
||||||
useTokenDetection: false,
|
useTokenDetection: false,
|
||||||
@ -338,7 +338,7 @@ function onboardingFixture() {
|
|||||||
},
|
},
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
useBlockie: false,
|
useBlockie: false,
|
||||||
useCollectibleDetection: false,
|
useNftDetection: false,
|
||||||
useNonceField: false,
|
useNonceField: false,
|
||||||
usePhishDetect: true,
|
usePhishDetect: true,
|
||||||
useTokenDetection: false,
|
useTokenDetection: false,
|
||||||
@ -407,9 +407,9 @@ class FixtureBuilder {
|
|||||||
|
|
||||||
withCollectiblesController(data) {
|
withCollectiblesController(data) {
|
||||||
merge(
|
merge(
|
||||||
this.fixture.data.CollectiblesController
|
this.fixture.data.NftController
|
||||||
? this.fixture.data.CollectiblesController
|
? this.fixture.data.NftController
|
||||||
: (this.fixture.data.CollectiblesController = {}),
|
: (this.fixture.data.NftController = {}),
|
||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
return this;
|
return this;
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
},
|
},
|
||||||
"theme": "light",
|
"theme": "light",
|
||||||
"useBlockie": false,
|
"useBlockie": false,
|
||||||
"useCollectibleDetection": false,
|
"useNftDetection": false,
|
||||||
"useNonceField": false,
|
"useNonceField": false,
|
||||||
"usePhishDetect": true,
|
"usePhishDetect": true,
|
||||||
"useTokenDetection": false
|
"useTokenDetection": false
|
||||||
|
@ -30,8 +30,8 @@ import Copy from '../../ui/icon/copy-icon.component';
|
|||||||
import { getCollectibleContracts } from '../../../ducks/metamask/metamask';
|
import { getCollectibleContracts } from '../../../ducks/metamask/metamask';
|
||||||
import { DEFAULT_ROUTE, SEND_ROUTE } from '../../../helpers/constants/routes';
|
import { DEFAULT_ROUTE, SEND_ROUTE } from '../../../helpers/constants/routes';
|
||||||
import {
|
import {
|
||||||
checkAndUpdateSingleCollectibleOwnershipStatus,
|
checkAndUpdateSingleNftOwnershipStatus,
|
||||||
removeAndIgnoreCollectible,
|
removeAndIgnoreNft,
|
||||||
} from '../../../store/actions';
|
} from '../../../store/actions';
|
||||||
import { CHAIN_IDS } from '../../../../shared/constants/network';
|
import { CHAIN_IDS } from '../../../../shared/constants/network';
|
||||||
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
||||||
@ -79,14 +79,14 @@ export default function CollectibleDetails({ collectible }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const onRemove = () => {
|
const onRemove = () => {
|
||||||
dispatch(removeAndIgnoreCollectible(address, tokenId));
|
dispatch(removeAndIgnoreNft(address, tokenId));
|
||||||
history.push(DEFAULT_ROUTE);
|
history.push(DEFAULT_ROUTE);
|
||||||
};
|
};
|
||||||
|
|
||||||
const prevCollectible = usePrevious(collectible);
|
const prevCollectible = usePrevious(collectible);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isEqual(prevCollectible, collectible)) {
|
if (!isEqual(prevCollectible, collectible)) {
|
||||||
checkAndUpdateSingleCollectibleOwnershipStatus(collectible);
|
checkAndUpdateSingleNftOwnershipStatus(collectible);
|
||||||
}
|
}
|
||||||
}, [collectible, prevCollectible]);
|
}, [collectible, prevCollectible]);
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ export default function CollectibleDetails({ collectible }) {
|
|||||||
const onSend = async () => {
|
const onSend = async () => {
|
||||||
await dispatch(
|
await dispatch(
|
||||||
startNewDraftTransaction({
|
startNewDraftTransaction({
|
||||||
type: ASSET_TYPES.COLLECTIBLE,
|
type: ASSET_TYPES.NFT,
|
||||||
details: collectible,
|
details: collectible,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -18,17 +18,17 @@ import {
|
|||||||
} from '../../../helpers/constants/design-system';
|
} from '../../../helpers/constants/design-system';
|
||||||
import { useI18nContext } from '../../../hooks/useI18nContext';
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
||||||
import { getCollectiblesDetectionNoticeDismissed } from '../../../ducks/metamask/metamask';
|
import { getCollectiblesDetectionNoticeDismissed } from '../../../ducks/metamask/metamask';
|
||||||
import { getIsMainnet, getUseCollectibleDetection } from '../../../selectors';
|
import { getIsMainnet, getUseNftDetection } from '../../../selectors';
|
||||||
import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes';
|
import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes';
|
||||||
import {
|
import {
|
||||||
checkAndUpdateAllCollectiblesOwnershipStatus,
|
checkAndUpdateAllNftsOwnershipStatus,
|
||||||
detectCollectibles,
|
detectNfts,
|
||||||
} from '../../../store/actions';
|
} from '../../../store/actions';
|
||||||
import { useCollectiblesCollections } from '../../../hooks/useCollectiblesCollections';
|
import { useCollectiblesCollections } from '../../../hooks/useCollectiblesCollections';
|
||||||
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
|
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
|
||||||
|
|
||||||
export default function CollectiblesTab({ onAddNFT }) {
|
export default function CollectiblesTab({ onAddNFT }) {
|
||||||
const useCollectibleDetection = useSelector(getUseCollectibleDetection);
|
const useNftDetection = useSelector(getUseNftDetection);
|
||||||
const isMainnet = useSelector(getIsMainnet);
|
const isMainnet = useSelector(getIsMainnet);
|
||||||
const collectibleDetectionNoticeDismissed = useSelector(
|
const collectibleDetectionNoticeDismissed = useSelector(
|
||||||
getCollectiblesDetectionNoticeDismissed,
|
getCollectiblesDetectionNoticeDismissed,
|
||||||
@ -46,9 +46,9 @@ export default function CollectiblesTab({ onAddNFT }) {
|
|||||||
|
|
||||||
const onRefresh = () => {
|
const onRefresh = () => {
|
||||||
if (isMainnet) {
|
if (isMainnet) {
|
||||||
dispatch(detectCollectibles());
|
dispatch(detectNfts());
|
||||||
}
|
}
|
||||||
checkAndUpdateAllCollectiblesOwnershipStatus();
|
checkAndUpdateAllNftsOwnershipStatus();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (collectiblesLoading) {
|
if (collectiblesLoading) {
|
||||||
@ -66,7 +66,7 @@ export default function CollectiblesTab({ onAddNFT }) {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{isMainnet &&
|
{isMainnet &&
|
||||||
!useCollectibleDetection &&
|
!useNftDetection &&
|
||||||
!collectibleDetectionNoticeDismissed ? (
|
!collectibleDetectionNoticeDismissed ? (
|
||||||
<CollectiblesDetectionNotice />
|
<CollectiblesDetectionNotice />
|
||||||
) : null}
|
) : null}
|
||||||
@ -123,7 +123,7 @@ export default function CollectiblesTab({ onAddNFT }) {
|
|||||||
className="collectibles-tab__link"
|
className="collectibles-tab__link"
|
||||||
justifyContent={JUSTIFY_CONTENT.FLEX_END}
|
justifyContent={JUSTIFY_CONTENT.FLEX_END}
|
||||||
>
|
>
|
||||||
{isMainnet && !useCollectibleDetection ? (
|
{isMainnet && !useNftDetection ? (
|
||||||
<Button type="link" onClick={onEnableAutoDetect}>
|
<Button type="link" onClick={onEnableAutoDetect}>
|
||||||
{t('enableAutoDetect')}
|
{t('enableAutoDetect')}
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -150,17 +150,17 @@ const render = ({
|
|||||||
selectedAddress,
|
selectedAddress,
|
||||||
chainId = '0x1',
|
chainId = '0x1',
|
||||||
collectiblesDetectionNoticeDismissed = false,
|
collectiblesDetectionNoticeDismissed = false,
|
||||||
useCollectibleDetection,
|
useNftDetection,
|
||||||
onAddNFT = jest.fn(),
|
onAddNFT = jest.fn(),
|
||||||
}) => {
|
}) => {
|
||||||
const store = configureStore({
|
const store = configureStore({
|
||||||
metamask: {
|
metamask: {
|
||||||
allCollectibles: {
|
allNfts: {
|
||||||
[ACCOUNT_1]: {
|
[ACCOUNT_1]: {
|
||||||
[chainId]: collectibles,
|
[chainId]: collectibles,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
allCollectibleContracts: {
|
allNftContracts: {
|
||||||
[ACCOUNT_1]: {
|
[ACCOUNT_1]: {
|
||||||
[chainId]: collectibleContracts,
|
[chainId]: collectibleContracts,
|
||||||
},
|
},
|
||||||
@ -168,7 +168,7 @@ const render = ({
|
|||||||
provider: { chainId },
|
provider: { chainId },
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
collectiblesDetectionNoticeDismissed,
|
collectiblesDetectionNoticeDismissed,
|
||||||
useCollectibleDetection,
|
useNftDetection,
|
||||||
collectiblesDropdownState,
|
collectiblesDropdownState,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -184,9 +184,9 @@ describe('Collectible Items', () => {
|
|||||||
setBackgroundConnection({
|
setBackgroundConnection({
|
||||||
setCollectiblesDetectionNoticeDismissed:
|
setCollectiblesDetectionNoticeDismissed:
|
||||||
setCollectiblesDetectionNoticeDismissedStub,
|
setCollectiblesDetectionNoticeDismissedStub,
|
||||||
detectCollectibles: detectCollectiblesStub,
|
detectNfts: detectCollectiblesStub,
|
||||||
getState: getStateStub,
|
getState: getStateStub,
|
||||||
checkAndUpdateAllCollectiblesOwnershipStatus:
|
checkAndUpdateAllNftsOwnershipStatus:
|
||||||
checkAndUpdateAllCollectiblesOwnershipStatusStub,
|
checkAndUpdateAllCollectiblesOwnershipStatusStub,
|
||||||
updateCollectibleDropDownState: updateCollectibleDropDownStateStub,
|
updateCollectibleDropDownState: updateCollectibleDropDownStateStub,
|
||||||
});
|
});
|
||||||
@ -231,7 +231,7 @@ describe('Collectible Items', () => {
|
|||||||
render({
|
render({
|
||||||
selectedAddress: ACCOUNT_1,
|
selectedAddress: ACCOUNT_1,
|
||||||
collectibles: COLLECTIBLES,
|
collectibles: COLLECTIBLES,
|
||||||
useCollectibleDetection: true,
|
useNftDetection: true,
|
||||||
});
|
});
|
||||||
expect(screen.queryByText('New! NFT detection')).not.toBeInTheDocument();
|
expect(screen.queryByText('New! NFT detection')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
@ -284,7 +284,7 @@ describe('Collectible Items', () => {
|
|||||||
render({
|
render({
|
||||||
selectedAddress: ACCOUNT_1,
|
selectedAddress: ACCOUNT_1,
|
||||||
collectibles: COLLECTIBLES,
|
collectibles: COLLECTIBLES,
|
||||||
useCollectibleDetection: true,
|
useNftDetection: true,
|
||||||
});
|
});
|
||||||
expect(detectCollectiblesStub).not.toHaveBeenCalled();
|
expect(detectCollectiblesStub).not.toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
@ -302,7 +302,7 @@ describe('Collectible Items', () => {
|
|||||||
chainId: '0x5',
|
chainId: '0x5',
|
||||||
selectedAddress: ACCOUNT_1,
|
selectedAddress: ACCOUNT_1,
|
||||||
collectibles: COLLECTIBLES,
|
collectibles: COLLECTIBLES,
|
||||||
useCollectibleDetection: true,
|
useNftDetection: true,
|
||||||
});
|
});
|
||||||
expect(
|
expect(
|
||||||
checkAndUpdateAllCollectiblesOwnershipStatusStub,
|
checkAndUpdateAllCollectiblesOwnershipStatusStub,
|
||||||
|
@ -19,8 +19,8 @@ const ConvertTokenToNFTModal = ({ hideModal, tokenAddress }) => {
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const allCollectibles = useSelector(getCollectibles);
|
const allNfts = useSelector(getCollectibles);
|
||||||
const tokenAddedAsNFT = allCollectibles.find(({ address }) =>
|
const tokenAddedAsNFT = allNfts.find(({ address }) =>
|
||||||
isEqualCaseInsensitive(address, tokenAddress),
|
isEqualCaseInsensitive(address, tokenAddress),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -278,25 +278,25 @@ export function getEnableEIP1559V2NoticeDismissed(state) {
|
|||||||
export const getCollectibles = (state) => {
|
export const getCollectibles = (state) => {
|
||||||
const {
|
const {
|
||||||
metamask: {
|
metamask: {
|
||||||
allCollectibles,
|
allNfts,
|
||||||
provider: { chainId },
|
provider: { chainId },
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
},
|
},
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
return allCollectibles?.[selectedAddress]?.[chainId] ?? [];
|
return allNfts?.[selectedAddress]?.[chainId] ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCollectibleContracts = (state) => {
|
export const getCollectibleContracts = (state) => {
|
||||||
const {
|
const {
|
||||||
metamask: {
|
metamask: {
|
||||||
allCollectibleContracts,
|
allNftContracts,
|
||||||
provider: { chainId },
|
provider: { chainId },
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
},
|
},
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
return allCollectibleContracts?.[selectedAddress]?.[chainId] ?? [];
|
return allNftContracts?.[selectedAddress]?.[chainId] ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getBlockGasLimit(state) {
|
export function getBlockGasLimit(state) {
|
||||||
|
@ -204,7 +204,7 @@ export function generateTransactionParams(sendState) {
|
|||||||
sendToken: draftTransaction.asset.details,
|
sendToken: draftTransaction.asset.details,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case ASSET_TYPES.COLLECTIBLE:
|
case ASSET_TYPES.NFT:
|
||||||
// When sending a token the to address is the contract address of
|
// When sending a token the to address is the contract address of
|
||||||
// the token being sent. The value is set to '0x0' and the data
|
// the token being sent. The value is set to '0x0' and the data
|
||||||
// is generated from the recipient address, token being sent and
|
// is generated from the recipient address, token being sent and
|
||||||
|
@ -64,7 +64,7 @@ describe('Send Slice Helpers', () => {
|
|||||||
value: '0x1',
|
value: '0x1',
|
||||||
},
|
},
|
||||||
asset: {
|
asset: {
|
||||||
type: ASSET_TYPES.COLLECTIBLE,
|
type: ASSET_TYPES.NFT,
|
||||||
balance: '0xaf',
|
balance: '0xaf',
|
||||||
details: {
|
details: {
|
||||||
address: '0xToken',
|
address: '0xToken',
|
||||||
|
@ -51,7 +51,7 @@ import {
|
|||||||
updateTransactionGasFees,
|
updateTransactionGasFees,
|
||||||
addPollingTokenToAppState,
|
addPollingTokenToAppState,
|
||||||
removePollingTokenFromAppState,
|
removePollingTokenFromAppState,
|
||||||
isCollectibleOwner,
|
isNftOwner,
|
||||||
getTokenStandardAndDetails,
|
getTokenStandardAndDetails,
|
||||||
showModal,
|
showModal,
|
||||||
addUnapprovedTransactionAndRouteToConfirmationPage,
|
addUnapprovedTransactionAndRouteToConfirmationPage,
|
||||||
@ -298,7 +298,7 @@ export const RECIPIENT_SEARCH_MODES = {
|
|||||||
* with the asset.
|
* with the asset.
|
||||||
* @property {AssetTypesString} type - The type of asset that the user
|
* @property {AssetTypesString} type - The type of asset that the user
|
||||||
* is attempting to send. Defaults to 'NATIVE' which represents the native
|
* is attempting to send. Defaults to 'NATIVE' which represents the native
|
||||||
* asset of the chain. Can also be 'TOKEN' or 'COLLECTIBLE'.
|
* asset of the chain. Can also be 'TOKEN' or 'NFT'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -562,7 +562,7 @@ export const computeEstimatedGasLimit = createAsyncThunk(
|
|||||||
* @typedef {object} Asset
|
* @typedef {object} Asset
|
||||||
* @property {AssetTypesString} type - The type of asset that the user
|
* @property {AssetTypesString} type - The type of asset that the user
|
||||||
* is attempting to send. Defaults to 'NATIVE' which represents the native
|
* is attempting to send. Defaults to 'NATIVE' which represents the native
|
||||||
* asset of the chain. Can also be 'TOKEN' or 'COLLECTIBLE'.
|
* asset of the chain. Can also be 'TOKEN' or 'NFT'.
|
||||||
* @property {string} balance - A hex string representing the balance
|
* @property {string} balance - A hex string representing the balance
|
||||||
* that the user holds of the asset that they are attempting to send.
|
* that the user holds of the asset that they are attempting to send.
|
||||||
* @property {TokenDetails} [details] - An object that describes the
|
* @property {TokenDetails} [details] - An object that describes the
|
||||||
@ -660,7 +660,7 @@ export const initializeSendState = createAsyncThunk(
|
|||||||
) {
|
) {
|
||||||
gasLimit =
|
gasLimit =
|
||||||
draftTransaction.asset.type === ASSET_TYPES.TOKEN ||
|
draftTransaction.asset.type === ASSET_TYPES.TOKEN ||
|
||||||
draftTransaction.asset.type === ASSET_TYPES.COLLECTIBLE
|
draftTransaction.asset.type === ASSET_TYPES.NFT
|
||||||
? GAS_LIMITS.BASE_TOKEN_ESTIMATE
|
? GAS_LIMITS.BASE_TOKEN_ESTIMATE
|
||||||
: GAS_LIMITS.SIMPLE;
|
: GAS_LIMITS.SIMPLE;
|
||||||
// Run our estimateGasLimit logic to get a more accurate estimation of
|
// Run our estimateGasLimit logic to get a more accurate estimation of
|
||||||
@ -960,7 +960,7 @@ const slice = createSlice({
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
draftTransaction.asset.type === ASSET_TYPES.TOKEN ||
|
draftTransaction.asset.type === ASSET_TYPES.TOKEN ||
|
||||||
draftTransaction.asset.type === ASSET_TYPES.COLLECTIBLE
|
draftTransaction.asset.type === ASSET_TYPES.NFT
|
||||||
) {
|
) {
|
||||||
draftTransaction.asset.details = asset.details;
|
draftTransaction.asset.details = asset.details;
|
||||||
} else {
|
} else {
|
||||||
@ -1782,7 +1782,7 @@ export function editExistingTransaction(assetType, transactionId) {
|
|||||||
type: assetType,
|
type: assetType,
|
||||||
details: {
|
details: {
|
||||||
address: transaction.txParams.to,
|
address: transaction.txParams.to,
|
||||||
...(assetType === ASSET_TYPES.COLLECTIBLE
|
...(assetType === ASSET_TYPES.NFT
|
||||||
? {
|
? {
|
||||||
tokenId:
|
tokenId:
|
||||||
getTokenIdParam(tokenData) ??
|
getTokenIdParam(tokenData) ??
|
||||||
@ -2069,7 +2069,7 @@ export function updateSendAsset(
|
|||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
details.standard === TOKEN_STANDARDS.ERC1155 &&
|
details.standard === TOKEN_STANDARDS.ERC1155 &&
|
||||||
type === ASSET_TYPES.COLLECTIBLE
|
type === ASSET_TYPES.NFT
|
||||||
) {
|
) {
|
||||||
throw new Error('Sends of ERC1155 tokens are not currently supported');
|
throw new Error('Sends of ERC1155 tokens are not currently supported');
|
||||||
} else if (
|
} else if (
|
||||||
@ -2088,7 +2088,7 @@ export function updateSendAsset(
|
|||||||
} else {
|
} else {
|
||||||
let isCurrentOwner = true;
|
let isCurrentOwner = true;
|
||||||
try {
|
try {
|
||||||
isCurrentOwner = await isCollectibleOwner(
|
isCurrentOwner = await isNftOwner(
|
||||||
sendingAddress,
|
sendingAddress,
|
||||||
details.address,
|
details.address,
|
||||||
details.tokenId,
|
details.tokenId,
|
||||||
@ -2292,7 +2292,7 @@ export function signTransaction() {
|
|||||||
|
|
||||||
if (draftTransaction.asset.type !== ASSET_TYPES.NATIVE) {
|
if (draftTransaction.asset.type !== ASSET_TYPES.NATIVE) {
|
||||||
transactionType =
|
transactionType =
|
||||||
draftTransaction.asset.type === ASSET_TYPES.COLLECTIBLE
|
draftTransaction.asset.type === ASSET_TYPES.NFT
|
||||||
? TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM
|
? TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM
|
||||||
: TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER;
|
: TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ describe('Send Slice', () => {
|
|||||||
.spyOn(Actions, 'updateTokenType')
|
.spyOn(Actions, 'updateTokenType')
|
||||||
.mockImplementation(() => Promise.resolve({ isERC721: false }));
|
.mockImplementation(() => Promise.resolve({ isERC721: false }));
|
||||||
jest
|
jest
|
||||||
.spyOn(Actions, 'isCollectibleOwner')
|
.spyOn(Actions, 'isNftOwner')
|
||||||
.mockImplementation(() => Promise.resolve(true));
|
.mockImplementation(() => Promise.resolve(true));
|
||||||
jest.spyOn(Actions, 'updateEditableParams').mockImplementation(() => ({
|
jest.spyOn(Actions, 'updateEditableParams').mockImplementation(() => ({
|
||||||
type: 'UPDATE_TRANSACTION_EDITABLE_PARAMS',
|
type: 'UPDATE_TRANSACTION_EDITABLE_PARAMS',
|
||||||
@ -2566,9 +2566,7 @@ describe('Send Slice', () => {
|
|||||||
|
|
||||||
const store = mockStore(editTransactionState);
|
const store = mockStore(editTransactionState);
|
||||||
|
|
||||||
await store.dispatch(
|
await store.dispatch(editExistingTransaction(ASSET_TYPES.NFT, 1));
|
||||||
editExistingTransaction(ASSET_TYPES.COLLECTIBLE, 1),
|
|
||||||
);
|
|
||||||
const actionResult = store.getActions();
|
const actionResult = store.getActions();
|
||||||
expect(actionResult).toHaveLength(9);
|
expect(actionResult).toHaveLength(9);
|
||||||
expect(actionResult[0]).toMatchObject({
|
expect(actionResult[0]).toMatchObject({
|
||||||
@ -2635,7 +2633,7 @@ describe('Send Slice', () => {
|
|||||||
tokenId: '15000',
|
tokenId: '15000',
|
||||||
},
|
},
|
||||||
error: null,
|
error: null,
|
||||||
type: ASSET_TYPES.COLLECTIBLE,
|
type: ASSET_TYPES.NFT,
|
||||||
},
|
},
|
||||||
initialAssetSet: true,
|
initialAssetSet: true,
|
||||||
},
|
},
|
||||||
|
@ -15,13 +15,13 @@ import Typography from '../../components/ui/typography';
|
|||||||
import ActionableMessage from '../../components/ui/actionable-message';
|
import ActionableMessage from '../../components/ui/actionable-message';
|
||||||
import PageContainer from '../../components/ui/page-container';
|
import PageContainer from '../../components/ui/page-container';
|
||||||
import {
|
import {
|
||||||
addCollectibleVerifyOwnership,
|
addNftVerifyOwnership,
|
||||||
getTokenStandardAndDetails,
|
getTokenStandardAndDetails,
|
||||||
ignoreTokens,
|
ignoreTokens,
|
||||||
setNewCollectibleAddedMessage,
|
setNewCollectibleAddedMessage,
|
||||||
} from '../../store/actions';
|
} from '../../store/actions';
|
||||||
import FormField from '../../components/ui/form-field';
|
import FormField from '../../components/ui/form-field';
|
||||||
import { getIsMainnet, getUseCollectibleDetection } from '../../selectors';
|
import { getIsMainnet, getUseNftDetection } from '../../selectors';
|
||||||
import { getCollectiblesDetectionNoticeDismissed } from '../../ducks/metamask/metamask';
|
import { getCollectiblesDetectionNoticeDismissed } from '../../ducks/metamask/metamask';
|
||||||
import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice';
|
import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice';
|
||||||
import { MetaMetricsContext } from '../../contexts/metametrics';
|
import { MetaMetricsContext } from '../../contexts/metametrics';
|
||||||
@ -32,7 +32,7 @@ export default function AddCollectible() {
|
|||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const useCollectibleDetection = useSelector(getUseCollectibleDetection);
|
const useNftDetection = useSelector(getUseNftDetection);
|
||||||
const isMainnet = useSelector(getIsMainnet);
|
const isMainnet = useSelector(getIsMainnet);
|
||||||
const collectibleDetectionNoticeDismissed = useSelector(
|
const collectibleDetectionNoticeDismissed = useSelector(
|
||||||
getCollectiblesDetectionNoticeDismissed,
|
getCollectiblesDetectionNoticeDismissed,
|
||||||
@ -54,7 +54,7 @@ export default function AddCollectible() {
|
|||||||
|
|
||||||
const handleAddCollectible = async () => {
|
const handleAddCollectible = async () => {
|
||||||
try {
|
try {
|
||||||
await dispatch(addCollectibleVerifyOwnership(address, tokenId));
|
await dispatch(addNftVerifyOwnership(address, tokenId));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const { message } = error;
|
const { message } = error;
|
||||||
dispatch(setNewCollectibleAddedMessage(message));
|
dispatch(setNewCollectibleAddedMessage(message));
|
||||||
@ -84,7 +84,7 @@ export default function AddCollectible() {
|
|||||||
token_contract_address: address,
|
token_contract_address: address,
|
||||||
token_symbol: tokenDetails?.symbol,
|
token_symbol: tokenDetails?.symbol,
|
||||||
tokenId: tokenId.toString(),
|
tokenId: tokenId.toString(),
|
||||||
asset_type: ASSET_TYPES.COLLECTIBLE,
|
asset_type: ASSET_TYPES.NFT,
|
||||||
token_standard: tokenDetails?.standard,
|
token_standard: tokenDetails?.standard,
|
||||||
source: EVENT.SOURCE.TOKEN.CUSTOM,
|
source: EVENT.SOURCE.TOKEN.CUSTOM,
|
||||||
},
|
},
|
||||||
@ -120,7 +120,7 @@ export default function AddCollectible() {
|
|||||||
contentComponent={
|
contentComponent={
|
||||||
<Box>
|
<Box>
|
||||||
{isMainnet &&
|
{isMainnet &&
|
||||||
!useCollectibleDetection &&
|
!useNftDetection &&
|
||||||
!collectibleDetectionNoticeDismissed ? (
|
!collectibleDetectionNoticeDismissed ? (
|
||||||
<CollectiblesDetectionNotice />
|
<CollectiblesDetectionNotice />
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -53,7 +53,7 @@ describe('AddCollectible', () => {
|
|||||||
expect(getByText('Add')).not.toBeEnabled();
|
expect(getByText('Add')).not.toBeEnabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call addCollectibleVerifyOwnership action with correct values (tokenId should not be in scientific notation)', () => {
|
it('should call addNftVerifyOwnership action with correct values (tokenId should not be in scientific notation)', () => {
|
||||||
const { getByTestId, getByText } = renderWithProvider(
|
const { getByTestId, getByText } = renderWithProvider(
|
||||||
<AddCollectible />,
|
<AddCollectible />,
|
||||||
store,
|
store,
|
||||||
@ -67,7 +67,7 @@ describe('AddCollectible', () => {
|
|||||||
});
|
});
|
||||||
const addCollectibleVerifyOwnershipSpy = jest.spyOn(
|
const addCollectibleVerifyOwnershipSpy = jest.spyOn(
|
||||||
Actions,
|
Actions,
|
||||||
'addCollectibleVerifyOwnership',
|
'addNftVerifyOwnership',
|
||||||
);
|
);
|
||||||
|
|
||||||
fireEvent.click(getByText('Add'));
|
fireEvent.click(getByText('Add'));
|
||||||
|
@ -97,7 +97,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
network,
|
network,
|
||||||
unapprovedTxs,
|
unapprovedTxs,
|
||||||
nextNonce,
|
nextNonce,
|
||||||
allCollectibleContracts,
|
allNftContracts,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
provider: { chainId },
|
provider: { chainId },
|
||||||
} = metamask;
|
} = metamask;
|
||||||
@ -175,7 +175,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const isCollectibleTransfer = Boolean(
|
const isCollectibleTransfer = Boolean(
|
||||||
allCollectibleContracts?.[selectedAddress]?.[chainId]?.find((contract) => {
|
allNftContracts?.[selectedAddress]?.[chainId]?.find((contract) => {
|
||||||
return isEqualCaseInsensitive(contract.address, fullTxData.txParams.to);
|
return isEqualCaseInsensitive(contract.address, fullTxData.txParams.to);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -44,7 +44,7 @@ export default class SendAmountRow extends Component {
|
|||||||
render() {
|
render() {
|
||||||
const { inError, asset } = this.props;
|
const { inError, asset } = this.props;
|
||||||
|
|
||||||
if (asset.type === ASSET_TYPES.COLLECTIBLE) {
|
if (asset.type === ASSET_TYPES.NFT) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ export default class SendAssetRow extends Component {
|
|||||||
return this.props.nativeCurrency;
|
return this.props.nativeCurrency;
|
||||||
case ASSET_TYPES.TOKEN:
|
case ASSET_TYPES.TOKEN:
|
||||||
return ERC20;
|
return ERC20;
|
||||||
case ASSET_TYPES.COLLECTIBLE:
|
case ASSET_TYPES.NFT:
|
||||||
return token?.standard;
|
return token?.standard;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -144,7 +144,7 @@ export default class SendAssetRow extends Component {
|
|||||||
if (token) {
|
if (token) {
|
||||||
return this.renderToken(token);
|
return this.renderToken(token);
|
||||||
}
|
}
|
||||||
} else if (type === ASSET_TYPES.COLLECTIBLE) {
|
} else if (type === ASSET_TYPES.NFT) {
|
||||||
const collectible = collectibles.find(
|
const collectible = collectibles.find(
|
||||||
({ address, tokenId }) =>
|
({ address, tokenId }) =>
|
||||||
isEqualCaseInsensitive(address, details.address) &&
|
isEqualCaseInsensitive(address, details.address) &&
|
||||||
@ -268,7 +268,7 @@ export default class SendAssetRow extends Component {
|
|||||||
<div
|
<div
|
||||||
key={address}
|
key={address}
|
||||||
className="send-v2__asset-dropdown__asset"
|
className="send-v2__asset-dropdown__asset"
|
||||||
onClick={() => this.selectToken(ASSET_TYPES.COLLECTIBLE, collectible)}
|
onClick={() => this.selectToken(ASSET_TYPES.NFT, collectible)}
|
||||||
>
|
>
|
||||||
<div className="send-v2__asset-dropdown__asset-icon">
|
<div className="send-v2__asset-dropdown__asset-icon">
|
||||||
<Identicon address={address} diameter={36} image={image} />
|
<Identicon address={address} diameter={36} image={image} />
|
||||||
|
@ -71,7 +71,7 @@ export default class SendContent extends Component {
|
|||||||
const showHexData =
|
const showHexData =
|
||||||
this.props.showHexData &&
|
this.props.showHexData &&
|
||||||
asset.type !== ASSET_TYPES.TOKEN &&
|
asset.type !== ASSET_TYPES.TOKEN &&
|
||||||
asset.type !== ASSET_TYPES.COLLECTIBLE;
|
asset.type !== ASSET_TYPES.NFT;
|
||||||
|
|
||||||
const showKnownRecipientWarning =
|
const showKnownRecipientWarning =
|
||||||
recipient.warning === 'knownAddressRecipient';
|
recipient.warning === 'knownAddressRecipient';
|
||||||
|
@ -14,8 +14,8 @@ export default class ExperimentalTab extends PureComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
useCollectibleDetection: PropTypes.bool,
|
useNftDetection: PropTypes.bool,
|
||||||
setUseCollectibleDetection: PropTypes.func,
|
setUseNftDetection: PropTypes.func,
|
||||||
setOpenSeaEnabled: PropTypes.func,
|
setOpenSeaEnabled: PropTypes.func,
|
||||||
openSeaEnabled: PropTypes.bool,
|
openSeaEnabled: PropTypes.bool,
|
||||||
eip1559V2Enabled: PropTypes.bool,
|
eip1559V2Enabled: PropTypes.bool,
|
||||||
@ -52,8 +52,8 @@ export default class ExperimentalTab extends PureComponent {
|
|||||||
|
|
||||||
const { t } = this.context;
|
const { t } = this.context;
|
||||||
const {
|
const {
|
||||||
useCollectibleDetection,
|
useNftDetection,
|
||||||
setUseCollectibleDetection,
|
setUseNftDetection,
|
||||||
openSeaEnabled,
|
openSeaEnabled,
|
||||||
setOpenSeaEnabled,
|
setOpenSeaEnabled,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
@ -72,7 +72,7 @@ export default class ExperimentalTab extends PureComponent {
|
|||||||
<div className="settings-page__content-item">
|
<div className="settings-page__content-item">
|
||||||
<div className="settings-page__content-item-col">
|
<div className="settings-page__content-item-col">
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
value={useCollectibleDetection}
|
value={useNftDetection}
|
||||||
onToggle={(value) => {
|
onToggle={(value) => {
|
||||||
this.context.trackEvent({
|
this.context.trackEvent({
|
||||||
category: EVENT.CATEGORIES.SETTINGS,
|
category: EVENT.CATEGORIES.SETTINGS,
|
||||||
@ -85,7 +85,7 @@ export default class ExperimentalTab extends PureComponent {
|
|||||||
if (!value && !openSeaEnabled) {
|
if (!value && !openSeaEnabled) {
|
||||||
setOpenSeaEnabled(!value);
|
setOpenSeaEnabled(!value);
|
||||||
}
|
}
|
||||||
setUseCollectibleDetection(!value);
|
setUseNftDetection(!value);
|
||||||
}}
|
}}
|
||||||
offLabel={t('off')}
|
offLabel={t('off')}
|
||||||
onLabel={t('on')}
|
onLabel={t('on')}
|
||||||
@ -104,8 +104,8 @@ export default class ExperimentalTab extends PureComponent {
|
|||||||
const {
|
const {
|
||||||
openSeaEnabled,
|
openSeaEnabled,
|
||||||
setOpenSeaEnabled,
|
setOpenSeaEnabled,
|
||||||
useCollectibleDetection,
|
useNftDetection,
|
||||||
setUseCollectibleDetection,
|
setUseNftDetection,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -133,8 +133,8 @@ export default class ExperimentalTab extends PureComponent {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
// value is positive when being toggled off
|
// value is positive when being toggled off
|
||||||
if (value && useCollectibleDetection) {
|
if (value && useNftDetection) {
|
||||||
setUseCollectibleDetection(false);
|
setUseNftDetection(false);
|
||||||
}
|
}
|
||||||
setOpenSeaEnabled(!value);
|
setOpenSeaEnabled(!value);
|
||||||
}}
|
}}
|
||||||
|
@ -2,13 +2,13 @@ import { compose } from 'redux';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
setUseCollectibleDetection,
|
setUseNftDetection,
|
||||||
setOpenSeaEnabled,
|
setOpenSeaEnabled,
|
||||||
setEIP1559V2Enabled,
|
setEIP1559V2Enabled,
|
||||||
setImprovedTokenAllowanceEnabled,
|
setImprovedTokenAllowanceEnabled,
|
||||||
} from '../../../store/actions';
|
} from '../../../store/actions';
|
||||||
import {
|
import {
|
||||||
getUseCollectibleDetection,
|
getUseNftDetection,
|
||||||
getOpenSeaEnabled,
|
getOpenSeaEnabled,
|
||||||
getEIP1559V2Enabled,
|
getEIP1559V2Enabled,
|
||||||
getIsImprovedTokenAllowanceEnabled,
|
getIsImprovedTokenAllowanceEnabled,
|
||||||
@ -17,7 +17,7 @@ import ExperimentalTab from './experimental-tab.component';
|
|||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
useCollectibleDetection: getUseCollectibleDetection(state),
|
useNftDetection: getUseNftDetection(state),
|
||||||
openSeaEnabled: getOpenSeaEnabled(state),
|
openSeaEnabled: getOpenSeaEnabled(state),
|
||||||
eip1559V2Enabled: getEIP1559V2Enabled(state),
|
eip1559V2Enabled: getEIP1559V2Enabled(state),
|
||||||
improvedTokenAllowanceEnabled: getIsImprovedTokenAllowanceEnabled(state),
|
improvedTokenAllowanceEnabled: getIsImprovedTokenAllowanceEnabled(state),
|
||||||
@ -26,8 +26,7 @@ const mapStateToProps = (state) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return {
|
return {
|
||||||
setUseCollectibleDetection: (val) =>
|
setUseNftDetection: (val) => dispatch(setUseNftDetection(val)),
|
||||||
dispatch(setUseCollectibleDetection(val)),
|
|
||||||
setOpenSeaEnabled: (val) => dispatch(setOpenSeaEnabled(val)),
|
setOpenSeaEnabled: (val) => dispatch(setOpenSeaEnabled(val)),
|
||||||
setEIP1559V2Enabled: (val) => dispatch(setEIP1559V2Enabled(val)),
|
setEIP1559V2Enabled: (val) => dispatch(setEIP1559V2Enabled(val)),
|
||||||
setImprovedTokenAllowanceEnabled: (val) =>
|
setImprovedTokenAllowanceEnabled: (val) =>
|
||||||
|
@ -1023,13 +1023,13 @@ export function getUseTokenDetection(state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the useCollectibleDetection flag which determines whether we autodetect NFTs
|
* To get the useNftDetection flag which determines whether we autodetect NFTs
|
||||||
*
|
*
|
||||||
* @param {*} state
|
* @param {*} state
|
||||||
* @returns Boolean
|
* @returns Boolean
|
||||||
*/
|
*/
|
||||||
export function getUseCollectibleDetection(state) {
|
export function getUseNftDetection(state) {
|
||||||
return Boolean(state.metamask.useCollectibleDetection);
|
return Boolean(state.metamask.useNftDetection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1781,7 +1781,7 @@ export async function getBalancesInSingleCall(tokens) {
|
|||||||
return await submitRequestToBackground('getBalancesInSingleCall', [tokens]);
|
return await submitRequestToBackground('getBalancesInSingleCall', [tokens]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addCollectible(address, tokenID, dontShowLoadingIndicator) {
|
export function addNft(address, tokenID, dontShowLoadingIndicator) {
|
||||||
return async (dispatch) => {
|
return async (dispatch) => {
|
||||||
if (!address) {
|
if (!address) {
|
||||||
throw new Error('MetaMask - Cannot add collectible without address');
|
throw new Error('MetaMask - Cannot add collectible without address');
|
||||||
@ -1793,7 +1793,7 @@ export function addCollectible(address, tokenID, dontShowLoadingIndicator) {
|
|||||||
dispatch(showLoadingIndication());
|
dispatch(showLoadingIndication());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await submitRequestToBackground('addCollectible', [address, tokenID]);
|
await submitRequestToBackground('addNft', [address, tokenID]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
dispatch(displayWarning(error.message));
|
dispatch(displayWarning(error.message));
|
||||||
@ -1804,7 +1804,7 @@ export function addCollectible(address, tokenID, dontShowLoadingIndicator) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addCollectibleVerifyOwnership(
|
export function addNftVerifyOwnership(
|
||||||
address,
|
address,
|
||||||
tokenID,
|
tokenID,
|
||||||
dontShowLoadingIndicator,
|
dontShowLoadingIndicator,
|
||||||
@ -1820,7 +1820,7 @@ export function addCollectibleVerifyOwnership(
|
|||||||
dispatch(showLoadingIndication());
|
dispatch(showLoadingIndication());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await submitRequestToBackground('addCollectibleVerifyOwnership', [
|
await submitRequestToBackground('addNftVerifyOwnership', [
|
||||||
address,
|
address,
|
||||||
tokenID,
|
tokenID,
|
||||||
]);
|
]);
|
||||||
@ -1841,11 +1841,7 @@ export function addCollectibleVerifyOwnership(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeAndIgnoreCollectible(
|
export function removeAndIgnoreNft(address, tokenID, dontShowLoadingIndicator) {
|
||||||
address,
|
|
||||||
tokenID,
|
|
||||||
dontShowLoadingIndicator,
|
|
||||||
) {
|
|
||||||
return async (dispatch) => {
|
return async (dispatch) => {
|
||||||
if (!address) {
|
if (!address) {
|
||||||
throw new Error('MetaMask - Cannot ignore collectible without address');
|
throw new Error('MetaMask - Cannot ignore collectible without address');
|
||||||
@ -1857,10 +1853,7 @@ export function removeAndIgnoreCollectible(
|
|||||||
dispatch(showLoadingIndication());
|
dispatch(showLoadingIndication());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await submitRequestToBackground('removeAndIgnoreCollectible', [
|
await submitRequestToBackground('removeAndIgnoreNft', [address, tokenID]);
|
||||||
address,
|
|
||||||
tokenID,
|
|
||||||
]);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
dispatch(displayWarning(error.message));
|
dispatch(displayWarning(error.message));
|
||||||
@ -1871,7 +1864,7 @@ export function removeAndIgnoreCollectible(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeCollectible(address, tokenID, dontShowLoadingIndicator) {
|
export function removeNft(address, tokenID, dontShowLoadingIndicator) {
|
||||||
return async (dispatch) => {
|
return async (dispatch) => {
|
||||||
if (!address) {
|
if (!address) {
|
||||||
throw new Error('MetaMask - Cannot remove collectible without address');
|
throw new Error('MetaMask - Cannot remove collectible without address');
|
||||||
@ -1883,7 +1876,7 @@ export function removeCollectible(address, tokenID, dontShowLoadingIndicator) {
|
|||||||
dispatch(showLoadingIndication());
|
dispatch(showLoadingIndication());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await submitRequestToBackground('removeCollectible', [address, tokenID]);
|
await submitRequestToBackground('removeNft', [address, tokenID]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
dispatch(displayWarning(error.message));
|
dispatch(displayWarning(error.message));
|
||||||
@ -1894,31 +1887,27 @@ export function removeCollectible(address, tokenID, dontShowLoadingIndicator) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkAndUpdateAllCollectiblesOwnershipStatus() {
|
export async function checkAndUpdateAllNftsOwnershipStatus() {
|
||||||
await submitRequestToBackground(
|
await submitRequestToBackground('checkAndUpdateAllNftsOwnershipStatus');
|
||||||
'checkAndUpdateAllCollectiblesOwnershipStatus',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isCollectibleOwner(
|
export async function isNftOwner(
|
||||||
ownerAddress,
|
ownerAddress,
|
||||||
collectibleAddress,
|
collectibleAddress,
|
||||||
collectibleId,
|
collectibleId,
|
||||||
) {
|
) {
|
||||||
return await submitRequestToBackground('isCollectibleOwner', [
|
return await submitRequestToBackground('isNftOwner', [
|
||||||
ownerAddress,
|
ownerAddress,
|
||||||
collectibleAddress,
|
collectibleAddress,
|
||||||
collectibleId,
|
collectibleId,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkAndUpdateSingleCollectibleOwnershipStatus(
|
export async function checkAndUpdateSingleNftOwnershipStatus(collectible) {
|
||||||
collectible,
|
await submitRequestToBackground('checkAndUpdateSingleNftOwnershipStatus', [
|
||||||
) {
|
collectible,
|
||||||
await submitRequestToBackground(
|
false,
|
||||||
'checkAndUpdateSingleCollectibleOwnershipStatus',
|
]);
|
||||||
[collectible, false],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getTokenStandardAndDetails(
|
export async function getTokenStandardAndDetails(
|
||||||
@ -2729,11 +2718,11 @@ export function setUseTokenDetection(val) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setUseCollectibleDetection(val) {
|
export function setUseNftDetection(val) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(showLoadingIndication());
|
dispatch(showLoadingIndication());
|
||||||
log.debug(`background.setUseCollectibleDetection`);
|
log.debug(`background.setUseNftDetection`);
|
||||||
callBackgroundMethod('setUseCollectibleDetection', [val], (err) => {
|
callBackgroundMethod('setUseNftDetection', [val], (err) => {
|
||||||
dispatch(hideLoadingIndication());
|
dispatch(hideLoadingIndication());
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(displayWarning(err.message));
|
dispatch(displayWarning(err.message));
|
||||||
@ -2755,11 +2744,11 @@ export function setOpenSeaEnabled(val) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function detectCollectibles() {
|
export function detectNfts() {
|
||||||
return async (dispatch) => {
|
return async (dispatch) => {
|
||||||
dispatch(showLoadingIndication());
|
dispatch(showLoadingIndication());
|
||||||
log.debug(`background.detectCollectibles`);
|
log.debug(`background.detectNfts`);
|
||||||
await submitRequestToBackground('detectCollectibles');
|
await submitRequestToBackground('detectNfts');
|
||||||
dispatch(hideLoadingIndication());
|
dispatch(hideLoadingIndication());
|
||||||
await forceUpdateMetamaskState(dispatch);
|
await forceUpdateMetamaskState(dispatch);
|
||||||
};
|
};
|
||||||
|
43
yarn.lock
43
yarn.lock
@ -2909,6 +2909,49 @@
|
|||||||
web3 "^0.20.7"
|
web3 "^0.20.7"
|
||||||
web3-provider-engine "^16.0.3"
|
web3-provider-engine "^16.0.3"
|
||||||
|
|
||||||
|
"@metamask/controllers@^33.0.0":
|
||||||
|
version "33.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-33.0.0.tgz#908c05f6bee741c0beecd9d85d50c304afa38f2b"
|
||||||
|
integrity sha512-ImnoLztyyE9qswPAv6zk7d40d5FTMPiJYqAjjnJz+hEYhhGPGYI87+2OF/i+kVLv3gatyBQzNxvE1qtQSDWJsg==
|
||||||
|
dependencies:
|
||||||
|
"@ethereumjs/common" "^2.3.1"
|
||||||
|
"@ethereumjs/tx" "^3.2.1"
|
||||||
|
"@ethersproject/abi" "^5.7.0"
|
||||||
|
"@ethersproject/contracts" "^5.7.0"
|
||||||
|
"@ethersproject/providers" "^5.7.0"
|
||||||
|
"@keystonehq/metamask-airgapped-keyring" "^0.6.1"
|
||||||
|
"@metamask/contract-metadata" "^1.35.0"
|
||||||
|
"@metamask/metamask-eth-abis" "3.0.0"
|
||||||
|
"@metamask/types" "^1.1.0"
|
||||||
|
"@types/uuid" "^8.3.0"
|
||||||
|
abort-controller "^3.0.0"
|
||||||
|
async-mutex "^0.2.6"
|
||||||
|
babel-runtime "^6.26.0"
|
||||||
|
deep-freeze-strict "^1.1.1"
|
||||||
|
eth-ens-namehash "^2.0.8"
|
||||||
|
eth-json-rpc-infura "^5.1.0"
|
||||||
|
eth-keyring-controller "^7.0.2"
|
||||||
|
eth-method-registry "1.1.0"
|
||||||
|
eth-phishing-detect "^1.2.0"
|
||||||
|
eth-query "^2.1.2"
|
||||||
|
eth-rpc-errors "^4.0.0"
|
||||||
|
eth-sig-util "^3.0.0"
|
||||||
|
ethereumjs-util "^7.0.10"
|
||||||
|
ethereumjs-wallet "^1.0.1"
|
||||||
|
ethjs-unit "^0.1.6"
|
||||||
|
fast-deep-equal "^3.1.3"
|
||||||
|
immer "^9.0.6"
|
||||||
|
isomorphic-fetch "^3.0.0"
|
||||||
|
json-rpc-engine "^6.1.0"
|
||||||
|
jsonschema "^1.2.4"
|
||||||
|
multiformats "^9.5.2"
|
||||||
|
nanoid "^3.1.31"
|
||||||
|
punycode "^2.1.1"
|
||||||
|
single-call-balance-checker-abi "^1.0.0"
|
||||||
|
uuid "^8.3.2"
|
||||||
|
web3 "^0.20.7"
|
||||||
|
web3-provider-engine "^16.0.3"
|
||||||
|
|
||||||
"@metamask/design-tokens@^1.6.0", "@metamask/design-tokens@^1.9.0":
|
"@metamask/design-tokens@^1.6.0", "@metamask/design-tokens@^1.9.0":
|
||||||
version "1.9.0"
|
version "1.9.0"
|
||||||
resolved "https://registry.yarnpkg.com/@metamask/design-tokens/-/design-tokens-1.9.0.tgz#2b173c671f36b0d3faa2e31ea4bf66e811a7ff49"
|
resolved "https://registry.yarnpkg.com/@metamask/design-tokens/-/design-tokens-1.9.0.tgz#2b173c671f36b0d3faa2e31ea4bf66e811a7ff49"
|
||||||
|
Loading…
Reference in New Issue
Block a user