From 4fb2cbe683816a17ebdb6491ef7196bc9d2634b5 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Fri, 27 Jul 2018 09:25:01 +0100 Subject: [PATCH] Adding register --- lib/modules/ipfs/embarkjs.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/modules/ipfs/embarkjs.js b/lib/modules/ipfs/embarkjs.js index e95a8eb0..f51a4388 100644 --- a/lib/modules/ipfs/embarkjs.js +++ b/lib/modules/ipfs/embarkjs.js @@ -132,10 +132,25 @@ __embarkIPFS.resolve = function (name, callback) { return callback(name + " is not registered"); } callback(err, res.value); - }) + }); }; __embarkIPFS.lookup = function () { console.error("Not Available"); }; +__embarkIPFS.register = function(addr, 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.publish(addr, function (err, res) { + if (err) { + return callback(addr + " is not publ"); + } + + callback(err, `https://gateway.ipfs.io/ipns/${res.name}`); + }); +};