diff --git a/app/components/Nav/Main/RootRPCMethodsUI.js b/app/components/Nav/Main/RootRPCMethodsUI.js index 301f1e21346..ed0dd98fa7b 100644 --- a/app/components/Nav/Main/RootRPCMethodsUI.js +++ b/app/components/Nav/Main/RootRPCMethodsUI.js @@ -261,8 +261,8 @@ const RootRPCMethodsUI = (props) => { if (!asset) { try { asset = {}; - asset.decimals = await AssetsContractController.getTokenDecimals(to); - asset.symbol = await AssetsContractController.getAssetSymbol(to); + asset.decimals = await AssetsContractController.getERC20TokenDecimals(to); + asset.symbol = await AssetsContractController.getERC721AssetSymbol(to); // adding `to` here as well asset.address = to; } catch (e) { diff --git a/app/components/UI/AddCustomToken/index.js b/app/components/UI/AddCustomToken/index.js index b9fc31d2a50..3f046817954 100644 --- a/app/components/UI/AddCustomToken/index.js +++ b/app/components/UI/AddCustomToken/index.js @@ -119,8 +119,8 @@ export default class AddCustomToken extends PureComponent { if (validated) { const address = this.state.address; const { AssetsContractController } = Engine.context; - const decimals = await AssetsContractController.getTokenDecimals(address); - const symbol = await AssetsContractController.getAssetSymbol(address); + const decimals = await AssetsContractController.getERC20TokenDecimals(address); + const symbol = await AssetsContractController.getERC721AssetSymbol(address); this.setState({ decimals: String(decimals), symbol }); } }; diff --git a/app/components/UI/ApproveTransactionReview/index.js b/app/components/UI/ApproveTransactionReview/index.js index 114677f168b..65451aa3120 100644 --- a/app/components/UI/ApproveTransactionReview/index.js +++ b/app/components/UI/ApproveTransactionReview/index.js @@ -280,8 +280,8 @@ class ApproveTransactionReview extends PureComponent { const contract = tokenList[safeToChecksumAddress(to)]; if (!contract) { try { - tokenDecimals = await AssetsContractController.getTokenDecimals(to); - tokenSymbol = await AssetsContractController.getAssetSymbol(to); + tokenDecimals = await AssetsContractController.getERC20TokenDecimals(to); + tokenSymbol = await AssetsContractController.getERC721AssetSymbol(to); } catch (e) { tokenSymbol = 'ERC20 Token'; tokenDecimals = 18; diff --git a/app/components/UI/Swaps/index.js b/app/components/UI/Swaps/index.js index 3f94c3e20a6..98ae990204f 100644 --- a/app/components/UI/Swaps/index.js +++ b/app/components/UI/Swaps/index.js @@ -273,7 +273,10 @@ function SwapsAmountView({ setContractBalanceAsUnits(safeNumberToBN(0)); const { AssetsContractController } = Engine.context; try { - const balance = await AssetsContractController.getBalanceOf(sourceToken.address, selectedAddress); + const balance = await AssetsContractController.getERC20BalanceOf( + sourceToken.address, + selectedAddress + ); setContractBalanceAsUnits(balance); setContractBalance(renderFromTokenMinimalUnit(balance, sourceToken.decimals)); } catch (e) { diff --git a/app/components/UI/TransactionEditor/index.js b/app/components/UI/TransactionEditor/index.js index 52ce9d5ff8f..72964970483 100644 --- a/app/components/UI/TransactionEditor/index.js +++ b/app/components/UI/TransactionEditor/index.js @@ -573,7 +573,7 @@ class TransactionEditor extends PureComponent { } = this.props; const { selectedAddress } = this.props; try { - const owner = await AssetsContractController.getOwnerOf(address, tokenId); + const owner = await AssetsContractController.getERC721OwnerOf(address, tokenId); const isOwner = toLowerCaseEquals(owner, selectedAddress); if (!isOwner) { return strings('transaction.invalid_collectible_ownership'); @@ -632,7 +632,7 @@ class TransactionEditor extends PureComponent { } else { const { AssetsContractController } = Engine.context; try { - contractBalanceForAddress = await AssetsContractController.getBalanceOf( + contractBalanceForAddress = await AssetsContractController.getERC20BalanceOf( selectedAsset.address, checksummedFrom ); diff --git a/app/components/Views/Send/index.js b/app/components/Views/Send/index.js index 1dc9941bb3b..ad2e5e8b0f8 100644 --- a/app/components/Views/Send/index.js +++ b/app/components/Views/Send/index.js @@ -362,7 +362,7 @@ class Send extends PureComponent { const { AssetsContractController } = Engine.context; const token = { address }; try { - const decimals = await AssetsContractController.getTokenDecimals(address); + const decimals = await AssetsContractController.getERC20TokenDecimals(address); token.decimals = parseInt(String(decimals)); } catch (e) { // Drop tx since we don't have any form to get decimals and send the correct tx @@ -375,7 +375,7 @@ class Send extends PureComponent { this.onCancel(); } try { - token.symbol = await AssetsContractController.getAssetSymbol(address); + token.symbol = await AssetsContractController.getERC721AssetSymbol(address); } catch (e) { token.symbol = 'ERC20'; } diff --git a/app/components/Views/SendFlow/SendTo/index.js b/app/components/Views/SendFlow/SendTo/index.js index a9aa8de7b46..c25458a41b0 100644 --- a/app/components/Views/SendFlow/SendTo/index.js +++ b/app/components/Views/SendFlow/SendTo/index.js @@ -346,7 +346,7 @@ class SendFlow extends PureComponent { const networkId = NetworkList[providerType].networkId; if (networkId === 1) { try { - const symbol = await AssetsContractController.getAssetSymbol(toSelectedAddress); + const symbol = await AssetsContractController.getERC721AssetSymbol(toSelectedAddress); if (symbol) { addressError = ( diff --git a/app/components/hooks/useTokenBalance.tsx b/app/components/hooks/useTokenBalance.tsx index d9b7b5398bf..a7128dc331b 100644 --- a/app/components/hooks/useTokenBalance.tsx +++ b/app/components/hooks/useTokenBalance.tsx @@ -17,7 +17,7 @@ const useTokenBalance = (requestedTokenAddress: string, userCurrentAddress: stri const { TokenBalancesController }: any = Engine.context; const fetchBalance = async (tokenAddress: string, userAddress: string): Promise => { - TokenBalancesController.getBalanceOf(tokenAddress, userAddress) + TokenBalancesController.getERC20BalanceOf(tokenAddress, userAddress) .then((balance: BN) => setTokenBalance(balance)) .catch(() => setError(true)) .finally(() => setLoading(false)); diff --git a/app/core/Engine.js b/app/core/Engine.js index 5394294faf7..b3a50cc660e 100644 --- a/app/core/Engine.js +++ b/app/core/Engine.js @@ -115,15 +115,12 @@ class Engine { { onPreferencesStateChange: (listener) => preferencesController.subscribe(listener), onNetworkStateChange: (listener) => networkController.subscribe(listener), - getAssetName: assetsContractController.getAssetName.bind(assetsContractController), - getAssetSymbol: assetsContractController.getAssetSymbol.bind(assetsContractController), - getCollectibleTokenURI: - assetsContractController.getCollectibleTokenURI.bind(assetsContractController), - getOwnerOf: assetsContractController.getOwnerOf.bind(assetsContractController), - balanceOfERC1155Collectible: - assetsContractController.balanceOfERC1155Collectible.bind(assetsContractController), - uriERC1155Collectible: - assetsContractController.uriERC1155Collectible.bind(assetsContractController), + getERC721AssetName: assetsContractController.getERC721AssetName.bind(assetsContractController), + getERC721AssetSymbol: assetsContractController.getERC721AssetSymbol.bind(assetsContractController), + getERC721TokenURI: assetsContractController.getERC721TokenURI.bind(assetsContractController), + getERC721OwnerOf: assetsContractController.getERC721OwnerOf.bind(assetsContractController), + getERC1155BalanceOf: assetsContractController.getERC1155BalanceOf.bind(assetsContractController), + getERC1155TokenURI: assetsContractController.getERC1155TokenURI.bind(assetsContractController), }, { useIPFSSubdomains: false, @@ -215,7 +212,7 @@ class Engine { { onTokensStateChange: (listener) => tokensController.subscribe(listener), getSelectedAddress: () => preferencesController.state.selectedAddress, - getBalanceOf: assetsContractController.getBalanceOf.bind(assetsContractController), + getERC20BalanceOf: assetsContractController.getERC20BalanceOf.bind(assetsContractController), }, { interval: 10000 } ), diff --git a/app/util/transactions/index.js b/app/util/transactions/index.js index 6f9a6d8f19a..e2774d18050 100644 --- a/app/util/transactions/index.js +++ b/app/util/transactions/index.js @@ -271,7 +271,7 @@ export async function isCollectibleAddress(address, tokenId) { const { AssetsContractController } = Engine.context; // Hack to know if the address is a collectible smart contract // for now this method is called from tx element so we have the respective 'tokenId' - const ownerOf = await AssetsContractController.getOwnerOf(address, tokenId); + const ownerOf = await AssetsContractController.getERC721OwnerOf(address, tokenId); const isCollectibleAddress = ownerOf && ownerOf !== '0x'; CollectibleAddresses.cache[address] = isCollectibleAddress; return isCollectibleAddress; diff --git a/package.json b/package.json index d1dfb3ccea0..1496176119d 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "dependencies": { "@exodus/react-native-payments": "git+https://github.com/MetaMask/react-native-payments.git#dbc8cbbed570892d2fea5e3d183bf243e062c1e5", "@metamask/contract-metadata": "^1.30.0", - "@metamask/controllers": "^22.0.0", + "@metamask/controllers": "25.1.0", "@metamask/etherscan-link": "^2.0.0", "@metamask/swaps-controller": "^6.5.0", "@react-native-clipboard/clipboard": "^1.8.4", diff --git a/patches/@metamask+controllers+22.0.0.patch b/patches/@metamask+controllers+22.0.0.patch deleted file mode 100644 index 12b56d46557..00000000000 --- a/patches/@metamask+controllers+22.0.0.patch +++ /dev/null @@ -1,222 +0,0 @@ -diff --git a/node_modules/@metamask/controllers/dist/assets/AssetsContractController.js b/node_modules/@metamask/controllers/dist/assets/AssetsContractController.js -index 6f47110..f0ba9fc 100644 ---- a/node_modules/@metamask/controllers/dist/assets/AssetsContractController.js -+++ b/node_modules/@metamask/controllers/dist/assets/AssetsContractController.js -@@ -67,9 +67,9 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - getBalanceOf(address, selectedAddress) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_token_abi_1.default).at(address); -+ const contract = new this.web3.eth.Contract(human_standard_token_abi_1.default, address); - return new Promise((resolve, reject) => { -- contract.balanceOf(selectedAddress, (error, result) => { -+ contract.methods.balanceOf(selectedAddress).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -88,9 +88,9 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - getTokenDecimals(address) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_token_abi_1.default).at(address); -+ const contract = new this.web3.eth.Contract(human_standard_token_abi_1.default, address); - return new Promise((resolve, reject) => { -- contract.decimals((error, result) => { -+ contract.methods.decimals().call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -110,7 +110,7 @@ class AssetsContractController extends BaseController_1.BaseController { - * @returns Promise resolving to token identifier for the 'index'th asset assigned to 'selectedAddress'. - */ - getCollectibleTokenId(address, selectedAddress, index) { -- const contract = this.web3.eth.contract(human_standard_collectible_abi_1.default).at(address); -+ const contract = new this.web3.eth.Contract(human_standard_collectible_abi_1.default, address); - return this.erc721Standard.getCollectibleTokenId(contract, selectedAddress, index); - } - /** -@@ -122,7 +122,7 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - getCollectibleTokenURI(address, tokenId) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_collectible_abi_1.default).at(address); -+ const contract = new this.web3.eth.Contract(human_standard_collectible_abi_1.default, address); - return this.erc721Standard.getCollectibleTokenURI(contract, tokenId); - }); - } -@@ -134,7 +134,7 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - getAssetName(address) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_collectible_abi_1.default).at(address); -+ const contract = new this.web3.eth.Contract(human_standard_collectible_abi_1.default, address); - return this.erc721Standard.getAssetName(contract); - }); - } -@@ -146,7 +146,7 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - getAssetSymbol(address) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_collectible_abi_1.default).at(address); -+ const contract = new this.web3.eth.Contract(human_standard_collectible_abi_1.default, address); - return this.erc721Standard.getAssetSymbol(contract); - }); - } -@@ -159,7 +159,7 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - getOwnerOf(address, tokenId) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_collectible_abi_1.default).at(address); -+ const contract = new this.web3.eth.Contract(human_standard_collectible_abi_1.default, address); - return this.erc721Standard.getOwnerOf(contract, tokenId); - }); - } -@@ -172,7 +172,7 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - uriERC1155Collectible(address, tokenId) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_multi_collectible_abi_1.default).at(address); -+ const contract = new this.web3.eth.Contract(human_standard_multi_collectible_abi_1.default, address); - return this.erc1155Standard.uri(contract, tokenId); - }); - } -@@ -186,7 +186,7 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - balanceOfERC1155Collectible(userAddress, collectibleAddress, collectibleId) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_multi_collectible_abi_1.default).at(collectibleAddress); -+ const contract = new this.web3.eth.Contract(human_standard_multi_collectible_abi_1.default, collectibleAddress); - return yield this.erc1155Standard.getBalanceOf(contract, userAddress, collectibleId); - }); - } -@@ -202,7 +202,7 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - transferSingleERC1155Collectible(collectibleAddress, senderAddress, recipientAddress, collectibleId, qty) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth.contract(human_standard_multi_collectible_abi_1.default).at(collectibleAddress); -+ const contract = new this.web3.eth.Contract(human_standard_multi_collectible_abi_1.default, collectibleAddress); - return yield this.erc1155Standard.transferSingle(contract, collectibleAddress, senderAddress, recipientAddress, collectibleId, qty); - }); - } -@@ -216,11 +216,10 @@ class AssetsContractController extends BaseController_1.BaseController { - */ - getBalancesInSingleCall(selectedAddress, tokensToDetect) { - return __awaiter(this, void 0, void 0, function* () { -- const contract = this.web3.eth -- .contract(single_call_balance_checker_abi_1.default) -- .at(SINGLE_CALL_BALANCES_ADDRESS); -+ const contract = new this.web3.eth -+ .Contract(single_call_balance_checker_abi_1.default, SINGLE_CALL_BALANCES_ADDRESS); - return new Promise((resolve, reject) => { -- contract.balances([selectedAddress], tokensToDetect, (error, result) => { -+ contract.methods.balances([selectedAddress], tokensToDetect).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -232,7 +231,7 @@ class AssetsContractController extends BaseController_1.BaseController { - tokensToDetect.forEach((tokenAddress, index) => { - const balance = result[index]; - /* istanbul ignore else */ -- if (!balance.isZero()) { -+ if (balance && balance !== '0') { - nonZeroBalances[tokenAddress] = balance; - } - }); -diff --git a/node_modules/@metamask/controllers/dist/assets/CollectibleStandards/ERC1155/ERC1155Standard.js b/node_modules/@metamask/controllers/dist/assets/CollectibleStandards/ERC1155/ERC1155Standard.js -index 8eafb2d..32c5357 100644 ---- a/node_modules/@metamask/controllers/dist/assets/CollectibleStandards/ERC1155/ERC1155Standard.js -+++ b/node_modules/@metamask/controllers/dist/assets/CollectibleStandards/ERC1155/ERC1155Standard.js -@@ -41,7 +41,7 @@ class ERC1155Standard { - */ - this.uri = (contract, tokenId) => __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.uri(tokenId, (error, result) => { -+ contract.methods.uri(tokenId).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -61,7 +61,7 @@ class ERC1155Standard { - */ - this.getBalanceOf = (contract, address, tokenId) => __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.balanceOf(address, tokenId, (error, result) => { -+ contract.methods.balanceOf(address, tokenId).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -86,7 +86,7 @@ class ERC1155Standard { - */ - this.transferSingle = (contract, operator, from, to, id, value) => __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.transferSingle(operator, from, to, id, value, (error, result) => { -+ contract.methods.transferSingle(operator, from, to, id, value).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -105,7 +105,7 @@ class ERC1155Standard { - */ - this.contractSupportsInterface = (contract, interfaceId) => __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.supportsInterface(interfaceId, (error, result) => { -+ contract.methods.supportsInterface(interfaceId).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -diff --git a/node_modules/@metamask/controllers/dist/assets/CollectibleStandards/ERC721/ERC721Standard.js b/node_modules/@metamask/controllers/dist/assets/CollectibleStandards/ERC721/ERC721Standard.js -index 6f8b482..aee6b5b 100644 ---- a/node_modules/@metamask/controllers/dist/assets/CollectibleStandards/ERC721/ERC721Standard.js -+++ b/node_modules/@metamask/controllers/dist/assets/CollectibleStandards/ERC721/ERC721Standard.js -@@ -42,7 +42,7 @@ class ERC721Standard { - */ - this.getCollectibleTokenId = (contract, selectedAddress, index) => __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.tokenOfOwnerByIndex(selectedAddress, index, (error, result) => { -+ contract.methods.tokenOfOwnerByIndex(selectedAddress, index).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -65,7 +65,7 @@ class ERC721Standard { - throw new Error('Contract does not support ERC721 metadata interface.'); - } - return new Promise((resolve, reject) => { -- contract.tokenURI(tokenId, (error, result) => { -+ contract.methods.tokenURI(tokenId).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -83,7 +83,7 @@ class ERC721Standard { - */ - this.getAssetName = (contract) => __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.name((error, result) => { -+ contract.methods.name().call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -101,7 +101,7 @@ class ERC721Standard { - */ - this.getAssetSymbol = (contract) => __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.symbol((error, result) => { -+ contract.methods.symbol().call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -120,7 +120,7 @@ class ERC721Standard { - */ - this.contractSupportsInterface = (contract, interfaceId) => __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.supportsInterface(interfaceId, (error, result) => { -+ contract.methods.supportsInterface(interfaceId).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); -@@ -141,7 +141,7 @@ class ERC721Standard { - getOwnerOf(contract, tokenId) { - return __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { -- contract.ownerOf(tokenId, (error, result) => { -+ contract.methods.ownerOf(tokenId).call((error, result) => { - /* istanbul ignore if */ - if (error) { - reject(error); diff --git a/patches/@metamask+controllers+25.1.0.patch b/patches/@metamask+controllers+25.1.0.patch new file mode 100644 index 00000000000..f28172b87e0 --- /dev/null +++ b/patches/@metamask+controllers+25.1.0.patch @@ -0,0 +1,172 @@ +diff --git a/node_modules/@metamask/controllers/dist/assets/Standards/CollectibleStandards/ERC1155/ERC1155Standard.js b/node_modules/@metamask/controllers/dist/assets/Standards/CollectibleStandards/ERC1155/ERC1155Standard.js +index 2e47f1a..ac49b60 100644 +--- a/node_modules/@metamask/controllers/dist/assets/Standards/CollectibleStandards/ERC1155/ERC1155Standard.js ++++ b/node_modules/@metamask/controllers/dist/assets/Standards/CollectibleStandards/ERC1155/ERC1155Standard.js +@@ -49,9 +49,9 @@ class ERC1155Standard { + * @returns Promise resolving to the 'tokenURI'. + */ + this.getTokenURI = (address, tokenId) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC1155).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC1155, address); + return new Promise((resolve, reject) => { +- contract.uri(tokenId, (error, result) => { ++ contract.methods.uri(tokenId).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -70,9 +70,9 @@ class ERC1155Standard { + * @returns Promise resolving to the 'balanceOf'. + */ + this.getBalanceOf = (contractAddress, address, tokenId) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC1155).at(contractAddress); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC1155, contractAddress); + return new Promise((resolve, reject) => { +- contract.balanceOf(address, tokenId, (error, result) => { ++ contract.methods.balanceOf(address, tokenId).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -95,9 +95,9 @@ class ERC1155Standard { + * @returns Promise resolving to the 'transferSingle'. + */ + this.transferSingle = (operator, from, to, id, value) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC1155).at(operator); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC1155, operator); + return new Promise((resolve, reject) => { +- contract.transferSingle(operator, from, to, id, value, (error, result) => { ++ contract.methods.transferSingle(operator, from, to, id, value).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -115,9 +115,9 @@ class ERC1155Standard { + * @returns Promise resolving to whether the contract implements `interfaceID`. + */ + this.contractSupportsInterface = (address, interfaceId) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC1155).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC1155, address); + return new Promise((resolve, reject) => { +- contract.supportsInterface(interfaceId, (error, result) => { ++ contract.methods.supportsInterface(interfaceId).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +diff --git a/node_modules/@metamask/controllers/dist/assets/Standards/CollectibleStandards/ERC721/ERC721Standard.js b/node_modules/@metamask/controllers/dist/assets/Standards/CollectibleStandards/ERC721/ERC721Standard.js +index 0935e9c..4914b49 100644 +--- a/node_modules/@metamask/controllers/dist/assets/Standards/CollectibleStandards/ERC721/ERC721Standard.js ++++ b/node_modules/@metamask/controllers/dist/assets/Standards/CollectibleStandards/ERC721/ERC721Standard.js +@@ -50,9 +50,9 @@ class ERC721Standard { + * @returns Promise resolving to token identifier for the 'index'th asset assigned to 'selectedAddress'. + */ + this.getCollectibleTokenId = (address, selectedAddress, index) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC721).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC721, address); + return new Promise((resolve, reject) => { +- contract.tokenOfOwnerByIndex(selectedAddress, index, (error, result) => { ++ contract.methods.tokenOfOwnerByIndex(selectedAddress, index).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -70,13 +70,13 @@ class ERC721Standard { + * @returns Promise resolving to the 'tokenURI'. + */ + this.getTokenURI = (address, tokenId) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC721).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC721, address); + const supportsMetadata = yield this.contractSupportsMetadataInterface(address); + if (!supportsMetadata) { + throw new Error('Contract does not support ERC721 metadata interface.'); + } + return new Promise((resolve, reject) => { +- contract.tokenURI(tokenId, (error, result) => { ++ contract.methods.tokenURI(tokenId).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -93,9 +93,9 @@ class ERC721Standard { + * @returns Promise resolving to the 'name'. + */ + this.getAssetName = (address) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC721).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC721, address); + return new Promise((resolve, reject) => { +- contract.name((error, result) => { ++ contract.methods.name().call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -112,9 +112,9 @@ class ERC721Standard { + * @returns Promise resolving to the 'symbol'. + */ + this.getAssetSymbol = (address) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC721).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC721, address); + return new Promise((resolve, reject) => { +- contract.symbol((error, result) => { ++ contract.methods.symbol().call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -132,9 +132,9 @@ class ERC721Standard { + * @returns Promise resolving to whether the contract implements `interfaceID`. + */ + this.contractSupportsInterface = (address, interfaceId) => __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC721).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC721, address); + return new Promise((resolve, reject) => { +- contract.supportsInterface(interfaceId, (error, result) => { ++ contract.methods.supportsInterface(interfaceId).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -187,9 +187,9 @@ class ERC721Standard { + */ + getOwnerOf(address, tokenId) { + return __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC721).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC721, address); + return new Promise((resolve, reject) => { +- contract.ownerOf(tokenId, (error, result) => { ++ contract.methods.ownerOf(tokenId).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +diff --git a/node_modules/@metamask/controllers/dist/assets/Standards/ERC20Standard.js b/node_modules/@metamask/controllers/dist/assets/Standards/ERC20Standard.js +index 5300699..df812c7 100644 +--- a/node_modules/@metamask/controllers/dist/assets/Standards/ERC20Standard.js ++++ b/node_modules/@metamask/controllers/dist/assets/Standards/ERC20Standard.js +@@ -25,9 +25,9 @@ class ERC20Standard { + */ + getBalanceOf(address, selectedAddress) { + return __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC20).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC20, address); + return new Promise((resolve, reject) => { +- contract.balanceOf(selectedAddress, (error, result) => { ++ contract.methods.balanceOf(selectedAddress).call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -46,9 +46,9 @@ class ERC20Standard { + */ + getTokenDecimals(address) { + return __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC20).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC20, address); + return new Promise((resolve, reject) => { +- contract.decimals((error, result) => { ++ contract.methods.decimals().call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); +@@ -67,9 +67,9 @@ class ERC20Standard { + */ + getTokenSymbol(address) { + return __awaiter(this, void 0, void 0, function* () { +- const contract = this.web3.eth.contract(metamask_eth_abis_1.abiERC20).at(address); ++ const contract = new this.web3.eth.Contract(metamask_eth_abis_1.abiERC20, address); + return new Promise((resolve, reject) => { +- contract.symbol((error, result) => { ++ contract.methods.symbol().call((error, result) => { + /* istanbul ignore if */ + if (error) { + reject(error); diff --git a/yarn.lock b/yarn.lock index ce777a43615..7c75e831b6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2158,46 +2158,7 @@ resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.30.0.tgz#fa8e1b0c3e7aaa963986088f691fb553ffbe3904" integrity sha512-b2usYW/ptQYnE6zhUmr4T+nvOAQJK5ABcpKudyQANpy4K099elpv4aN0WcrcOcwV99NHOdMzFP3ZuG0HoAyOBQ== -"@metamask/controllers@^22.0.0": - version "22.0.0" - resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-22.0.0.tgz#54f172be2ae7e32ce47536a1ff06e35cc6ee3c80" - integrity sha512-5m4aT+B87IOAvvlbfgqI5n7Pd6VSQUjHBfm34qMBBL5jjUFUSfK6BL0h6ef2jxTE2VCuyBibQ8A7sETQ1+Hd+Q== - dependencies: - "@ethereumjs/common" "^2.3.1" - "@ethereumjs/tx" "^3.2.1" - "@metamask/contract-metadata" "^1.31.0" - "@types/uuid" "^8.3.0" - abort-controller "^3.0.0" - async-mutex "^0.2.6" - babel-runtime "^6.26.0" - eth-ens-namehash "^2.0.8" - eth-json-rpc-infura "^5.1.0" - eth-keyring-controller "^6.2.1" - eth-method-registry "1.1.0" - eth-phishing-detect "^1.1.14" - 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" - ethers "^5.4.1" - ethjs-unit "^0.1.6" - ethjs-util "^0.1.6" - human-standard-collectible-abi "^1.0.2" - human-standard-multi-collectible-abi "^1.0.4" - human-standard-token-abi "^2.0.0" - immer "^9.0.6" - isomorphic-fetch "^3.0.0" - jsonschema "^1.2.4" - multiformats "^9.5.2" - nanoid "^3.1.12" - 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/controllers@^25.1.0": +"@metamask/controllers@25.1.0", "@metamask/controllers@^25.1.0": version "25.1.0" resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-25.1.0.tgz#2efee24a9a2b03ab2a2b0422c8f250931c269560" integrity sha512-syndn2lIhtlACzaqjDrw23dJzw8pZ6en4Cr35C7B9RRS87EhahUqkPP73moAzLtvbyqtBlAUO1HHrqV3lw4E5g== @@ -7920,7 +7881,7 @@ ethjs-util@0.1.3: is-hex-prefixed "1.0.0" strip-hex-prefix "1.0.0" -ethjs-util@0.1.6, ethjs-util@^0.1.3, ethjs-util@^0.1.6: +ethjs-util@0.1.6, ethjs-util@^0.1.3: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" integrity sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w== @@ -9189,16 +9150,6 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -human-standard-collectible-abi@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/human-standard-collectible-abi/-/human-standard-collectible-abi-1.0.2.tgz#077bae9ed1b0b0b82bc46932104b4b499c941aa0" - integrity sha512-nD3ITUuSAIBgkaCm9J2BGwlHL8iEzFjJfTleDAC5Wi8RBJEXXhxV0JeJjd95o+rTwf98uTE5MW+VoBKOIYQh0g== - -human-standard-multi-collectible-abi@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/human-standard-multi-collectible-abi/-/human-standard-multi-collectible-abi-1.0.4.tgz#981625bc1a6bea5fef90567f9e12c11581fac497" - integrity sha512-ylR9JDXClDJAxWD/QJxsjXJJdLTUmhipTquMAgrfybXL3qX3x3P/vmKg92A7qFu7SqVOf2hyv5dA8vX0j+0Thg== - human-standard-token-abi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/human-standard-token-abi/-/human-standard-token-abi-2.0.0.tgz#e0c2057596d0a1d4a110f91f974a37f4b904f008" @@ -11867,7 +11818,7 @@ nano-json-stream-parser@^0.1.2: resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" integrity sha1-DMj20OK2IrR5xA1JnEbWS3Vcb18= -nanoid@^3.1.12, nanoid@^3.1.15, nanoid@^3.1.31: +nanoid@^3.1.15, nanoid@^3.1.31: version "3.2.0" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.2.0.tgz#62667522da6673971cca916a6d3eff3f415ff80c" integrity sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==