core
core copied to clipboard
Convert TokensController from BaseControllerV1 to BaseControllerV2
Considering that converting TokenDetectionController to BaseController v2 took longer than expected due to unforeseen changes, we want to be more conscientious about converting TokensController.
Figure out all of the changes we would want to make in upgrading this controller, outline those changes here and create new tickets if appropriate.
TokensController is mostly in good shape. It already uses a messenger, it already broadcasts events through it and it already handles actions properly.
Along with the main change of extending BaseControllerV2 class instead of V1, we can:
- Rename
TokenStatetype toTokensControllerState, to match other controllers. - Same for
TokensConfig->TokensControllerConfig - We should be able to use the already declared allowed events and actions
- We should lower the visibility of these functions to
#:-
_createEthersContract->#createEthersContract -
_detectIsERC721->#detectIsERC721 -
_generateRandomId->#generateRandomId -
_getNewAllTokensState->#getNewAllTokensState -
_getProvider->#getProvider -
_requestApproval->#requestApproval
-
- We should be able to remove the
hubproperty, since it appears unused (TODO: verify this statement) - Tests should be refactored to support the new controller version
- In addition to that, we can create a
withControllerhelper to make tests more readable and easier to be maintained
- In addition to that, we can create a
hub is used in Mobile in one place.