Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
handle approval when adding account
Browse files Browse the repository at this point in the history
  • Loading branch information
owencraston committed Sep 19, 2023
1 parent a933bac commit 452c039
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/SnapKeyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const KeyringStateStruct = object({
export type KeyringState = Infer<typeof KeyringStateStruct>;

export type SnapKeyringCallbacks = {
saveState: () => Promise<void>;
saveState: (origin: string) => Promise<void>;
removeAccount(address: string): Promise<void>;
};

Expand Down Expand Up @@ -82,11 +82,14 @@ export class SnapKeyring extends EventEmitter {
switch (method) {
case KeyringEvent.AccountCreated:
case KeyringEvent.AccountUpdated: {
await this.#syncAllSnapsAccounts(snapId);
await this.#callbacks.saveState();
return null;
try {
await this.#syncAllSnapsAccounts(snapId);
await this.#callbacks.saveState(snapId);
return null;
} catch (error) {
throw new Error((error as Error).message);
}
}

case KeyringEvent.AccountDeleted: {
const { id } = params as any;
const account =
Expand Down

0 comments on commit 452c039

Please sign in to comment.