mirror of https://github.com/embarklabs/embark.git
Add ipns resolve
This commit is contained in:
parent
2e9fa345be
commit
1427b4596d
|
@ -120,4 +120,22 @@ __embarkIPFS.getUrl = function (hash) {
|
||||||
return (this._getUrl || "http://localhost:8080/ipfs/") + hash;
|
return (this._getUrl || "http://localhost:8080/ipfs/") + hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
__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);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._ipfsConnection.name.resolve(name, (err, res) => {
|
||||||
|
if (err) {
|
||||||
|
return callback(name + " is not registered");
|
||||||
|
}
|
||||||
|
callback(err, res.value);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
__embarkIPFS.lookup = function () {
|
||||||
|
console.error("Not Available");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ class IPFS {
|
||||||
let code = "";
|
let code = "";
|
||||||
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
|
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
|
||||||
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS);";
|
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS);";
|
||||||
|
code += "\nEmbarkJS.Names.registerProvider('ipns', __embarkIPFS);";
|
||||||
|
|
||||||
this.embark.addCodeToEmbarkJS(code);
|
this.embark.addCodeToEmbarkJS(code);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue