diff --git a/migrations/scripts/2_libs.js b/migrations/scripts/2_libs.js index e5b5b13b..cfac8690 100644 --- a/migrations/scripts/2_libs.js +++ b/migrations/scripts/2_libs.js @@ -14,6 +14,8 @@ module.exports = async function (_, network, [, from]) { targets.WitnetPriceFeedsLib, ] + const selection = utils.getWitnetArtifactsFromArgs() + const deployer = await WitnetDeployer.deployed() for (const index in libs) { const key = libs[index] @@ -21,6 +23,7 @@ module.exports = async function (_, network, [, from]) { if ( utils.isNullAddress(addresses[network][key]) || (await web3.eth.getCode(addresses[network][key])).length < 3 + || selection.includes(key) ) { utils.traceHeader(`Deploying '${key}'...`) const libInitCode = artifact.toJSON().bytecode diff --git a/migrations/scripts/3_core.js b/migrations/scripts/3_core.js index bbc26a1e..35a05940 100644 --- a/migrations/scripts/3_core.js +++ b/migrations/scripts/3_core.js @@ -67,11 +67,15 @@ async function deploy (specs) { const addresses = await utils.readAddresses() if (!addresses[network]) addresses[network] = {}; + + const selection = utils.getWitnetArtifactsFromArgs() const contract = artifacts.require(key) if ( utils.isNullAddress(addresses[network][key]) || (await web3.eth.getCode(addresses[network][key])).length < 3 + || selection.includes(key) + || (libs && selection.filter(item => libs.includes(item)).length > 0) ) { utils.traceHeader(`Deploying '${key}'...`) console.info(" ", "> account: ", from) @@ -82,7 +86,7 @@ async function deploy (specs) { if (immutables?.values) values = [...values, ...immutables.values] const constructorArgs = web3.eth.abi.encodeParameters(types, values) if (constructorArgs.length > 2) { - console.info(" ", "> constructor types:", types) + console.info(" ", "> constructor types:", JSON.stringify(types)) console.info(" ", "> constructor args: ", constructorArgs.slice(2)) } const coreBytecode = link(contract.toJSON().bytecode, libs, targets) diff --git a/migrations/scripts/4_proxies.js b/migrations/scripts/4_proxies.js index e5af6185..b4dedfe4 100644 --- a/migrations/scripts/4_proxies.js +++ b/migrations/scripts/4_proxies.js @@ -3,11 +3,16 @@ const merge = require("lodash.merge") const settings = require("../../settings") const utils = require("../../src/utils") +const version = `${ + require("../../package").version +}-${ + require("child_process").execSync("git rev-parse HEAD").toString().trim().substring(0, 7) +}` + const WitnetDeployer = artifacts.require("WitnetDeployer") const WitnetProxy = artifacts.require("WitnetProxy") module.exports = async function (_, network, [, from, reporter]) { - const addresses = await utils.readAddresses(network) const targets = settings.getArtifacts(network) const specs = settings.getSpecs(network) @@ -94,11 +99,12 @@ async function deploy (target) { utils.traceHeader(`Upgrading '${key}'...`) const oldVersion = await oldImpl.version.call({ from }) const newVersion = await newImpl.version.call({ from }) + const color = newVersion === version ? `\x1b[1;97m` : `\x1b[93m` if ( (process.argv.length >= 3 && process.argv[2].includes("--upgrade-all")) || ( - ["y", "yes"].includes( - (await utils.prompt(` > From v${oldVersion} to ${targets[key]} v${newVersion} ? (y/N) `)).toLowerCase().trim() - ) + ["y", "yes"].includes((await + utils.prompt(` > Upgrade to ${color}${targets[key]} v${newVersion}\x1b[0m? (y/N) `) + ).toLowerCase().trim()) ) ) { const initdata = mutables ? web3.eth.abi.encodeParameters(mutables.types, mutables.values) : "0x"