diff --git a/package.json b/package.json index 499e3f32e..ac1777e5f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ipfs-api", "version": "9.0.0", "description": "A client library for the IPFS HTTP API. Follows interface-ipfs-core spec", - "main": "lib/index.js", + "main": "src/index.js", "jsnext:main": "src/index.js", "scripts": { "test": "node --max_old_space_size=4096 node_modules/.bin/gulp test:node", @@ -103,4 +103,4 @@ "url": "https://github.com/ipfs/js-ipfs-api/issues" }, "homepage": "https://github.com/ipfs/js-ipfs-api" -} \ No newline at end of file +} diff --git a/src/api/block.js b/src/api/block.js index e7458c023..41c880408 100644 --- a/src/api/block.js +++ b/src/api/block.js @@ -3,14 +3,21 @@ const promisify = require('promisify-es6') const bl = require('bl') const Block = require('ipfs-block') +const multihash = require('multihashes') +const CID = require('cids') module.exports = (send) => { return { get: promisify((args, opts, callback) => { + // TODO this needs to be adjusted with the new go-ipfs http-api + if (args && CID.isCID(args)) { + args = multihash.toB58String(args.multihash) + } if (typeof (opts) === 'function') { callback = opts opts = {} } + return send({ path: 'block/get', args: args, @@ -32,6 +39,11 @@ module.exports = (send) => { }) }), stat: promisify((args, opts, callback) => { + // TODO this needs to be adjusted with the new go-ipfs http-api + if (args && CID.isCID(args)) { + args = multihash.toB58String(args.multihash) + } + if (typeof (opts) === 'function') { callback = opts opts = {} @@ -50,7 +62,13 @@ module.exports = (send) => { }) }) }), - put: promisify((block, callback) => { + put: promisify((block, cid, callback) => { + // TODO this needs to be adjusted with the new go-ipfs http-api + if (typeof cid === 'function') { + callback = cid + cid = {} + } + if (Array.isArray(block)) { const err = new Error('block.put() only accepts 1 file') return callback(err)