attempt at deploying on dev net
Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
parent
42fe72392b
commit
e8d55bdb0d
|
@ -3,96 +3,7 @@ import namehash from 'eth-ens-namehash';
|
|||
/*global web3*/
|
||||
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,
|
||||
|
@ -242,32 +153,8 @@ __embarkENS.resolverInterface = [
|
|||
}
|
||||
];
|
||||
|
||||
__embarkENS.registryAddresses = {
|
||||
// Mainnet
|
||||
"1": "0x314159265dd8dbb310642f98f50c066173c1259b",
|
||||
// Ropsten
|
||||
"3": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
||||
// Rinkeby
|
||||
"4": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A"
|
||||
};
|
||||
|
||||
__embarkENS.setProvider = function () {
|
||||
const self = this;
|
||||
// get network id and then assign ENS contract based on that
|
||||
let registryAddresses = this.registryAddresses;
|
||||
this.ens = null;
|
||||
web3.eth.net.getId().then(id => {
|
||||
if (registryAddresses[id] !== undefined) {
|
||||
self.ens = new web3.eth.Contract(self.registryInterface, registryAddresses[id]);
|
||||
}
|
||||
// todo: deploy at this point
|
||||
}).catch(e => {
|
||||
if (e.message.indexOf('Provider not set or invalid') > -1) {
|
||||
console.warn('ENS is not available in this chain');
|
||||
return;
|
||||
}
|
||||
console.error(e);
|
||||
});
|
||||
__embarkENS.setProvider = function (jsonObject) {
|
||||
this.ens = JSON.parse(jsonObject);
|
||||
};
|
||||
|
||||
__embarkENS.resolve = function(name) {
|
||||
|
|
|
@ -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 + ");";
|
||||
|
||||
|
|
Loading…
Reference in New Issue