mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Refactor KeyringTypes constant (#17490)
The `HardwareKeyringTypes` constant has been renamed to `KeyringTypes` and moved to a separate constants module, to reflect that it contains more than just hardware wallet keyring types. This corrects a mistake made recently during a TypeScript conversion.
This commit is contained in:
parent
a854cfdb93
commit
d6b49ae383
@ -1,5 +1,5 @@
|
|||||||
import { draftTransactionInitialState } from '../ui/ducks/send';
|
import { draftTransactionInitialState } from '../ui/ducks/send';
|
||||||
import { HardwareKeyringTypes } from '../shared/constants/hardware-wallets';
|
import { KeyringType } from '../shared/constants/keyring';
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
invalidCustomNetwork: {
|
invalidCustomNetwork: {
|
||||||
@ -1168,14 +1168,14 @@ const state = {
|
|||||||
unapprovedTypedMessages: {},
|
unapprovedTypedMessages: {},
|
||||||
unapprovedTypedMessagesCount: 0,
|
unapprovedTypedMessagesCount: 0,
|
||||||
keyringTypes: [
|
keyringTypes: [
|
||||||
HardwareKeyringTypes.imported,
|
KeyringType.imported,
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
KeyringType.hdKeyTree,
|
||||||
HardwareKeyringTypes.trezor,
|
KeyringType.trezor,
|
||||||
HardwareKeyringTypes.ledger,
|
KeyringType.ledger,
|
||||||
],
|
],
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: [
|
accounts: [
|
||||||
'0x64a845a5b02460acf8a3d84503b0d68d028b4bb4',
|
'0x64a845a5b02460acf8a3d84503b0d68d028b4bb4',
|
||||||
'0xb19ac54efa18cc3a14a5b821bfec73d284bf0c5e',
|
'0xb19ac54efa18cc3a14a5b821bfec73d284bf0c5e',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { KeyringController } from '@metamask/eth-keyring-controller';
|
import { KeyringController } from '@metamask/eth-keyring-controller';
|
||||||
import log from 'loglevel';
|
import log from 'loglevel';
|
||||||
|
|
||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../shared/constants/keyring';
|
||||||
|
|
||||||
const seedPhraseVerifier = {
|
const seedPhraseVerifier = {
|
||||||
/**
|
/**
|
||||||
@ -23,7 +23,7 @@ const seedPhraseVerifier = {
|
|||||||
|
|
||||||
const keyringController = new KeyringController({});
|
const keyringController = new KeyringController({});
|
||||||
const keyringBuilder = keyringController.getKeyringBuilderForType(
|
const keyringBuilder = keyringController.getKeyringBuilderForType(
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
KeyringType.hdKeyTree,
|
||||||
);
|
);
|
||||||
const keyring = keyringBuilder();
|
const keyring = keyringBuilder();
|
||||||
const opts = {
|
const opts = {
|
||||||
|
@ -6,13 +6,13 @@ import { cloneDeep } from 'lodash';
|
|||||||
import { KeyringController } from '@metamask/eth-keyring-controller';
|
import { KeyringController } from '@metamask/eth-keyring-controller';
|
||||||
import firstTimeState from '../first-time-state';
|
import firstTimeState from '../first-time-state';
|
||||||
import mockEncryptor from '../../../test/lib/mock-encryptor';
|
import mockEncryptor from '../../../test/lib/mock-encryptor';
|
||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../shared/constants/keyring';
|
||||||
import seedPhraseVerifier from './seed-phrase-verifier';
|
import seedPhraseVerifier from './seed-phrase-verifier';
|
||||||
|
|
||||||
describe('SeedPhraseVerifier', () => {
|
describe('SeedPhraseVerifier', () => {
|
||||||
describe('verifyAccounts', () => {
|
describe('verifyAccounts', () => {
|
||||||
const password = 'passw0rd1';
|
const password = 'passw0rd1';
|
||||||
const { hdKeyTree } = HardwareKeyringTypes;
|
const { hdKeyTree } = KeyringType;
|
||||||
|
|
||||||
let keyringController;
|
let keyringController;
|
||||||
let primaryKeyring;
|
let primaryKeyring;
|
||||||
|
@ -74,10 +74,8 @@ import {
|
|||||||
SWAPS_CLIENT_ID,
|
SWAPS_CLIENT_ID,
|
||||||
} from '../../shared/constants/swaps';
|
} from '../../shared/constants/swaps';
|
||||||
import { CHAIN_IDS, NETWORK_TYPES } from '../../shared/constants/network';
|
import { CHAIN_IDS, NETWORK_TYPES } from '../../shared/constants/network';
|
||||||
import {
|
import { HardwareDeviceNames } from '../../shared/constants/hardware-wallets';
|
||||||
HardwareDeviceNames,
|
import { KeyringType } from '../../shared/constants/keyring';
|
||||||
HardwareKeyringTypes,
|
|
||||||
} from '../../shared/constants/hardware-wallets';
|
|
||||||
import {
|
import {
|
||||||
CaveatTypes,
|
CaveatTypes,
|
||||||
RestrictedMethods,
|
RestrictedMethods,
|
||||||
@ -2372,7 +2370,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const [primaryKeyring] = keyringController.getKeyringsByType(
|
const [primaryKeyring] = keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
KeyringType.hdKeyTree,
|
||||||
);
|
);
|
||||||
if (!primaryKeyring) {
|
if (!primaryKeyring) {
|
||||||
throw new Error('MetamaskController - No HD Key Tree found');
|
throw new Error('MetamaskController - No HD Key Tree found');
|
||||||
@ -2496,10 +2494,10 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
const [hdKeyring] = this.keyringController.getKeyringsByType(
|
const [hdKeyring] = this.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
KeyringType.hdKeyTree,
|
||||||
);
|
);
|
||||||
const simpleKeyPairKeyrings = this.keyringController.getKeyringsByType(
|
const simpleKeyPairKeyrings = this.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
KeyringType.hdKeyTree,
|
||||||
);
|
);
|
||||||
const hdAccounts = await hdKeyring.getAccounts();
|
const hdAccounts = await hdKeyring.getAccounts();
|
||||||
const simpleKeyPairKeyringAccounts = await Promise.all(
|
const simpleKeyPairKeyringAccounts = await Promise.all(
|
||||||
@ -2663,7 +2661,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
getPrimaryKeyringMnemonic() {
|
getPrimaryKeyringMnemonic() {
|
||||||
const [keyring] = this.keyringController.getKeyringsByType(
|
const [keyring] = this.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
KeyringType.hdKeyTree,
|
||||||
);
|
);
|
||||||
if (!keyring.mnemonic) {
|
if (!keyring.mnemonic) {
|
||||||
throw new Error('Primary keyring mnemonic unavailable.');
|
throw new Error('Primary keyring mnemonic unavailable.');
|
||||||
@ -2803,12 +2801,12 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
async getAccountType(address) {
|
async getAccountType(address) {
|
||||||
const keyring = await this.keyringController.getKeyringForAccount(address);
|
const keyring = await this.keyringController.getKeyringForAccount(address);
|
||||||
switch (keyring.type) {
|
switch (keyring.type) {
|
||||||
case HardwareKeyringTypes.trezor:
|
case KeyringType.trezor:
|
||||||
case HardwareKeyringTypes.lattice:
|
case KeyringType.lattice:
|
||||||
case HardwareKeyringTypes.qr:
|
case KeyringType.qr:
|
||||||
case HardwareKeyringTypes.ledger:
|
case KeyringType.ledger:
|
||||||
return 'hardware';
|
return 'hardware';
|
||||||
case HardwareKeyringTypes.imported:
|
case KeyringType.imported:
|
||||||
return 'imported';
|
return 'imported';
|
||||||
default:
|
default:
|
||||||
return 'MetaMask';
|
return 'MetaMask';
|
||||||
@ -2826,14 +2824,14 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
async getDeviceModel(address) {
|
async getDeviceModel(address) {
|
||||||
const keyring = await this.keyringController.getKeyringForAccount(address);
|
const keyring = await this.keyringController.getKeyringForAccount(address);
|
||||||
switch (keyring.type) {
|
switch (keyring.type) {
|
||||||
case HardwareKeyringTypes.trezor:
|
case KeyringType.trezor:
|
||||||
return keyring.getModel();
|
return keyring.getModel();
|
||||||
case HardwareKeyringTypes.qr:
|
case KeyringType.qr:
|
||||||
return keyring.getName();
|
return keyring.getName();
|
||||||
case HardwareKeyringTypes.ledger:
|
case KeyringType.ledger:
|
||||||
// TODO: get model after ledger keyring exposes method
|
// TODO: get model after ledger keyring exposes method
|
||||||
return HardwareDeviceNames.ledger;
|
return HardwareDeviceNames.ledger;
|
||||||
case HardwareKeyringTypes.lattice:
|
case KeyringType.lattice:
|
||||||
// TODO: get model after lattice keyring exposes method
|
// TODO: get model after lattice keyring exposes method
|
||||||
return HardwareDeviceNames.lattice;
|
return HardwareDeviceNames.lattice;
|
||||||
default:
|
default:
|
||||||
@ -2907,7 +2905,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async addNewAccount(accountCount) {
|
async addNewAccount(accountCount) {
|
||||||
const [primaryKeyring] = this.keyringController.getKeyringsByType(
|
const [primaryKeyring] = this.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
KeyringType.hdKeyTree,
|
||||||
);
|
);
|
||||||
if (!primaryKeyring) {
|
if (!primaryKeyring) {
|
||||||
throw new Error('MetamaskController - No HD Key Tree found');
|
throw new Error('MetamaskController - No HD Key Tree found');
|
||||||
@ -2952,7 +2950,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async verifySeedPhrase() {
|
async verifySeedPhrase() {
|
||||||
const [primaryKeyring] = this.keyringController.getKeyringsByType(
|
const [primaryKeyring] = this.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
KeyringType.hdKeyTree,
|
||||||
);
|
);
|
||||||
if (!primaryKeyring) {
|
if (!primaryKeyring) {
|
||||||
throw new Error('MetamaskController - No HD Key Tree found');
|
throw new Error('MetamaskController - No HD Key Tree found');
|
||||||
@ -3074,7 +3072,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(
|
||||||
HardwareKeyringTypes.imported,
|
KeyringType.imported,
|
||||||
[privateKey],
|
[privateKey],
|
||||||
);
|
);
|
||||||
const [firstAccount] = await keyring.getAccounts();
|
const [firstAccount] = await keyring.getAccounts();
|
||||||
@ -3229,7 +3227,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
const keyring = await this.keyringController.getKeyringForAccount(address);
|
const keyring = await this.keyringController.getKeyringForAccount(address);
|
||||||
|
|
||||||
switch (keyring.type) {
|
switch (keyring.type) {
|
||||||
case HardwareKeyringTypes.ledger: {
|
case KeyringType.ledger: {
|
||||||
return new Promise((_, reject) => {
|
return new Promise((_, reject) => {
|
||||||
reject(
|
reject(
|
||||||
new Error('Ledger does not support eth_getEncryptionPublicKey.'),
|
new Error('Ledger does not support eth_getEncryptionPublicKey.'),
|
||||||
@ -3237,7 +3235,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
case HardwareKeyringTypes.trezor: {
|
case KeyringType.trezor: {
|
||||||
return new Promise((_, reject) => {
|
return new Promise((_, reject) => {
|
||||||
reject(
|
reject(
|
||||||
new Error('Trezor does not support eth_getEncryptionPublicKey.'),
|
new Error('Trezor does not support eth_getEncryptionPublicKey.'),
|
||||||
@ -3245,7 +3243,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
case HardwareKeyringTypes.lattice: {
|
case KeyringType.lattice: {
|
||||||
return new Promise((_, reject) => {
|
return new Promise((_, reject) => {
|
||||||
reject(
|
reject(
|
||||||
new Error('Lattice does not support eth_getEncryptionPublicKey.'),
|
new Error('Lattice does not support eth_getEncryptionPublicKey.'),
|
||||||
@ -3253,7 +3251,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
case HardwareKeyringTypes.qr: {
|
case KeyringType.qr: {
|
||||||
return Promise.reject(
|
return Promise.reject(
|
||||||
new Error('QR hardware does not support eth_getEncryptionPublicKey.'),
|
new Error('QR hardware does not support eth_getEncryptionPublicKey.'),
|
||||||
);
|
);
|
||||||
@ -4296,14 +4294,14 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
setLocked() {
|
setLocked() {
|
||||||
const [trezorKeyring] = this.keyringController.getKeyringsByType(
|
const [trezorKeyring] = this.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.trezor,
|
KeyringType.trezor,
|
||||||
);
|
);
|
||||||
if (trezorKeyring) {
|
if (trezorKeyring) {
|
||||||
trezorKeyring.dispose();
|
trezorKeyring.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
const [ledgerKeyring] = this.keyringController.getKeyringsByType(
|
const [ledgerKeyring] = this.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.ledger,
|
KeyringType.ledger,
|
||||||
);
|
);
|
||||||
ledgerKeyring?.destroy?.();
|
ledgerKeyring?.destroy?.();
|
||||||
|
|
||||||
|
@ -11,10 +11,8 @@ import { TransactionStatus } from '../../shared/constants/transaction';
|
|||||||
import createTxMeta from '../../test/lib/createTxMeta';
|
import createTxMeta from '../../test/lib/createTxMeta';
|
||||||
import { NETWORK_TYPES } from '../../shared/constants/network';
|
import { NETWORK_TYPES } from '../../shared/constants/network';
|
||||||
import { createTestProviderTools } from '../../test/stub/provider';
|
import { createTestProviderTools } from '../../test/stub/provider';
|
||||||
import {
|
import { HardwareDeviceNames } from '../../shared/constants/hardware-wallets';
|
||||||
HardwareDeviceNames,
|
import { KeyringType } from '../../shared/constants/keyring';
|
||||||
HardwareKeyringTypes,
|
|
||||||
} from '../../shared/constants/hardware-wallets';
|
|
||||||
import { deferredPromise } from './lib/util';
|
import { deferredPromise } from './lib/util';
|
||||||
|
|
||||||
const Ganache = require('../../test/e2e/ganache');
|
const Ganache = require('../../test/e2e/ganache');
|
||||||
@ -275,7 +273,7 @@ describe('MetaMaskController', function () {
|
|||||||
it('adds private key to keyrings in KeyringController', async function () {
|
it('adds private key to keyrings in KeyringController', async function () {
|
||||||
const simpleKeyrings =
|
const simpleKeyrings =
|
||||||
metamaskController.keyringController.getKeyringsByType(
|
metamaskController.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.imported,
|
KeyringType.imported,
|
||||||
);
|
);
|
||||||
const pubAddressHexArr = await simpleKeyrings[0].getAccounts();
|
const pubAddressHexArr = await simpleKeyrings[0].getAccounts();
|
||||||
const privKeyHex = await simpleKeyrings[0].exportAccount(
|
const privKeyHex = await simpleKeyrings[0].exportAccount(
|
||||||
@ -555,11 +553,11 @@ describe('MetaMaskController', function () {
|
|||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
const keyrings =
|
const keyrings =
|
||||||
await metamaskController.keyringController.getKeyringsByType(
|
await metamaskController.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.trezor,
|
KeyringType.trezor,
|
||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
metamaskController.keyringController.addNewKeyring.getCall(0).args,
|
metamaskController.keyringController.addNewKeyring.getCall(0).args,
|
||||||
[HardwareKeyringTypes.trezor],
|
[KeyringType.trezor],
|
||||||
);
|
);
|
||||||
assert.equal(keyrings.length, 1);
|
assert.equal(keyrings.length, 1);
|
||||||
});
|
});
|
||||||
@ -571,11 +569,11 @@ describe('MetaMaskController', function () {
|
|||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
const keyrings =
|
const keyrings =
|
||||||
await metamaskController.keyringController.getKeyringsByType(
|
await metamaskController.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.ledger,
|
KeyringType.ledger,
|
||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
metamaskController.keyringController.addNewKeyring.getCall(0).args,
|
metamaskController.keyringController.addNewKeyring.getCall(0).args,
|
||||||
[HardwareKeyringTypes.ledger],
|
[KeyringType.ledger],
|
||||||
);
|
);
|
||||||
assert.equal(keyrings.length, 1);
|
assert.equal(keyrings.length, 1);
|
||||||
});
|
});
|
||||||
@ -651,7 +649,7 @@ describe('MetaMaskController', function () {
|
|||||||
await metamaskController.forgetDevice(HardwareDeviceNames.trezor);
|
await metamaskController.forgetDevice(HardwareDeviceNames.trezor);
|
||||||
const keyrings =
|
const keyrings =
|
||||||
await metamaskController.keyringController.getKeyringsByType(
|
await metamaskController.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.trezor,
|
KeyringType.trezor,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.deepEqual(keyrings[0].accounts, []);
|
assert.deepEqual(keyrings[0].accounts, []);
|
||||||
@ -711,7 +709,7 @@ describe('MetaMaskController', function () {
|
|||||||
it('should set unlockedAccount in the keyring', async function () {
|
it('should set unlockedAccount in the keyring', async function () {
|
||||||
const keyrings =
|
const keyrings =
|
||||||
await metamaskController.keyringController.getKeyringsByType(
|
await metamaskController.keyringController.getKeyringsByType(
|
||||||
HardwareKeyringTypes.trezor,
|
KeyringType.trezor,
|
||||||
);
|
);
|
||||||
assert.equal(keyrings[0].unlockedAccount, accountToUnlock);
|
assert.equal(keyrings[0].unlockedAccount, accountToUnlock);
|
||||||
});
|
});
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* Accounts can be instantiated from simple, HD or the multiple hardware wallet
|
* Hardware wallets supported by MetaMask.
|
||||||
* keyring types. Both simple and HD are treated as default but we do special
|
|
||||||
* case accounts managed by a hardware wallet.
|
|
||||||
*/
|
*/
|
||||||
export enum HardwareKeyringTypes {
|
export enum HardwareKeyringType {
|
||||||
ledger = 'Ledger Hardware',
|
ledger = 'Ledger Hardware',
|
||||||
trezor = 'Trezor Hardware',
|
trezor = 'Trezor Hardware',
|
||||||
lattice = 'Lattice Hardware',
|
lattice = 'Lattice Hardware',
|
||||||
qr = 'QR Hardware Wallet Device',
|
qr = 'QR Hardware Wallet Device',
|
||||||
hdKeyTree = 'HD Key Tree',
|
|
||||||
imported = 'Simple Key Pair',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum HardwareKeyringNames {
|
export enum HardwareKeyringNames {
|
||||||
|
17
shared/constants/keyring.ts
Normal file
17
shared/constants/keyring.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { HardwareKeyringType } from './hardware-wallets';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These are the keyrings that are managed entirely by MetaMask.
|
||||||
|
*/
|
||||||
|
export enum InternalKeyringType {
|
||||||
|
hdKeyTree = 'HD Key Tree',
|
||||||
|
imported = 'Simple Key Pair',
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All keyrings supported by MetaMask.
|
||||||
|
*/
|
||||||
|
export const KeyringType = {
|
||||||
|
...HardwareKeyringType,
|
||||||
|
...InternalKeyringType,
|
||||||
|
};
|
@ -1,5 +1,5 @@
|
|||||||
import { CHAIN_IDS } from '../../shared/constants/network';
|
import { CHAIN_IDS } from '../../shared/constants/network';
|
||||||
import { HardwareKeyringTypes } from '../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../shared/constants/keyring';
|
||||||
|
|
||||||
const createGetSmartTransactionFeesApiResponse = () => {
|
const createGetSmartTransactionFeesApiResponse = () => {
|
||||||
return {
|
return {
|
||||||
@ -252,13 +252,10 @@ export const createSwapsMockStore = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
selectedAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
selectedAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
keyringTypes: [
|
keyringTypes: [KeyringType.imported, KeyringType.hdKeyTree],
|
||||||
HardwareKeyringTypes.imported,
|
|
||||||
HardwareKeyringTypes.hdKeyTree,
|
|
||||||
],
|
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: [
|
accounts: [
|
||||||
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
'c5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
'c5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
||||||
@ -266,7 +263,7 @@ export const createSwapsMockStore = () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.imported,
|
type: KeyringType.imported,
|
||||||
accounts: ['0xd85a4b6a394794842887b8284293d69163007bbb'],
|
accounts: ['0xd85a4b6a394794842887b8284293d69163007bbb'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -3,7 +3,7 @@ import sinon from 'sinon';
|
|||||||
import configureMockStore from 'redux-mock-store';
|
import configureMockStore from 'redux-mock-store';
|
||||||
import { fireEvent, screen } from '@testing-library/react';
|
import { fireEvent, screen } from '@testing-library/react';
|
||||||
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
||||||
import { HardwareKeyringTypes } from '../../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../../shared/constants/keyring';
|
||||||
import AccountMenu from '.';
|
import AccountMenu from '.';
|
||||||
|
|
||||||
describe('Account Menu', () => {
|
describe('Account Menu', () => {
|
||||||
@ -37,11 +37,11 @@ describe('Account Menu', () => {
|
|||||||
],
|
],
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: ['0xAdress'],
|
accounts: ['0xAdress'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.imported,
|
type: KeyringType.imported,
|
||||||
accounts: ['0x1'],
|
accounts: ['0x1'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -2,10 +2,8 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { useI18nContext } from '../../../hooks/useI18nContext';
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
||||||
import {
|
import { HardwareKeyringNames } from '../../../../shared/constants/hardware-wallets';
|
||||||
HardwareKeyringNames,
|
import { KeyringType } from '../../../../shared/constants/keyring';
|
||||||
HardwareKeyringTypes,
|
|
||||||
} from '../../../../shared/constants/hardware-wallets';
|
|
||||||
|
|
||||||
export default function KeyRingLabel({ keyring }) {
|
export default function KeyRingLabel({ keyring }) {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
@ -19,19 +17,19 @@ export default function KeyRingLabel({ keyring }) {
|
|||||||
const { type } = keyring;
|
const { type } = keyring;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case HardwareKeyringTypes.qr:
|
case KeyringType.qr:
|
||||||
label = HardwareKeyringNames.qr;
|
label = HardwareKeyringNames.qr;
|
||||||
break;
|
break;
|
||||||
case HardwareKeyringTypes.imported:
|
case KeyringType.imported:
|
||||||
label = t('imported');
|
label = t('imported');
|
||||||
break;
|
break;
|
||||||
case HardwareKeyringTypes.trezor:
|
case KeyringType.trezor:
|
||||||
label = HardwareKeyringNames.trezor;
|
label = HardwareKeyringNames.trezor;
|
||||||
break;
|
break;
|
||||||
case HardwareKeyringTypes.ledger:
|
case KeyringType.ledger:
|
||||||
label = HardwareKeyringNames.ledger;
|
label = HardwareKeyringNames.ledger;
|
||||||
break;
|
break;
|
||||||
case HardwareKeyringTypes.lattice:
|
case KeyringType.lattice:
|
||||||
label = HardwareKeyringNames.lattice;
|
label = HardwareKeyringNames.lattice;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -11,7 +11,7 @@ import { renderWithProvider } from '../../../../../test/lib/render-helpers';
|
|||||||
|
|
||||||
import * as actions from '../../../../store/actions';
|
import * as actions from '../../../../store/actions';
|
||||||
import { CHAIN_IDS } from '../../../../../shared/constants/network';
|
import { CHAIN_IDS } from '../../../../../shared/constants/network';
|
||||||
import { HardwareKeyringTypes } from '../../../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../../../shared/constants/keyring';
|
||||||
|
|
||||||
import UnconnectedAccountAlert from '.';
|
import UnconnectedAccountAlert from '.';
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ describe('Unconnected Account Alert', () => {
|
|||||||
|
|
||||||
const keyrings = [
|
const keyrings = [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: [
|
accounts: [
|
||||||
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
'0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b',
|
'0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b',
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
import { useI18nContext } from '../../../hooks/useI18nContext';
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
||||||
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
||||||
import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../shared/constants/app';
|
import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../shared/constants/app';
|
||||||
import { HardwareKeyringTypes } from '../../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../../shared/constants/keyring';
|
||||||
import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
|
import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
|
||||||
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
||||||
import { ICON_NAMES } from '../../component-library';
|
import { ICON_NAMES } from '../../component-library';
|
||||||
@ -42,7 +42,7 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
|
|||||||
const trackEvent = useContext(MetaMetricsContext);
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
const blockExplorerLinkText = useSelector(getBlockExplorerLinkText);
|
const blockExplorerLinkText = useSelector(getBlockExplorerLinkText);
|
||||||
|
|
||||||
const isRemovable = keyring.type !== HardwareKeyringTypes.hdKeyTree;
|
const isRemovable = keyring.type !== KeyringType.hdKeyTree;
|
||||||
|
|
||||||
const routeToAddBlockExplorerUrl = () => {
|
const routeToAddBlockExplorerUrl = () => {
|
||||||
history.push(`${NETWORKS_ROUTE}#blockExplorerUrl`);
|
history.push(`${NETWORKS_ROUTE}#blockExplorerUrl`);
|
||||||
|
@ -3,7 +3,7 @@ import configureStore from 'redux-mock-store';
|
|||||||
import { fireEvent, screen, waitFor } from '@testing-library/react';
|
import { fireEvent, screen, waitFor } from '@testing-library/react';
|
||||||
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
||||||
import { CHAIN_IDS } from '../../../../shared/constants/network';
|
import { CHAIN_IDS } from '../../../../shared/constants/network';
|
||||||
import { HardwareKeyringTypes } from '../../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../../shared/constants/keyring';
|
||||||
import MenuBar from './menu-bar';
|
import MenuBar from './menu-bar';
|
||||||
|
|
||||||
const initState = {
|
const initState = {
|
||||||
@ -21,7 +21,7 @@ const initState = {
|
|||||||
},
|
},
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -4,7 +4,7 @@ import thunk from 'redux-thunk';
|
|||||||
import { fireEvent, waitFor } from '@testing-library/react';
|
import { fireEvent, waitFor } from '@testing-library/react';
|
||||||
import { CHAIN_IDS } from '../../../../shared/constants/network';
|
import { CHAIN_IDS } from '../../../../shared/constants/network';
|
||||||
import { renderWithProvider } from '../../../../test/jest/rendering';
|
import { renderWithProvider } from '../../../../test/jest/rendering';
|
||||||
import { HardwareKeyringTypes } from '../../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../../shared/constants/keyring';
|
||||||
import EthOverview from './eth-overview';
|
import EthOverview from './eth-overview';
|
||||||
|
|
||||||
// Mock BUYABLE_CHAINS_MAP
|
// Mock BUYABLE_CHAINS_MAP
|
||||||
@ -56,11 +56,11 @@ describe('EthOverview', () => {
|
|||||||
selectedAddress: '0x1',
|
selectedAddress: '0x1',
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.imported,
|
type: KeyringType.imported,
|
||||||
accounts: ['0x1', '0x2'],
|
accounts: ['0x1', '0x2'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.ledger,
|
type: KeyringType.ledger,
|
||||||
accounts: [],
|
accounts: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -4,7 +4,7 @@ import thunk from 'redux-thunk';
|
|||||||
import { fireEvent, waitFor } from '@testing-library/react';
|
import { fireEvent, waitFor } from '@testing-library/react';
|
||||||
import { CHAIN_IDS } from '../../../../shared/constants/network';
|
import { CHAIN_IDS } from '../../../../shared/constants/network';
|
||||||
import { renderWithProvider } from '../../../../test/jest/rendering';
|
import { renderWithProvider } from '../../../../test/jest/rendering';
|
||||||
import { HardwareKeyringTypes } from '../../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../../shared/constants/keyring';
|
||||||
import TokenOverview from './token-overview';
|
import TokenOverview from './token-overview';
|
||||||
|
|
||||||
// Mock BUYABLE_CHAINS_MAP
|
// Mock BUYABLE_CHAINS_MAP
|
||||||
@ -42,11 +42,11 @@ describe('TokenOverview', () => {
|
|||||||
selectedAddress: '0x1',
|
selectedAddress: '0x1',
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: ['0x1', '0x2'],
|
accounts: ['0x1', '0x2'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.ledger,
|
type: KeyringType.ledger,
|
||||||
accounts: [],
|
accounts: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
import { updateTransactionGasFees } from '../../store/actions';
|
import { updateTransactionGasFees } from '../../store/actions';
|
||||||
import { setCustomGasLimit, setCustomGasPrice } from '../gas/gas.duck';
|
import { setCustomGasLimit, setCustomGasPrice } from '../gas/gas.duck';
|
||||||
|
|
||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../shared/constants/keyring';
|
||||||
import { isEqualCaseInsensitive } from '../../../shared/modules/string-utils';
|
import { isEqualCaseInsensitive } from '../../../shared/modules/string-utils';
|
||||||
import { stripHexPrefix } from '../../../shared/modules/hexstring-utils';
|
import { stripHexPrefix } from '../../../shared/modules/hexstring-utils';
|
||||||
import {
|
import {
|
||||||
@ -407,7 +407,7 @@ export function getLedgerTransportType(state) {
|
|||||||
export function isAddressLedger(state, address) {
|
export function isAddressLedger(state, address) {
|
||||||
const keyring = findKeyringForAddress(state, address);
|
const keyring = findKeyringForAddress(state, address);
|
||||||
|
|
||||||
return keyring?.type === HardwareKeyringTypes.ledger;
|
return keyring?.type === KeyringType.ledger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -419,6 +419,6 @@ export function isAddressLedger(state, address) {
|
|||||||
*/
|
*/
|
||||||
export function doesUserHaveALedgerAccount(state) {
|
export function doesUserHaveALedgerAccount(state) {
|
||||||
return state.metamask.keyrings.some((kr) => {
|
return state.metamask.keyrings.some((kr) => {
|
||||||
return kr.type === HardwareKeyringTypes.ledger;
|
return kr.type === KeyringType.ledger;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
} from '../../pages/send/send.constants';
|
} from '../../pages/send/send.constants';
|
||||||
import { CHAIN_IDS } from '../../../shared/constants/network';
|
import { CHAIN_IDS } from '../../../shared/constants/network';
|
||||||
import { GasEstimateTypes, GAS_LIMITS } from '../../../shared/constants/gas';
|
import { GasEstimateTypes, GAS_LIMITS } from '../../../shared/constants/gas';
|
||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../shared/constants/keyring';
|
||||||
import {
|
import {
|
||||||
AssetType,
|
AssetType,
|
||||||
TokenStandard,
|
TokenStandard,
|
||||||
@ -1278,7 +1278,7 @@ describe('Send Slice', () => {
|
|||||||
identities: { '0xAddress': { address: '0xAddress' } },
|
identities: { '0xAddress': { address: '0xAddress' } },
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: ['0xAddress'],
|
accounts: ['0xAddress'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -6,7 +6,7 @@ import { renderWithProvider } from '../../../test/lib/render-helpers';
|
|||||||
import { setBackgroundConnection } from '../../../test/jest';
|
import { setBackgroundConnection } from '../../../test/jest';
|
||||||
import { INITIAL_SEND_STATE_FOR_EXISTING_DRAFT } from '../../../test/jest/mocks';
|
import { INITIAL_SEND_STATE_FOR_EXISTING_DRAFT } from '../../../test/jest/mocks';
|
||||||
import { GasEstimateTypes } from '../../../shared/constants/gas';
|
import { GasEstimateTypes } from '../../../shared/constants/gas';
|
||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../shared/constants/keyring';
|
||||||
import { CHAIN_IDS } from '../../../shared/constants/network';
|
import { CHAIN_IDS } from '../../../shared/constants/network';
|
||||||
import { domainInitialState } from '../../ducks/domains';
|
import { domainInitialState } from '../../ducks/domains';
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ const baseStore = {
|
|||||||
selectedAddress: '0x0',
|
selectedAddress: '0x0',
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: ['0x0'],
|
accounts: ['0x0'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -8,7 +8,7 @@ import qrCode from 'qrcode-generator';
|
|||||||
import Button from '../../components/ui/button';
|
import Button from '../../components/ui/button';
|
||||||
import LoadingScreen from '../../components/ui/loading-screen';
|
import LoadingScreen from '../../components/ui/loading-screen';
|
||||||
import { MINUTE, SECOND } from '../../../shared/constants/time';
|
import { MINUTE, SECOND } from '../../../shared/constants/time';
|
||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../shared/constants/keyring';
|
||||||
|
|
||||||
const PASSWORD_PROMPT_SCREEN = 'PASSWORD_PROMPT_SCREEN';
|
const PASSWORD_PROMPT_SCREEN = 'PASSWORD_PROMPT_SCREEN';
|
||||||
const REVEAL_SEED_SCREEN = 'REVEAL_SEED_SCREEN';
|
const REVEAL_SEED_SCREEN = 'REVEAL_SEED_SCREEN';
|
||||||
@ -82,7 +82,7 @@ export default class MobileSyncPage extends Component {
|
|||||||
async exportAccounts() {
|
async exportAccounts() {
|
||||||
const addresses = [];
|
const addresses = [];
|
||||||
this.props.keyrings.forEach((keyring) => {
|
this.props.keyrings.forEach((keyring) => {
|
||||||
if (keyring.type === HardwareKeyringTypes.imported) {
|
if (keyring.type === KeyringType.imported) {
|
||||||
addresses.push(keyring.accounts[0]);
|
addresses.push(keyring.accounts[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
setBackgroundConnection,
|
setBackgroundConnection,
|
||||||
} from '../../../test/jest';
|
} from '../../../test/jest';
|
||||||
import { GasEstimateTypes } from '../../../shared/constants/gas';
|
import { GasEstimateTypes } from '../../../shared/constants/gas';
|
||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../shared/constants/keyring';
|
||||||
import { INITIAL_SEND_STATE_FOR_EXISTING_DRAFT } from '../../../test/jest/mocks';
|
import { INITIAL_SEND_STATE_FOR_EXISTING_DRAFT } from '../../../test/jest/mocks';
|
||||||
import Send from './send';
|
import Send from './send';
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ const baseStore = {
|
|||||||
selectedAddress: '0x0',
|
selectedAddress: '0x0',
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.hdKeyTree,
|
type: KeyringType.hdKeyTree,
|
||||||
accounts: ['0x0'],
|
accounts: ['0x0'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import configureMockStore from 'redux-mock-store';
|
import configureMockStore from 'redux-mock-store';
|
||||||
import { fireEvent } from '@testing-library/react';
|
import { fireEvent } from '@testing-library/react';
|
||||||
import { renderWithProvider } from '../../../test/lib/render-helpers';
|
import { renderWithProvider } from '../../../test/lib/render-helpers';
|
||||||
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../../shared/constants/keyring';
|
||||||
import TokenAllowance from './token-allowance';
|
import TokenAllowance from './token-allowance';
|
||||||
|
|
||||||
const testTokenAddress = '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F';
|
const testTokenAddress = '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F';
|
||||||
@ -65,10 +65,10 @@ const state = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
unapprovedTxs: {},
|
unapprovedTxs: {},
|
||||||
keyringTypes: [HardwareKeyringTypes.ledger],
|
keyringTypes: [KeyringType.ledger],
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.ledger,
|
type: KeyringType.ledger,
|
||||||
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -26,11 +26,11 @@ import {
|
|||||||
NETWORK_TYPES,
|
NETWORK_TYPES,
|
||||||
} from '../../shared/constants/network';
|
} from '../../shared/constants/network';
|
||||||
import {
|
import {
|
||||||
HardwareKeyringTypes,
|
|
||||||
WebHIDConnectedStatuses,
|
WebHIDConnectedStatuses,
|
||||||
LedgerTransportTypes,
|
LedgerTransportTypes,
|
||||||
HardwareTransportStates,
|
HardwareTransportStates,
|
||||||
} from '../../shared/constants/hardware-wallets';
|
} from '../../shared/constants/hardware-wallets';
|
||||||
|
import { KeyringType } from '../../shared/constants/keyring';
|
||||||
import { MESSAGE_TYPE } from '../../shared/constants/app';
|
import { MESSAGE_TYPE } from '../../shared/constants/app';
|
||||||
|
|
||||||
import { TRUNCATED_NAME_CHAR_LIMIT } from '../../shared/constants/labels';
|
import { TRUNCATED_NAME_CHAR_LIMIT } from '../../shared/constants/labels';
|
||||||
@ -127,7 +127,7 @@ export function hasUnsignedQRHardwareTransaction(state) {
|
|||||||
}
|
}
|
||||||
const { from } = txParams;
|
const { from } = txParams;
|
||||||
const { keyrings } = state.metamask;
|
const { keyrings } = state.metamask;
|
||||||
const qrKeyring = keyrings.find((kr) => kr.type === HardwareKeyringTypes.qr);
|
const qrKeyring = keyrings.find((kr) => kr.type === KeyringType.qr);
|
||||||
if (!qrKeyring) {
|
if (!qrKeyring) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ export function hasUnsignedQRHardwareMessage(state) {
|
|||||||
}
|
}
|
||||||
const { from } = msgParams;
|
const { from } = msgParams;
|
||||||
const { keyrings } = state.metamask;
|
const { keyrings } = state.metamask;
|
||||||
const qrKeyring = keyrings.find((kr) => kr.type === HardwareKeyringTypes.qr);
|
const qrKeyring = keyrings.find((kr) => kr.type === KeyringType.qr);
|
||||||
if (!qrKeyring) {
|
if (!qrKeyring) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -232,11 +232,11 @@ export function getAccountType(state) {
|
|||||||
const type = currentKeyring && currentKeyring.type;
|
const type = currentKeyring && currentKeyring.type;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case HardwareKeyringTypes.trezor:
|
case KeyringType.trezor:
|
||||||
case HardwareKeyringTypes.ledger:
|
case KeyringType.ledger:
|
||||||
case HardwareKeyringTypes.lattice:
|
case KeyringType.lattice:
|
||||||
return 'hardware';
|
return 'hardware';
|
||||||
case HardwareKeyringTypes.imported:
|
case KeyringType.imported:
|
||||||
return 'imported';
|
return 'imported';
|
||||||
default:
|
default:
|
||||||
return 'default';
|
return 'default';
|
||||||
@ -934,8 +934,7 @@ export const getUnreadNotificationsCount = createSelector(
|
|||||||
*/
|
*/
|
||||||
function getAllowedAnnouncementIds(state) {
|
function getAllowedAnnouncementIds(state) {
|
||||||
const currentKeyring = getCurrentKeyring(state);
|
const currentKeyring = getCurrentKeyring(state);
|
||||||
const currentKeyringIsLedger =
|
const currentKeyringIsLedger = currentKeyring?.type === KeyringType.ledger;
|
||||||
currentKeyring?.type === HardwareKeyringTypes.ledger;
|
|
||||||
const supportsWebHid = window.navigator.hid !== undefined;
|
const supportsWebHid = window.navigator.hid !== undefined;
|
||||||
const currentlyUsingLedgerLive =
|
const currentlyUsingLedgerLive =
|
||||||
getLedgerTransportType(state) === LedgerTransportTypes.live;
|
getLedgerTransportType(state) === LedgerTransportTypes.live;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import mockState from '../../test/data/mock-state.json';
|
import mockState from '../../test/data/mock-state.json';
|
||||||
import { HardwareKeyringTypes } from '../../shared/constants/hardware-wallets';
|
import { KeyringType } from '../../shared/constants/keyring';
|
||||||
import * as selectors from './selectors';
|
import * as selectors from './selectors';
|
||||||
|
|
||||||
describe('Selectors', () => {
|
describe('Selectors', () => {
|
||||||
@ -105,38 +105,38 @@ describe('Selectors', () => {
|
|||||||
|
|
||||||
describe('#isHardwareWallet', () => {
|
describe('#isHardwareWallet', () => {
|
||||||
it('returns false if it is not a HW wallet', () => {
|
it('returns false if it is not a HW wallet', () => {
|
||||||
mockState.metamask.keyrings[0].type = HardwareKeyringTypes.imported;
|
mockState.metamask.keyrings[0].type = KeyringType.imported;
|
||||||
expect(selectors.isHardwareWallet(mockState)).toBe(false);
|
expect(selectors.isHardwareWallet(mockState)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns true if it is a Ledger HW wallet', () => {
|
it('returns true if it is a Ledger HW wallet', () => {
|
||||||
mockState.metamask.keyrings[0].type = HardwareKeyringTypes.ledger;
|
mockState.metamask.keyrings[0].type = KeyringType.ledger;
|
||||||
expect(selectors.isHardwareWallet(mockState)).toBe(true);
|
expect(selectors.isHardwareWallet(mockState)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns true if it is a Trezor HW wallet', () => {
|
it('returns true if it is a Trezor HW wallet', () => {
|
||||||
mockState.metamask.keyrings[0].type = HardwareKeyringTypes.trezor;
|
mockState.metamask.keyrings[0].type = KeyringType.trezor;
|
||||||
expect(selectors.isHardwareWallet(mockState)).toBe(true);
|
expect(selectors.isHardwareWallet(mockState)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getHardwareWalletType', () => {
|
describe('#getHardwareWalletType', () => {
|
||||||
it('returns undefined if it is not a HW wallet', () => {
|
it('returns undefined if it is not a HW wallet', () => {
|
||||||
mockState.metamask.keyrings[0].type = HardwareKeyringTypes.imported;
|
mockState.metamask.keyrings[0].type = KeyringType.imported;
|
||||||
expect(selectors.getHardwareWalletType(mockState)).toBeUndefined();
|
expect(selectors.getHardwareWalletType(mockState)).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns "Ledger Hardware" if it is a Ledger HW wallet', () => {
|
it('returns "Ledger Hardware" if it is a Ledger HW wallet', () => {
|
||||||
mockState.metamask.keyrings[0].type = HardwareKeyringTypes.ledger;
|
mockState.metamask.keyrings[0].type = KeyringType.ledger;
|
||||||
expect(selectors.getHardwareWalletType(mockState)).toBe(
|
expect(selectors.getHardwareWalletType(mockState)).toBe(
|
||||||
HardwareKeyringTypes.ledger,
|
KeyringType.ledger,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns "Trezor Hardware" if it is a Trezor HW wallet', () => {
|
it('returns "Trezor Hardware" if it is a Trezor HW wallet', () => {
|
||||||
mockState.metamask.keyrings[0].type = HardwareKeyringTypes.trezor;
|
mockState.metamask.keyrings[0].type = KeyringType.trezor;
|
||||||
expect(selectors.getHardwareWalletType(mockState)).toBe(
|
expect(selectors.getHardwareWalletType(mockState)).toBe(
|
||||||
HardwareKeyringTypes.trezor,
|
KeyringType.trezor,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -174,7 +174,7 @@ describe('Selectors', () => {
|
|||||||
...mockState.metamask,
|
...mockState.metamask,
|
||||||
keyrings: [
|
keyrings: [
|
||||||
{
|
{
|
||||||
type: HardwareKeyringTypes.ledger,
|
type: KeyringType.ledger,
|
||||||
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user