Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getKeyringForDevice (deviceName, hdPath = null) {
let keyringName = null
switch (deviceName) {
case 'trezor':
keyringName = TrezorKeyring.type
break
case 'ledger':
keyringName = LedgerBridgeKeyring.type
break
default:
throw new Error('MetamaskController:getKeyringForDevice - Unknown device')
}
let keyring = await this.keyringController.getKeyringsByType(keyringName)[0]
if (!keyring) {
keyring = await this.keyringController.addNewKeyring(keyringName)
}
if (hdPath && keyring.setHdPath) {
keyring.setHdPath(hdPath)
}
keyring.network = this.networkController.getProviderConfig().type