From 8224cb0a8152a24f9f42e288a237bc15da33b43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20D=C3=ADaz?= Date: Mon, 19 Feb 2024 10:31:55 +0100 Subject: [PATCH] chore: fmt! --- hardhat.config.js | 4 ++-- migrations/scripts/1_deployer.js | 1 - migrations/scripts/2_libs.js | 1 - migrations/scripts/3_core.js | 5 ++--- migrations/scripts/4_proxies.js | 3 +-- package.json | 2 +- scripts/prepare.js | 2 +- scripts/verify-core.js | 22 +++++++++++----------- scripts/verify-impls.js | 23 +++++++++++------------ scripts/verify-libs.js | 17 ++++++++--------- src/index.js | 2 +- src/utils.js | 20 +++++++++++++------- 12 files changed, 51 insertions(+), 51 deletions(-) diff --git a/hardhat.config.js b/hardhat.config.js index 24f45c38..677130bb 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -32,8 +32,8 @@ module.exports = { .map(([network, config]) => { const [ecosystem] = utils.getRealmNetworkFromString(network) const envar = `ETHERSCAN_${ecosystem.toUpperCase()}_API_KEY` - return [network, - config?.verify?.apiKey || process.env[envar] || process.env.ETHERSCAN_API_KEY || "MY_API_KEY" + return [network, + config?.verify?.apiKey || process.env[envar] || process.env.ETHERSCAN_API_KEY || "MY_API_KEY", ] }), ), diff --git a/migrations/scripts/1_deployer.js b/migrations/scripts/1_deployer.js index fef03883..77b52653 100644 --- a/migrations/scripts/1_deployer.js +++ b/migrations/scripts/1_deployer.js @@ -4,7 +4,6 @@ const WitnetDeployer = artifacts.require("WitnetDeployer") const WitnetProxy = artifacts.require("WitnetProxy") module.exports = async function (deployer, network, [,,, master]) { - const addresses = await utils.readJsonFromFile("./migrations/addresses.json") if (!addresses[network]) addresses[network] = {} diff --git a/migrations/scripts/2_libs.js b/migrations/scripts/2_libs.js index 47e0020a..859fe8aa 100644 --- a/migrations/scripts/2_libs.js +++ b/migrations/scripts/2_libs.js @@ -4,7 +4,6 @@ const utils = require("../../src/utils") const WitnetDeployer = artifacts.require("WitnetDeployer") module.exports = async function (_, network, [, from]) { - const addresses = await utils.readJsonFromFile("./migrations/addresses.json") if (!addresses[network]) addresses[network] = {} diff --git a/migrations/scripts/3_core.js b/migrations/scripts/3_core.js index ea520809..b2d001c7 100644 --- a/migrations/scripts/3_core.js +++ b/migrations/scripts/3_core.js @@ -10,7 +10,6 @@ const version = `${ const WitnetDeployer = artifacts.require("WitnetDeployer") module.exports = async function (_, network, [, from]) { - const specs = settings.getSpecs(network) const targets = settings.getArtifacts(network) @@ -134,7 +133,7 @@ async function deploy (specs) { // save addresses file if required if (!utils.isDryRun(network)) { await utils.overwriteJsonFile("./migrations/addresses.json", addresses) - const args = await utils.readJsonFromFile("./migrations/constructorArgs.json"); + const args = await utils.readJsonFromFile("./migrations/constructorArgs.json") if (!args[network]) args[network] = {} args[network][key] = constructorArgs.slice(2) await utils.overwriteJsonFile("./migrations/constructorArgs.json", args) @@ -148,7 +147,7 @@ async function deploy (specs) { const lib = artifacts.require(libname) contract.link(lib) console.info(" ", "> external library: ", `${libname}@${lib.address}`) - }; + }; console.info(" ", "> contract address: ", contract.address) console.info(" ", "> contract codehash:", web3.utils.soliditySha3(await web3.eth.getCode(contract.address))) console.info() diff --git a/migrations/scripts/4_proxies.js b/migrations/scripts/4_proxies.js index 6162a7ac..173fddc7 100644 --- a/migrations/scripts/4_proxies.js +++ b/migrations/scripts/4_proxies.js @@ -13,7 +13,6 @@ const WitnetDeployer = artifacts.require("WitnetDeployer") const WitnetProxy = artifacts.require("WitnetProxy") module.exports = async function (_, network, [, from, reporter]) { - const targets = settings.getArtifacts(network) const specs = settings.getSpecs(network) @@ -120,7 +119,7 @@ async function deploy (target) { const tx = await upgradeProxyTo(from, proxyAddr, newImpl.address, initdata) utils.traceTx(tx) } catch (ex) { - console.error(" ", "> Exception:\n",ex) + console.error(" ", "> Exception:\n", ex) } } } else { diff --git a/package.json b/package.json index c64107d7..4e22037f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "migrate": "npx truffle migrate --network", "networks": "node ./scripts/networks.js 2>&1", "ops:rng:sla": "npx truffle migrate --migrations_directory ./migrations/ops/rng/sla --network", - "prepare": "npx truffle compile --all && npx hardhat compile && node ./scripts/prepare.js", + "prepare": "npx truffle compile --all && npx hardhat compile --force && node ./scripts/prepare.js", "test": "pnpm run clean && npx truffle test", "verify:core": "node ./scripts/verify-core.js 2>&1", "verify:libs": "node ./scripts/verify-libs.js 2>&1", diff --git a/scripts/prepare.js b/scripts/prepare.js index 6fda7a86..d82ff282 100644 --- a/scripts/prepare.js +++ b/scripts/prepare.js @@ -6,7 +6,7 @@ if (fs.existsSync("./artifacts")) { if (os.type() === "Windows_NT") { exec("del /s /q artifacts\\*.dbg.json") } else { - exec('find ./artifacts -name "*.dbg.json" -exec rm -r {} \\;') + exec("find ./artifacts -name \"*.dbg.json\" -exec rm -r {} \\;") } } diff --git a/scripts/verify-core.js b/scripts/verify-core.js index 5bb1df42..797a8509 100644 --- a/scripts/verify-core.js +++ b/scripts/verify-core.js @@ -3,27 +3,27 @@ const utils = require("../src/utils") if (process.argv.length < 3) { - console.error(`\nUsage:\n\n$ node ./scripts/verify-proxies.js : ...OPTIONAL_ARGS\n`) - process.exit(0) + console.error("\nUsage:\n\n$ node ./scripts/verify-proxies.js : ...OPTIONAL_ARGS\n") + process.exit(0) } const network = process.argv[2].toLowerCase().replaceAll(".", ":") -const header = network.toUpperCase() + " CORE"; +const header = network.toUpperCase() + " CORE" console.info() console.info(header) console.info("=".repeat(header.length)) console.info() -utils.traceVerify(network, "WitnetDeployer"); -utils.traceVerify(network, "WitnetProxy"); +utils.traceVerify(network, "WitnetDeployer") +utils.traceVerify(network, "WitnetProxy") const singletons = [ - "WitnetOracle", - "WitnetPriceFeeds", - "WitnetRequestBytecodes", - "witnetRequestFactory" -]; + "WitnetOracle", + "WitnetPriceFeeds", + "WitnetRequestBytecodes", + "witnetRequestFactory", +] for (const index in singletons) { - utils.traceVerify(network, `${singletons[index]} --custom-proxy WitnetProxy`); + utils.traceVerify(network, `${singletons[index]} --custom-proxy WitnetProxy`) } diff --git a/scripts/verify-impls.js b/scripts/verify-impls.js index ce1a6f11..c888ea61 100644 --- a/scripts/verify-impls.js +++ b/scripts/verify-impls.js @@ -4,13 +4,13 @@ const settings = require("../settings") const utils = require("../src/utils") if (process.argv.length < 3) { - console.error(`\nUsage:\n\n$ node ./scripts/verify-proxies.js : ...OPTIONAL_ARGS\n`) - process.exit(0) + console.error("\nUsage:\n\n$ node ./scripts/verify-proxies.js : ...OPTIONAL_ARGS\n") + process.exit(0) } const network = process.argv[2].toLowerCase().replaceAll(".", ":") -const header = network.toUpperCase(); +const header = network.toUpperCase() console.info() console.info(header) console.info("=".repeat(header.length)) @@ -18,15 +18,14 @@ console.info() const artifacts = settings.getArtifacts(network) const impls = [ - artifacts["WitnetOracle"], - artifacts["WitnetPriceFeeds"], - artifacts["WitnetRequestBytecodes"], - artifacts["WitnetRequestFactory"], -]; + artifacts.WitnetOracle, + artifacts.WitnetPriceFeeds, + artifacts.WitnetRequestBytecodes, + artifacts.WitnetRequestFactory, +] const constructorArgs = require("../migrations/constructorArgs.json") for (const index in impls) { - utils.traceVerify(network, `${impls[index]} --forceConstructorArgs string:${ - constructorArgs[network][impls[index]] - } --verifiers etherscan`); + utils.traceVerify(network, `${impls[index]} --forceConstructorArgs string:${ + constructorArgs[network][impls[index]] + } --verifiers etherscan`) } - diff --git a/scripts/verify-libs.js b/scripts/verify-libs.js index 333353de..ff123b66 100644 --- a/scripts/verify-libs.js +++ b/scripts/verify-libs.js @@ -4,13 +4,13 @@ const settings = require("../settings") const utils = require("../src/utils") if (process.argv.length < 3) { - console.error(`\nUsage:\n\n$ node ./scripts/verify-proxies.js : ...OPTIONAL_ARGS\n`) - process.exit(0) + console.error("\nUsage:\n\n$ node ./scripts/verify-proxies.js : ...OPTIONAL_ARGS\n") + process.exit(0) } const network = process.argv[2].toLowerCase().replaceAll(".", ":") -const header = network.toUpperCase()+ " LIBS"; +const header = network.toUpperCase() + " LIBS" console.info() console.info(header) console.info("=".repeat(header.length)) @@ -18,11 +18,10 @@ console.info() const artifacts = settings.getArtifacts(network) const libs = [ - artifacts["WitnetEncodingLib"], - artifacts["WitnetErrorsLib"], - artifacts["WitnetPriceFeedsLib"], -]; + artifacts.WitnetEncodingLib, + artifacts.WitnetErrorsLib, + artifacts.WitnetPriceFeedsLib, +] for (const index in libs) { - utils.traceVerify(network, `${libs[index]}`); + utils.traceVerify(network, `${libs[index]}`) } - diff --git a/src/index.js b/src/index.js index 40f67d5f..1f475f7d 100644 --- a/src/index.js +++ b/src/index.js @@ -37,7 +37,7 @@ module.exports = { WitnetRequestBytecodes: require("../artifacts/contracts/WitnetRequestBytecodes.sol/WitnetRequestBytecodes.json"), WitnetRequestFactory: require("../artifacts/contracts/WitnetRequestFactory.sol/WitnetRequestFactory.json"), WitnetRequestTemplate: require("../artifacts/contracts/WitnetRequestTemplate.sol/WitnetRequestTemplate.json"), - WitnetUpgradableBase: require("../artifacts/contracts/core/WitnetUpgradableBase.sol/WitnetUpgradableBase.json") + WitnetUpgradableBase: require("../artifacts/contracts/core/WitnetUpgradableBase.sol/WitnetUpgradableBase.json"), }, settings: require("../settings"), utils, diff --git a/src/utils.js b/src/utils.js index 9fc25864..dc74e767 100644 --- a/src/utils.js +++ b/src/utils.js @@ -138,15 +138,21 @@ function traceTx (tx) { console.info(" ", "> transaction hash: ", tx.receipt.transactionHash) console.info(" ", "> gas used: ", tx.receipt.gasUsed.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")) console.info(" ", "> gas price: ", tx.receipt.effectiveGasPrice / 10 ** 9, "gwei") - console.info(" ", "> total cost: ", parseFloat(BigInt(tx.receipt.gasUsed) * BigInt(tx.receipt.effectiveGasPrice) / BigInt(10 ** 18)).toString(), "ETH") + console.info(" ", "> total cost: ", parseFloat( + BigInt(tx.receipt.gasUsed) * + BigInt(tx.receipt.effectiveGasPrice) / + BigInt(10 ** 18) + ).toString(), + "ETH" + ) } -function traceVerify(network, verifyArgs) { +function traceVerify (network, verifyArgs) { console.log( - execSync( - `npx truffle run verify --network ${network} ${verifyArgs} ${process.argv.slice(3)}`, - { stdout: 'inherit' } - ).toString().split("\n") + execSync( + `npx truffle run verify --network ${network} ${verifyArgs} ${process.argv.slice(3)}`, + { stdout: "inherit" } + ).toString().split("\n") .join("\n") - ); + ) }