mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-18 10:16:30 +00:00
Merge pull request #906 from embark-framework/bugfix/ens-require-default-account
Warning if no default account for ens
This commit is contained in:
commit
0848d81b3e
@ -131,6 +131,7 @@ __embarkENS.resolverInterface = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const defaultAccountNotSetError = 'web3.eth.defaultAccount not set';
|
||||||
const providerNotSetError = 'ENS provider not set';
|
const providerNotSetError = 'ENS provider not set';
|
||||||
const NoDecodeAddrError = 'Error: Couldn\'t decode address from ABI: 0x';
|
const NoDecodeAddrError = 'Error: Couldn\'t decode address from ABI: 0x';
|
||||||
const NoDecodeStringError = 'ERROR: The returned value is not a convertible string: 0x0';
|
const NoDecodeStringError = 'ERROR: The returned value is not a convertible string: 0x0';
|
||||||
@ -151,7 +152,6 @@ __embarkENS.setProvider = function (config) {
|
|||||||
const ERROR_MESSAGE = 'ENS is not available in this chain';
|
const ERROR_MESSAGE = 'ENS is not available in this chain';
|
||||||
self.registration = config.registration;
|
self.registration = config.registration;
|
||||||
self.env = config.env;
|
self.env = config.env;
|
||||||
|
|
||||||
EmbarkJS.onReady(() => {
|
EmbarkJS.onReady(() => {
|
||||||
web3.eth.net.getId()
|
web3.eth.net.getId()
|
||||||
.then((id) => {
|
.then((id) => {
|
||||||
@ -176,6 +176,10 @@ __embarkENS.resolve = function (name, callback) {
|
|||||||
if (!this.ens) {
|
if (!this.ens) {
|
||||||
return callback(providerNotSetError);
|
return callback(providerNotSetError);
|
||||||
}
|
}
|
||||||
|
if (!web3.eth.defaultAccount) {
|
||||||
|
return callback(defaultAccountNotSetError);
|
||||||
|
}
|
||||||
|
|
||||||
let node = namehash.hash(name);
|
let node = namehash.hash(name);
|
||||||
|
|
||||||
function cb(err, addr) {
|
function cb(err, addr) {
|
||||||
@ -202,6 +206,9 @@ __embarkENS.lookup = function (address, callback) {
|
|||||||
if (!this.ens) {
|
if (!this.ens) {
|
||||||
return callback(providerNotSetError);
|
return callback(providerNotSetError);
|
||||||
}
|
}
|
||||||
|
if (!web3.eth.defaultAccount) {
|
||||||
|
return callback(defaultAccountNotSetError);
|
||||||
|
}
|
||||||
if (address.startsWith("0x")) {
|
if (address.startsWith("0x")) {
|
||||||
address = address.slice(2);
|
address = address.slice(2);
|
||||||
}
|
}
|
||||||
@ -229,6 +236,10 @@ __embarkENS.lookup = function (address, callback) {
|
|||||||
__embarkENS.registerSubDomain = function (name, address, callback) {
|
__embarkENS.registerSubDomain = function (name, address, callback) {
|
||||||
callback = callback || function () {};
|
callback = callback || function () {};
|
||||||
|
|
||||||
|
if (!web3.eth.defaultAccount) {
|
||||||
|
return callback(defaultAccountNotSetError);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.env !== 'development' && this.env !== 'privatenet') {
|
if (this.env !== 'development' && this.env !== 'privatenet') {
|
||||||
return callback('Sub-domain registration is only available in development or privatenet mode');
|
return callback('Sub-domain registration is only available in development or privatenet mode');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user