Skip to content

Commit

Permalink
chore: eslint --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Feb 5, 2024
1 parent 089ed32 commit a4769ea
Show file tree
Hide file tree
Showing 15 changed files with 745 additions and 745 deletions.
14 changes: 7 additions & 7 deletions artifacts/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
WitnetBytecodes: require("../artifacts/WitnetBytecodes.json"),
WitnetPriceFeeds: require("../artifacts/WitnetPriceFeeds.json"),
WitnetRandomness: require("../artifacts/WitnetRandomness.json"),
WitnetRequest: require("../artifacts/WitnetRequest.json"),
WitnetRequestFactory: require("../artifacts/witnetRequestFactory.json"),
WitnetRequestTemplate: require("../artifacts/WitnetRequestTemplate.json"),
};
WitnetBytecodes: require("../artifacts/WitnetBytecodes.json"),
WitnetPriceFeeds: require("../artifacts/WitnetPriceFeeds.json"),
WitnetRandomness: require("../artifacts/WitnetRandomness.json"),
WitnetRequest: require("../artifacts/WitnetRequest.json"),
WitnetRequestFactory: require("../artifacts/witnetRequestFactory.json"),
WitnetRequestTemplate: require("../artifacts/WitnetRequestTemplate.json"),
}
3 changes: 2 additions & 1 deletion migrations/scripts/1_deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ const utils = require("../../src/utils")

const WitnetDeployer = artifacts.require("WitnetDeployer")

