From 5494de3ef81598bfc86fb47463cb97007fb24220 Mon Sep 17 00:00:00 2001 From: Jorge Izquierdo Date: Wed, 8 Nov 2017 18:03:09 +0100 Subject: [PATCH 1/3] Add ENS registry address flag --- bin/cli.js | 9 +++++---- package-lock.json | 2 +- src/handle.js | 8 +++++--- src/utils/ens-resolve.js | 36 +++++++++++++++++++++--------------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 0b12aa812..a81163fdc 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -5,19 +5,20 @@ const handle = require('../src/handle') const cli = meow(` Usage $ aragon-dev-cli - + Commands init Initialize a new Aragon module version Bump the module version versions List the published versions of this module publish Publish a new version of the module - playground Inject module into local Aragon application - + playground Inject module into local Aragon application + Options - --key The Ethereum private key to sign transactions with. Raw transaction will be dumped to stdout if no key is provided. + --key The Ethereum private key to sign transactions with. Raw transaction will be dumped to stdout if no key is provided. --registry The repository registry to use for creating and publishing packages (default: aragonpm.eth) --rpc A URI to the Ethereum node used for RPC calls (default: https://ropsten.infura.io) --chain-id The ID of the chain to interact with (default: 3) + --ens Address for the ENS registry (default: canonical ENS for chainId) Examples $ aragon-dev-cli version major diff --git a/package-lock.json b/package-lock.json index b2e43be3e..0dbbf74cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "@aragon/aragon-dev-cli", + "name": "@aragon/cli", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/src/handle.js b/src/handle.js index 7085fdcaf..46a83d24d 100644 --- a/src/handle.js +++ b/src/handle.js @@ -44,7 +44,8 @@ const handlers = { .then(async ({ appName }) => { const eth = new Web3Eth(flags.rpc) - const repoAddress = await ens.resolve(appName, eth, flags.chainId) + const ensAddress = flags.ens || ens.chainRegistry(flags.chainId) + const repoAddress = await ens.resolve(appName, eth, ensAddress) if (repoAddress === consts.NULL_ADDRESS) { return [] } @@ -200,11 +201,12 @@ const handlers = { .then(async ({ appName, version, hash }) => { const eth = new Web3Eth(flags.rpc) - let repoAddress = await ens.resolve(appName, eth, flags.chainId) + const ensAddress = flags.ens || ens.chainRegistry(flags.chainId) + let repoAddress = await ens.resolve(appName, eth, ensAddress) if (repoAddress === consts.NULL_ADDRESS) { // Create new repo const registryName = appName.split('.').splice(-2).join('.') - const registryAddress = await ens.resolve(registryName, eth, flags.chainId) + const registryAddress = await ens.resolve(registryName, eth, ensAddress) if (registryAddress === consts.NULL_ADDRESS) { reporter.error(`Registry ${registryName} does not exist.`) return diff --git a/src/utils/ens-resolve.js b/src/utils/ens-resolve.js index 697b2a2d8..f1ca22051 100644 --- a/src/utils/ens-resolve.js +++ b/src/utils/ens-resolve.js @@ -3,22 +3,28 @@ const consts = require('./constants') const registries = { 1: '0x314159265dd8dbb310642f98f50c066173c1259b', - 3: '0x112234455c3a32fd11230c42e7bccd4a84e02010' + 3: '0x112234455c3a32fd11230c42e7bccd4a84e02010', } -module.exports.resolve = function (name, eth, chainId = 1) { - const node = hash(name) +module.exports = { + chainRegistry(chainId) { + return registries[chainId] + }, - return new eth.Contract( - require('../../abi/ens/ENSRegistry.json'), - registries[chainId] - ).methods.resolver(node).call() - .then((resolverAddress) => - resolverAddress === consts.NULL_ADDRESS - ? resolverAddress - : new eth.Contract( - require('../../abi/ens/ENSResolver.json'), - resolverAddress - ).methods.addr(node).call() - ) + resolve(name, eth, registryAddress = this.chainRegistry(1)) { + const node = hash(name) + + return new eth.Contract( + require('../../abi/ens/ENSRegistry.json'), + registryAddress + ).methods.resolver(node).call() + .then((resolverAddress) => + resolverAddress === consts.NULL_ADDRESS + ? resolverAddress + : new eth.Contract( + require('../../abi/ens/ENSResolver.json'), + resolverAddress + ).methods.addr(node).call() + ) + }, } From fb54e1e12c7028de5892af0b5a8d5c7ed36dbcdd Mon Sep 17 00:00:00 2001 From: Jorge Izquierdo Date: Mon, 13 Nov 2017 15:09:32 +0100 Subject: [PATCH 2/3] Rename registry flags --- bin/cli.js | 4 ++-- src/handle.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index a81163fdc..35754c5c4 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -15,10 +15,10 @@ const cli = meow(` Options --key The Ethereum private key to sign transactions with. Raw transaction will be dumped to stdout if no key is provided. - --registry The repository registry to use for creating and publishing packages (default: aragonpm.eth) + --apm-registry The repository registry to use for creating and publishing packages (default: aragonpm.eth) --rpc A URI to the Ethereum node used for RPC calls (default: https://ropsten.infura.io) --chain-id The ID of the chain to interact with (default: 3) - --ens Address for the ENS registry (default: canonical ENS for chainId) + --ens-registry Address for the ENS registry (default: canonical ENS for chainId) Examples $ aragon-dev-cli version major diff --git a/src/handle.js b/src/handle.js index 46a83d24d..57128b0c1 100644 --- a/src/handle.js +++ b/src/handle.js @@ -26,12 +26,12 @@ const handlers = { reporter.fatal('No name specified') } - if (!flags.registry) { + if (!flags.apm-registry) { reporter.fatal('No registry specified') } pkg.write({ - appName: name + '.' + flags.registry, + appName: name + '.' + flags.apm-registry, version: '1.0.0', roles: [], path: 'src/App.sol' @@ -44,7 +44,7 @@ const handlers = { .then(async ({ appName }) => { const eth = new Web3Eth(flags.rpc) - const ensAddress = flags.ens || ens.chainRegistry(flags.chainId) + const ensAddress = flags.ens-registry || ens.chainRegistry(flags.chainId) const repoAddress = await ens.resolve(appName, eth, ensAddress) if (repoAddress === consts.NULL_ADDRESS) { return [] @@ -201,7 +201,7 @@ const handlers = { .then(async ({ appName, version, hash }) => { const eth = new Web3Eth(flags.rpc) - const ensAddress = flags.ens || ens.chainRegistry(flags.chainId) + const ensAddress = flags.ens-registry || ens.chainRegistry(flags.chainId) let repoAddress = await ens.resolve(appName, eth, ensAddress) if (repoAddress === consts.NULL_ADDRESS) { // Create new repo From c569d2ec60b21bdaab835eb6be3b06c1da967763 Mon Sep 17 00:00:00 2001 From: Jorge Izquierdo Date: Tue, 14 Nov 2017 10:53:34 +0100 Subject: [PATCH 3/3] Remove apm-registry flag for init command --- bin/cli.js | 13 ++++--------- src/handle.js | 10 +++------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 35754c5c4..39b1b476d 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -7,7 +7,7 @@ const cli = meow(` $ aragon-dev-cli Commands - init Initialize a new Aragon module + init Initialize a new Aragon module (e.g. test.aragonpm.eth) version Bump the module version versions List the published versions of this module publish Publish a new version of the module @@ -15,7 +15,6 @@ const cli = meow(` Options --key The Ethereum private key to sign transactions with. Raw transaction will be dumped to stdout if no key is provided. - --apm-registry The repository registry to use for creating and publishing packages (default: aragonpm.eth) --rpc A URI to the Ethereum node used for RPC calls (default: https://ropsten.infura.io) --chain-id The ID of the chain to interact with (default: 3) --ens-registry Address for the ENS registry (default: canonical ENS for chainId) @@ -24,18 +23,14 @@ const cli = meow(` $ aragon-dev-cli version major New version is 2.0.0 - $ aragon-dev-cli init poll --registry=module-corp.eth - Created new module poll.module-corp.eth - - $ aragon-dev-cli init cool-app + $ aragon-dev-cli init cool-app.aragonpm.eth Created new module cool-app.aragonpm.eth `, { default: { - registry: 'aragonpm.eth', rpc: 'https://ropsten.infura.io', - chainId: 3 + chainId: 3, }, - string: ['key', 'rpc', 'registry'] + string: ['key', 'rpc', 'ens-registry'] }) handle(cli) diff --git a/src/handle.js b/src/handle.js index 57128b0c1..384d98da1 100644 --- a/src/handle.js +++ b/src/handle.js @@ -26,12 +26,8 @@ const handlers = { reporter.fatal('No name specified') } - if (!flags.apm-registry) { - reporter.fatal('No registry specified') - } - pkg.write({ - appName: name + '.' + flags.apm-registry, + appName: name, version: '1.0.0', roles: [], path: 'src/App.sol' @@ -44,7 +40,7 @@ const handlers = { .then(async ({ appName }) => { const eth = new Web3Eth(flags.rpc) - const ensAddress = flags.ens-registry || ens.chainRegistry(flags.chainId) + const ensAddress = flags.ensRegistry || ens.chainRegistry(flags.chainId) const repoAddress = await ens.resolve(appName, eth, ensAddress) if (repoAddress === consts.NULL_ADDRESS) { return [] @@ -201,7 +197,7 @@ const handlers = { .then(async ({ appName, version, hash }) => { const eth = new Web3Eth(flags.rpc) - const ensAddress = flags.ens-registry || ens.chainRegistry(flags.chainId) + const ensAddress = flags.ensRegistry || ens.chainRegistry(flags.chainId) let repoAddress = await ens.resolve(appName, eth, ensAddress) if (repoAddress === consts.NULL_ADDRESS) { // Create new repo