|
|
@ -66,11 +66,9 @@ import { |
|
|
|
GAS_DEV_API_BASE_URL, |
|
|
|
GAS_DEV_API_BASE_URL, |
|
|
|
SWAPS_CLIENT_ID, |
|
|
|
SWAPS_CLIENT_ID, |
|
|
|
} from '../../shared/constants/swaps'; |
|
|
|
} from '../../shared/constants/swaps'; |
|
|
|
|
|
|
|
import { KEYRING_TYPES } from '../../shared/constants/keyrings'; |
|
|
|
import { CHAIN_IDS } from '../../shared/constants/network'; |
|
|
|
import { CHAIN_IDS } from '../../shared/constants/network'; |
|
|
|
import { |
|
|
|
import { DEVICE_NAMES } from '../../shared/constants/hardware-wallets'; |
|
|
|
DEVICE_NAMES, |
|
|
|
|
|
|
|
KEYRING_TYPES, |
|
|
|
|
|
|
|
} from '../../shared/constants/hardware-wallets'; |
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
CaveatTypes, |
|
|
|
CaveatTypes, |
|
|
|
RestrictedMethods, |
|
|
|
RestrictedMethods, |
|
|
@ -2136,8 +2134,9 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
ethQuery, |
|
|
|
ethQuery, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const [primaryKeyring] = |
|
|
|
const [primaryKeyring] = keyringController.getKeyringsByType( |
|
|
|
keyringController.getKeyringsByType('HD Key Tree'); |
|
|
|
KEYRING_TYPES.HD_KEY_TREE, |
|
|
|
|
|
|
|
); |
|
|
|
if (!primaryKeyring) { |
|
|
|
if (!primaryKeyring) { |
|
|
|
throw new Error('MetamaskController - No HD Key Tree found'); |
|
|
|
throw new Error('MetamaskController - No HD Key Tree found'); |
|
|
|
} |
|
|
|
} |
|
|
@ -2262,9 +2261,12 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Accounts
|
|
|
|
// Accounts
|
|
|
|
const [hdKeyring] = this.keyringController.getKeyringsByType('HD Key Tree'); |
|
|
|
const [hdKeyring] = this.keyringController.getKeyringsByType( |
|
|
|
const simpleKeyPairKeyrings = |
|
|
|
KEYRING_TYPES.HD_KEY_TREE, |
|
|
|
this.keyringController.getKeyringsByType('Simple Key Pair'); |
|
|
|
); |
|
|
|
|
|
|
|
const simpleKeyPairKeyrings = this.keyringController.getKeyringsByType( |
|
|
|
|
|
|
|
KEYRING_TYPES.IMPORTED, |
|
|
|
|
|
|
|
); |
|
|
|
const hdAccounts = await hdKeyring.getAccounts(); |
|
|
|
const hdAccounts = await hdKeyring.getAccounts(); |
|
|
|
const simpleKeyPairKeyringAccounts = await Promise.all( |
|
|
|
const simpleKeyPairKeyringAccounts = await Promise.all( |
|
|
|
simpleKeyPairKeyrings.map((keyring) => keyring.getAccounts()), |
|
|
|
simpleKeyPairKeyrings.map((keyring) => keyring.getAccounts()), |
|
|
@ -2361,7 +2363,9 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
* Gets the mnemonic of the user's primary keyring. |
|
|
|
* Gets the mnemonic of the user's primary keyring. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getPrimaryKeyringMnemonic() { |
|
|
|
getPrimaryKeyringMnemonic() { |
|
|
|
const [keyring] = this.keyringController.getKeyringsByType('HD Key Tree'); |
|
|
|
const [keyring] = this.keyringController.getKeyringsByType( |
|
|
|
|
|
|
|
KEYRING_TYPES.HD_KEY_TREE, |
|
|
|
|
|
|
|
); |
|
|
|
if (!keyring.mnemonic) { |
|
|
|
if (!keyring.mnemonic) { |
|
|
|
throw new Error('Primary keyring mnemonic unavailable.'); |
|
|
|
throw new Error('Primary keyring mnemonic unavailable.'); |
|
|
|
} |
|
|
|
} |
|
|
@ -2592,8 +2596,9 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
* @returns {} keyState |
|
|
|
* @returns {} keyState |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async addNewAccount(accountCount) { |
|
|
|
async addNewAccount(accountCount) { |
|
|
|
const [primaryKeyring] = |
|
|
|
const [primaryKeyring] = this.keyringController.getKeyringsByType( |
|
|
|
this.keyringController.getKeyringsByType('HD Key Tree'); |
|
|
|
KEYRING_TYPES.HD_KEY_TREE, |
|
|
|
|
|
|
|
); |
|
|
|
if (!primaryKeyring) { |
|
|
|
if (!primaryKeyring) { |
|
|
|
throw new Error('MetamaskController - No HD Key Tree found'); |
|
|
|
throw new Error('MetamaskController - No HD Key Tree found'); |
|
|
|
} |
|
|
|
} |
|
|
@ -2636,8 +2641,9 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
* encoded as an array of UTF-8 bytes. |
|
|
|
* encoded as an array of UTF-8 bytes. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async verifySeedPhrase() { |
|
|
|
async verifySeedPhrase() { |
|
|
|
const [primaryKeyring] = |
|
|
|
const [primaryKeyring] = this.keyringController.getKeyringsByType( |
|
|
|
this.keyringController.getKeyringsByType('HD Key Tree'); |
|
|
|
KEYRING_TYPES.HD_KEY_TREE, |
|
|
|
|
|
|
|
); |
|
|
|
if (!primaryKeyring) { |
|
|
|
if (!primaryKeyring) { |
|
|
|
throw new Error('MetamaskController - No HD Key Tree found'); |
|
|
|
throw new Error('MetamaskController - No HD Key Tree found'); |
|
|
|
} |
|
|
|
} |
|
|
@ -2758,7 +2764,7 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
async importAccountWithStrategy(strategy, args) { |
|
|
|
async importAccountWithStrategy(strategy, args) { |
|
|
|
const privateKey = await accountImporter.importAccount(strategy, args); |
|
|
|
const privateKey = await accountImporter.importAccount(strategy, args); |
|
|
|
const keyring = await this.keyringController.addNewKeyring( |
|
|
|
const keyring = await this.keyringController.addNewKeyring( |
|
|
|
'Simple Key Pair', |
|
|
|
KEYRING_TYPES.IMPORTED, |
|
|
|
[privateKey], |
|
|
|
[privateKey], |
|
|
|
); |
|
|
|
); |
|
|
|
const [firstAccount] = await keyring.getAccounts(); |
|
|
|
const [firstAccount] = await keyring.getAccounts(); |
|
|
|