module.exports = async function (deployer, network, [, from,, master]) {
module.exports = async function (deployer, network, [, from,, master]) {
const addresses = await utils.readAddresses(network)

let factory
if (utils.isNullAddress(addresses?.WitnetDeployer)) {
await deployer.deploy(WitnetDeployer, { from: master })
Expand Down
4 changes: 2 additions & 2 deletions migrations/scripts/2_libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const utils = require("../../src/utils")
const WitnetDeployer = artifacts.require("WitnetDeployer")

module.exports = async function (_, network, [, from]) {
const addresses = await utils.readAddresses(network);
const addresses = await utils.readAddresses(network)

const targets = settings.getArtifacts(network);
const targets = settings.getArtifacts(network)
const libs = [
targets.WitnetErrorsLib,
targets.WitnetEncodingLib,
Expand Down
13 changes: 6 additions & 7 deletions migrations/scripts/3_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ const version = `${
const WitnetDeployer = artifacts.require("WitnetDeployer")

module.exports = async function (_, network, [, from]) {
const isDryRun = utils.isDryRun(network);//network === "test" || network.split("-")[1] === "fork" || network.split("-")[0] === "develop"
const addresses = await utils.readAddresses(network)

const addresses = await utils.readAddresses(network);
const specs = settings.getSpecs(network);
const targets = settings.getArtifacts(network);
const specs = settings.getSpecs(network)
const targets = settings.getArtifacts(network)

// Deploy/upgrade WitnetBytecodes target implementation, if required
await deploy({
Expand All @@ -32,7 +31,7 @@ module.exports = async function (_, network, [, from]) {
],
},
})

// Deploy/upgrade WitnetRequestFactory target implementation, if required
await deploy({
addresses,
Expand All @@ -51,7 +50,7 @@ module.exports = async function (_, network, [, from]) {
],
},
})

// Deploy/upgrade WitnetRequestBoard target implementation, if required
await deploy({
addresses,
Expand All @@ -72,7 +71,7 @@ module.exports = async function (_, network, [, from]) {
})

// save addresses file if required
if (!isDryRun) {
if (!utils.isDryRun(network)) {
await utils.saveAddresses(network, addresses)
}
}
Expand Down
15 changes: 7 additions & 8 deletions migrations/scripts/4_proxies.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ const WitnetDeployer = artifacts.require("WitnetDeployer")
const WitnetProxy = artifacts.require("WitnetProxy")

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

const addresses = await utils.readAddresses(network);
const targets = settings.getArtifacts(network);
const specs = settings.getSpecs(network);

const addresses = await utils.readAddresses(network)

const targets = settings.getArtifacts(network)
const specs = settings.getSpecs(network)

const singletons = [
"WitnetBytecodes",
"WitnetRequestFactory",
Expand All @@ -29,13 +28,13 @@ module.exports = async function (_, network, [, from, reporter]) {
// Deploy/upgrade singleton proxies, if required
for (const index in singletons) {
await deploy({
addresses,
addresses,
from,
specs,
targets,
key: singletons[index],
})
if (!isDryRun) {
if (!utils.isDryRun(network)) {
await utils.saveAddresses(network, addresses)
}
}
Expand Down
81 changes: 38 additions & 43 deletions migrations/scripts/5_apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,48 @@ const utils = require("../../src/utils")
const WitnetDeployer = artifacts.require("WitnetDeployer")

module.exports = async function (_, network, [,,, from]) {
const isDryRun = utils.isDryRun(network);
const addresses = await utils.readAddresses(network)

const addresses = await utils.readAddresses(network);
const specs = settings.getSpecs(network);
const targets = settings.getArtifacts(network);
const specs = settings.getSpecs(network)
const targets = settings.getArtifacts(network)

// Deploy the WitnetPriceFeeds oracle, if required
{
await deploy({
addresses,
from,
targets,
key: targets.WitnetPriceFeeds,
libs: specs.WitnetPriceFeeds.libs,
vanity: specs.WitnetPriceFeeds?.vanity || 0,
immutables: specs.WitnetPriceFeeds.immutables,
intrinsics: {
types: ["address", "address"],
values: [
/* _operator */ from,
/* _wrb */ await determineProxyAddr(from, specs.WitnetRequestBoard?.vanity || 3),
],
},
})
}
await deploy({
addresses,
from,
targets,
key: targets.WitnetPriceFeeds,
libs: specs.WitnetPriceFeeds.libs,
vanity: specs.WitnetPriceFeeds?.vanity || 0,
immutables: specs.WitnetPriceFeeds.immutables,
intrinsics: {
types: ["address", "address"],
values: [
/* _operator */ from,
/* _wrb */ await determineProxyAddr(from, specs.WitnetRequestBoard?.vanity || 3),
],
},
})
// Deploy the WitnetRandomness oracle, if required
{
await deploy({
addresses,
from,
targets,
key: targets.WitnetRandomness,
libs: specs.WitnetRandomness?.libs,
vanity: specs.WitnetRandomness?.vanity || 0,
immutables: specs.WitnetRandomness?.immutables,
intrinsics: {
types: ["address", "address"],
values: [
/* _operator */ from,
/* _wrb */ await determineProxyAddr(from, specs.WitnetRequestBoard?.vanity || 3),
],
},
})
}
await deploy({
addresses,
from,
targets,
key: targets.WitnetRandomness,
libs: specs.WitnetRandomness?.libs,
vanity: specs.WitnetRandomness?.vanity || 0,
immutables: specs.WitnetRandomness?.immutables,
intrinsics: {
types: ["address", "address"],
values: [
/* _operator */ from,
/* _wrb */ await determineProxyAddr(from, specs.WitnetRequestBoard?.vanity || 3),
],
},
})

// save addresses file if required
if (!isDryRun) {
if (!utils.isDryRun(network)) {
await utils.saveAddresses(network, addresses)
}
}
Expand All @@ -73,7 +68,7 @@ async function deploy (specs) {
}
const coreBytecode = link(artifact.toJSON().bytecode, libs, targets)
if (coreBytecode.indexOf("__") > -1) {
console.info(bytecode)
console.info(coreBytecode)
console.info("Cannot deploy due to some missing libs")
process.exit(1)
}
Expand Down Expand Up @@ -111,7 +106,7 @@ async function determineProxyAddr (from, nonce) {

function link (bytecode, libs, targets) {
if (libs && Array.isArray(libs) && libs.length > 0) {
for (index in libs) {
for (const index in libs) {
const key = targets[libs[index]]
const lib = artifacts.require(key)
bytecode = bytecode.replaceAll(`__${key}${"_".repeat(38 - key.length)}`, lib.address.slice(2))
Expand Down
1 change: 0 additions & 1 deletion scripts/vanity3gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module.exports = async function () {
let network = "default"
let prefix = "0x00"
let suffix = "0x00"
const hexArgs = ""
process.argv.map((argv, index, args) => {
if (argv === "--offset") {
offset = parseInt(args[index + 1])
Expand Down
76 changes: 38 additions & 38 deletions settings/artifacts.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
module.exports = {
default: {
WitnetBytecodes: "WitnetBytecodesDefault",
WitnetEncodingLib: "WitnetEncodingLib",
WitnetErrorsLib: "WitnetErrorsLib",
WitnetPriceFeeds: "WitnetPriceFeeds",
WitnetPriceFeedsLib: "WitnetPriceFeedsLib",
WitnetRandomness: "WitnetRandomness",
WitnetRequestBoard: "WitnetRequestBoardTrustableDefault",
WitnetRequestFactory: "WitnetRequestFactoryDefault",
},
boba: {
WitnetRequestBoard: "WitnetRequestBoardTrustableOvm2",
},
conflux: {
WitnetRequestFactory: "WitnetRequestFactoryCfxCore",
},
mantle: {
WitnetRequestBoard: "WitnetRequestBoardTrustableOvm2",
},
optimism: {
WitnetRequestBoard: "WitnetRequestBoardTrustableOvm2",
},
"polygon.zkevm.goerli": {
WitnetBytecodes: "WitnetBytecodesNoSha256",
},
"polygon.zkevm.mainnet": {
WitnetBytecodes: "WitnetBytecodesNoSha256",
},
reef: {
WitnetRequestBoard: "WitnetRequestBoardTrustableReef",
},
scroll: {
WitnetBytecodes: "WitnetBytecodesNoSha256",
},
"syscoin.rollux.testnet": {
WitnetRequestBoard: "WitnetRequestBoardTrustableOvm2",
},
};
default: {
WitnetBytecodes: "WitnetBytecodesDefault",
WitnetEncodingLib: "WitnetEncodingLib",
WitnetErrorsLib: "WitnetErrorsLib",
WitnetPriceFeeds: "WitnetPriceFeeds",
WitnetPriceFeedsLib: "WitnetPriceFeedsLib",
WitnetRandomness: "WitnetRandomness",
WitnetRequestBoard: "WitnetRequestBoardTrustableDefault",
WitnetRequestFactory: "WitnetRequestFactoryDefault",
},
boba: {
WitnetRequestBoard: "WitnetRequestBoardTrustableOvm2",
},
conflux: {
WitnetRequestFactory: "WitnetRequestFactoryCfxCore",
},
mantle: {
WitnetRequestBoard: "WitnetRequestBoardTrustableOvm2",
},
optimism: {
WitnetRequestBoard: "WitnetRequestBoardTrustableOvm2",
},
"polygon.zkevm.goerli": {
WitnetBytecodes: "WitnetBytecodesNoSha256",
},
"polygon.zkevm.mainnet": {
WitnetBytecodes: "WitnetBytecodesNoSha256",
},
reef: {
WitnetRequestBoard: "WitnetRequestBoardTrustableReef",
},
scroll: {
WitnetBytecodes: "WitnetBytecodesNoSha256",
},
"syscoin.rollux.testnet": {
WitnetRequestBoard: "WitnetRequestBoardTrustableOvm2",
},
}
72 changes: 37 additions & 35 deletions settings/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const artifacts = require("./artifacts")
const { merge } = require("lodash")
const networks = require("./networks")
Expand All @@ -7,37 +6,40 @@ const solidity = require("./solidity")
const utils = require("../src/utils")

module.exports = {
getArtifacts: (network) => {
const [eco, net] = utils.getRealmNetworkFromArgs(network);
return merge(
artifacts.default,
artifacts[eco],
artifacts[net]
);
},
getCompilers: (network) => {
const [eco, net] = utils.getRealmNetworkFromArgs(network);
return merge(
solidity.default,
solidity[eco],
solidity[net],
);
},
getNetworks: (network) => {
const [eco, net] = utils.getRealmNetworkFromArgs(network);
return merge(
networks.default,
networks[eco],
networks[net],
);
},
getSpecs: (network) => {
const [eco, net] = utils.getRealmNetworkFromArgs(network);
return merge(
specs.default,
specs[eco],
specs[net]
);
},
artifacts, networks, solidity, specs,
};
getArtifacts: (network) => {
const [eco, net] = utils.getRealmNetworkFromArgs(network)
return merge(
artifacts.default,
artifacts[eco],
artifacts[net]
)
},
getCompilers: (network) => {
const [eco, net] = utils.getRealmNetworkFromArgs(network)
return merge(
solidity.default,
solidity[eco],
solidity[net],
)
},
getNetworks: (network) => {
const [eco, net] = utils.getRealmNetworkFromArgs(network)
return merge(
networks.default,
networks[eco],
networks[net],
)
},
getSpecs: (network) => {
const [eco, net] = utils.getRealmNetworkFromArgs(network)
return merge(
specs.default,
specs[eco],
specs[net]
)
},
artifacts,
networks,
solidity,
specs,
}
Loading

0 comments on commit a4769ea

Please sign in to comment.