1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Allow custom encryptor to be passed to MetaMaskController and KeyringControllers.

This commit is contained in:
Dan Finlay 2017-09-21 15:47:25 -07:00
parent 9bd55f4897
commit e9043f22df
3 changed files with 4 additions and 6 deletions

View File

@ -36,7 +36,7 @@ class KeyringController extends EventEmitter {
identities: {},
})
this.ethStore = opts.ethStore
this.encryptor = encryptor
this.encryptor = opts.encryptor || encryptor
this.keyrings = []
this.getNetwork = opts.getNetwork
}

View File

@ -95,6 +95,7 @@ module.exports = class MetamaskController extends EventEmitter {
initState: initState.KeyringController,
ethStore: this.ethStore,
getNetwork: this.networkController.getNetworkState.bind(this.networkController),
encryptor: opts.encryptor || undefined,
})
this.keyringController.on('newAccount', (address) => {
this.preferencesController.setSelectedAddress(address)
@ -674,4 +675,4 @@ module.exports = class MetamaskController extends EventEmitter {
return Promise.resolve(rpcTarget)
})
}
}
}

View File

@ -27,12 +27,9 @@ describe('KeyringController', function () {
ethStore: {
addAccount (acct) { accounts.push(ethUtil.addHexPrefix(acct)) },
},
encryptor: mockEncryptor,
})
// Stub out the browser crypto for a mock encryptor.
// Browser crypto is tested in the integration test suite.
keyringController.encryptor = mockEncryptor
keyringController.createNewVaultAndKeychain(password)
.then(function (newState) {
newState