Merge pull request #8 from embark-framework/features/ens

Change functions for ENS
This commit is contained in:
Iuri Matias 2018-07-27 14:31:39 -04:00 committed by GitHub
commit 5207c450a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 15 deletions

View File

@ -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",

View File

@ -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;