Skip to content

Commit

Permalink
chore: fmt!
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Feb 19, 2024
1 parent f2f9e53 commit 8224cb0
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}),
),
Expand Down
1 change: 0 additions & 1 deletion migrations/scripts/1_deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}

Expand Down
1 change: 0 additions & 1 deletion migrations/scripts/2_libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}

Expand Down
5 changes: 2 additions & 3 deletions migrations/scripts/3_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions migrations/scripts/4_proxies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion scripts/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} \\;")
}
}

Expand Down
22 changes: 11 additions & 11 deletions scripts/verify-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
const utils = require("../src/utils")

if (process.argv.length < 3) {
console.error(`\nUsage:\n\n$ node ./scripts/verify-proxies.js <ecosystem>:<network> ...OPTIONAL_ARGS\n`)
process.exit(0)
console.error("\nUsage:\n\n$ node ./scripts/verify-proxies.js <ecosystem>:<network> ...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`)
}
23 changes: 11 additions & 12 deletions scripts/verify-impls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,28 @@ const settings = require("../settings")
const utils = require("../src/utils")

if (process.argv.length < 3) {
console.error(`\nUsage:\n\n$ node ./scripts/verify-proxies.js <ecosystem>:<network> ...OPTIONAL_ARGS\n`)
process.exit(0)
console.error("\nUsage:\n\n$ node ./scripts/verify-proxies.js <ecosystem>:<network> ...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))
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`)
}

17 changes: 8 additions & 9 deletions scripts/verify-libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ const settings = require("../settings")
const utils = require("../src/utils")

if (process.argv.length < 3) {
console.error(`\nUsage:\n\n$ node ./scripts/verify-proxies.js <ecosystem>:<network> ...OPTIONAL_ARGS\n`)
process.exit(0)
console.error("\nUsage:\n\n$ node ./scripts/verify-proxies.js <ecosystem>:<network> ...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))
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]}`)
}

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 13 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
)
}

0 comments on commit 8224cb0

Please sign in to comment.