2018-07-27 11:29:15 +00:00
|
|
|
/*global __embarkIPFS*/
|
|
|
|
|
2018-07-27 09:51:17 +00:00
|
|
|
__embarkIPFS.resolve = function (name, callback) {
|
|
|
|
callback = callback || function () {};
|
|
|
|
if (!this._ipfsConnection) {
|
|
|
|
var connectionError = new Error('No IPFS connection. Please ensure to call Embark.Names.setProvider()');
|
|
|
|
return callback(connectionError);
|
|
|
|
}
|
|
|
|
|
2018-07-27 11:21:52 +00:00
|
|
|
this._ipfsConnection.name.resolve(name)
|
|
|
|
.then(res => {
|
|
|
|
callback(null, res.Path);
|
|
|
|
})
|
|
|
|
.catch(() => {
|
2018-07-27 09:51:17 +00:00
|
|
|
return callback(name + " is not registered");
|
2018-07-27 11:21:52 +00:00
|
|
|
});
|
2018-07-27 09:51:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
__embarkIPFS.register = function(addr, options) {
|
|
|
|
if (!this._ipfsConnection) {
|
|
|
|
return new Error('No IPFS connection. Please ensure to call Embark.Names.setProvider()');
|
|
|
|
}
|
|
|
|
|
2018-07-27 13:09:33 +00:00
|
|
|
return this._ipfsConnection.name.publish("/ipfs/" + addr, options);
|
2018-07-27 09:51:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
__embarkIPFS.lookup = function () {
|
|
|
|
return new Error("Not Implemented");
|
|
|
|
};
|