Skip to content

Commit

Permalink
fix: update vault during fullUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed May 23, 2023
1 parent 2ea579f commit ab236e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/keyring-controller/src/KeyringController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,14 @@ describe('KeyringController', () => {
await withController(
{ cacheEncryptionKey },
async ({ controller, initialState }) => {
const initialVault = controller.state.vault;
const currentState = await controller.createNewVaultAndRestore(
password,
uint8ArraySeed,
);
expect(initialState).not.toBe(currentState);
expect(controller.state.vault).toBeDefined();
expect(controller.state.vault).toStrictEqual(initialVault);
},
);
});
Expand Down Expand Up @@ -267,6 +270,7 @@ describe('KeyringController', () => {
expect(
isValidHexAddress(currentState.keyrings[0].accounts[0]),
).toBe(true);
expect(controller.state.vault).toBeDefined();
},
);
});
Expand All @@ -278,6 +282,7 @@ describe('KeyringController', () => {
expect(keyring.accounts).not.toStrictEqual([]);
expect(keyring.index).toStrictEqual(0);
expect(keyring.type).toStrictEqual('HD Key Tree');
expect(controller.state.vault).toBeDefined();
});
});
});
Expand All @@ -290,6 +295,7 @@ describe('KeyringController', () => {
const initialSeedWord = await controller.exportSeedPhrase(
password,
);
const initialVault = controller.state.vault;
const currentState = await controller.createNewVaultAndKeychain(
password,
);
Expand All @@ -300,6 +306,7 @@ describe('KeyringController', () => {
expect(initialState).toBe(currentState);
expect(currentSeedWord).toBeDefined();
expect(initialSeedWord).toBe(currentSeedWord);
expect(initialVault).toStrictEqual(controller.state.vault);
},
);
});
Expand Down
5 changes: 4 additions & 1 deletion packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,10 @@ export class KeyringController extends BaseController<
},
),
);
this.update({ keyrings: [...keyrings] });
this.update({
keyrings: [...keyrings],
vault: this.#keyring.store.getState().vault,
});
return this.#keyring.fullUpdate();
}

Expand Down

0 comments on commit ab236e0

Please sign in to comment.