Skip to content

Commit

Permalink
chore: fmt!
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Jan 12, 2024
1 parent 153f486 commit bc0bd92
Show file tree
Hide file tree
Showing 12 changed files with 506 additions and 476 deletions.
40 changes: 20 additions & 20 deletions migrations/scripts/1_deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ const utils = require("../../scripts/utils")
const WitnetDeployer = artifacts.require("WitnetDeployer")

module.exports = async function (deployer, network, [, from,, master]) {
const isDryRun = network === "test" || network.split("-")[1] === "fork" || network.split("-")[0] === "develop"
const ecosystem = utils.getRealmNetworkFromArgs()[0]
network = network.split("-")[0]
const isDryRun = network === "test" || network.split("-")[1] === "fork" || network.split("-")[0] === "develop"
const ecosystem = utils.getRealmNetworkFromArgs()[0]
network = network.split("-")[0]

if (!addresses[ecosystem]) addresses[ecosystem] = {}
if (!addresses[ecosystem][network]) addresses[ecosystem][network] = {}
if (!addresses[ecosystem]) addresses[ecosystem] = {}
if (!addresses[ecosystem][network]) addresses[ecosystem][network] = {}

let factory
if (utils.isNullAddress(addresses[ecosystem][network]?.WitnetDeployer)) {
await deployer.deploy(WitnetDeployer, { from: master })
factory = await WitnetDeployer.deployed()
addresses[ecosystem][network].WitnetDeployer = factory.address
} else {
factory = await WitnetDeployer.at(addresses[ecosystem][network].WitnetDeployer)
WitnetDeployer.address = factory.address
utils.traceHeader("Skipped 'WitnetDeployer'")
console.info(" > Contract address:", factory.address)
console.info()
}
let factory
if (utils.isNullAddress(addresses[ecosystem][network]?.WitnetDeployer)) {
await deployer.deploy(WitnetDeployer, { from: master })
factory = await WitnetDeployer.deployed()
addresses[ecosystem][network].WitnetDeployer = factory.address
} else {
factory = await WitnetDeployer.at(addresses[ecosystem][network].WitnetDeployer)
WitnetDeployer.address = factory.address
utils.traceHeader("Skipped 'WitnetDeployer'")
console.info(" > Contract address:", factory.address)
console.info()
}

if (!isDryRun) {
utils.saveAddresses(addresses)
}
if (!isDryRun) {
utils.saveAddresses(addresses)
}
}
89 changes: 44 additions & 45 deletions migrations/scripts/2_libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,52 @@ const utils = require("../../scripts/utils")
const WitnetDeployer = artifacts.require("WitnetDeployer")

module.exports = async function (_, network, [, from]) {
const isDryRun = network === "test" || network.split("-")[1] === "fork" || network.split("-")[0] === "develop"
const ecosystem = utils.getRealmNetworkFromArgs()[0]
network = network.split("-")[0]
const isDryRun = network === "test" || network.split("-")[1] === "fork" || network.split("-")[0] === "develop"
const ecosystem = utils.getRealmNetworkFromArgs()[0]
network = network.split("-")[0]

const addresses = require("../witnet.addresses")
if (!addresses[ecosystem]) addresses[ecosystem] = {}
if (!addresses[ecosystem][network]) addresses[ecosystem][network] = {}
const addresses = require("../witnet.addresses")
if (!addresses[ecosystem]) addresses[ecosystem] = {}
if (!addresses[ecosystem][network]) addresses[ecosystem][network] = {}

const targets = merge(
settings.artifacts.default,
settings.artifacts[ecosystem],
settings.artifacts[network]
)
const libs = [
targets.WitnetErrorsLib,
targets.WitnetEncodingLib,
targets.WitnetPriceFeedsLib,
]
const targets = merge(
settings.artifacts.default,
settings.artifacts[ecosystem],
settings.artifacts[network]
)
const libs = [
targets.WitnetErrorsLib,
targets.WitnetEncodingLib,
targets.WitnetPriceFeedsLib,
]

const deployer = await WitnetDeployer.deployed()
for (index in libs) {
const key = libs[index]
const artifact = artifacts.require(key)
if (utils.isNullAddress(addresses[ecosystem][network][key])) {
utils.traceHeader(`Deploying '${key}'...`)
const libInitCode = artifact.toJSON().bytecode
const libAddr = await deployer.determineAddr.call(libInitCode, "0x0", { from })
console.info(" ", "> account: ", from)
console.info(" ", "> balance: ", web3.utils.fromWei(await web3.eth.getBalance(from), 'ether'), "ETH")
const tx = await deployer.deploy(libInitCode, "0x0", { from })
utils.traceTx(tx)
if ((await web3.eth.getCode(libAddr)).length > 3) {
addresses[ecosystem][network][key] = libAddr
} else {
console.info(`Error: Library was not deployed on expected address: ${libAddr}`)
process.exit(1)
}
} else {
utils.traceHeader(`Skipped '${key}'`)
}
artifact.address = addresses[ecosystem][network][key]
console.info(" ", "> library address: ", artifact.address)
console.info(" ", "> library codehash: ", web3.utils.soliditySha3(await web3.eth.getCode(artifact.address)))
console.info()
if (!isDryRun) {
utils.saveAddresses(addresses)
}
const deployer = await WitnetDeployer.deployed()
for (index in libs) {

Check failure on line 29 in migrations/scripts/2_libs.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'index' is not defined
const key = libs[index]

Check failure on line 30 in migrations/scripts/2_libs.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'index' is not defined
const artifact = artifacts.require(key)
if (utils.isNullAddress(addresses[ecosystem][network][key])) {
utils.traceHeader(`Deploying '${key}'...`)
const libInitCode = artifact.toJSON().bytecode
const libAddr = await deployer.determineAddr.call(libInitCode, "0x0", { from })
console.info(" ", "> account: ", from)
console.info(" ", "> balance: ", web3.utils.fromWei(await web3.eth.getBalance(from), "ether"), "ETH")
const tx = await deployer.deploy(libInitCode, "0x0", { from })
utils.traceTx(tx)
if ((await web3.eth.getCode(libAddr)).length > 3) {
addresses[ecosystem][network][key] = libAddr
} else {
console.info(`Error: Library was not deployed on expected address: ${libAddr}`)
process.exit(1)
}
} else {
utils.traceHeader(`Skipped '${key}'`)
}

artifact.address = addresses[ecosystem][network][key]
console.info(" ", "> library address: ", artifact.address)
console.info(" ", "> library codehash: ", web3.utils.soliditySha3(await web3.eth.getCode(artifact.address)))
console.info()
if (!isDryRun) {
utils.saveAddresses(addresses)
}
}
}
Loading

0 comments on commit bc0bd92

Please sign in to comment.