Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
As part of the Wallet Framework Team's Q2 2024 OKRs (O3KR1: "100% completion of all core controllers to BaseControllerV2"), the
AssetsContractControllerneeds to be converted to a V2 controller.However, because
AssetsContractControllerhas an empty state object, it is a non-controller, which must be able to communicate with other controllers using amessagingSystem, but should not inherit from theBaseControllerV2class.Explanation
This commit introduces and applies the messenger pattern to the
AssetsContractControllerclass:AssetsContractControllerMessengerand associated types.BaseControllerV1.BaseControllerV2.The newly defined messenger actions/events are applied downstream in
NftControllerandTokenBalancesController.References
Changelog
@metamask/assets-controllersAdded
TokenBalancesControllerMessengermust allow theAssetsContractController:getERC20BalanceOfaction in addition to its previous allowed actions. (#4397)NftControllerMessengermust allow the following actions in addition to its previous allowed actions:AssetsContractController:getERC721AssetName,AssetsContractController:getERC721AssetSymbol,AssetsContractController:getERC721TokenURI,AssetsContractController:getERC721OwnerOf,AssetsContractController:getERC1155BalanceOf,AssetsContractController:getERC1155TokenURI. (#4397)AssetsContractControllerclass: (#4397)messenger.messagingSystem.ipfsGatewayandchainId. As corresponding setters have not been defined, these properties are not externally mutable.AssetsContractControllerMessengertype (#4397)AssetsContractControllerMessengermust allow the external actionsNetworkController:getNetworkClientById,NetworkController:getNetworkConfigurationByNetworkClientId,NetworkController:getSelectedNetworkClient,NetworkController:getState.AssetsContractControllerMessengermust allow the external eventsPreferencesController:stateChange,NetworkController:networkDidChange.AssetsContractControllerActions,AssetsContractControllerEvents,AssetsContractControllerGetERC20StandardAction,AssetsContractControllerGetERC721StandardAction,AssetsContractControllerGetERC1155StandardAction,AssetsContractControllerGetERC20BalanceOfAction,AssetsContractControllerGetERC20TokenDecimalsAction,AssetsContractControllerGetERC20TokenNameAction,AssetsContractControllerGetERC721NftTokenIdAction,AssetsContractControllerGetERC721TokenURIAction,AssetsContractControllerGetERC721AssetNameAction,AssetsContractControllerGetERC721AssetSymbolAction,AssetsContractControllerGetERC721OwnerOfAction,AssetsContractControllerGetERC1155TokenURIAction,AssetsContractControllerGetERC1155BalanceOfAction,AssetsContractControllerTransferSingleERC1155Action,AssetsContractControllerGetTokenStandardAndDetailsAction,AssetsContractControllerGetBalancesInSingleCallAction. (#4397)setProvidermethod toAssetsContractController. (#4397)providersetter method, and widens theproviderfunction parameter type fromProvidertoProvider | undefined.Changed
SINGLE_CALL_BALANCES_ADDRESS_BY_CHAINIDis narrowed fromRecord<Hex, string>to the const-asserted literal properties of theSINGLE_CALL_BALANCES_ADDRESS_BY_CHAINIDobject. (#4397)SupportedTokenDetectionNetworks.Record<Hex, string>using thesatisfieskeyword.BalanceMaptype from aninterfaceinto a type alias. (#4397)stringby default, and are compatible with theStateConstrainttype defined in the@metamask/base-controllerpackage.Removed
AssetsContractControllerclass: (#4397)AssetsContractControllerno longer inherits fromBaseControllerV1.onPreferencesStateChange,onNetworkDidChange,getNetworkClientById, and replace with corresponding messenger actions and events.name,config(along with its propertiesprovider,ipfsGateway,chainId).getProvider,getChainId.providersetter method.getERC20BalanceOfconstructor option callback from theTokenBalancesControllerOptionstype and theTokenBalancesControllerconstructor. (#4397)NftControllerconstructor option callbacks:getERC721AssetName,getERC721AssetSymbol,getERC721TokenURI,getERC721OwnerOf,getERC1155BalanceOf,getERC1155TokenURI. (#4397)AssetsContractConfigtype. (#4397)MISSING_PROVIDER_ERROR. (#4397)Fixed
getERC721NftTokenIdmethod of theAssetsContractControllerinto an async function. (#4397)Checklist