From 9d9431d7ed8bd834ad920d18e2f210ffa1b78da1 Mon Sep 17 00:00:00 2001 From: Trevor Porter Date: Tue, 12 Apr 2022 17:14:01 +0100 Subject: [PATCH] nits --- typescript/infra/src/core/check.ts | 27 +++++++++++++-------------- typescript/infra/src/core/govern.ts | 9 +++++++-- typescript/infra/src/utils/utils.ts | 4 ++-- typescript/sdk/src/core/app.ts | 5 ++++- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/typescript/infra/src/core/check.ts b/typescript/infra/src/core/check.ts index 44b931d18..478fbf423 100644 --- a/typescript/infra/src/core/check.ts +++ b/typescript/infra/src/core/check.ts @@ -60,7 +60,9 @@ export class AbacusCoreChecker extends AbacusAppChecker< ]; this.app.remoteDomainNumbers(domain).map((remote) => { owners.push(this.app.mustGetInbox(remote, domain).owner()); - owners.push(this.app.mustGetInboxMultisigValidatorManager(remote, domain).owner()); + owners.push( + this.app.mustGetInboxMultisigValidatorManager(remote, domain).owner(), + ); }); const actual = await Promise.all(owners); actual.map((_) => expect(_).to.equal(owner)); @@ -90,10 +92,12 @@ export class AbacusCoreChecker extends AbacusAppChecker< let multisigValidatorManager: MultisigValidatorManager; // Check the outboxMultisigValidatorManager if (domain === outboxDomain) { - multisigValidatorManager = this.app.mustGetContracts(domain).outboxMultisigValidatorManager; + multisigValidatorManager = + this.app.mustGetContracts(domain).outboxMultisigValidatorManager; } else { // Check an inboxMultisigValidatorManager - multisigValidatorManager = this.app.mustGetInboxMultisigValidatorManager(outboxDomain, domain); + multisigValidatorManager = + this.app.mustGetInboxMultisigValidatorManager(outboxDomain, domain); } return this.checkMultisigValidatorManager( domain, @@ -115,7 +119,8 @@ export class AbacusCoreChecker extends AbacusAppChecker< multisigValidatorManager: MultisigValidatorManager, ): Promise { const outboxDomainName = this.app.mustResolveDomainName(outboxDomain); - const expected = this.config.multisigValidatorManagers[outboxDomainName]?.validatorSet; + const expected = + this.config.multisigValidatorManagers[outboxDomainName]?.validatorSet; expect(expected).to.not.be.undefined; const actual = await multisigValidatorManager.validatorSet(); @@ -124,17 +129,11 @@ export class AbacusCoreChecker extends AbacusAppChecker< const expectedSet = new Set(expected); const actualSet = new Set(actual); - const toEnroll = setDifference( - expectedSet, - actualSet, - ); - const toUnenroll = setDifference( - actualSet, - expectedSet, - ); + const toEnroll = setDifference(expectedSet, actualSet); + const toUnenroll = setDifference(actualSet, expectedSet); // Validators that should be enrolled - for (const [validatorToEnroll] of toEnroll.entries()) { + for (const validatorToEnroll of toEnroll) { const violation: ValidatorViolation = { domain: localDomain, type: CoreViolationType.Validator, @@ -148,7 +147,7 @@ export class AbacusCoreChecker extends AbacusAppChecker< } // Validators that should be unenrolled - for (const [validatorToUnenroll] of toUnenroll.entries()) { + for (const validatorToUnenroll of toUnenroll) { const violation: ValidatorViolation = { domain: localDomain, type: CoreViolationType.Validator, diff --git a/typescript/infra/src/core/govern.ts b/typescript/infra/src/core/govern.ts index 1f8600dc1..9bbaf3358 100644 --- a/typescript/infra/src/core/govern.ts +++ b/typescript/infra/src/core/govern.ts @@ -84,14 +84,19 @@ export class AbacusCoreGovernor extends AbacusCoreChecker { tx = await multisigValidatorManager.populateTransaction.enrollValidator( violation.expected, ); - } else if (violation.actual !== undefined && violation.expected === undefined) { + } else if ( + violation.actual !== undefined && + violation.expected === undefined + ) { // Unenrolling an existing validator tx = await multisigValidatorManager.populateTransaction.unenrollValidator( violation.actual, ); } else { // Invalid state - throw new Error(`Expected exactly one of actual ${violation.actual} or expected ${violation.expected} to be undefined`); + throw new Error( + `Expected exactly one of actual ${violation.actual} or expected ${violation.expected} to be undefined`, + ); } if (tx.to === undefined) throw new Error('undefined tx.to'); diff --git a/typescript/infra/src/utils/utils.ts b/typescript/infra/src/utils/utils.ts index ed2a8190c..ead200d64 100644 --- a/typescript/infra/src/utils/utils.ts +++ b/typescript/infra/src/utils/utils.ts @@ -161,8 +161,8 @@ export function writeJSON(directory: string, filename: string, obj: any) { // Returns a \ b export function setDifference(a: Set, b: Set) { let diff = new Set(a); - for (const elem of diff) { - diff.delete(elem); + for (const element of b) { + diff.delete(element); } return diff; } diff --git a/typescript/sdk/src/core/app.ts b/typescript/sdk/src/core/app.ts index 344737c17..72140ed5b 100644 --- a/typescript/sdk/src/core/app.ts +++ b/typescript/sdk/src/core/app.ts @@ -26,7 +26,10 @@ export class AbacusCore extends AbacusApp< return contracts.inbox(srcName); } - mustGetInboxMultisigValidatorManager(src: NameOrDomain, dest: NameOrDomain): InboxMultisigValidatorManager { + mustGetInboxMultisigValidatorManager( + src: NameOrDomain, + dest: NameOrDomain, + ): InboxMultisigValidatorManager { const contracts = this.mustGetContracts(dest); const srcName = this.mustGetDomain(src).name; return contracts.inboxMultisigValidatorManager(srcName);