Skip to content

Commit

Permalink
refactor: verification scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Nov 4, 2024
1 parent 355db94 commit 240acb3
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 123 deletions.
8 changes: 8 additions & 0 deletions migrations/scripts/3_framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@ function linkBaseLibs (bytecode, baseLibs, networkArtifacts) {
return bytecode
}

async function settleArtifactAddress(addresses, network, domain, artifact, addr) {
if (!addresses[network]) addresses[network] = {}
if (!addresses[network][domain]) addresses[network][domain] = {}
addresses[network][domain][artifact] = addr
await utils.overwriteJsonFile("./migrations/addresses.json", addresses)
return addresses
}

async function unfoldTargetSpecs (domain, target, targetBase, from, network, networkArtifacts, networkSpecs, ancestors) {
if (!ancestors) ancestors = []
else if (ancestors.includes(targetBase)) {
Expand Down
29 changes: 0 additions & 29 deletions scripts/verify-apps.js

This file was deleted.

33 changes: 0 additions & 33 deletions scripts/verify-core.js

This file was deleted.

32 changes: 0 additions & 32 deletions scripts/verify-impls.js

This file was deleted.

29 changes: 0 additions & 29 deletions scripts/verify-libs.js

This file was deleted.

43 changes: 43 additions & 0 deletions scripts/verify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

const addresses = require("../migrations/addresses.json")
const constructorArgs = require("../migrations/constructorArgs.json")
const settings = require("../settings")
const utils = require("../src/utils")

if (process.argv.length < 3) {
console.error("\nUsage:\n\n$ node ./scripts/verify-core.js <ecosystem>:<network> ...OPTIONAL_ARGS\n")
process.exit(0)
}

const network = process.argv[2].toLowerCase().replaceAll(".", ":")
const networkArtifacts = settings.getArtifacts(network)

utils.traceVerify(network, networkArtifacts?.WitnetDeployer)

const framework = {
libs: networkArtifacts.libs,
core: networkArtifacts.core,
apps: networkArtifacts.apps,
}

for (const domain in framework) {
const header = network.toUpperCase() + " " + domain.toUpperCase()
console.info()
console.info(header)
console.info("=".repeat(header.length))
console.info()
for (const base in framework[domain]) {
const impl = framework[domain][base]
if (utils.isUpgradableArtifact(impl)) {
const addr = utils.getNetworkArtifactAddress(network, domain, addresses, base)
utils.traceVerify(network, `WitnetProxy@${addr} --custom-proxy WitnetProxy`)
}
const forceConstructorArgs = constructorArgs[network][impl] || constructorArgs?.default[impl]
if (forceConstructorArgs) {
utils.traceVerify(network, `${impl} --forceConstructorArgs string:${forceConstructorArgs} --verifiers etherscan,sourcify`)
} else {
utils.traceVerify(network, `${impl} --verifiers etherscan,sourcify`)
}
}
}

0 comments on commit 240acb3

Please sign in to comment.