mirror of https://github.com/embarklabs/embark.git
Use promise on ipns namesystem
This commit is contained in:
parent
7194b045e6
commit
4c4501a069
|
@ -5,12 +5,13 @@ __embarkIPFS.resolve = function (name, callback) {
|
|||
return callback(connectionError);
|
||||
}
|
||||
|
||||
this._ipfsConnection.name.resolve(name, (err, res) => {
|
||||
if (err) {
|
||||
this._ipfsConnection.name.resolve(name)
|
||||
.then(res => {
|
||||
callback(null, res.Path);
|
||||
})
|
||||
.catch(() => {
|
||||
return callback(name + " is not registered");
|
||||
}
|
||||
callback(err, res.value);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
__embarkIPFS.register = function(addr, options) {
|
||||
|
@ -18,13 +19,13 @@ __embarkIPFS.register = function(addr, options) {
|
|||
return new Error('No IPFS connection. Please ensure to call Embark.Names.setProvider()');
|
||||
}
|
||||
|
||||
return this._ipfsConnection.name.publish(addr, options, function (err, res) {
|
||||
if (err) {
|
||||
return new Error('No IPFS connection. Please ensure to call Embark.Names.setProvider()');
|
||||
}
|
||||
|
||||
return `https://gateway.ipfs.io/ipns/${res.name}`;
|
||||
});
|
||||
this._ipfsConnection.name.publish("/ipfs/" + addr, options)
|
||||
.then(res => {
|
||||
return `https://gateway.ipfs.io/ipns/${res.name}`;
|
||||
})
|
||||
.catch((err) => {
|
||||
return new Error('Unexpected Error: ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
__embarkIPFS.lookup = function () {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = {
|
||||
default: {
|
||||
available_providers: ["ens"],
|
||||
available_providers: ["ens", "ipns"],
|
||||
provider: "ens",
|
||||
register: {
|
||||
rootDomain: "embark.eth",
|
||||
|
|
Loading…
Reference in New Issue