mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-22 20:18:22 +00:00
conflict in embark js
This commit is contained in:
parent
dffbcf032f
commit
974d492428
@ -173,11 +173,10 @@ __embarkENS.setProvider = function (config) {
|
||||
EmbarkJS.onReady(() => {
|
||||
web3.eth.net.getId()
|
||||
.then((id) => {
|
||||
const address = self.registryAddresses[id] || config.address;
|
||||
const registryAddress = self.registryAddresses[id] || config.registryAddress;
|
||||
self.isAvailable = true;
|
||||
self.ens = new EmbarkJS.Contract({abi: config.abi, address});
|
||||
self.ens.setProvider(web3.currentProvider);
|
||||
self.ens.options.from = web3.eth.defaultAccount;
|
||||
self.ens = new EmbarkJS.Contract({abi: config.registryAbi, address: registryAddress});
|
||||
self.registrar = new EmbarkJS.Contract({abi: config.registrarAbi, address: config.registrarAddress});
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.message.indexOf('Provider not set or invalid') > -1) {
|
||||
@ -195,7 +194,6 @@ __embarkENS.resolve = function (name, callback) {
|
||||
return callback(providerNotSetError);
|
||||
}
|
||||
let node = namehash.hash(name);
|
||||
console.log('NODE TO RESOLVE', node);
|
||||
|
||||
function cb(err, addr) {
|
||||
if (err === NoDecodeAddrError) {
|
||||
@ -242,6 +240,29 @@ __embarkENS.lookup = function (address, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
__embarkENS.registerSubDomain = function (name, address, callback) {
|
||||
callback = callback || function () {};
|
||||
|
||||
const resolveAddr = address || '0x0000000000000000000000000000000000000000';
|
||||
const toSend = this.registrar.methods.register(web3.utils.sha3(name), web3.eth.defaultAccount, resolveAddr);
|
||||
|
||||
toSend.estimateGas().then(gasEstimated => {
|
||||
return toSend.send({gas: gasEstimated + 1000}).then(transaction => {
|
||||
if (transaction.status !== "0x1" && transaction.status !== "0x01") {
|
||||
console.warn('Failed transaction', transaction);
|
||||
return callback('Failed to register. Check gas cost.');
|
||||
}
|
||||
callback(null, transaction);
|
||||
}).catch(err => {
|
||||
callback('Failed to register with error: ' + (err.message || err));
|
||||
console.error(err);
|
||||
});
|
||||
}).catch(err => {
|
||||
callback("Register would error. Is it already registered? Do you have token balance? Is Allowance set? " + (err.message || err));
|
||||
console.error(err);
|
||||
});
|
||||
};
|
||||
|
||||
__embarkENS.isAvailable = function () {
|
||||
return Boolean(this.isAvailable);
|
||||
};
|
||||
|
@ -1,6 +1,7 @@
|
||||
const fs = require('../../core/fs.js');
|
||||
const utils = require('../../utils/utils.js');
|
||||
const namehash = require('eth-ens-namehash');
|
||||
const async = require('async');
|
||||
|
||||
class ENS {
|
||||
constructor(embark, _options) {
|
||||
@ -14,11 +15,24 @@ class ENS {
|
||||
this.addENSToEmbarkJS();
|
||||
this.configureContracts();
|
||||
|
||||
self.embark.registerActionForEvent("contracts:deploy:afterAll", (cb) => {
|
||||
self.events.request('contracts:contract', "ENSRegistry", (contract) => {
|
||||
self.embark.registerActionForEvent("contracts:deploy:afterAll", (cb) => {
|
||||
async.parallel([
|
||||
function getENSRegistry(paraCb) {
|
||||
self.events.request('contracts:contract', "ENSRegistry", (contract) => {
|
||||
paraCb(null, contract);
|
||||
});
|
||||
},
|
||||
function getRegistrar(paraCb) {
|
||||
self.events.request('contracts:contract', "FIFSRegistrar", (contract) => {
|
||||
paraCb(null, contract);
|
||||
});
|
||||
}
|
||||
], (err, results) => {
|
||||
let config = {
|
||||
abi: contract.abiDefinition,
|
||||
address: contract.deployedAddress
|
||||
registryAbi: results[0].abiDefinition,
|
||||
registryAddress: results[0].deployedAddress,
|
||||
registrarAbi: results[1].abiDefinition,
|
||||
registrarAddress: results[1].deployedAddress
|
||||
};
|
||||
self.addSetProvider(config);
|
||||
cb();
|
||||
|
Loading…
x
Reference in New Issue
Block a user