Skip to content

Commit

Permalink
Merge EthKeyringController into KeyringController (#3830)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito authored Jan 30, 2024
1 parent 8c09b16 commit 50ee1ee
Show file tree
Hide file tree
Showing 9 changed files with 943 additions and 170 deletions.
6 changes: 3 additions & 3 deletions packages/keyring-controller/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module.exports = merge(baseConfig, {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 100,
branches: 95.71,
functions: 100,
lines: 100,
statements: 100,
lines: 99.21,
statements: 99.22,
},
},

Expand Down
6 changes: 4 additions & 2 deletions packages/keyring-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
"dependencies": {
"@keystonehq/metamask-airgapped-keyring": "^0.13.1",
"@metamask/base-controller": "^4.1.1",
"@metamask/eth-keyring-controller": "^17.0.1",
"@metamask/browser-passworder": "^4.3.0",
"@metamask/eth-hd-keyring": "^7.0.1",
"@metamask/eth-sig-util": "^7.0.1",
"@metamask/eth-simple-keyring": "^6.0.1",
"@metamask/keyring-api": "^3.0.0",
"@metamask/message-manager": "^7.3.8",
"@metamask/utils": "^8.3.0",
Expand All @@ -48,7 +51,6 @@
"@keystonehq/bc-ur-registry-eth": "^0.9.0",
"@lavamoat/allow-scripts": "^2.3.1",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/eth-sig-util": "^7.0.1",
"@metamask/scure-bip39": "^2.1.1",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
Expand Down
23 changes: 18 additions & 5 deletions packages/keyring-controller/src/KeyringController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { TransactionFactory } from '@ethereumjs/tx';
import { CryptoHDKey, ETHSignature } from '@keystonehq/bc-ur-registry-eth';
import { MetaMaskKeyring as QRKeyring } from '@keystonehq/metamask-airgapped-keyring';
import { ControllerMessenger } from '@metamask/base-controller';
import {
KeyringControllerError,
keyringBuilderFactory,
} from '@metamask/eth-keyring-controller';
import HDKeyring from '@metamask/eth-hd-keyring';
import {
normalize,
recoverPersonalSignature,
Expand Down Expand Up @@ -34,6 +31,7 @@ import { MockErc4337Keyring } from '../tests/mocks/mockErc4337Keyring';
import { MockKeyring } from '../tests/mocks/mockKeyring';
import MockShallowGetAccountsKeyring from '../tests/mocks/mockShallowGetAccountsKeyring';
import { buildMockTransaction } from '../tests/mocks/mockTransaction';
import { KeyringControllerError } from './constants';
import type {
KeyringControllerEvents,
KeyringControllerMessenger,
Expand All @@ -45,6 +43,7 @@ import {
AccountImportStrategy,
KeyringController,
KeyringTypes,
keyringBuilderFactory,
} from './KeyringController';

jest.mock('uuid', () => {
Expand Down Expand Up @@ -527,6 +526,20 @@ describe('KeyringController', () => {
},
);
});

it('should throw error if the first account is not found on the keyring', async () => {
jest
.spyOn(HDKeyring.prototype, 'getAccounts')
.mockResolvedValue([]);
await withController(
{ skipVaultCreation: true },
async ({ controller }) => {
await expect(
controller.createNewVaultAndKeychain(password),
).rejects.toThrow(KeyringControllerError.NoFirstAccount);
},
);
});
});

describe('when there is an existing vault', () => {
Expand Down Expand Up @@ -1214,7 +1227,7 @@ describe('KeyringController', () => {
data: '',
from: initialState.keyrings[0].accounts[0],
}),
).toThrow("Can't sign an empty message");
).rejects.toThrow("Can't sign an empty message");
});
});

Expand Down
Loading

0 comments on commit 50ee1ee

Please sign in to comment.