* EIP-1559 - Provide support for Ledger

* Update ui/selectors/selectors.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Add shared constants for hw types

* bump eth-ledger-bridge-keyring to v0.7.0

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Alex <adonesky@gmail.com>
feature/default_network_editable
Dan J Miller 3 years ago committed by GitHub
parent 8a8ce3a0c0
commit a4c0133bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      app/scripts/metamask-controller.js
  2. 2
      package.json
  3. 9
      shared/constants/hardware-wallets.js
  4. 6
      ui/selectors/selectors.js
  5. 14
      yarn.lock

@ -29,6 +29,7 @@ import {
} from '@metamask/controllers'; } from '@metamask/controllers';
import { TRANSACTION_STATUSES } from '../../shared/constants/transaction'; import { TRANSACTION_STATUSES } from '../../shared/constants/transaction';
import { MAINNET_CHAIN_ID } from '../../shared/constants/network'; import { MAINNET_CHAIN_ID } from '../../shared/constants/network';
import { KEYRING_TYPES } from '../../shared/constants/hardware-wallets';
import { UI_NOTIFICATIONS } from '../../shared/notifications'; import { UI_NOTIFICATIONS } from '../../shared/notifications';
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils'; import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
import { MILLISECOND } from '../../shared/constants/time'; import { MILLISECOND } from '../../shared/constants/time';
@ -79,16 +80,6 @@ export const METAMASK_CONTROLLER_EVENTS = {
APPROVAL_STATE_CHANGE: 'ApprovalController:stateChange', APPROVAL_STATE_CHANGE: 'ApprovalController:stateChange',
}; };
/**
* 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 { export default class MetamaskController extends EventEmitter {
/** /**
* @constructor * @constructor
@ -2083,10 +2074,7 @@ export default class MetamaskController extends EventEmitter {
const address = const address =
fromAddress || this.preferencesController.getSelectedAddress(); fromAddress || this.preferencesController.getSelectedAddress();
const keyring = await this.keyringController.getKeyringForAccount(address); const keyring = await this.keyringController.getKeyringForAccount(address);
return ( return keyring.type !== KEYRING_TYPES.TREZOR;
keyring.type !== KEYRING_TYPES.LEDGER &&
keyring.type !== KEYRING_TYPES.TREZOR
);
} }
//============================================================================= //=============================================================================

@ -105,7 +105,7 @@
"@material-ui/core": "^4.11.0", "@material-ui/core": "^4.11.0",
"@metamask/contract-metadata": "^1.28.0", "@metamask/contract-metadata": "^1.28.0",
"@metamask/controllers": "^15.0.0", "@metamask/controllers": "^15.0.0",
"@metamask/eth-ledger-bridge-keyring": "^0.6.0", "@metamask/eth-ledger-bridge-keyring": "^0.7.0",
"@metamask/eth-token-tracker": "^3.0.1", "@metamask/eth-token-tracker": "^3.0.1",
"@metamask/etherscan-link": "^2.1.0", "@metamask/etherscan-link": "^2.1.0",
"@metamask/jazzicon": "^2.0.0", "@metamask/jazzicon": "^2.0.0",

@ -0,0 +1,9 @@
/**
* 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.
*/
export const KEYRING_TYPES = {
LEDGER: 'Ledger Hardware',
TREZOR: 'Trezor Hardware',
};

