diff options
author | Bruno <brunobar79@gmail.com> | 2018-06-13 14:09:25 +0800 |
---|---|---|
committer | Bruno <brunobar79@gmail.com> | 2018-06-13 14:09:25 +0800 |
commit | 704e2a21f8a3fc5f3d6245c5a924cd2df0cfd36e (patch) | |
tree | 800afc82dbf83fa971d8fd5523124c861dfb31dc /app/scripts | |
parent | bb4cc72646def9b32fffb8e6a208a2cae9d4f8c6 (diff) | |
download | tangerine-wallet-browser-704e2a21f8a3fc5f3d6245c5a924cd2df0cfd36e.tar.gz tangerine-wallet-browser-704e2a21f8a3fc5f3d6245c5a924cd2df0cfd36e.tar.zst tangerine-wallet-browser-704e2a21f8a3fc5f3d6245c5a924cd2df0cfd36e.zip |
clean up
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/metamask-controller.js | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 6c380fd71..c57b643bb 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -131,7 +131,7 @@ module.exports = class MetamaskController extends EventEmitter { provider: this.provider, blockTracker: this.blockTracker, }) - + // key mgmt const additionalKeyrings = [TrezorKeyring] this.keyringController = new KeyringController({ @@ -423,7 +423,6 @@ module.exports = class MetamaskController extends EventEmitter { } - //============================================================================= // VAULT / KEYRING RELATED METHODS //============================================================================= @@ -537,19 +536,23 @@ module.exports = class MetamaskController extends EventEmitter { */ async connectHardware (deviceName, page) { - const keyringController = this.keyringController - const keyring = await keyringController.getKeyringsByType( - 'Trezor Hardware' - )[0] - if (!keyring) { - throw new Error('MetamaskController - No Trezor Hardware Keyring found') - } - - const accounts = await keyring.getPage(page) + switch (deviceName) { + case 'trezor': + const keyringController = this.keyringController + const keyring = await keyringController.getKeyringsByType( + 'Trezor Hardware' + )[0] + if (!keyring) { + throw new Error('MetamaskController - No Trezor Hardware Keyring found') + } - this.accountTracker.syncWithAddresses(accounts.map(a => a.address)) + const accounts = await keyring.getPage(page) + this.accountTracker.syncWithAddresses(accounts.map(a => a.address)) + return accounts - return accounts + default: + throw new Error('MetamaskController - Unknown device') + } } /** @@ -581,7 +584,7 @@ module.exports = class MetamaskController extends EventEmitter { const { identities } = this.preferencesController.store.getState() return { ...keyState, identities } } - + // // Account Management @@ -1037,7 +1040,7 @@ module.exports = class MetamaskController extends EventEmitter { * Allows a user to begin the seed phrase recovery process. * @param {Function} cb - A callback function called when complete. */ - markPasswordForgotten(cb) { + markPasswordForgotten (cb) { this.configManager.setPasswordForgotten(true) this.sendUpdate() cb() @@ -1047,7 +1050,7 @@ module.exports = class MetamaskController extends EventEmitter { * Allows a user to end the seed phrase recovery process. * @param {Function} cb - A callback function called when complete. */ - unMarkPasswordForgotten(cb) { + unMarkPasswordForgotten (cb) { this.configManager.setPasswordForgotten(false) this.sendUpdate() cb() |