Skip to content

Commit

Permalink
Add standar lint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xGabi committed Sep 4, 2019
1 parent 9a9f82d commit 40f8e6a
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 257 deletions.
114 changes: 57 additions & 57 deletions scripts/deploy/apm-open.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const namehash = require("eth-ens-namehash").hash;
const keccak256 = require("js-sha3").keccak_256;
const namehash = require('eth-ens-namehash').hash
const keccak256 = require('js-sha3').keccak_256

const deployAPM = require("./apm");
const deployAPM = require('./apm')

const globalArtifacts = this.artifacts; // Not injected unless called directly via truffle
const globalWeb3 = this.web3; // Not injected unless called directly via truffle
const globalArtifacts = this.artifacts // Not injected unless called directly via truffle
const globalWeb3 = this.web3 // Not injected unless called directly via truffle

const defaultOwner = process.env.OWNER;
const defaultDaoFactoryAddress = process.env.DAO_FACTORY;
const defaultENSAddress = process.env.ENS;
const defaultOwner = process.env.OWNER
const defaultDaoFactoryAddress = process.env.DAO_FACTORY
const defaultENSAddress = process.env.ENS

module.exports = async (
truffleExecCallback,
Expand All @@ -18,90 +18,90 @@ module.exports = async (
ensAddress = defaultENSAddress,
owner = defaultOwner,
daoFactoryAddress = defaultDaoFactoryAddress,
verbose = true
verbose = true,
} = {}
) => {
const log = (...args) => {
if (verbose) {
console.log(...args);
console.log(...args)
}
};
}

const APMRegistry = artifacts.require("APMRegistry");
const ENSSubdomainRegistrar = artifacts.require("ENSSubdomainRegistrar");
const Kernel = artifacts.require("Kernel");
const ACL = artifacts.require("ACL");
const APMRegistry = artifacts.require('APMRegistry')
const ENSSubdomainRegistrar = artifacts.require('ENSSubdomainRegistrar')
const Kernel = artifacts.require('Kernel')
const ACL = artifacts.require('ACL')

const tldName = "aragonpm.eth";
const labelName = "open";
const tldHash = namehash(tldName);
const labelHash = "0x" + keccak256(labelName);
const tldName = 'aragonpm.eth'
const labelName = 'open'
const tldHash = namehash(tldName)
const labelHash = '0x' + keccak256(labelName)

// deploy `aragonpm.eth`
const { apmFactory, ens, apm } = await deployAPM(null, {
artifacts,
web3,
ensAddress,
daoFactoryAddress,
verbose
});
verbose,
})

ensAddress = ens.address;
const registrar = await apm.registrar();
const apmENSSubdomainRegistrar = ENSSubdomainRegistrar.at(registrar);
const create_name_role = await apmENSSubdomainRegistrar.CREATE_NAME_ROLE();
ensAddress = ens.address
const registrar = await apm.registrar()
const apmENSSubdomainRegistrar = ENSSubdomainRegistrar.at(registrar)
const create_name_role = await apmENSSubdomainRegistrar.CREATE_NAME_ROLE()

log("Managing permissions...");
const kernel = Kernel.at(await apm.kernel());
const acl = ACL.at(await kernel.acl());
log('Managing permissions...')
const kernel = Kernel.at(await apm.kernel())
const acl = ACL.at(await kernel.acl())

log(`Remove manager for create_name_role`);
log(`Remove manager for create_name_role`)
// We need to remove the manager of the role to add permissions
await acl.removePermissionManager(registrar, create_name_role, {
from: owner
});
log(`Create permission for root account on create_name_role`);
from: owner,
})
log(`Create permission for root account on create_name_role`)
await acl.createPermission(owner, registrar, create_name_role, owner, {
from: owner
});
log("=========");
from: owner,
})
log('=========')

log(`TLD: ${tldName} (${tldHash})`);
log(`Label: ${labelName} (${labelHash})`);
log("=========");
log(`TLD: ${tldName} (${tldHash})`)
log(`Label: ${labelName} (${labelHash})`)
log('=========')

