Move ipns function to ipfs

This commit is contained in:
Anthony Laibe 2018-08-22 10:14:25 +01:00
parent e7531dead4
commit f5ce019140
2 changed files with 20 additions and 12 deletions

View File

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

View File

@ -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();
};