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