diff --git a/package.json b/package.json index 61ce838..9d9feeb 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ ], "scripts": { "babel": "npm run babel:browser && npm run babel:node", - "babel:browser": "BABEL_ENV=browser babel --out-dir dist/browser src", - "babel:node": "BABEL_ENV=node babel --out-dir dist src", + "babel:browser": "cross-env BABEL_ENV=browser babel --out-dir dist/browser src", + "babel:node": "cross-env BABEL_ENV=node babel --out-dir dist src", "build": "npm run clean && npm run babel && npm run webpack", "clean": "rimraf dist embark.min.js embarkjs-*.tgz package", "http-server": "http-server", @@ -57,6 +57,7 @@ "@babel/preset-env": "7.0.0-beta.54", "ajv": "6.5.2", "babel-loader": "8.0.0-beta.4", + "cross-env": "5.2.0", "http-server": "0.11.1", "rimraf": "2.6.2", "webpack": "4.16.1", diff --git a/src/names.js b/src/names.js index baad2ed..9d95abc 100644 --- a/src/names.js +++ b/src/names.js @@ -1,6 +1,7 @@ let Names = {}; Names.Providers = {}; +Names.noProviderError = 'Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")'; Names.registerProvider = function (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 -Names.resolve = function (name) { +Names.resolve = function (name, callback) { 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 -Names.lookup = function (identifier) { +Names.lookup = function (identifier, callback) { 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 () { return this.currentNameSystems.isAvailable(); }; -// To Implement - - -// register a name -Names.register = function(name, options) { +Names.registerSubDomain = function(name, address, callback) { 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;