1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

NetworkController: Simplify event types (#19252)

In the `core` version of this controller, event types are not held in an
enum but are specified directly as strings instead.

Simplifying the event types will make it easier to compare the
NetworkController unit tests between extension and core.
This commit is contained in:
Elliot Winkler 2023-05-26 10:35:52 -06:00 committed by GitHub
parent b387a6e795
commit c2bbbb1dbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 113 deletions

View File

@ -13,7 +13,7 @@ import { convertHexToDecimal } from '@metamask/controller-utils';
import { NETWORK_TYPES } from '../../../shared/constants/network';
import { toChecksumHexAddress } from '../../../shared/modules/hexstring-utils';
import DetectTokensController from './detect-tokens';
import { NetworkController, NetworkControllerEventType } from './network';
import { NetworkController } from './network';
import PreferencesController from './preferences';
describe('DetectTokensController', function () {
@ -248,7 +248,7 @@ describe('DetectTokensController', function () {
),
onNetworkStateChange: (cb) =>
networkControllerMessenger.subscribe(
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
() => {
const networkState = network.store.getState();
const modifiedNetworkState = {

View File

@ -19,7 +19,6 @@ import { MetaMetricsNetworkEventSource } from '../../../../shared/constants/meta
import {
NetworkController,
NetworkControllerEvent,
NetworkControllerEventType,
NetworkControllerOptions,
NetworkControllerState,
ProviderConfiguration,
@ -871,7 +870,7 @@ describe('NetworkController', () => {
const promiseForNoInfuraIsUnblockedEvents = waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await controller.lookupNetwork();
@ -890,7 +889,7 @@ describe('NetworkController', () => {
const promiseForNoInfuraIsBlockedEvents = waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await controller.lookupNetwork();
@ -954,7 +953,7 @@ describe('NetworkController', () => {
const promiseForNoInfuraIsUnblockedEvents = waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await controller.lookupNetwork();
@ -985,7 +984,7 @@ describe('NetworkController', () => {
const promiseForNoInfuraIsBlockedEvents = waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await controller.lookupNetwork();
@ -1368,12 +1367,12 @@ describe('NetworkController', () => {
const promiseForNoInfuraIsUnblockedEvents =
waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
});
const promiseForInfuraIsBlocked = waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
});
await controller.lookupNetwork();
@ -1788,12 +1787,12 @@ describe('NetworkController', () => {
const promiseForNoInfuraIsUnblockedEvents =
waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
});
const promiseForInfuraIsBlocked = waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
});
await controller.lookupNetwork();
@ -2198,12 +2197,12 @@ describe('NetworkController', () => {
const promiseForNoInfuraIsUnblockedEvents =
waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
});
const promiseForInfuraIsBlocked = waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
});
await controller.lookupNetwork();
@ -2582,7 +2581,7 @@ describe('NetworkController', () => {
operation: async () => {
const networkWillChange = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.NetworkWillChange,
eventType: 'NetworkController:networkWillChange',
operation: async () => {
await controller.rollbackToPreviousProvider();
},
@ -2957,7 +2956,7 @@ describe('NetworkController', () => {
operation: async () => {
const networkDidChange = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.NetworkDidChange,
eventType: 'NetworkController:networkDidChange',
operation: async () => {
await controller.rollbackToPreviousProvider();
},
@ -3024,12 +3023,12 @@ describe('NetworkController', () => {
const promiseForNoInfuraIsUnblockedEvents =
waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
});
const promiseForInfuraIsBlocked = waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
});
await waitForLookupNetworkToComplete({
@ -3321,7 +3320,7 @@ describe('NetworkController', () => {
operation: async () => {
const networkWillChange = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.NetworkWillChange,
eventType: 'NetworkController:networkWillChange',
operation: async () => {
await controller.rollbackToPreviousProvider();
},
@ -3644,7 +3643,7 @@ describe('NetworkController', () => {
operation: async () => {
const networkDidChange = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.NetworkDidChange,
eventType: 'NetworkController:networkDidChange',
operation: async () => {
await controller.rollbackToPreviousProvider();
},
@ -3695,7 +3694,7 @@ describe('NetworkController', () => {
operation: async () => {
const infuraIsUnblocked = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await controller.rollbackToPreviousProvider();
},
@ -4537,7 +4536,7 @@ function refreshNetworkTests({
const networkWillChange = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.NetworkWillChange,
eventType: 'NetworkController:networkWillChange',
operation: () => {
// Intentionally not awaited because we're capturing an event
// emitted partway through the operation
@ -4562,7 +4561,7 @@ function refreshNetworkTests({
const networkDidChange = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.NetworkDidChange,
eventType: 'NetworkController:networkDidChange',
operation: () => {
// Intentionally not awaited because we're capturing an event
// emitted partway through the operation
@ -5083,7 +5082,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await operation(controller);
},
@ -5106,7 +5105,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5162,7 +5161,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await operation(controller);
},
@ -5191,7 +5190,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5222,7 +5221,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5278,7 +5277,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await operation(controller);
},
@ -5307,7 +5306,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5360,7 +5359,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5390,7 +5389,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
operation: async () => {
await operation(controller);
},
@ -5446,7 +5445,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await operation(controller);
},
@ -5475,7 +5474,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5506,7 +5505,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5562,7 +5561,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await operation(controller);
},
@ -5591,7 +5590,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5622,7 +5621,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5684,7 +5683,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await operation(controller);
},
@ -5716,7 +5715,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5750,7 +5749,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5812,7 +5811,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await operation(controller);
},
@ -5844,7 +5843,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5903,7 +5902,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await operation(controller);
@ -5936,7 +5935,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
operation: async () => {
await operation(controller);
},
@ -5997,7 +5996,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
operation: async () => {
await operation(controller);
},
@ -6029,7 +6028,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsUnblocked,
eventType: 'NetworkController:infuraIsUnblocked',
count: 0,
operation: async () => {
await operation(controller);
@ -6063,7 +6062,7 @@ function lookupNetworkTests({
const payloads = await waitForPublishedEvents({
messenger,
eventType: NetworkControllerEventType.InfuraIsBlocked,
eventType: 'NetworkController:infuraIsBlocked',
count: 0,
operation: async () => {
await operation(controller);
@ -6093,17 +6092,13 @@ function buildMessenger() {
* @returns The network controller restricted messenger.
*/
function buildNetworkControllerMessenger(messenger = buildMessenger()) {
return messenger.getRestricted<
'NetworkController',
never,
NetworkControllerEventType
>({
return messenger.getRestricted({
name: 'NetworkController',
allowedEvents: [
NetworkControllerEventType.NetworkDidChange,
NetworkControllerEventType.NetworkWillChange,
NetworkControllerEventType.InfuraIsBlocked,
NetworkControllerEventType.InfuraIsUnblocked,
'NetworkController:networkDidChange',
'NetworkController:networkWillChange',
'NetworkController:infuraIsBlocked',
'NetworkController:infuraIsUnblocked',
],
});
}

View File

@ -82,35 +82,13 @@ type NetworkConfigurationId = string;
*/
type ChainId = Hex;
/**
* The set of event types that NetworkController can publish via its messenger.
*/
export enum NetworkControllerEventType {
/**
* @see {@link NetworkControllerNetworkDidChangeEvent}
*/
NetworkDidChange = 'NetworkController:networkDidChange',
/**
* @see {@link NetworkControllerNetworkWillChangeEvent}
*/
NetworkWillChange = 'NetworkController:networkWillChange',
/**
* @see {@link NetworkControllerInfuraIsBlockedEvent}
*/
InfuraIsBlocked = 'NetworkController:infuraIsBlocked',
/**
* @see {@link NetworkControllerInfuraIsUnblockedEvent}
*/
InfuraIsUnblocked = 'NetworkController:infuraIsUnblocked',
}
/**
* `networkWillChange` is published when the current network is about to be
* switched, but the new provider has not been created and no state changes have
* occurred yet.
*/
export type NetworkControllerNetworkWillChangeEvent = {
type: NetworkControllerEventType.NetworkWillChange;
type: 'NetworkController:networkWillChange';
payload: [];
};
@ -119,7 +97,7 @@ export type NetworkControllerNetworkWillChangeEvent = {
* switched network (but before the network has been confirmed to be available).
*/
export type NetworkControllerNetworkDidChangeEvent = {
type: NetworkControllerEventType.NetworkDidChange;
type: 'NetworkController:networkDidChange';
payload: [];
};
@ -129,7 +107,7 @@ export type NetworkControllerNetworkDidChangeEvent = {
* location.
*/
export type NetworkControllerInfuraIsBlockedEvent = {
type: NetworkControllerEventType.InfuraIsBlocked;
type: 'NetworkController:infuraIsBlocked';
payload: [];
};
@ -139,7 +117,7 @@ export type NetworkControllerInfuraIsBlockedEvent = {
* their location, or the network is switched to a non-Infura network.
*/
export type NetworkControllerInfuraIsUnblockedEvent = {
type: NetworkControllerEventType.InfuraIsUnblocked;
type: 'NetworkController:infuraIsUnblocked';
payload: [];
};
@ -159,8 +137,8 @@ export type NetworkControllerMessenger = RestrictedControllerMessenger<
typeof name,
never,
NetworkControllerEvent,
never,
NetworkControllerEventType
string,
string
>;
/**
@ -611,14 +589,11 @@ export class NetworkController extends EventEmitter {
const listener = () => {
networkChanged = true;
this.#messenger.unsubscribe(
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
listener,
);
};
this.#messenger.subscribe(
NetworkControllerEventType.NetworkDidChange,
listener,
);
this.#messenger.subscribe('NetworkController:networkDidChange', listener);
try {
const results = await Promise.all([
@ -664,10 +639,7 @@ export class NetworkController extends EventEmitter {
// in the process of being called, so we don't need to go further.
return;
}
this.#messenger.unsubscribe(
NetworkControllerEventType.NetworkDidChange,
listener,
);
this.#messenger.unsubscribe('NetworkController:networkDidChange', listener);
this.store.updateState({
networkStatus,
@ -692,15 +664,15 @@ export class NetworkController extends EventEmitter {
if (isInfura) {
if (networkStatus === NetworkStatus.Available) {
this.#messenger.publish(NetworkControllerEventType.InfuraIsUnblocked);
this.#messenger.publish('NetworkController:infuraIsUnblocked');
} else if (networkStatus === NetworkStatus.Blocked) {
this.#messenger.publish(NetworkControllerEventType.InfuraIsBlocked);
this.#messenger.publish('NetworkController:infuraIsBlocked');
}
} else {
// Always publish infuraIsUnblocked regardless of network status to
// prevent consumers from being stuck in a blocked state if they were
// previously connected to an Infura network that was blocked
this.#messenger.publish(NetworkControllerEventType.InfuraIsUnblocked);
this.#messenger.publish('NetworkController:infuraIsUnblocked');
}
}
@ -892,12 +864,12 @@ export class NetworkController extends EventEmitter {
* the new network.
*/
async #switchNetwork(providerConfig: ProviderConfiguration) {
this.#messenger.publish(NetworkControllerEventType.NetworkWillChange);
this.#messenger.publish('NetworkController:networkWillChange');
this.#resetNetworkId();
this.#resetNetworkStatus();
this.#resetNetworkDetails();
this.#configureProvider(providerConfig);
this.#messenger.publish(NetworkControllerEventType.NetworkDidChange);
this.#messenger.publish('NetworkController:networkDidChange');
await this.lookupNetwork();
}

View File

@ -140,10 +140,7 @@ import createTabIdMiddleware from './lib/createTabIdMiddleware';
import createOnboardingMiddleware from './lib/createOnboardingMiddleware';
import { setupMultiplex } from './lib/stream-utils';
import EnsController from './controllers/ens';
import {
NetworkController,
NetworkControllerEventType,
} from './controllers/network';
import { NetworkController } from './controllers/network';
import PreferencesController from './controllers/preferences';
import AppStateController from './controllers/app-state';
import CachedBalancesController from './controllers/cached-balances';
@ -269,7 +266,12 @@ export default class MetamaskController extends EventEmitter {
const networkControllerMessenger = this.controllerMessenger.getRestricted({
name: 'NetworkController',
allowedEvents: Object.values(NetworkControllerEventType),
allowedEvents: [
'NetworkController:networkWillChange',
'NetworkController:networkDidChange',
'NetworkController:infuraIsBlocked',
'NetworkController:infuraIsUnblocked',
],
});
this.networkController = new NetworkController({
messenger: networkControllerMessenger,
@ -316,11 +318,11 @@ export default class MetamaskController extends EventEmitter {
initLangCode: opts.initLangCode,
onInfuraIsBlocked: networkControllerMessenger.subscribe.bind(
networkControllerMessenger,
NetworkControllerEventType.InfuraIsBlocked,
'NetworkController:infuraIsBlocked',
),
onInfuraIsUnblocked: networkControllerMessenger.subscribe.bind(
networkControllerMessenger,
NetworkControllerEventType.InfuraIsUnblocked,
'NetworkController:infuraIsUnblocked',
),
tokenListController: this.tokenListController,
provider: this.provider,
@ -366,7 +368,7 @@ export default class MetamaskController extends EventEmitter {
// network provider by one update.
onNetworkStateChange: (cb) =>
networkControllerMessenger.subscribe(
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
() => {
const networkState = this.networkController.store.getState();
const modifiedNetworkState = {
@ -477,7 +479,7 @@ export default class MetamaskController extends EventEmitter {
preferencesStore: this.preferencesController.store,
onNetworkDidChange: networkControllerMessenger.subscribe.bind(
networkControllerMessenger,
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
),
getNetworkIdentifier: () => {
const { type, rpcUrl } =
@ -516,7 +518,7 @@ export default class MetamaskController extends EventEmitter {
// onNetworkDidChange
onNetworkStateChange: networkControllerMessenger.subscribe.bind(
networkControllerMessenger,
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
),
getCurrentNetworkEIP1559Compatibility:
this.networkController.getEIP1559Compatibility.bind(
@ -642,7 +644,7 @@ export default class MetamaskController extends EventEmitter {
this.networkController.store.getState().providerConfig.chainId,
onNetworkDidChange: networkControllerMessenger.subscribe.bind(
networkControllerMessenger,
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
),
});
@ -654,7 +656,7 @@ export default class MetamaskController extends EventEmitter {
blockTracker: this.blockTracker,
onNetworkDidChange: networkControllerMessenger.subscribe.bind(
networkControllerMessenger,
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
),
getCurrentChainId: () =>
this.networkController.store.getState().providerConfig.chainId,
@ -1151,7 +1153,7 @@ export default class MetamaskController extends EventEmitter {
});
networkControllerMessenger.subscribe(
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
async () => {
const { ticker } =
this.networkController.store.getState().providerConfig;
@ -1279,7 +1281,7 @@ export default class MetamaskController extends EventEmitter {
// ensure accountTracker updates balances after network change
networkControllerMessenger.subscribe(
NetworkControllerEventType.NetworkDidChange,
'NetworkController:networkDidChange',
() => {
this.accountTracker._updateAccounts();
},
@ -1287,7 +1289,7 @@ export default class MetamaskController extends EventEmitter {
// clear unapproved transactions and messages when the network will change
networkControllerMessenger.subscribe(
NetworkControllerEventType.NetworkWillChange,
'NetworkController:networkWillChange',
() => {
this.txController.txStateManager.clearUnapprovedTxs();
this.encryptionPublicKeyController.clearUnapproved();