mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Put hardware wallets behind an HARDWARE_WALLETS_MV3 flag (#17354)
* Put hardware wallets behind an HARDWARE_WALLETS_MV3 flag Disable Hardware connect buttons if the flag is set. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> update to metamask/eth-keyring-controller Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> revert to eth-keyring-controller v8 Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> LAvamost after rebase Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lock file. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Added toaster for removed NFTs (#17297) * added notification for remove nfts * reverted names for tabs * updated default key * updated snapshot * updated remove nft toast to danger Setup network controller mocks per-test (#17250) The network controller unit test network mocks are now setup for each test. This makes modifying network behavior on a per-test basis easier, and makes it more clear which test relies upon which mocks. Security provider check (OpenSea) (#16584) chore: copy update for metamask fee on swaps (#17133) * linter fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * setLedgerTransportPreference in the metamask-controller should not be called, or should return immediately, if canUseHardwareWallets() is false Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
This commit is contained in:
parent
1d1b751f62
commit
16ea4a8046
@ -642,8 +642,9 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
await opts.openPopup();
|
await opts.openPopup();
|
||||||
});
|
});
|
||||||
|
|
||||||
let additionalKeyrings = [];
|
let additionalKeyrings = [keyringBuilderFactory(QRHardwareKeyring)];
|
||||||
if (!isManifestV3) {
|
|
||||||
|
if (this.canUseHardwareWallets()) {
|
||||||
const additionalKeyringTypes = [
|
const additionalKeyringTypes = [
|
||||||
TrezorKeyring,
|
TrezorKeyring,
|
||||||
LedgerBridgeKeyring,
|
LedgerBridgeKeyring,
|
||||||
@ -661,6 +662,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
encryptor: opts.encryptor || undefined,
|
encryptor: opts.encryptor || undefined,
|
||||||
cacheEncryptionKey: isManifestV3,
|
cacheEncryptionKey: isManifestV3,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.keyringController.memStore.subscribe((state) =>
|
this.keyringController.memStore.subscribe((state) =>
|
||||||
this._onKeyringControllerUpdate(state),
|
this._onKeyringControllerUpdate(state),
|
||||||
);
|
);
|
||||||
@ -1330,6 +1332,10 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canUseHardwareWallets() {
|
||||||
|
return !isManifestV3 || process.env.CONF?.HARDWARE_WALLETS_MV3;
|
||||||
|
}
|
||||||
|
|
||||||
resetStates(resetMethods) {
|
resetStates(resetMethods) {
|
||||||
resetMethods.forEach((resetMethod) => {
|
resetMethods.forEach((resetMethod) => {
|
||||||
try {
|
try {
|
||||||
@ -2588,6 +2594,12 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
|
|
||||||
async getKeyringForDevice(deviceName, hdPath = null) {
|
async getKeyringForDevice(deviceName, hdPath = null) {
|
||||||
let keyringName = null;
|
let keyringName = null;
|
||||||
|
if (
|
||||||
|
deviceName !== HardwareDeviceNames.QR &&
|
||||||
|
!this.canUseHardwareWallets()
|
||||||
|
) {
|
||||||
|
throw new Error('Hardware wallets are not supported on this version.');
|
||||||
|
}
|
||||||
switch (deviceName) {
|
switch (deviceName) {
|
||||||
case HardwareDeviceNames.trezor:
|
case HardwareDeviceNames.trezor:
|
||||||
keyringName = TrezorKeyring.type;
|
keyringName = TrezorKeyring.type;
|
||||||
@ -4405,6 +4417,10 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
* @param {string} transportType - The Ledger transport type.
|
* @param {string} transportType - The Ledger transport type.
|
||||||
*/
|
*/
|
||||||
async setLedgerTransportPreference(transportType) {
|
async setLedgerTransportPreference(transportType) {
|
||||||
|
if (!this.canUseHardwareWallets()) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const currentValue =
|
const currentValue =
|
||||||
this.preferencesController.getLedgerTransportPreference();
|
this.preferencesController.getLedgerTransportPreference();
|
||||||
const newValue =
|
const newValue =
|
||||||
|
@ -15,6 +15,7 @@ import {
|
|||||||
} from '../../../../shared/constants/hardware-wallets';
|
} from '../../../../shared/constants/hardware-wallets';
|
||||||
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
|
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
|
||||||
import { EVENT } from '../../../../shared/constants/metametrics';
|
import { EVENT } from '../../../../shared/constants/metametrics';
|
||||||
|
import { isManifestV3 } from '../../../../shared/modules/mv3.utils';
|
||||||
|
|
||||||
export default class SelectHardware extends Component {
|
export default class SelectHardware extends Component {
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
@ -32,6 +33,10 @@ export default class SelectHardware extends Component {
|
|||||||
selectedDevice: null,
|
selectedDevice: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
shouldShowConnectButton() {
|
||||||
|
return !isManifestV3 || process.env.CONF?.HARDWARE_WALLETS_MV3;
|
||||||
|
}
|
||||||
|
|
||||||
connect = () => {
|
connect = () => {
|
||||||
if (this.state.selectedDevice) {
|
if (this.state.selectedDevice) {
|
||||||
this.props.connectToHardwareWallet(this.state.selectedDevice);
|
this.props.connectToHardwareWallet(this.state.selectedDevice);
|
||||||
@ -103,14 +108,15 @@ export default class SelectHardware extends Component {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="hw-connect__btn-wrapper">
|
<div className="hw-connect__btn-wrapper">
|
||||||
{this.renderConnectToLedgerButton()}
|
{this.shouldShowConnectButton() && this.renderConnectToLedgerButton()}
|
||||||
{this.renderConnectToTrezorButton()}
|
{this.shouldShowConnectButton() && this.renderConnectToTrezorButton()}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="hw-connect__btn-wrapper"
|
className="hw-connect__btn-wrapper"
|
||||||
style={{ margin: '10px 0 0 0' }}
|
style={{ margin: '10px 0 0 0' }}
|
||||||
>
|
>
|
||||||
{this.renderConnectToLatticeButton()}
|
{this.shouldShowConnectButton() &&
|
||||||
|
this.renderConnectToLatticeButton()}
|
||||||
{this.renderConnectToQRButton()}
|
{this.renderConnectToQRButton()}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user