From 23f7484d60357bea4590d8dd4582237b39988670 Mon Sep 17 00:00:00 2001 From: Dmytro Stebaiev Date: Mon, 18 Sep 2023 16:36:47 +0300 Subject: [PATCH] Remove negated conditions --- .eslintrc.cjs | 1 - src/contractFactory.ts | 6 ++--- src/submitters/auto-submitter.ts | 39 +++++++++++++++----------------- src/submitters/submitter.ts | 6 ++--- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 3517640..3d2f234 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -28,7 +28,6 @@ module.exports = { "never" ], - "no-negated-condition": "warn", "no-shadow": "warn", "no-ternary": "warn", "no-undefined": "warn", diff --git a/src/contractFactory.ts b/src/contractFactory.ts index b323989..0d3c153 100644 --- a/src/contractFactory.ts +++ b/src/contractFactory.ts @@ -122,13 +122,13 @@ const getLibrariesToUpgrade = async ( if (manifest.libraries[libraryName] === undefined) { librariesToUpgrade.push(libraryName); } else if ( - hashBytecode(byteCodes.get(libraryName) as string) !== + hashBytecode(byteCodes.get(libraryName) as string) === manifest.libraries[libraryName].bytecodeHash ) { - librariesToUpgrade.push(libraryName); - } else { oldLibraries[libraryName] = manifest.libraries[libraryName].address; + } else { + librariesToUpgrade.push(libraryName); } } return { diff --git a/src/submitters/auto-submitter.ts b/src/submitters/auto-submitter.ts index 5d79cfa..96e772c 100644 --- a/src/submitters/auto-submitter.ts +++ b/src/submitters/auto-submitter.ts @@ -127,34 +127,31 @@ export class AutoSubmitter extends Submitter { private static _getSchainHash () { // Query Context to get schain hash - if (!process.env.SCHAIN_HASH) { - if (!process.env.SCHAIN_NAME) { - console.log(chalk.red("Set schain name" + - " to SCHAIN_NAME environment variable")); - console.log(chalk.red("or schain hash" + - " to SCHAIN_HASH environment variable")); - throw Error("Schain is not set"); - } else { - return ethers.utils.solidityKeccak256( - ["string"], - [process.env.SCHAIN_NAME] - ); - } - } else { + if (process.env.SCHAIN_HASH) { return process.env.SCHAIN_HASH; } + if (process.env.SCHAIN_NAME) { + return ethers.utils.solidityKeccak256( + ["string"], + [process.env.SCHAIN_NAME] + ); + } + console.log(chalk.red("Set schain name" + + " to SCHAIN_NAME environment variable")); + console.log(chalk.red("or schain hash" + + " to SCHAIN_HASH environment variable")); + throw Error("Schain is not set"); } private static _getMainnetChainId () { - if (!process.env.MAINNET_CHAIN_ID) { - console.log(chalk.red("Set chainId of mainnet" + - " to MAINNET_CHAIN_ID environment variable")); - console.log(chalk.red("Use 1 for Ethereum mainnet" + - " or 5 for Goerli")); - throw Error("Mainnet chainId is not set"); - } else { + if (process.env.MAINNET_CHAIN_ID) { return Number.parseInt(process.env.MAINNET_CHAIN_ID); } + console.log(chalk.red("Set chainId of mainnet" + + " to MAINNET_CHAIN_ID environment variable")); + console.log(chalk.red("Use 1 for Ethereum mainnet" + + " or 5 for Goerli")); + throw Error("Mainnet chainId is not set"); } private static async _versionFunctionExists () { diff --git a/src/submitters/submitter.ts b/src/submitters/submitter.ts index 6de9e55..c48bbe4 100644 --- a/src/submitters/submitter.ts +++ b/src/submitters/submitter.ts @@ -8,14 +8,14 @@ export abstract class Submitter { // Protected protected static _atomicityWarning () { - if (!process.env.ALLOW_NOT_ATOMIC_UPGRADE) { + if (process.env.ALLOW_NOT_ATOMIC_UPGRADE) { + console.log(chalk.yellow("Not atomic upgrade is performing")); + } else { console.log(chalk.red("The upgrade will consist" + " of multiple transactions and will not be atomic")); console.log(chalk.red("If not atomic upgrade is OK" + " set ALLOW_NOT_ATOMIC_UPGRADE environment variable")); process.exit(EXIT_CODES.NOT_ATOMIC_UPGRADE); - } else { - console.log(chalk.yellow("Not atomic upgrade is performing")); } } }