From fdc8272ee5320b05eeaa2843a4826c6b30ab96eb Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Fri, 18 Oct 2024 10:00:54 +0200 Subject: [PATCH 1/6] chore: upgrade assets-controllers to v34.0.0 --- app/core/Engine.ts | 68 ++-- app/selectors/accountTrackerController.ts | 6 +- ...accountTrackerControllerReRenders.test.tsx | 6 +- app/selectors/types.ts | 4 +- package.json | 2 +- ...@metamask+assets-controllers+34.0.0.patch} | 378 ++++-------------- yarn.lock | 12 +- 7 files changed, 126 insertions(+), 350 deletions(-) rename patches/{@metamask+assets-controllers+33.0.0.patch => @metamask+assets-controllers+34.0.0.patch} (65%) diff --git a/app/core/Engine.ts b/app/core/Engine.ts index a93a46e8d21..ef0828642fa 100644 --- a/app/core/Engine.ts +++ b/app/core/Engine.ts @@ -3,7 +3,7 @@ import Crypto from 'react-native-quick-crypto'; import { scrypt } from 'react-native-fast-crypto'; import { AccountTrackerController, - AccountTrackerState, + AccountTrackerControllerState, AssetsContractController, CurrencyRateController, CurrencyRateState, @@ -334,7 +334,7 @@ type PermissionsByRpcMethod = ReturnType; type Permissions = PermissionsByRpcMethod[keyof PermissionsByRpcMethod]; export interface EngineState { - AccountTrackerController: AccountTrackerState; + AccountTrackerController: AccountTrackerControllerState; AddressBookController: AddressBookControllerState; AssetsContractController: BaseState; NftController: NftControllerState; @@ -515,7 +515,7 @@ class Engine { showApprovalRequest: () => undefined, typesExcludedFromRateLimiting: [ ApprovalType.Transaction, - ApprovalType.WatchAsset + ApprovalType.WatchAsset, ], }); @@ -653,7 +653,6 @@ class Engine { chainId: networkController.getNetworkClientById( networkController?.state.selectedNetworkClientId, ).configuration.chainId, - selectedAddress: preferencesController.state.selectedAddress, provider: networkController.getProviderAndBlockTracker().provider, state: initialState.TokensController, // @ts-expect-error TODO: Resolve mismatch between base-controller versions. @@ -662,11 +661,14 @@ class Engine { allowedActions: [ `${approvalController.name}:addRequest`, 'NetworkController:getNetworkClientById', + 'AccountsController:getAccount', + 'AccountsController:getSelectedAccount', ], allowedEvents: [ 'PreferencesController:stateChange', 'NetworkController:networkDidChange', 'TokenListController:stateChange', + 'AccountsController:selectedEvmAccountChange', ], }), }); @@ -940,34 +942,24 @@ class Engine { ), }); - const accountTrackerController = new AccountTrackerController( - { - // @ts-expect-error TODO: Resolve mismatch between base-controller versions - messenger: this.controllerMessenger.getRestricted({ - name: 'AccountTrackerController', - allowedActions: [ - `AccountsController:getSelectedAccount`, - `AccountsController:listAccounts`, - ], - allowedEvents: [ - 'AccountsController:selectedEvmAccountChange', - 'AccountsController:selectedAccountChange', - ], - }), - getMultiAccountBalancesEnabled: () => - preferencesController.state.isMultiAccountBalancesEnabled, - getCurrentChainId: () => - toHexadecimal( - networkController.getNetworkClientById( - networkController?.state.selectedNetworkClientId, - ).configuration.chainId, - ), - getNetworkClientById: - networkController.getNetworkClientById.bind(networkController), - }, - undefined, - { accounts: {} }, - ); + const accountTrackerController = new AccountTrackerController({ + // @ts-expect-error TODO: Resolve mismatch between base-controller versions + messenger: this.controllerMessenger.getRestricted({ + name: 'AccountTrackerController', + allowedActions: [ + 'AccountsController:getSelectedAccount', + 'AccountsController:listAccounts', + 'PreferencesController:getState', + 'NetworkController:getState', + 'NetworkController:getNetworkClientById', + ], + allowedEvents: [ + 'AccountsController:selectedEvmAccountChange', + 'AccountsController:selectedAccountChange', + ], + }), + state: { accounts: {} }, + }); const permissionController = new PermissionController({ // @ts-expect-error TODO: Resolve mismatch between base-controller versions. messenger: this.controllerMessenger.getRestricted({ @@ -1454,15 +1446,16 @@ class Engine { 'TokenListController:getState', 'TokensController:getState', 'TokensController:addDetectedTokens', + 'AccountsController:getAccount', ], allowedEvents: [ - 'AccountsController:selectedAccountChange', 'KeyringController:lock', 'KeyringController:unlock', 'PreferencesController:stateChange', 'NetworkController:networkDidChange', 'TokenListController:stateChange', 'TokensController:stateChange', + 'AccountsController:selectedEvmAccountChange', ], }), trackMetaMetricsEvent: () => @@ -1512,7 +1505,7 @@ class Engine { // @ts-expect-error TODO: Resolve mismatch between base-controller versions. messenger: this.controllerMessenger.getRestricted({ name: 'TokenBalancesController', - allowedActions: ['PreferencesController:getState'], + allowedActions: ['AccountsController:getSelectedAccount'], allowedEvents: ['TokensController:stateChange'], }), getERC20BalanceOf: assetsContractController.getERC20BalanceOf.bind( @@ -1528,12 +1521,13 @@ class Engine { 'TokensController:getState', 'NetworkController:getNetworkClientById', 'NetworkController:getState', - 'PreferencesController:getState', + 'AccountsController:getAccount', + 'AccountsController:getSelectedAccount', ], allowedEvents: [ - 'PreferencesController:stateChange', 'TokensController:stateChange', 'NetworkController:stateChange', + 'AccountsController:selectedEvmAccountChange', ], }), tokenPricesService: codefiTokenApiV2, @@ -1786,7 +1780,7 @@ class Engine { return; } provider.sendAsync = provider.sendAsync.bind(provider); - AccountTrackerController.configure({ provider }); + // AccountTrackerController.configure({ provider }); AssetsContractController.configure({ provider }); SwapsController.configure({ diff --git a/app/selectors/accountTrackerController.ts b/app/selectors/accountTrackerController.ts index f034cacdad8..d87dc1be939 100644 --- a/app/selectors/accountTrackerController.ts +++ b/app/selectors/accountTrackerController.ts @@ -1,6 +1,6 @@ import { createSelector } from 'reselect'; import { - AccountTrackerState, + AccountTrackerControllerState, AccountInformation, } from '@metamask/assets-controllers'; import { RootState } from '../reducers'; @@ -13,12 +13,12 @@ const selectAccountTrackerControllerState = (state: RootState) => export const selectAccounts = createDeepEqualSelector( selectAccountTrackerControllerState, - (accountTrackerControllerState: AccountTrackerState) => + (accountTrackerControllerState: AccountTrackerControllerState) => accountTrackerControllerState.accounts, ); export const selectAccountsByChainId = createSelector( selectAccountTrackerControllerState, - (accountTrackerControllerState: AccountTrackerState) => + (accountTrackerControllerState: AccountTrackerControllerState) => accountTrackerControllerState.accountsByChainId, ); export const selectAccountsLength = createSelector( diff --git a/app/selectors/accountTrackerControllerReRenders.test.tsx b/app/selectors/accountTrackerControllerReRenders.test.tsx index 3365c82b2b0..10e95e985be 100644 --- a/app/selectors/accountTrackerControllerReRenders.test.tsx +++ b/app/selectors/accountTrackerControllerReRenders.test.tsx @@ -9,7 +9,7 @@ import { TextMatch, TextMatchOptions, } from '@testing-library/react-native/build/matches'; -import { AccountTrackerState } from '@metamask/assets-controllers'; +import { AccountTrackerControllerState } from '@metamask/assets-controllers'; import { NetworkController } from '@metamask/network-controller'; import { AccountsControllerState } from '@metamask/accounts-controller'; import { @@ -166,7 +166,7 @@ jest.mock('../core/Engine', () => ({ '0xC4966c0D659D99699BFD7EB54D8fafEE40e4a756': { balance: '0x22' }, }, }, - } as Partial, + } as Partial, } as EngineState, })); @@ -243,7 +243,7 @@ describe('selectAccountBalanceByChainId', () => { [MOCK_ADDRESS_2]: { balance: MOCK_BALANCE_2 }, }, }, - } as Partial, + } as Partial, } as EngineState, }, } as RootState; diff --git a/app/selectors/types.ts b/app/selectors/types.ts index 061cec63b82..aa29131865e 100644 --- a/app/selectors/types.ts +++ b/app/selectors/types.ts @@ -1,5 +1,5 @@ import { - AccountTrackerState, + AccountTrackerControllerState, CurrencyRateState, NftDetectionController, NftControllerState, @@ -27,7 +27,7 @@ import { SnapController } from '@metamask/snaps-controllers'; export interface EngineState { engine: { backgroundState: { - AccountTrackerController: AccountTrackerState; + AccountTrackerController: AccountTrackerControllerState; AddressBookController: AddressBookControllerState; AssetsContractController: BaseState; NftController: NftControllerState; diff --git a/package.json b/package.json index 87384ba2998..f9030773866 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "@metamask/accounts-controller": "^18.2.1", "@metamask/address-book-controller": "^6.0.1", "@metamask/approval-controller": "^7.0.1", - "@metamask/assets-controllers": "^33.0.0", + "@metamask/assets-controllers": "^34.0.0", "@metamask/base-controller": "^7.0.1", "@metamask/composable-controller": "^3.0.0", "@metamask/contract-metadata": "^2.1.0", diff --git a/patches/@metamask+assets-controllers+33.0.0.patch b/patches/@metamask+assets-controllers+34.0.0.patch similarity index 65% rename from patches/@metamask+assets-controllers+33.0.0.patch rename to patches/@metamask+assets-controllers+34.0.0.patch index 18d12fd948f..1efac39421d 100644 --- a/patches/@metamask+assets-controllers+33.0.0.patch +++ b/patches/@metamask+assets-controllers+34.0.0.patch @@ -1,5 +1,30 @@ +diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-2NQRWANM.js b/node_modules/@metamask/assets-controllers/dist/chunk-2NQRWANM.js +index c164c90..1b148d8 100644 +--- a/node_modules/@metamask/assets-controllers/dist/chunk-2NQRWANM.js ++++ b/node_modules/@metamask/assets-controllers/dist/chunk-2NQRWANM.js +@@ -189,6 +189,20 @@ var TokensController = class extends _basecontroller.BaseController { + } + ); + } ++ ++ /** ++ * THIS FUNCTIONS IS CURRENTLY PATCHED AND STILL NEEDS TO BE IMPLEMENTED ON THE CORE REPO ++ * Resets to the default state ++ */ ++ reset() { ++ this.update((state) => { ++ state.allTokens = {}; ++ state.allIgnoredTokens = {}; ++ state.ignoredTokens = []; ++ state.tokens = []; ++ }); ++ } ++ + /** + * Adds a token to the stored token list. + * diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-354SINOH.js b/node_modules/@metamask/assets-controllers/dist/chunk-354SINOH.js -index 7f87776..ed19186 100644 +index 7f87776..c391efb 100644 --- a/node_modules/@metamask/assets-controllers/dist/chunk-354SINOH.js +++ b/node_modules/@metamask/assets-controllers/dist/chunk-354SINOH.js @@ -9,7 +9,7 @@ var _chunkZ4BLTVTBjs = require('./chunk-Z4BLTVTB.js'); @@ -19,7 +44,7 @@ index 7f87776..ed19186 100644 var _disabled, _addNft, _getNftState, _inProcessNftFetchingUpdates, _onPreferencesControllerStateChange, onPreferencesControllerStateChange_fn, _getOwnerNftApi, getOwnerNftApi_fn, _getOwnerNfts, getOwnerNfts_fn; var NftDetectionController = class extends _basecontroller.BaseController { /** -@@ -134,6 +135,61 @@ var NftDetectionController = class extends _basecontroller.BaseController { +@@ -134,6 +135,62 @@ var NftDetectionController = class extends _basecontroller.BaseController { apiNfts = resultNftApi.tokens.filter( (elm) => elm.token.isSpam === false && (elm.blockaidResult?.result_type ? elm.blockaidResult?.result_type === "Benign" /* Benign */ : true) ); @@ -78,11 +103,12 @@ index 7f87776..ed19186 100644 + }); + } + } ++ const addNftPromises = apiNfts.map(async (nft) => { const { tokenId, diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-7JWDWDXT.js b/node_modules/@metamask/assets-controllers/dist/chunk-7JWDWDXT.js -index af5d784..99e4a32 100644 +index af5d784..410e36d 100644 --- a/node_modules/@metamask/assets-controllers/dist/chunk-7JWDWDXT.js +++ b/node_modules/@metamask/assets-controllers/dist/chunk-7JWDWDXT.js @@ -44,7 +44,7 @@ var getDefaultNftControllerState = () => ({ @@ -139,7 +165,7 @@ index af5d784..99e4a32 100644 _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _useIpfsSubdomains, useIpfsSubdomains); _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _isIpfsGatewayEnabled, isIpfsGatewayEnabled); _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getERC721AssetName, getERC721AssetName); -@@ -279,6 +279,18 @@ var NftController = class extends _basecontroller.BaseController { +@@ -279,6 +279,19 @@ var NftController = class extends _basecontroller.BaseController { _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _onSelectedAccountChange, onSelectedAccountChange_fn).bind(this) ); } @@ -155,10 +181,11 @@ index af5d784..99e4a32 100644 + state.ignoredNfts = []; + }); + } ++ getNftApi() { return `${_controllerutils.NFT_API_BASE_URL}/tokens`; } -@@ -797,7 +809,7 @@ _mutex = new WeakMap(); +@@ -797,7 +810,7 @@ _mutex = new WeakMap(); _selectedAccountId = new WeakMap(); _chainId = new WeakMap(); _ipfsGateway = new WeakMap(); @@ -167,7 +194,7 @@ index af5d784..99e4a32 100644 _useIpfsSubdomains = new WeakMap(); _isIpfsGatewayEnabled = new WeakMap(); _getERC721AssetName = new WeakMap(); -@@ -822,7 +834,7 @@ onNetworkControllerNetworkDidChange_fn = function({ +@@ -822,7 +835,7 @@ onNetworkControllerNetworkDidChange_fn = function({ _onPreferencesControllerStateChange = new WeakSet(); onPreferencesControllerStateChange_fn = async function({ ipfsGateway, @@ -176,7 +203,7 @@ index af5d784..99e4a32 100644 isIpfsGatewayEnabled }) { const selectedAccount = this.messagingSystem.call( -@@ -830,9 +842,9 @@ onPreferencesControllerStateChange_fn = async function({ +@@ -830,9 +843,9 @@ onPreferencesControllerStateChange_fn = async function({ ); _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _selectedAccountId, selectedAccount.id); _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _ipfsGateway, ipfsGateway); @@ -188,7 +215,7 @@ index af5d784..99e4a32 100644 if (needsUpdateNftMetadata && selectedAccount) { await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateNftUpdateForAccount, updateNftUpdateForAccount_fn).call(this, selectedAccount); } -@@ -841,7 +853,7 @@ _onSelectedAccountChange = new WeakSet(); +@@ -841,7 +854,7 @@ _onSelectedAccountChange = new WeakSet(); onSelectedAccountChange_fn = async function(internalAccount) { const oldSelectedAccountId = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _selectedAccountId); _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _selectedAccountId, internalAccount.id); @@ -197,7 +224,7 @@ index af5d784..99e4a32 100644 if (needsUpdateNftMetadata) { await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateNftUpdateForAccount, updateNftUpdateForAccount_fn).call(this, internalAccount); } -@@ -865,9 +877,14 @@ updateNestedNftState_fn = function(newCollection, baseStateKey, { userAddress, c +@@ -865,9 +878,15 @@ updateNestedNftState_fn = function(newCollection, baseStateKey, { userAddress, c }); }; _getNftInformationFromApi = new WeakSet(); @@ -208,16 +235,18 @@ index af5d784..99e4a32 100644 + }); + // Convert hex chainId to number + const convertedChainId = (0, _controllerutils.convertHexToDecimal)(chainId).toString(); ++ const urlParams = new URLSearchParams({ - chainIds: "1", + chainIds: convertedChainId, tokens: `${contractAddress}:${tokenId}`, includeTopBid: "true", includeAttributes: "true", -@@ -881,12 +898,26 @@ getNftInformationFromApi_fn = async function(contractAddress, tokenId) { +@@ -881,12 +900,27 @@ getNftInformationFromApi_fn = async function(contractAddress, tokenId) { } } }); ++ + const getCollectionParams = new URLSearchParams({ + chainId: convertedChainId, + id: `${nftInformation?.tokens[0]?.token?.collection?.id}` @@ -242,7 +271,7 @@ index af5d784..99e4a32 100644 }; } const { -@@ -918,7 +949,16 @@ getNftInformationFromApi_fn = async function(contractAddress, tokenId) { +@@ -918,7 +952,16 @@ getNftInformationFromApi_fn = async function(contractAddress, tokenId) { }, rarityRank && { rarityRank }, rarity && { rarity }, @@ -260,7 +289,7 @@ index af5d784..99e4a32 100644 ); return nftMetadata; }; -@@ -938,7 +978,7 @@ getNftInformationFromTokenURI_fn = async function(contractAddress, tokenId, netw +@@ -938,7 +981,7 @@ getNftInformationFromTokenURI_fn = async function(contractAddress, tokenId, netw tokenURI: tokenURI ?? null }; } @@ -269,7 +298,7 @@ index af5d784..99e4a32 100644 if (!hasIpfsTokenURI && !isDisplayNFTMediaToggleEnabled) { return { image: null, -@@ -946,7 +986,8 @@ getNftInformationFromTokenURI_fn = async function(contractAddress, tokenId, netw +@@ -946,7 +989,8 @@ getNftInformationFromTokenURI_fn = async function(contractAddress, tokenId, netw description: null, standard: standard || null, favorite: false, @@ -279,7 +308,7 @@ index af5d784..99e4a32 100644 }; } if (hasIpfsTokenURI) { -@@ -956,6 +997,16 @@ getNftInformationFromTokenURI_fn = async function(contractAddress, tokenId, netw +@@ -956,6 +1000,16 @@ getNftInformationFromTokenURI_fn = async function(contractAddress, tokenId, netw _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _useIpfsSubdomains) ); } @@ -296,7 +325,7 @@ index af5d784..99e4a32 100644 try { const object = await _controllerutils.handleFetch.call(void 0, tokenURI); const image = Object.prototype.hasOwnProperty.call(object, "image") ? "image" : ( -@@ -977,7 +1028,8 @@ getNftInformationFromTokenURI_fn = async function(contractAddress, tokenId, netw +@@ -977,7 +1031,8 @@ getNftInformationFromTokenURI_fn = async function(contractAddress, tokenId, netw description: null, standard: standard || null, favorite: false, @@ -306,7 +335,7 @@ index af5d784..99e4a32 100644 }; } }; -@@ -1008,10 +1060,22 @@ getNftInformation_fn = async function(contractAddress, tokenId, networkClientId) +@@ -1008,10 +1063,22 @@ getNftInformation_fn = async function(contractAddress, tokenId, networkClientId) _controllerutils.safelyExecute.call(void 0, () => _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getNftInformationFromTokenURI, getNftInformationFromTokenURI_fn).call(this, contractAddress, tokenId, networkClientId) ), @@ -331,7 +360,7 @@ index af5d784..99e4a32 100644 return { ...nftApiMetadata, name: blockchainMetadata?.name ?? nftApiMetadata?.name ?? null, -@@ -1095,7 +1159,8 @@ addIndividualNft_fn = async function(tokenAddress, tokenId, nftMetadata, nftCont +@@ -1095,7 +1162,8 @@ addIndividualNft_fn = async function(tokenAddress, tokenId, nftMetadata, nftCont nftMetadata, existingEntry ); @@ -341,7 +370,7 @@ index af5d784..99e4a32 100644 return; } const indexToUpdate = nfts.findIndex( -@@ -1127,7 +1192,8 @@ addIndividualNft_fn = async function(tokenAddress, tokenId, nftMetadata, nftCont +@@ -1127,7 +1195,8 @@ addIndividualNft_fn = async function(tokenAddress, tokenId, nftMetadata, nftCont symbol: nftContract.symbol, tokenId: tokenId.toString(), standard: nftMetadata.standard, @@ -351,121 +380,41 @@ index af5d784..99e4a32 100644 }); } } finally { -diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-FGAZXVKS.js b/node_modules/@metamask/assets-controllers/dist/chunk-FGAZXVKS.js -index 4a6aa79..da5f9c1 100644 ---- a/node_modules/@metamask/assets-controllers/dist/chunk-FGAZXVKS.js -+++ b/node_modules/@metamask/assets-controllers/dist/chunk-FGAZXVKS.js -@@ -179,6 +179,15 @@ var TokenRatesController = class extends _pollingcontroller.StaticIntervalPollin +diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js b/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js +index 995ec6b..38f7010 100644 +--- a/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js ++++ b/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js +@@ -67,12 +67,23 @@ var TokenBalancesController = class extends _basecontroller.BaseController { + _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getERC20BalanceOf, getERC20BalanceOf); + this.poll(); + } ++ + /** + * Allows controller to update tracked tokens contract balances. + */ enable() { _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _disabled, false); } ++ + /** + * THIS FUNCTIONS IS CURRENTLY PATCHED AND STILL NEEDS TO BE IMPLEMENTED ON THE CORE REPO + * Resets to the default state + */ + reset() { + this.update((state) => { -+ state.marketData = {}; ++ state.contractBalances = {}; + }); + } /** - * Blocks controller from making network calls - */ -diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-NWVMFCSC.js b/node_modules/@metamask/assets-controllers/dist/chunk-NWVMFCSC.js -index cdb2710..5a7529d 100644 ---- a/node_modules/@metamask/assets-controllers/dist/chunk-NWVMFCSC.js -+++ b/node_modules/@metamask/assets-controllers/dist/chunk-NWVMFCSC.js -@@ -19,7 +19,7 @@ function getDefaultTokenBalancesState() { - contractBalances: {} - }; - } --var _handle, _getERC20BalanceOf, _interval, _tokens, _disabled; -+var _handle, _getERC20BalanceOf, _interval, _tokens, _disabled, _updateInProgress; - var TokenBalancesController = class extends _basecontroller.BaseController { - /** - * Construct a Token Balances Controller. -@@ -54,9 +54,11 @@ var TokenBalancesController = class extends _basecontroller.BaseController { - _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _interval, void 0); - _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _tokens, void 0); - _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _disabled, void 0); -+ _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateInProgress, void 0); - _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _disabled, disabled); - _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _interval, interval); - _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _tokens, tokens); -+ _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _updateInProgress, false); - this.messagingSystem.subscribe( - "TokensController:stateChange", - ({ tokens: newTokens, detectedTokens }) => { -@@ -78,6 +80,15 @@ var TokenBalancesController = class extends _basecontroller.BaseController { + * Blocks controller from updating tracked tokens contract balances. */ - disable() { - _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _disabled, true); -+ } -+ /** -+ * THIS FUNCTIONS IS CURRENTLY PATCHED AND STILL NEEDS TO BE IMPLEMENTED ON THE CORE REPO -+ * Resets to the default state -+ */ -+ reset() { -+ this.update((state) => { -+ state.contractBalances = {}; -+ }); - } - /** - * Starts a new polling interval. -@@ -107,20 +118,28 @@ var TokenBalancesController = class extends _basecontroller.BaseController { - "PreferencesController:getState" - ); - const newContractBalances = {}; -- for (const token of _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _tokens)) { -+ -+ const balancePromises = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _tokens).map((token) => { - const { address } = token; -- try { -- const balance = await _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getERC20BalanceOf).call(this, address, selectedAddress); -- newContractBalances[address] = _controllerutils.toHex.call(void 0, balance); -- token.hasBalanceError = false; -- } catch (error) { -- newContractBalances[address] = _controllerutils.toHex.call(void 0, 0); -- token.hasBalanceError = true; -- } -- } -+ return _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getERC20BalanceOf).call(this, address, selectedAddress).then((balance) => { -+ newContractBalances[address] = _controllerutils.toHex.call(void 0, balance); -+ token = { -+ ...token, -+ hasBalanceError: false -+ }; -+ }).catch((error) => { -+ newContractBalances[address] = _controllerutils.toHex.call(void 0, 0); -+ token = { -+ ...token, -+ hasBalanceError: true -+ }; -+ }); -+ }); -+ await Promise.all(balancePromises); - this.update((state) => { - state.contractBalances = newContractBalances; - }); -+ _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _updateInProgress, false); - } - }; - _handle = new WeakMap(); -@@ -128,6 +147,7 @@ _getERC20BalanceOf = new WeakMap(); - _interval = new WeakMap(); - _tokens = new WeakMap(); - _disabled = new WeakMap(); -+_updateInProgress = new WeakMap(); - var TokenBalancesController_default = TokenBalancesController; - - -diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-RJBYLTY5.js b/node_modules/@metamask/assets-controllers/dist/chunk-RJBYLTY5.js -index 294447b..5e522de 100644 ---- a/node_modules/@metamask/assets-controllers/dist/chunk-RJBYLTY5.js -+++ b/node_modules/@metamask/assets-controllers/dist/chunk-RJBYLTY5.js -@@ -293,6 +293,19 @@ var TokensController = class extends _basecontroller.BaseController { - releaseLock(); - } +diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-RPQ737HL.js b/node_modules/@metamask/assets-controllers/dist/chunk-RPQ737HL.js +index b14af30..ee7141e 100644 +--- a/node_modules/@metamask/assets-controllers/dist/chunk-RPQ737HL.js ++++ b/node_modules/@metamask/assets-controllers/dist/chunk-RPQ737HL.js +@@ -173,6 +173,16 @@ var TokenRatesController = class extends _pollingcontroller.StaticIntervalPollin + _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _subscribeToNetworkStateChange, subscribeToNetworkStateChange_fn).call(this); + _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _subscribeToAccountChange, subscribeToAccountChange_fn).call(this); } + + /** @@ -474,127 +423,17 @@ index 294447b..5e522de 100644 + */ + reset() { + this.update((state) => { -+ state.allTokens = {}; -+ state.allIgnoredTokens = {}; -+ state.ignoredTokens = []; -+ state.tokens = []; ++ state.marketData = {}; + }); + } /** - * Add a batch of tokens. - * -diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-T5ZX5BV7.js b/node_modules/@metamask/assets-controllers/dist/chunk-T5ZX5BV7.js -index 9c89a65..2ac17ba 100644 ---- a/node_modules/@metamask/assets-controllers/dist/chunk-T5ZX5BV7.js -+++ b/node_modules/@metamask/assets-controllers/dist/chunk-T5ZX5BV7.js -@@ -87,6 +87,7 @@ var CurrencyRateController = class extends _pollingcontroller.StaticIntervalPoll - const nativeCurrencyForExchangeRate = Object.values( - _controllerutils.TESTNET_TICKER_SYMBOLS - ).includes(nativeCurrency) ? _controllerutils.FALL_BACK_VS_CURRENCY : nativeCurrency; -+ let shouldUpdateState = true; - try { - if (currentCurrency && nativeCurrency && // if either currency is an empty string we can skip the comparison - // because it will result in an error from the api and ultimately -@@ -103,23 +104,27 @@ var CurrencyRateController = class extends _pollingcontroller.StaticIntervalPoll - } - } catch (error) { - if (!(error instanceof Error && error.message.includes("market does not exist for this coin pair"))) { -+ // Don't update state on transient / unexpected errors -+ shouldUpdateState = false; - throw error; - } - } finally { - try { -- this.update(() => { -- return { -- currencyRates: { -- ...currencyRates, -- [nativeCurrency]: { -- conversionDate, -- conversionRate, -- usdConversionRate -- } -- }, -- currentCurrency -- }; -- }); -+ if(shouldUpdateState) { -+ this.update(() => { -+ return { -+ currencyRates: { -+ ...currencyRates, -+ [nativeCurrency]: { -+ conversionDate, -+ conversionRate, -+ usdConversionRate -+ } -+ }, -+ currentCurrency -+ }; -+ }); -+ } - } finally { - releaseLock(); - } -diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-VZF43NDM.js b/node_modules/@metamask/assets-controllers/dist/chunk-VZF43NDM.js -index 871ba96..02f5036 100644 ---- a/node_modules/@metamask/assets-controllers/dist/chunk-VZF43NDM.js -+++ b/node_modules/@metamask/assets-controllers/dist/chunk-VZF43NDM.js -@@ -165,7 +165,9 @@ var TokenDetectionController = class extends _pollingcontroller.StaticIntervalPo - if (!this.isActive) { - return; - } -- const addressAgainstWhichToDetect = selectedAddress ?? _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _selectedAddress); -+ const currentAddress = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _selectedAddress); -+ const currentAddressChecksum = _controllerutils.toChecksumHexAddress.call(void 0, currentAddress) -+ const addressAgainstWhichToDetect = _controllerutils.toChecksumHexAddress.call(void 0, selectedAddress) ?? currentAddressChecksum; - const { chainId, networkClientId: selectedNetworkClientId } = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getCorrectChainIdAndNetworkClientId, getCorrectChainIdAndNetworkClientId_fn).call(this, networkClientId); - const chainIdAgainstWhichToDetect = chainId; - const networkClientIdAgainstWhichToDetect = selectedNetworkClientId; -@@ -228,12 +230,10 @@ registerEventListeners_fn = function() { - "PreferencesController:stateChange", - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/no-misused-promises -- async ({ selectedAddress: newSelectedAddress, useTokenDetection }) => { -- const isSelectedAddressChanged = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _selectedAddress) !== newSelectedAddress; -+ async ({ useTokenDetection }) => { - const isDetectionChangedFromPreferences = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _isDetectionEnabledFromPreferences) !== useTokenDetection; -- _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _selectedAddress, newSelectedAddress); - _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _isDetectionEnabledFromPreferences, useTokenDetection); -- if (isSelectedAddressChanged || isDetectionChangedFromPreferences) { -+ if ( isDetectionChangedFromPreferences) { - await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _restartTokenDetection, restartTokenDetection_fn).call(this, { - selectedAddress: _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _selectedAddress) - }); + * Allows controller to make active and passive polling requests + */ diff --git a/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts b/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts -index b663e26..09f72c6 100644 +index b663e26..af93d16 100644 --- a/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts +++ b/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts -@@ -7,7 +7,7 @@ import type { PreferencesControllerStateChangeEvent } from '@metamask/preference - import type { Hex } from '@metamask/utils'; - import type { AssetsContractController } from './AssetsContractController'; - import { Source } from './constants'; --import type { Collection, Attributes, LastSale } from './NftDetectionController'; -+import type { Collection, Attributes, LastSale, TopBid } from './NftDetectionController'; - type NFTStandardType = 'ERC721' | 'ERC1155'; - type SuggestedNftMeta = { - asset: { -@@ -108,11 +108,13 @@ export type NftMetadata = { - creator?: string; - transactionId?: string; - tokenURI?: string | null; -+ error?: string; - collection?: Collection; - address?: string; -- attributes?: Attributes; -+ attributes?: Attributes[]; - lastSale?: LastSale; - rarityRank?: string; -+ topBid?: TopBid; - }; - /** - * @type NftControllerState -@@ -419,6 +421,11 @@ export declare class NftController extends BaseController; @@ -607,65 +446,8 @@ index b663e26..09f72c6 100644 export default NftController; //# sourceMappingURL=NftController.d.ts.map \ No newline at end of file -diff --git a/node_modules/@metamask/assets-controllers/dist/types/NftDetectionController.d.ts b/node_modules/@metamask/assets-controllers/dist/types/NftDetectionController.d.ts -index c645b3a..2f1c945 100644 ---- a/node_modules/@metamask/assets-controllers/dist/types/NftDetectionController.d.ts -+++ b/node_modules/@metamask/assets-controllers/dist/types/NftDetectionController.d.ts -@@ -227,7 +227,41 @@ export type Attributes = { - topBidValue?: number | null; - createdAt?: string; - }; --export type Collection = { -+ -+export type GetCollectionsResponse = { -+ collections: CollectionResponse[]; -+}; -+export type CollectionResponse = { -+ id?: string; -+ openseaVerificationStatus?: string; -+ contractDeployedAt?: string; -+ creator?: string; -+ ownerCount?: string; -+ topBid?: TopBid & { -+ sourceDomain?: string; -+ }; -+}; -+export type FloorAskCollection = { -+ id?: string; -+ price?: Price; -+ maker?: string; -+ kind?: string; -+ validFrom?: number; -+ validUntil?: number; -+ source?: SourceCollection; -+ rawData?: Metadata; -+ isNativeOffChainCancellable?: boolean; -+}; -+ -+export type SourceCollection = { -+ id: string; -+ domain: string; -+ name: string; -+ icon: string; -+ url: string; -+}; -+ -+export type TokenCollection = { - id?: string; - name?: string; - slug?: string; -@@ -243,7 +277,9 @@ export type Collection = { - floorAskPrice?: Price; - royaltiesBps?: number; - royalties?: Royalties[]; -+ floorAsk?: FloorAskCollection; - }; -+export type Collection = TokenCollection & CollectionResponse; - export type Royalties = { - bps?: number; - recipient?: string; diff --git a/node_modules/@metamask/assets-controllers/dist/types/TokenBalancesController.d.ts b/node_modules/@metamask/assets-controllers/dist/types/TokenBalancesController.d.ts -index 52bb3ac..d4d5c0a 100644 +index 45d58f8..ce24723 100644 --- a/node_modules/@metamask/assets-controllers/dist/types/TokenBalancesController.d.ts +++ b/node_modules/@metamask/assets-controllers/dist/types/TokenBalancesController.d.ts @@ -79,6 +79,11 @@ export declare class TokenBalancesController extends BaseController Date: Fri, 18 Oct 2024 11:01:24 +0200 Subject: [PATCH 2/6] chore: update patch --- app/core/EngineService/EngineService.ts | 5 +- .../@metamask+assets-controllers+34.0.0.patch | 126 +++++++++++++++++- 2 files changed, 128 insertions(+), 3 deletions(-) diff --git a/app/core/EngineService/EngineService.ts b/app/core/EngineService/EngineService.ts index 04cc0027f2b..010a251c822 100644 --- a/app/core/EngineService/EngineService.ts +++ b/app/core/EngineService/EngineService.ts @@ -71,7 +71,10 @@ class EngineService { name: 'KeyringController', key: `${engine.context.KeyringController.name}:stateChange`, }, - { name: 'AccountTrackerController' }, + { + name: 'AccountTrackerController', + key: 'AccountTrackerController:stateChange', + }, { name: 'NetworkController', key: AppConstants.NETWORK_STATE_CHANGE_EVENT, diff --git a/patches/@metamask+assets-controllers+34.0.0.patch b/patches/@metamask+assets-controllers+34.0.0.patch index 1efac39421d..60ae48c7b95 100644 --- a/patches/@metamask+assets-controllers+34.0.0.patch +++ b/patches/@metamask+assets-controllers+34.0.0.patch @@ -381,10 +381,31 @@ index af5d784..410e36d 100644 } } finally { diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js b/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js -index 995ec6b..38f7010 100644 +index 995ec6b..f7b15e1 100644 --- a/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js +++ b/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js -@@ -67,12 +67,23 @@ var TokenBalancesController = class extends _basecontroller.BaseController { +@@ -19,7 +19,7 @@ function getDefaultTokenBalancesState() { + contractBalances: {} + }; + } +-var _handle, _getERC20BalanceOf, _interval, _tokens, _disabled; ++var _handle, _getERC20BalanceOf, _interval, _tokens, _disabled, _updateInProgress; + var TokenBalancesController = class extends _basecontroller.BaseController { + /** + * Construct a Token Balances Controller. +@@ -54,9 +54,11 @@ var TokenBalancesController = class extends _basecontroller.BaseController { + _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _interval, void 0); + _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _tokens, void 0); + _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _disabled, void 0); ++ _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateInProgress, void 0); + _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _disabled, disabled); + _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _interval, interval); + _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _tokens, tokens); ++ _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _updateInProgress, false); + this.messagingSystem.subscribe( + "TokensController:stateChange", + ({ tokens: newTokens, detectedTokens }) => { +@@ -67,12 +69,23 @@ var TokenBalancesController = class extends _basecontroller.BaseController { _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getERC20BalanceOf, getERC20BalanceOf); this.poll(); } @@ -408,6 +429,54 @@ index 995ec6b..38f7010 100644 /** * Blocks controller from updating tracked tokens contract balances. */ +@@ -107,20 +120,28 @@ var TokenBalancesController = class extends _basecontroller.BaseController { + "AccountsController:getSelectedAccount" + ); + const newContractBalances = {}; +- for (const token of _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _tokens)) { +- const { address } = token; +- try { +- const balance = await _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getERC20BalanceOf).call(this, address, selectedInternalAccount.address); +- newContractBalances[address] = _controllerutils.toHex.call(void 0, balance); +- token.hasBalanceError = false; +- } catch (error) { +- newContractBalances[address] = _controllerutils.toHex.call(void 0, 0); +- token.hasBalanceError = true; +- } +- } ++ ++ const balancePromises = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _tokens).map((token) => { ++ return _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getERC20BalanceOf).call(this, address, selectedAddress).then((balance) => { ++ newContractBalances[address] = _controllerutils.toHex.call(void 0, balance); ++ token = { ++ ...token, ++ hasBalanceError: false ++ }; ++ }).catch((error) => { ++ newContractBalances[address] = _controllerutils.toHex.call(void 0, 0); ++ token = { ++ ...token, ++ hasBalanceError: true ++ }; ++ }); ++ }); ++ await Promise.all(balancePromises); ++ + this.update((state) => { + state.contractBalances = newContractBalances; + }); ++ _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _updateInProgress, false); + } + }; + _handle = new WeakMap(); +@@ -128,6 +149,7 @@ _getERC20BalanceOf = new WeakMap(); + _interval = new WeakMap(); + _tokens = new WeakMap(); + _disabled = new WeakMap(); ++_updateInProgress = new WeakMap(); + var TokenBalancesController_default = TokenBalancesController; + + diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-RPQ737HL.js b/node_modules/@metamask/assets-controllers/dist/chunk-RPQ737HL.js index b14af30..ee7141e 100644 --- a/node_modules/@metamask/assets-controllers/dist/chunk-RPQ737HL.js @@ -429,6 +498,59 @@ index b14af30..ee7141e 100644 /** * Allows controller to make active and passive polling requests */ +diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-T5ZX5BV7.js b/node_modules/@metamask/assets-controllers/dist/chunk-T5ZX5BV7.js +index 9c89a65..2ac17ba 100644 +--- a/node_modules/@metamask/assets-controllers/dist/chunk-T5ZX5BV7.js ++++ b/node_modules/@metamask/assets-controllers/dist/chunk-T5ZX5BV7.js +@@ -87,6 +87,7 @@ var CurrencyRateController = class extends _pollingcontroller.StaticIntervalPoll + const nativeCurrencyForExchangeRate = Object.values( + _controllerutils.TESTNET_TICKER_SYMBOLS + ).includes(nativeCurrency) ? _controllerutils.FALL_BACK_VS_CURRENCY : nativeCurrency; ++ let shouldUpdateState = true; + try { + if (currentCurrency && nativeCurrency && // if either currency is an empty string we can skip the comparison + // because it will result in an error from the api and ultimately +@@ -103,23 +104,27 @@ var CurrencyRateController = class extends _pollingcontroller.StaticIntervalPoll + } + } catch (error) { + if (!(error instanceof Error && error.message.includes("market does not exist for this coin pair"))) { ++ // Don't update state on transient / unexpected errors ++ shouldUpdateState = false; + throw error; + } + } finally { + try { +- this.update(() => { +- return { +- currencyRates: { +- ...currencyRates, +- [nativeCurrency]: { +- conversionDate, +- conversionRate, +- usdConversionRate +- } +- }, +- currentCurrency +- }; +- }); ++ if(shouldUpdateState) { ++ this.update(() => { ++ return { ++ currencyRates: { ++ ...currencyRates, ++ [nativeCurrency]: { ++ conversionDate, ++ conversionRate, ++ usdConversionRate ++ } ++ }, ++ currentCurrency ++ }; ++ }); ++ } + } finally { + releaseLock(); + } diff --git a/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts b/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts index b663e26..af93d16 100644 --- a/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts From 784a752ddf0e123d445adb1c24b825492e0bf5c8 Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Fri, 18 Oct 2024 11:30:11 +0200 Subject: [PATCH 3/6] chore: update patch --- patches/@metamask+assets-controllers+34.0.0.patch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/patches/@metamask+assets-controllers+34.0.0.patch b/patches/@metamask+assets-controllers+34.0.0.patch index 60ae48c7b95..623ce8c3124 100644 --- a/patches/@metamask+assets-controllers+34.0.0.patch +++ b/patches/@metamask+assets-controllers+34.0.0.patch @@ -381,7 +381,7 @@ index af5d784..410e36d 100644 } } finally { diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js b/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js -index 995ec6b..f7b15e1 100644 +index 995ec6b..80cafa4 100644 --- a/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js +++ b/node_modules/@metamask/assets-controllers/dist/chunk-NHFZIY2K.js @@ -19,7 +19,7 @@ function getDefaultTokenBalancesState() { @@ -429,12 +429,14 @@ index 995ec6b..f7b15e1 100644 /** * Blocks controller from updating tracked tokens contract balances. */ -@@ -107,20 +120,28 @@ var TokenBalancesController = class extends _basecontroller.BaseController { +@@ -107,20 +120,29 @@ var TokenBalancesController = class extends _basecontroller.BaseController { "AccountsController:getSelectedAccount" ); const newContractBalances = {}; - for (const token of _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _tokens)) { -- const { address } = token; ++ ++ const balancePromises = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _tokens).map((token) => { + const { address } = token; - try { - const balance = await _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getERC20BalanceOf).call(this, address, selectedInternalAccount.address); - newContractBalances[address] = _controllerutils.toHex.call(void 0, balance); @@ -444,9 +446,7 @@ index 995ec6b..f7b15e1 100644 - token.hasBalanceError = true; - } - } -+ -+ const balancePromises = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _tokens).map((token) => { -+ return _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getERC20BalanceOf).call(this, address, selectedAddress).then((balance) => { ++ return _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getERC20BalanceOf).call(this, address, selectedInternalAccount.address).then((balance) => { + newContractBalances[address] = _controllerutils.toHex.call(void 0, balance); + token = { + ...token, @@ -469,7 +469,7 @@ index 995ec6b..f7b15e1 100644 } }; _handle = new WeakMap(); -@@ -128,6 +149,7 @@ _getERC20BalanceOf = new WeakMap(); +@@ -128,6 +150,7 @@ _getERC20BalanceOf = new WeakMap(); _interval = new WeakMap(); _tokens = new WeakMap(); _disabled = new WeakMap(); From d5c3efbd947aecae3bdc85f42f6f6cde3190812f Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Fri, 18 Oct 2024 12:13:11 +0200 Subject: [PATCH 4/6] chore: update patch --- .../@metamask+assets-controllers+34.0.0.patch | 84 ++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/patches/@metamask+assets-controllers+34.0.0.patch b/patches/@metamask+assets-controllers+34.0.0.patch index 623ce8c3124..07493ea82c8 100644 --- a/patches/@metamask+assets-controllers+34.0.0.patch +++ b/patches/@metamask+assets-controllers+34.0.0.patch @@ -552,10 +552,34 @@ index 9c89a65..2ac17ba 100644 releaseLock(); } diff --git a/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts b/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts -index b663e26..af93d16 100644 +index b663e26..09f72c6 100644 --- a/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts +++ b/node_modules/@metamask/assets-controllers/dist/types/NftController.d.ts -@@ -419,6 +419,11 @@ export declare class NftController extends BaseController; @@ -568,6 +592,62 @@ index b663e26..af93d16 100644 export default NftController; //# sourceMappingURL=NftController.d.ts.map \ No newline at end of file +diff --git a/node_modules/@metamask/assets-controllers/dist/types/NftDetectionController.d.ts b/node_modules/@metamask/assets-controllers/dist/types/NftDetectionController.d.ts +index c645b3a..e5c223b 100644 +--- a/node_modules/@metamask/assets-controllers/dist/types/NftDetectionController.d.ts ++++ b/node_modules/@metamask/assets-controllers/dist/types/NftDetectionController.d.ts +@@ -227,7 +227,40 @@ export type Attributes = { + topBidValue?: number | null; + createdAt?: string; + }; +-export type Collection = { ++export type GetCollectionsResponse = { ++ collections: CollectionResponse[]; ++}; ++export type CollectionResponse = { ++ id?: string; ++ openseaVerificationStatus?: string; ++ contractDeployedAt?: string; ++ creator?: string; ++ ownerCount?: string; ++ topBid?: TopBid & { ++ sourceDomain?: string; ++ }; ++}; ++export type FloorAskCollection = { ++ id?: string; ++ price?: Price; ++ maker?: string; ++ kind?: string; ++ validFrom?: number; ++ validUntil?: number; ++ source?: SourceCollection; ++ rawData?: Metadata; ++ isNativeOffChainCancellable?: boolean; ++}; ++ ++export type SourceCollection = { ++ id: string; ++ domain: string; ++ name: string; ++ icon: string; ++ url: string; ++}; ++ ++export type TokenCollection = { + id?: string; + name?: string; + slug?: string; +@@ -243,7 +276,9 @@ export type Collection = { + floorAskPrice?: Price; + royaltiesBps?: number; + royalties?: Royalties[]; ++ floorAsk?: FloorAskCollection; + }; ++export type Collection = TokenCollection & CollectionResponse; + export type Royalties = { + bps?: number; + recipient?: string; diff --git a/node_modules/@metamask/assets-controllers/dist/types/TokenBalancesController.d.ts b/node_modules/@metamask/assets-controllers/dist/types/TokenBalancesController.d.ts index 45d58f8..ce24723 100644 --- a/node_modules/@metamask/assets-controllers/dist/types/TokenBalancesController.d.ts From e891068ce7b8d1e70b9eb20f7d9e024f232100b9 Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Fri, 18 Oct 2024 12:31:06 +0200 Subject: [PATCH 5/6] chore: fix default state --- app/core/Engine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/core/Engine.ts b/app/core/Engine.ts index ef0828642fa..77c38a1d1f8 100644 --- a/app/core/Engine.ts +++ b/app/core/Engine.ts @@ -958,7 +958,7 @@ class Engine { 'AccountsController:selectedAccountChange', ], }), - state: { accounts: {} }, + state: initialState.AccountTrackerController ?? { accounts: {} }, }); const permissionController = new PermissionController({ // @ts-expect-error TODO: Resolve mismatch between base-controller versions. From 7faf675fdeb011ab6900f5ee2ed694a634c31071 Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Fri, 18 Oct 2024 13:06:58 +0200 Subject: [PATCH 6/6] fix: rm comment --- app/core/Engine.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/core/Engine.ts b/app/core/Engine.ts index 77c38a1d1f8..a0bbf9344ed 100644 --- a/app/core/Engine.ts +++ b/app/core/Engine.ts @@ -1780,7 +1780,6 @@ class Engine { return; } provider.sendAsync = provider.sendAsync.bind(provider); - // AccountTrackerController.configure({ provider }); AssetsContractController.configure({ provider }); SwapsController.configure({