From 9e42db12692fa0e5846354d90ef3c9205dc4a330 Mon Sep 17 00:00:00 2001 From: Michele Esposito Date: Thu, 17 Aug 2023 11:05:54 +0200 Subject: [PATCH] refactor: use QRKeyring from KeyringController --- app/scripts/controllers/app-state.js | 5 ----- app/scripts/metamask-controller.js | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/scripts/controllers/app-state.js b/app/scripts/controllers/app-state.js index 9603542dac85..4ad2520484b7 100644 --- a/app/scripts/controllers/app-state.js +++ b/app/scripts/controllers/app-state.js @@ -26,7 +26,6 @@ export default class AppStateController extends EventEmitter { initState, onInactiveTimeout, preferencesStore, - qrHardwareStore, messenger, } = opts; super(); @@ -76,10 +75,6 @@ export default class AppStateController extends EventEmitter { } }); - qrHardwareStore.subscribe((state) => { - this.store.updateState({ qrHardware: state }); - }); - const { preferences } = preferencesStore.getState(); this._setInactiveTimeout(preferences.autoLockTimeLimit); diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 52fc263aa53e..68cddf9dbd4b 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -607,15 +607,12 @@ export default class MetamaskController extends EventEmitter { getChainId: () => this.networkController.state.providerConfig.chainId, }); - this.qrHardwareKeyring = new QRHardwareKeyring(); - this.appStateController = new AppStateController({ addUnlockListener: this.on.bind(this, 'unlock'), isUnlocked: this.isUnlocked.bind(this), initState: initState.AppStateController, onInactiveTimeout: () => this.setLocked(), preferencesStore: this.preferencesController.store, - qrHardwareStore: this.qrHardwareKeyring.getMemStore(), messenger: this.controllerMessenger.getRestricted({ name: 'AppStateController', allowedActions: [ @@ -2225,6 +2222,7 @@ export default class MetamaskController extends EventEmitter { addressBookController, alertController, appStateController, + coreKeyringController, nftController, nftDetectionController, currencyRateController, @@ -2237,7 +2235,6 @@ export default class MetamaskController extends EventEmitter { onboardingController, permissionController, preferencesController, - qrHardwareKeyring, swapsController, tokensController, smartTransactionsController, @@ -2338,15 +2335,17 @@ export default class MetamaskController extends EventEmitter { // qr hardware devices submitQRHardwareCryptoHDKey: - qrHardwareKeyring.submitCryptoHDKey.bind(qrHardwareKeyring), + coreKeyringController.submitQRCryptoHDKey.bind(coreKeyringController), submitQRHardwareCryptoAccount: - qrHardwareKeyring.submitCryptoAccount.bind(qrHardwareKeyring), - cancelSyncQRHardware: - qrHardwareKeyring.cancelSync.bind(qrHardwareKeyring), - submitQRHardwareSignature: - qrHardwareKeyring.submitSignature.bind(qrHardwareKeyring), + coreKeyringController.submitQRCryptoAccount.bind(coreKeyringController), + cancelSyncQRHardware: coreKeyringController.cancelQRSynchronization.bind( + coreKeyringController, + ), + submitQRHardwareSignature: coreKeyringController.submitQRSignature.bind( + coreKeyringController, + ), cancelQRHardwareSignRequest: - qrHardwareKeyring.cancelSignRequest.bind(qrHardwareKeyring), + coreKeyringController.cancelQRSignRequest.bind(coreKeyringController), // vault management submitPassword: this.submitPassword.bind(this),