diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index e50fb5b4..0e936e78 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -3,96 +3,7 @@ import namehash from 'eth-ens-namehash'; /*global web3, EmbarkJS*/ let __embarkENS = {}; -// registry interface for later -__embarkENS.registryInterface = [ - { - "constant": true, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "resolver", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "owner", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "resolver", - "type": "address" - } - ], - "name": "setResolver", - "outputs": [], - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "label", - "type": "bytes32" - }, - { - "name": "owner", - "type": "address" - } - ], - "name": "setSubnodeOwner", - "outputs": [], - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "owner", - "type": "address" - } - ], - "name": "setOwner", - "outputs": [], - "type": "function" - } -]; - +// resolver interface __embarkENS.resolverInterface = [ { "constant": true, diff --git a/lib/modules/ens/index.js b/lib/modules/ens/index.js index 0b0c6656..56e60268 100644 --- a/lib/modules/ens/index.js +++ b/lib/modules/ens/index.js @@ -1,3 +1,4 @@ +/*global web3*/ const fs = require('../../core/fs.js'); const utils = require('../../utils/utils.js'); @@ -7,6 +8,8 @@ class ENS { this.events = embark.events; this.namesConfig = embark.config.namesystemConfig; this.embark = embark; + this.ensRegistry = null; + this.ensResolver = null; this.addENSToEmbarkJS(); this.addSetProvider(); @@ -23,6 +26,7 @@ class ENS { return; } + // get namehash, import it into file self.events.request("version:get:eth-ens-namehash", function(EnsNamehashVersion) { let currentEnsNamehashVersion = require('../../../package.json').dependencies["eth-ens-namehash"]; if (EnsNamehashVersion !== currentEnsNamehashVersion) { @@ -39,8 +43,43 @@ class ENS { this.embark.addCodeToEmbarkJS(code); } + configureENSRegistry() { + const self = this; + self.embark.addContractFile('./contracts/ENSRegistry.sol'); + self.embark.registerContractConfiguration({ + "default": { + "gas": "auto", + "ENSRegistry": { + "deploy": true, + } + }, + "ropsten": { + "ENSRegistry": { + "address": "0x112234455c3a32fd11230c42e7bccd4a84e02010" + } + }, + "rinkeby": { + "ENSRegistry": { + "address": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A" + } + }, + "mainnet": { + "ENSRegistry": { + "address": "0x314159265dd8dbb310642f98f50c066173c1259b" + } + } + }); + self.events.on("deploy:contract:deployed", (contract) => { + if (contract.className === "ENSRegistry") { + return web3.eth.Contract(contract.abiDefinition, contract.address); + } + }) + } + addSetProvider() { - let config = JSON.stringify({}); + const self = this; + + let config = JSON.stringify(self.configureENSRegistry()); let code = "\nEmbarkJS.Names.setProvider('ens'," + config + ");";