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 e469d67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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
8 changes: 6 additions & 2 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ export class KeyringController extends BaseController<
}

/**
* Update keyrings in state and calls KeyringController fullUpdate method returning current state.
* Update keyrings and vault in state and calls KeyringController
* fullUpdate method returning current state.
*
* @returns The current state.
*/
Expand All @@ -697,7 +698,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 e469d67

Please sign in to comment.