@ -8,6 +8,7 @@ import {
NETWORK_TYPE_RPC, NETWORK_TYPE_RPC,
NATIVE_CURRENCY_TOKEN_IMAGE_MAP, NATIVE_CURRENCY_TOKEN_IMAGE_MAP,
} from '../../shared/constants/network'; } from '../../shared/constants/network';
import { KEYRING_TYPES } from '../../shared/constants/hardware-wallets';
import { import {
SWAPS_CHAINID_DEFAULT_TOKEN_MAP, SWAPS_CHAINID_DEFAULT_TOKEN_MAP,
@ -82,8 +83,9 @@ export function getCurrentKeyring(state) {
} }
export function isEIP1559Account(state) { export function isEIP1559Account(state) {
// Neither hardware wallet supports 1559 at this time // Trezor does not support 1559 at this time
return !isHardwareWallet(state); const currentKeyring = getCurrentKeyring(state);
return currentKeyring && currentKeyring.type !== KEYRING_TYPES.TREZOR;
} }
export function checkNetworkAndAccountSupports1559(state) { export function checkNetworkAndAccountSupports1559(state) {

@ -1564,7 +1564,7 @@
crc-32 "^1.2.0" crc-32 "^1.2.0"
ethereumjs-util "^7.1.0" ethereumjs-util "^7.1.0"
"@ethereumjs/tx@^3.1.1", "@ethereumjs/tx@^3.1.4", "@ethereumjs/tx@^3.2.1", "@ethereumjs/tx@^3.3.0": "@ethereumjs/tx@^3.1.4", "@ethereumjs/tx@^3.2.0", "@ethereumjs/tx@^3.2.1", "@ethereumjs/tx@^3.3.0":
version "3.3.0" version "3.3.0"
resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.3.0.tgz#14ed1b7fa0f28e1cd61e3ecbdab824205f6a4378" resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.3.0.tgz#14ed1b7fa0f28e1cd61e3ecbdab824205f6a4378"
integrity sha512-yTwEj2lVzSMgE6Hjw9Oa1DZks/nKTWM8Wn4ykDNapBPua2f4nXO3qKnni86O6lgDj5fVNRqbDsD0yy7/XNGDEA== integrity sha512-yTwEj2lVzSMgE6Hjw9Oa1DZks/nKTWM8Wn4ykDNapBPua2f4nXO3qKnni86O6lgDj5fVNRqbDsD0yy7/XNGDEA==
@ -2814,16 +2814,14 @@
resolved "https://registry.yarnpkg.com/@metamask/eslint-config/-/eslint-config-6.0.0.tgz#ec53e8ab278073e882411ed89705bc7d06b78c81" resolved "https://registry.yarnpkg.com/@metamask/eslint-config/-/eslint-config-6.0.0.tgz#ec53e8ab278073e882411ed89705bc7d06b78c81"
integrity sha512-LyakGYGwM8UQOGhwWa+5erAI1hXuiTgf/y7USzOomX6H9KiuY09IAUYnPh7ToPG2sedD2F48UF1bUm8yvCoZOw== integrity sha512-LyakGYGwM8UQOGhwWa+5erAI1hXuiTgf/y7USzOomX6H9KiuY09IAUYnPh7ToPG2sedD2F48UF1bUm8yvCoZOw==
"@metamask/eth-ledger-bridge-keyring@^0.6.0": "@metamask/eth-ledger-bridge-keyring@^0.7.0":
version "0.6.0" version "0.7.0"
resolved "https://registry.yarnpkg.com/@metamask/eth-ledger-bridge-keyring/-/eth-ledger-bridge-keyring-0.6.0.tgz#2f1344eb76bf880c8cfbb92b9b64510920c7e335" resolved "https://registry.yarnpkg.com/@metamask/eth-ledger-bridge-keyring/-/eth-ledger-bridge-keyring-0.7.0.tgz#7d80e1e3dfab91ba2b6a1a2a5e352320e948b568"
integrity sha512-eP0f8Q7o5K35wVinK2EjEw/gVY/pvzkAcbk49CwQEzGPKm6d+AAURJZ0o33/8gYGIrpq4bmWZhZzgyAbphgVLw== integrity sha512-0UOEb/c3/fkatDK+se3gOHaGQ0RTRLbG5DqsoeowZ/JcO4wcMxBhOiIgOY4domOqUTekKKVPNC7Pc0mHpM9sAQ==
dependencies: dependencies:
"@ethereumjs/tx" "^3.1.1" "@ethereumjs/tx" "^3.2.0"
eth-sig-util "^2.0.0" eth-sig-util "^2.0.0"
ethereumjs-tx "^1.3.4"
ethereumjs-util "^7.0.9" ethereumjs-util "^7.0.9"
events "^2.0.0"
hdkey "0.8.0" hdkey "0.8.0"
"@metamask/eth-token-tracker@^3.0.1": "@metamask/eth-token-tracker@^3.0.1":

Loading…
Cancel
Save