Skip to content

Commit

Permalink
refactor: use QRKeyring from KeyringController
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed Sep 7, 2023
1 parent 2a7776d commit 9e42db1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
5 changes: 0 additions & 5 deletions app/scripts/controllers/app-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default class AppStateController extends EventEmitter {
initState,
onInactiveTimeout,
preferencesStore,
qrHardwareStore,
messenger,
} = opts;
super();
Expand Down Expand Up @@ -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);

Expand Down
21 changes: 10 additions & 11 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -2225,6 +2222,7 @@ export default class MetamaskController extends EventEmitter {
addressBookController,
alertController,
appStateController,
coreKeyringController,
nftController,
nftDetectionController,
currencyRateController,
Expand All @@ -2237,7 +2235,6 @@ export default class MetamaskController extends EventEmitter {
onboardingController,
permissionController,
preferencesController,
qrHardwareKeyring,
swapsController,
tokensController,
smartTransactionsController,
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 9e42db1

Please sign in to comment.