log(`Assigning ENS name (${labelName}.${tldName}) to factory...`);
log(`Assigning ENS name (${labelName}.${tldName}) to factory...`)
try {
await apmENSSubdomainRegistrar.createName(labelHash, apmFactory.address, {
from: owner
});
from: owner,
})
} catch (err) {
console.error(
`Error: could not set the owner of '${labelName}.${tldName}' on the given ENS instance`,
`(${ensAddress}). Make sure you have ownership rights over the subdomain.`
);
throw err;
)
throw err
}

log("Deploying Open APM...");
const receipt = await apmFactory.newAPM(tldHash, labelHash, owner);
log('Deploying Open APM...')
const receipt = await apmFactory.newAPM(tldHash, labelHash, owner)

log("=========");
const openAPMAddr = receipt.logs.filter(l => l.event == "DeployAPM")[0].args
.apm;
log("# Open APM:");
log("Address:", openAPMAddr);
log("Transaction hash:", receipt.tx);
log("=========");
log('=========')
const openAPMAddr = receipt.logs.filter(l => l.event == 'DeployAPM')[0].args
.apm
log('# Open APM:')
log('Address:', openAPMAddr)
log('Transaction hash:', receipt.tx)
log('=========')

if (typeof truffleExecCallback === "function") {
if (typeof truffleExecCallback === 'function') {
// Called directly via `truffle exec`
truffleExecCallback();
truffleExecCallback()
} else {
return {
apmFactory,
ens,
apm: APMRegistry.at(openAPMAddr)
};
apm: APMRegistry.at(openAPMAddr),
}
}
};
}
162 changes: 81 additions & 81 deletions scripts/deploy/apm-registries.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const namehash = require("eth-ens-namehash").hash;
const keccak256 = require("js-sha3").keccak_256;
const namehash = require('eth-ens-namehash').hash
const keccak256 = require('js-sha3').keccak_256

const deployAPM = require("./apm");
const deployAPM = require('./apm')

const globalArtifacts = this.artifacts; // Not injected unless called directly via truffle
const globalWeb3 = this.web3; // Not injected unless called directly via truffle
const globalArtifacts = this.artifacts // Not injected unless called directly via truffle
const globalWeb3 = this.web3 // Not injected unless called directly via truffle

const defaultOwner = process.env.OWNER;
const defaultDaoFactoryAddress = process.env.DAO_FACTORY;
const defaultENSAddress = process.env.ENS;
const defaultOwner = process.env.OWNER
const defaultDaoFactoryAddress = process.env.DAO_FACTORY
const defaultENSAddress = process.env.ENS

module.exports = async (
truffleExecCallback,
Expand All @@ -18,129 +18,129 @@ module.exports = async (
ensAddress = defaultENSAddress,
owner = defaultOwner,
daoFactoryAddress = defaultDaoFactoryAddress,
verbose = true
verbose = true,
} = {}
) => {
const log = (...args) => {
if (verbose) {
console.log(...args);
console.log(...args)
}
};
}

// const APMRegistry = artifacts.require("APMRegistry");
const ENSSubdomainRegistrar = artifacts.require("ENSSubdomainRegistrar");
const Kernel = artifacts.require("Kernel");
const ACL = artifacts.require("ACL");
const ENSSubdomainRegistrar = artifacts.require('ENSSubdomainRegistrar')
const Kernel = artifacts.require('Kernel')
const ACL = artifacts.require('ACL')

const tldName = "aragonpm.eth";
const tldHash = namehash(tldName);
const openLabelName = "open";
const hatchLabelName = "hatch";
const openLabelHash = "0x" + keccak256(openLabelName);
const hatchLabelHash = "0x" + keccak256(hatchLabelName);
const tldName = 'aragonpm.eth'
const tldHash = namehash(tldName)
const openLabelName = 'open'
const hatchLabelName = 'hatch'
const openLabelHash = '0x' + keccak256(openLabelName)
const hatchLabelHash = '0x' + keccak256(hatchLabelName)

// deploy `aragonpm.eth`
const { apmFactory, ens, apm } = await deployAPM(null, {
artifacts,
web3,
ensAddress,
daoFactoryAddress,
verbose
});
verbose,
})

ensAddress = ens.address;
const registrar = await apm.registrar();
const apmENSSubdomainRegistrar = ENSSubdomainRegistrar.at(registrar);
const create_name_role = await apmENSSubdomainRegistrar.CREATE_NAME_ROLE();
ensAddress = ens.address
const registrar = await apm.registrar()
const apmENSSubdomainRegistrar = ENSSubdomainRegistrar.at(registrar)
const create_name_role = await apmENSSubdomainRegistrar.CREATE_NAME_ROLE()

