core icon indicating copy to clipboard operation
core copied to clipboard

[tokens-controller] Expose `getState` action and `stateChange` event

Open tommasini opened this issue 1 year ago • 4 comments

With Token Detection Controller and Token Balances Controller, calling "TokensController:getState" action and subscribing "TokensController:stateChange" event, the Tokens Controller needs to be updated to extend Base Controller v2, to start to expose this action and this event and this action.

Where they are currently being used Token Detection Controller: https://github.com/MetaMask/core/blob/8769bd80eb9a131f9fb75ae5f85491eedfc19e62/packages/assets-controllers/src/TokenDetectionController.ts#L522 Token Balances Controller: https://github.com/MetaMask/core/blob/4433150274d74a1858d4fc83ecd2361e53f12f3c/packages/assets-controllers/src/TokenBalancesController.ts#L143

tommasini avatar May 08 '24 17:05 tommasini

I don't think we need to update it to BaseControllerV2 necessarily, we just need to add the missing action and event

Gudahtt avatar May 08 '24 18:05 Gudahtt

Ah okok! I thought that it was something that we wanted to do to to every controller that it was still extending v1, sorry my mistake!

tommasini avatar May 08 '24 19:05 tommasini

Oh we definitely want to update everything to BaseControllerV2, but that might be a bit more challenging than just adding the missing action and event. Unsure in this case. We can solve this either way.

Gudahtt avatar May 08 '24 19:05 Gudahtt

I agree that the BaseControllerV2 upgrade for TokensController should be tracked in its own ticket since it involves more tasks: https://github.com/MetaMask/core/issues/4075.

I edited the title to reflect this and narrow the scope of this ticket.

MajorLift avatar May 09 '24 15:05 MajorLift