mirror of
https://github.com/embarklabs/EmbarkJS.git
synced 2025-01-09 12:05:51 +00:00
Merge pull request #8 from embark-framework/features/ens
Change functions for ENS
This commit is contained in:
commit
5207c450a6
@ -18,8 +18,8 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"babel": "npm run babel:browser && npm run babel:node",
|
"babel": "npm run babel:browser && npm run babel:node",
|
||||||
"babel:browser": "BABEL_ENV=browser babel --out-dir dist/browser src",
|
"babel:browser": "cross-env BABEL_ENV=browser babel --out-dir dist/browser src",
|
||||||
"babel:node": "BABEL_ENV=node babel --out-dir dist src",
|
"babel:node": "cross-env BABEL_ENV=node babel --out-dir dist src",
|
||||||
"build": "npm run clean && npm run babel && npm run webpack",
|
"build": "npm run clean && npm run babel && npm run webpack",
|
||||||
"clean": "rimraf dist embark.min.js embarkjs-*.tgz package",
|
"clean": "rimraf dist embark.min.js embarkjs-*.tgz package",
|
||||||
"http-server": "http-server",
|
"http-server": "http-server",
|
||||||
@ -57,6 +57,7 @@
|
|||||||
"@babel/preset-env": "7.0.0-beta.54",
|
"@babel/preset-env": "7.0.0-beta.54",
|
||||||
"ajv": "6.5.2",
|
"ajv": "6.5.2",
|
||||||
"babel-loader": "8.0.0-beta.4",
|
"babel-loader": "8.0.0-beta.4",
|
||||||
|
"cross-env": "5.2.0",
|
||||||
"http-server": "0.11.1",
|
"http-server": "0.11.1",
|
||||||
"rimraf": "2.6.2",
|
"rimraf": "2.6.2",
|
||||||
"webpack": "4.16.1",
|
"webpack": "4.16.1",
|
||||||
|
23
src/names.js
23
src/names.js
@ -1,6 +1,7 @@
|
|||||||
let Names = {};
|
let Names = {};
|
||||||
|
|
||||||
Names.Providers = {};
|
Names.Providers = {};
|
||||||
|
Names.noProviderError = 'Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")';
|
||||||
|
|
||||||
Names.registerProvider = function (providerName, obj) {
|
Names.registerProvider = function (providerName, obj) {
|
||||||
Names.Providers[providerName] = obj;
|
Names.Providers[providerName] = obj;
|
||||||
@ -19,34 +20,30 @@ Names.setProvider = function (provider, options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// resolve resolves a name into an identifier of some kind
|
// resolve resolves a name into an identifier of some kind
|
||||||
Names.resolve = function (name) {
|
Names.resolve = function (name, callback) {
|
||||||
if (!this.currentNameSystems) {
|
if (!this.currentNameSystems) {
|
||||||
throw new Error('Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")');
|
throw new Error(this.noProviderError);
|
||||||
}
|
}
|
||||||
return this.currentNameSystems.resolve(name);
|
return this.currentNameSystems.resolve(name, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
// the reverse of resolve, resolves using an identifier to get to a name
|
// the reverse of resolve, resolves using an identifier to get to a name
|
||||||
Names.lookup = function (identifier) {
|
Names.lookup = function (identifier, callback) {
|
||||||
if (!this.currentNameSystems) {
|
if (!this.currentNameSystems) {
|
||||||
throw new Error('Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")');
|
throw new Error(this.noProviderError);
|
||||||
}
|
}
|
||||||
return this.currentNameSystems.lookup(identifier);
|
return this.currentNameSystems.lookup(identifier, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Names.isAvailable = function () {
|
Names.isAvailable = function () {
|
||||||
return this.currentNameSystems.isAvailable();
|
return this.currentNameSystems.isAvailable();
|
||||||
};
|
};
|
||||||
|
|
||||||
// To Implement
|
Names.registerSubDomain = function(name, address, callback) {
|
||||||
|
|
||||||
|
|
||||||
// register a name
|
|
||||||
Names.register = function(name, options) {
|
|
||||||
if (!this.currentNameSystems) {
|
if (!this.currentNameSystems) {
|
||||||
throw new Error('Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")');
|
throw new Error(this.noProviderError);
|
||||||
}
|
}
|
||||||
return this.currentNameSystems.register(name, options);
|
return this.currentNameSystems.registerSubDomain(name, address, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Names;
|
export default Names;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user