1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

add account eip1559 detection support (#11380)

* add account eip1559 detection support

* add constants for keyring types
This commit is contained in:
Brad Decker 2021-06-28 12:29:08 -05:00 committed by GitHub
parent b6f514e293
commit bc4a9b16d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,6 +73,16 @@ export const METAMASK_CONTROLLER_EVENTS = {
UPDATE_BADGE: 'updateBadge',
};
/**
* Accounts can be instantiated from simple, HD or the two hardware wallet
* keyring types. Both simple and HD are treated as default but we do special
* case accounts managed by a hardware wallet.
*/
const KEYRING_TYPES = {
LEDGER: 'Ledger Hardware',
TREZOR: 'Trezor Hardware',
};
export default class MetamaskController extends EventEmitter {
/**
* @constructor
@ -1786,7 +1796,7 @@ export default class MetamaskController extends EventEmitter {
const keyring = await this.keyringController.getKeyringForAccount(address);
switch (keyring.type) {
case 'Ledger Hardware': {
case KEYRING_TYPES.LEDGER: {
return new Promise((_, reject) => {
reject(
new Error('Ledger does not support eth_getEncryptionPublicKey.'),
@ -1794,7 +1804,7 @@ export default class MetamaskController extends EventEmitter {
});
}
case 'Trezor Hardware': {
case KEYRING_TYPES.TREZOR: {
return new Promise((_, reject) => {
reject(
new Error('Trezor does not support eth_getEncryptionPublicKey.'),
@ -1933,6 +1943,24 @@ export default class MetamaskController extends EventEmitter {
cb(null, this.getState());
}
/**
* Method to return a boolean if the keyring for the currently selected
* account is a ledger or trezor keyring.
* TODO: remove this method when Ledger and Trezor release their supported
* client utilities for EIP-1559
* @returns {boolean} true if the keyring type supports EIP-1559
*/
getCurrentAccountEIP1559Compatibility() {
const selectedAddress = this.preferencesController.getSelectedAddress();
const keyring = this.keyringController.getKeyringForAccount(
selectedAddress,
);
return (
keyring.type !== KEYRING_TYPES.LEDGER &&
keyring.type !== KEYRING_TYPES.TREZOR
);
}
//=============================================================================
// END (VAULT / KEYRING RELATED METHODS)
//=============================================================================