-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: assets controllers package upgrade with fix #36808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (2 files, +0 -8)
🧪 @MetaMask/qa (1 files, +0 -14)
|
useExternalServices: true, | ||
// from core PreferencesController | ||
isMultiAccountBalancesEnabled: true, | ||
useMultiAccountBalanceChecker: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting them together as it'll be easier to remove one when we eventually migrate to the core PreferencesController
. For now, and considering this PR is already big enough, we are keeping both.
*/ | ||
export function getKeyringControllerMessenger( | ||
messenger: Messenger<AllowedActions, AllowedEvents>, | ||
messenger: Messenger<never, never>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was using the wrong types from a different controller. KeyringController
does not require any AllowedActions
or AllowedEvents
networkClientId, | ||
); | ||
}, | ||
includeStakedAssets: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not part of this PR to include staked assets in the assets list. When we want to enable them, we can do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved the properties together so it's easier to refactor them when the time comes.
setUseMultiAccountBalanceChecker(val: boolean): void { | ||
this.update((state) => { | ||
state.useMultiAccountBalanceChecker = val; | ||
state.isMultiAccountBalancesEnabled = val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making sure isMultiAccountBalancesEnabled
gets updated as well. Before this, it was always kept as true and not being used at all.
|
||
// clear accounts in AccountTrackerController | ||
this.accountTrackerController.clearAccounts(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not being done in mobile.
// this.accountTrackerController.updateAccountByAddress({ | ||
// address: from, | ||
// networkClientId, | ||
// }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no equivalent method in this version of the controller to update a specific account for a specific network.
refresh
does not work with a specific account, but with the selected account, which is not good here as the transaction could be for any account in the wallet.syncBalanceWithAddresses
only returns the results, but it does not update the state.
We can either do:
- Full refresh of all accounts for that network (unnecessarily expensive)
- No refresh at all and wait for the balances to update on their own
- Make changes to
AccountTrackerController
to support this feature
|
||
this.accountTrackerController.syncWithAddresses(addresses); | ||
// TODO AccountTrackerController Migration: Review how this works before merging | ||
// this.accountTrackerController.syncWithAddresses(addresses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no equivalent method for this currently.
Why do we want KeyringController state changes to update every single address balance? Mobile does not seem to be doing it.
|
||
// Updating accounts in this.accountTrackerController before starting UI syncing ensure that | ||
// state has account balance before it is synced with UI | ||
await this.accountTrackerController.updateAccountsAllActiveNetworks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very odd thing to do. The UI should be able to handle the default state of AccountTrackerController
. Current testing shows that it does.
Do we want to do a full refresh and wait for the result before entering the UI?
At best, we should manage that within the UI, not force it here.
oldAccounts.concat(accounts.map((a) => a.address.toLowerCase())), | ||
), | ||
]; | ||
this.accountTrackerController.syncWithAddresses(accountsToTrack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses the old addresses
state and adds the accounts to the state for balance tracking after they appear in the page and before they've been confirmed.
We do not have an equivalent feature in the new AccountTrackerController
.
|
||
export function getBlockGasLimit(state) { | ||
return state.metamask.currentBlockGasLimit; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not being used or referenced anywhere.
Description
Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist