Skip to content

perf: persist Snap accounts only once #15027

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions app/core/Engine/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,13 @@ export class Engine {
allowedEvents: [],
});

// Necessary to persist the keyrings and update the accounts both within the keyring controller and accounts controller
const persistAndUpdateAccounts = async () => {
await this.keyringController.persistAllKeyrings();
await this.accountsController.updateAccounts();
};

additionalKeyrings.push(
snapKeyringBuilder(snapKeyringBuildMessenger, {
persistKeyringHelper: () => persistAndUpdateAccounts(),
persistKeyringHelper: async () => {
// Necessary to only persist the keyrings, the `AccountsController` will
// automatically react to `KeyringController:stateChange`.
await this.keyringController.persistAllKeyrings();
},
removeAccountHelper: (address) => this.removeAccount(address),
}),
);
Expand Down
Loading