From 7c1f34a60458e567cbf22106672255f37b3aad6a Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Sun, 9 Feb 2020 20:31:53 +0000 Subject: [PATCH 1/2] fix: block put with CID as string --- package.json | 2 +- src/core/components/block/put.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 45034674e5..1227dd8bc5 100644 --- a/package.json +++ b/package.json @@ -184,7 +184,7 @@ "form-data": "^3.0.0", "go-ipfs-dep": "^0.4.23", "hat": "0.0.3", - "interface-ipfs-core": "^0.131.7", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#test/block-put-cid-string", "ipfs-interop": "github:ipfs/interop#refactor/async-await", "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#remove-option-normalisation", "ncp": "^2.0.0", diff --git a/src/core/components/block/put.js b/src/core/components/block/put.js index 526bc23e7f..2d4b292faf 100644 --- a/src/core/components/block/put.js +++ b/src/core/components/block/put.js @@ -3,6 +3,7 @@ const Block = require('ipfs-block') const multihashing = require('multihashing-async') const CID = require('cids') +const isIPFS = require('is-ipfs') module.exports = ({ blockService, gcLock, preload }) => { return async function put (block, options) { @@ -13,8 +14,8 @@ module.exports = ({ blockService, gcLock, preload }) => { } if (!Block.isBlock(block)) { - if (options.cid && CID.isCID(options.cid)) { - block = new Block(block, options.cid) + if (options.cid && isIPFS.cid(options.cid)) { + block = new Block(block, CID.isCID(options.cid) ? options.cid : new CID(options.cid)) } else { const mhtype = options.mhtype || 'sha2-256' const format = options.format || 'dag-pb' From 94e4f8a45b76f2fa8eed872e3b0f7372eb9ff7c4 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Sun, 9 Feb 2020 23:02:40 +0000 Subject: [PATCH 2/2] chore: update interface-ipfs-core dep --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1227dd8bc5..fe8515957c 100644 --- a/package.json +++ b/package.json @@ -184,7 +184,7 @@ "form-data": "^3.0.0", "go-ipfs-dep": "^0.4.23", "hat": "0.0.3", - "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#test/block-put-cid-string", + "interface-ipfs-core": "^0.132.0", "ipfs-interop": "github:ipfs/interop#refactor/async-await", "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#remove-option-normalisation", "ncp": "^2.0.0",