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 Aug 17, 2023
1 parent 6b72316 commit 3a6f05d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 0 additions & 6 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 All @@ -50,7 +49,6 @@ export default class AppStateController extends EventEmitter {
trezorModel: null,
currentPopupId: undefined,
...initState,
qrHardware: {},
nftsDropdownState: {},
usedNetworks: {
'0x1': true,
Expand All @@ -72,10 +70,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
24 changes: 15 additions & 9 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,15 +603,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 @@ -2205,7 +2202,6 @@ export default class MetamaskController extends EventEmitter {
onboardingController,
permissionController,
preferencesController,
qrHardwareKeyring,
swapsController,
tokensController,
smartTransactionsController,
Expand Down Expand Up @@ -2302,15 +2298,25 @@ export default class MetamaskController extends EventEmitter {

// qr hardware devices
submitQRHardwareCryptoHDKey:
qrHardwareKeyring.submitCryptoHDKey.bind(qrHardwareKeyring),
this.coreKeyringController.submitQRCryptoHDKey.bind(
this.coreKeyringController,
),
submitQRHardwareCryptoAccount:
qrHardwareKeyring.submitCryptoAccount.bind(qrHardwareKeyring),
this.coreKeyringController.submitQRCryptoAccount.bind(
this.coreKeyringController,
),
cancelSyncQRHardware:
qrHardwareKeyring.cancelSync.bind(qrHardwareKeyring),
this.coreKeyringController.cancelQRSynchronization.bind(
this.coreKeyringController,
),
submitQRHardwareSignature:
qrHardwareKeyring.submitSignature.bind(qrHardwareKeyring),
this.coreKeyringController.submitQRSignature.bind(
this.coreKeyringController,
),
cancelQRHardwareSignRequest:
qrHardwareKeyring.cancelSignRequest.bind(qrHardwareKeyring),
this.coreKeyringController.cancelQRSignRequest.bind(
this.coreKeyringController,
),

// vault management
submitPassword: this.submitPassword.bind(this),
Expand Down

0 comments on commit 3a6f05d

Please sign in to comment.