mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-23 12:38:18 +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(() => {
|
EmbarkJS.onReady(() => {
|
||||||
web3.eth.net.getId()
|
web3.eth.net.getId()
|
||||||
.then((id) => {
|
.then((id) => {
|
||||||
const address = self.registryAddresses[id] || config.address;
|
const registryAddress = self.registryAddresses[id] || config.registryAddress;
|
||||||
self.isAvailable = true;
|
self.isAvailable = true;
|
||||||
self.ens = new EmbarkJS.Contract({abi: config.abi, address});
|
self.ens = new EmbarkJS.Contract({abi: config.registryAbi, address: registryAddress});
|
||||||
self.ens.setProvider(web3.currentProvider);
|
self.registrar = new EmbarkJS.Contract({abi: config.registrarAbi, address: config.registrarAddress});
|
||||||
self.ens.options.from = web3.eth.defaultAccount;
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.message.indexOf('Provider not set or invalid') > -1) {
|
if (err.message.indexOf('Provider not set or invalid') > -1) {
|
||||||
@ -195,7 +194,6 @@ __embarkENS.resolve = function (name, callback) {
|
|||||||
return callback(providerNotSetError);
|
return callback(providerNotSetError);
|
||||||
}
|
}
|
||||||
let node = namehash.hash(name);
|
let node = namehash.hash(name);
|
||||||
console.log('NODE TO RESOLVE', node);
|
|
||||||
|
|
||||||
function cb(err, addr) {
|
function cb(err, addr) {
|
||||||
if (err === NoDecodeAddrError) {
|
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 () {
|
__embarkENS.isAvailable = function () {
|
||||||
return Boolean(this.isAvailable);
|
return Boolean(this.isAvailable);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const fs = require('../../core/fs.js');
|
const fs = require('../../core/fs.js');
|
||||||
const utils = require('../../utils/utils.js');
|
const utils = require('../../utils/utils.js');
|
||||||
const namehash = require('eth-ens-namehash');
|
const namehash = require('eth-ens-namehash');
|
||||||
|
const async = require('async');
|
||||||
|
|
||||||
class ENS {
|
class ENS {
|
||||||
constructor(embark, _options) {
|
constructor(embark, _options) {
|
||||||
@ -15,10 +16,23 @@ class ENS {
|
|||||||
this.configureContracts();
|
this.configureContracts();
|
||||||
|
|
||||||
self.embark.registerActionForEvent("contracts:deploy:afterAll", (cb) => {
|
self.embark.registerActionForEvent("contracts:deploy:afterAll", (cb) => {
|
||||||
|
async.parallel([
|
||||||
|
function getENSRegistry(paraCb) {
|
||||||
self.events.request('contracts:contract', "ENSRegistry", (contract) => {
|
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 = {
|
let config = {
|
||||||
abi: contract.abiDefinition,
|
registryAbi: results[0].abiDefinition,
|
||||||
address: contract.deployedAddress
|
registryAddress: results[0].deployedAddress,
|
||||||
|
registrarAbi: results[1].abiDefinition,
|
||||||
|
registrarAddress: results[1].deployedAddress
|
||||||
};
|
};
|
||||||
self.addSetProvider(config);
|
self.addSetProvider(config);
|
||||||
cb();
|
cb();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user