log("Managing permissions...");
const kernel = Kernel.at(await apm.kernel());
const acl = ACL.at(await kernel.acl());
log('Managing permissions...')
const kernel = Kernel.at(await apm.kernel())
const acl = ACL.at(await kernel.acl())

log(`Remove manager for create_name_role`);
log(`Remove manager for create_name_role`)
// We need to remove the manager of the role to add permissions
await acl.removePermissionManager(registrar, create_name_role, {
from: owner
});
log(`Create permission for root account on create_name_role`);
from: owner,
})
log(`Create permission for root account on create_name_role`)
await acl.createPermission(owner, registrar, create_name_role, owner, {
from: owner
});
log("=========");
from: owner,
})
log('=========')

log(`TLD: ${tldName} (${tldHash})`);
log(`Open Label: ${openLabelName} (${openLabelHash})`);
log(`Hatch Label: ${hatchLabelName} (${hatchLabelHash})`);
log("=========");
log(`TLD: ${tldName} (${tldHash})`)
log(`Open Label: ${openLabelName} (${openLabelHash})`)
log(`Hatch Label: ${hatchLabelName} (${hatchLabelHash})`)
log('=========')

log(
`Assigning ENS name (${openLabelName}.${tldName}) and (${hatchLabelName}.${tldName}) to factory...`
);
)
try {
await apmENSSubdomainRegistrar.createName(
openLabelHash,
apmFactory.address,
{
from: owner
from: owner,
}
);
)
} catch (err) {
console.error(
`Error: could not set the owner of '${openLabelName}.${tldName}' on the given ENS instance`,
`(${ensAddress}). Make sure you have ownership rights over the subdomain.`
);
throw err;
)
throw err
}

try {
await apmENSSubdomainRegistrar.createName(
hatchLabelHash,
apmFactory.address,
{
from: owner
from: owner,
}
);
)
} catch (err) {
console.error(
`Error: could not set the owner of '${hatchLabelName}.${tldName}' on the given ENS instance`,
`(${ensAddress}). Make sure you have ownership rights over the subdomain.`
);
throw err;
)
throw err
}
log("=========");

log("Deploying Open APM...");
let receipt = await apmFactory.newAPM(tldHash, openLabelHash, owner);

log("=========");

log("=========");
const openAPMAddr = receipt.logs.filter(l => l.event == "DeployAPM")[0].args
.apm;
log("# Open APM:");
log("Address:", openAPMAddr);
log("Transaction hash:", receipt.tx);
log("=========");

log("=========");
log("Deploying Hatch APM...");
receipt = await apmFactory.newAPM(tldHash, hatchLabelHash, owner);

log("=========");
const hatchAPMAddr = receipt.logs.filter(l => l.event == "DeployAPM")[0].args
.apm;
log("# Hatch APM:");
log("Address:", hatchAPMAddr);
log("Transaction hash:", receipt.tx);
log("=========");

if (typeof truffleExecCallback === "function") {
log('=========')

log('Deploying Open APM...')
let receipt = await apmFactory.newAPM(tldHash, openLabelHash, owner)

log('=========')

log('=========')
const openAPMAddr = receipt.logs.filter(l => l.event == 'DeployAPM')[0].args
.apm
log('# Open APM:')
log('Address:', openAPMAddr)
log('Transaction hash:', receipt.tx)
log('=========')

log('=========')
log('Deploying Hatch APM...')
receipt = await apmFactory.newAPM(tldHash, hatchLabelHash, owner)

log('=========')
const hatchAPMAddr = receipt.logs.filter(l => l.event == 'DeployAPM')[0].args
.apm
log('# Hatch APM:')
log('Address:', hatchAPMAddr)
log('Transaction hash:', receipt.tx)
log('=========')

if (typeof truffleExecCallback === 'function') {
// Called directly via `truffle exec`
truffleExecCallback();
truffleExecCallback()
} else {
return {
apmFactory,
ens
};
ens,
}
}
};
}
Loading

0 comments on commit 40f8e6a

Please sign in to comment.