Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment script is missing registration and configuration for open.aragonpm.eth #639

Open
spark8899 opened this issue Oct 12, 2022 · 1 comment

Comments

@spark8899
Copy link

spark8899 commented Oct 12, 2022

I wrote a script here. I deploy v4.4.0

deploy-openapm.js
`const namehash = require('eth-ens-namehash').hash
const keccak256 = require('js-sha3').keccak_256

const deployENS = require('./deploy-test-ens')
const deployDaoFactory = require('./deploy-daofactory')
const getAccounts = require('./helpers/get-accounts')

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

const ZERO_ADDR = '0x0000000000000000000000000000000000000000'

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

module.exports = async (
truffleExecCallback,
{
artifacts = globalArtifacts,
web3 = globalWeb3,
ensAddress = defaultENSAddress,
owner = defaultOwner,
daoFactoryAddress = defaultDaoFactoryAddress,
verbose = true
} = {}
) => {
const log = (...args) => {
if (verbose) { console.log(...args) }
}

const APMRegistry = artifacts.require('APMRegistry')
const Repo = artifacts.require('Repo')
const ENSSubdomainRegistrar = artifacts.require('ENSSubdomainRegistrar')

const DAOFactory = artifacts.require('DAOFactory')
const APMRegistryFactory = artifacts.require('APMRegistryFactory')
const ENS = artifacts.require('ENS')
const Kernel = artifacts.require('Kernel')
const ACL = artifacts.require('ACL')

const tldName = 'eth'
const labelName = 'aragonpm'
const tldHash = namehash(tldName)
const labelHash = '0x'+keccak256(labelName)
const apmNode = namehash(${labelName}.${tldName})

const openTldName = 'aragonpm.eth'
const openLabelName = 'open'
const openTldHash = namehash(openTldName)
const openLabelHash = '0x'+keccak256(openLabelName)
const openApmNode = namehash(${openLabelName}.${openTldName})

const apmFactoryAddress = '0xc3eb5cb0574595e6cc20faa8a809ada5820db9c9'
const ANY_ENTITY = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF';
const CREATE_REPO_ROLE = '0x'+keccak256('CREATE_REPO_ROLE');

let ens

log('Deploying OPEN APM...')

const accounts = await getAccounts(web3)
if (!owner) {
owner = accounts[0]
log('OWNER env variable not found, setting APM owner to the provider's first account')
}
log('Owner:', owner)

if (!ensAddress) {
log('=========')
log('Missing ENS! Deploying a custom ENS...')
ens = (await deployENS(null, { artifacts, owner, verbose: false })).ens
ensAddress = ens.address
} else {
ens = ENS.at(ensAddress)
}

const registrar = await ens.owner(apmNode)
const ensSubdomainRegistrar = await ENSSubdomainRegistrar.at(registrar)
log('ensSubdomainRegistrar:', ensSubdomainRegistrar.address)

const kernelAddr = await ensSubdomainRegistrar.kernel()
const kernel = await Kernel.at(kernelAddr)
log('kernelAddr:', kernelAddr)

const aclAddr = await kernel.acl()
const acl = await ACL.at(aclAddr)
log('aclAddr:', aclAddr)

log('ENS:', ensAddress)
log('=========')
log(TLD: ${tldName} (${tldHash}))
log(Label: ${labelName} (${labelHash}))
log(ApmNode: ${labelName}.${tldName} (${apmNode}))
log('=========')
log(OPEN TLD: ${openTldName} (${openTldHash}))
log(OPEN Label: ${openLabelName} (${openLabelHash}))
log(OpenApmNode: ${openLabelName}.${openTldName} (${openApmNode}))

log('=========')
log('=========')
log('Deploying OPEN APM bases...')

//process.exit()

let daoFactory
if (daoFactoryAddress) {
daoFactory = DAOFactory.at(daoFactoryAddress)
const hasEVMScripts = await daoFactory.regFactory() !== ZERO_ADDR

log(`Using provided DAOFactory (with${hasEVMScripts ? '' : 'out' } EVMScripts):`, daoFactoryAddress)

} else {
log('Deploying DAOFactory with EVMScripts...')
daoFactory = (await deployDaoFactory(null, { artifacts, withEvmScriptRegistryFactory: true, verbose: false })).daoFactory
}

let apmFactory
log('Get APMRegistryFactory...')
apmFactory = await APMRegistryFactory.at(apmFactoryAddress)
log(apmFactory: ${apmFactoryAddress})

log('Create permission for root account on CREATE_NAME_ROLE')
await acl.grantPermission(
owner,
registrar,
await ensSubdomainRegistrar.CREATE_NAME_ROLE()
);

log('Creating open subdomain and assigning it to APMRegistryFactory')
await ensSubdomainRegistrar.createName(openLabelHash, apmFactory.address)

log(Assigning ENS name (${openLabelName}.${openTldName}) to factory...)
log('Deploying open APM...')
const receipt = await apmFactory.newAPM(openTldHash, openLabelHash, owner)

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

log('Create permission for ANY_ENTITY on CREATE_REPO_ROLE')
let apmOpen = await APMRegistry.at(apmOpenAddr)
log('apmOpenAddr:', apmOpenAddr)

let kernelApmAddr = await apmOpen.kernel()
let kernelApmOpen = await Kernel.at(kernelApmAddr)
log('kernelApmAddr:', kernelApmAddr)

let aclApmAddr = await kernelApmOpen.acl()
let aclApmOpen = await ACL.at(aclApmAddr)
log('aclApmAddr:', aclApmAddr)

log('aclApmOpen gratPermission')
await aclApmOpen.grantPermission(
ANY_ENTITY,
apmOpenAddr,
CREATE_REPO_ROLE
)

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

if (typeof truffleExecCallback === 'function') {
// Called directly via truffle exec
truffleExecCallback()
} else {
return {
apmFactory,
ens,
apmOpen: APMRegistry.at(apmOpenAddr),
}
}
}
`

@welcome
Copy link

welcome bot commented Oct 12, 2022

Thanks for opening your first issue in aragonOS! Someone will circle back soon ⚡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant