diff --git a/src/names.js b/src/names.js index 7394e51..9d95abc 100644 --- a/src/names.js +++ b/src/names.js @@ -46,11 +46,4 @@ Names.registerSubDomain = function(name, address, callback) { return this.currentNameSystems.registerSubDomain(name, address, callback); }; -Names.register = function(name, callback) { - if (!this.currentNameSystems) { - throw new Error(this.noProviderError); - } - return this.currentNameSystems.register(name, callback); -}; - export default Names; diff --git a/src/storage.js b/src/storage.js index 2bae51f..de3455f 100644 --- a/src/storage.js +++ b/src/storage.js @@ -3,35 +3,50 @@ import {detectSeries} from 'async'; const Storage = {}; Storage.Providers = {}; +Storage.noProviderError = 'Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'; Storage.saveText = function (text) { if (!this.currentStorage) { - throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + throw new Error(this.noProviderError); } return this.currentStorage.saveText(text); }; Storage.get = function (hash) { if (!this.currentStorage) { - throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + throw new Error(this.noProviderError); } return this.currentStorage.get(hash); }; Storage.uploadFile = function (inputSelector) { if (!this.currentStorage) { - throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + throw new Error(this.noProviderError); } return this.currentStorage.uploadFile(inputSelector); }; Storage.getUrl = function (hash) { if (!this.currentStorage) { - throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + throw new Error(this.noProviderError); } return this.currentStorage.getUrl(hash); }; +Storage.resolve = function (name, callback) { + if (!this.currentStorage) { + throw new Error(this.noProviderError); + } + return this.currentStorage.resolve(name, callback); +}; + +Storage.register = function (addr, callback) { + if (!this.currentStorage) { + throw new Error(this.noProviderError); + } + return this.currentStorage.register(addr, callback); +}; + Storage.registerProvider = function (providerName, obj) { this.Providers[providerName] = obj; }; @@ -50,7 +65,7 @@ Storage.setProvider = function (provider, options) { Storage.isAvailable = function () { if (!this.currentStorage) { - throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + throw new Error(this.noProviderError); } return this.currentStorage.isAvailable(); };