diff --git a/package.json b/package.json index 6ca11e0338..1ce98a121d 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "execa": "^1.0.0", "form-data": "^2.3.3", "hat": "0.0.3", - "interface-ipfs-core": "~0.97.1", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#refactor/cidv1b32-default", "ipfsd-ctl": "~0.41.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0", @@ -86,8 +86,8 @@ "boom": "^7.2.0", "bs58": "^4.0.1", "byteman": "^1.3.5", - "cid-tool": "~0.2.0", - "cids": "~0.5.5", + "cid-tool": "github:multiformats/js-cid-tool#refactor/cidv1base32-default", + "cids": "github:multiformats/js-cid#refactor/cidv1base32-default", "class-is": "^1.1.0", "datastore-core": "~0.6.0", "datastore-pubsub": "~0.1.1", @@ -103,24 +103,24 @@ "hoek": "^6.1.2", "human-to-milliseconds": "^1.0.0", "interface-datastore": "~0.6.0", - "ipfs-bitswap": "~0.22.0", - "ipfs-block": "~0.8.0", + "ipfs-bitswap": "github:ipfs/js-ipfs-bitswap#refactor/cidv1base32-default", + "ipfs-block": "github:ipfs/js-ipfs-block#refactor/cidv1base32-default", "ipfs-block-service": "~0.15.1", "ipfs-http-client": "^29.0.0", - "ipfs-http-response": "~0.2.1", - "ipfs-mfs": "~0.9.1", + "ipfs-http-response": "github:ipfs/js-ipfs-http-response#refactor/cidv1base32-default", + "ipfs-mfs": "github:ipfs/js-ipfs-mfs#refactor/cidv1b32-default", "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.26.1", "ipfs-unixfs": "~0.1.16", - "ipfs-unixfs-engine": "~0.35.3", - "ipld": "~0.21.1", - "ipld-bitcoin": "~0.1.8", - "ipld-dag-pb": "~0.15.0", - "ipld-ethereum": "^2.0.1", - "ipld-git": "~0.2.2", - "ipld-zcash": "~0.1.6", + "ipfs-unixfs-engine": "github:ipfs/js-ipfs-unixfs-engine#refactor/cidv1b32-default", + "ipld": "github:ipld/js-ipld#refactor/cidv1base32-default", + "ipld-bitcoin": "github:ipld/js-ipld-bitcoin#refactor/cidv1base32-default", + "ipld-dag-pb": "github:ipld/js-ipld-dag-pb#refactor/cidv1b32-default", + "ipld-ethereum": "github:ipld/js-ipld-ethereum#refactor/cidv1base32-default", + "ipld-git": "github:ipld/js-ipld-git#refactor/cidv1base32-default", + "ipld-zcash": "github:ipld/js-ipld-zcash#refactor/cidv1base32-default", "ipns": "~0.5.0", - "is-ipfs": "~0.4.8", + "is-ipfs": "github:ipfs/is-ipfs#refactor/cidv1base32-default", "is-pull-stream": "~0.0.0", "is-stream": "^1.1.0", "joi": "^14.3.0", diff --git a/src/core/components/block.js b/src/core/components/block.js index 6a1bb960d1..290a767b62 100644 --- a/src/core/components/block.js +++ b/src/core/components/block.js @@ -56,16 +56,9 @@ module.exports = function block (self) { const mhtype = options.mhtype || 'sha2-256' const format = options.format || 'dag-pb' - let cidVersion + const cidVersion = options.version == null ? 1 : options.version // const mhlen = options.mhlen || 0 - if (options.version == null) { - // Pick appropriate CID version - cidVersion = mhtype === 'sha2-256' && format === 'dag-pb' ? 0 : 1 - } else { - cidVersion = options.version - } - multihashing(block, mhtype, (err, multihash) => { if (err) { return cb(err) diff --git a/src/core/components/files-regular/add-pull-stream.js b/src/core/components/files-regular/add-pull-stream.js index 0d56b5e459..90ebfe373f 100644 --- a/src/core/components/files-regular/add-pull-stream.js +++ b/src/core/components/files-regular/add-pull-stream.js @@ -27,7 +27,7 @@ function prepareFile (file, self, opts, callback) { ? cb(null, file) : self.object.get(file.multihash, Object.assign({}, opts, { preload: false }), cb), (node, cb) => { - const b58Hash = cid.toBaseEncodedString() + const cidStr = cid.toBaseEncodedString() let size = node.size @@ -38,8 +38,8 @@ function prepareFile (file, self, opts, callback) { cb(null, { path: opts.wrapWithDirectory ? file.path.substring(WRAPPER.length) - : (file.path || b58Hash), - hash: b58Hash, + : (file.path || cidStr), + hash: cidStr, size }) } diff --git a/src/core/components/object.js b/src/core/components/object.js index 85a3137522..77043ddbf3 100644 --- a/src/core/components/object.js +++ b/src/core/components/object.js @@ -8,7 +8,6 @@ const dagPB = require('ipld-dag-pb') const DAGNode = dagPB.DAGNode const DAGLink = dagPB.DAGLink const CID = require('cids') -const mh = require('multihashes') const Unixfs = require('ipfs-unixfs') const errCode = require('err-code') @@ -50,7 +49,7 @@ function parseJSONBuffer (buf, callback) { return new DAGLink( link.Name || link.name, link.Size || link.size, - mh.fromB58String(link.Hash || link.hash || link.multihash) + link.Hash || link.hash || link.multihash ) }) data = Buffer.from(parsed.Data) @@ -88,7 +87,7 @@ module.exports = function object (self) { } self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { @@ -138,7 +137,7 @@ module.exports = function object (self) { } self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { @@ -201,7 +200,7 @@ module.exports = function object (self) { function next () { self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { diff --git a/test/cli/object.js b/test/cli/object.js index ceb9f24627..10684aef25 100644 --- a/test/cli/object.js +++ b/test/cli/object.js @@ -34,8 +34,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should new and print CID encoded in specified base', () => { + it('should new and print CID encoded in specified base', () => { return ipfs('object new --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n' @@ -103,8 +102,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should put and print CID encoded in specified base', () => { + it('should put and print CID encoded in specified base', () => { return ipfs('object put test/fixtures/test-data/node.json --cid-base=base64') .then((out) => { expect(out).to.eql( @@ -188,8 +186,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should append-data and print CID encoded in specified base', () => { + it('should append-data and print CID encoded in specified base', () => { return ipfs('object patch append-data QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n test/fixtures/test-data/badconfig --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n' @@ -205,8 +202,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should set-data and print CID encoded in specified base', () => { + it('should set-data and print CID encoded in specified base', () => { return ipfs('object patch set-data QmfY37rjbPCZRnhvvJuQ46htW3VCAWziVB991P79h6WSv6 test/fixtures/test-data/badconfig --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n' @@ -222,8 +218,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should add-link and print CID encoded in specified base', () => { + it('should add-link and print CID encoded in specified base', () => { return ipfs('object patch add-link QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n foo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOEVPbXq2xYoEsRZhaPB61btcy1x359osjv4a2L/lgPs\n' @@ -239,8 +234,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should rm-link and print CID encoded in specified base', () => { + it('should rm-link and print CID encoded in specified base', () => { return ipfs('object patch rm-link QmdVHE8fUD6FLNLugtNxqDFyhaCgdob372hs6BYEe75VAK foo --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n' diff --git a/test/http-api/inject/object.js b/test/http-api/inject/object.js index e329e98c64..13c5de8766 100644 --- a/test/http-api/inject/object.js +++ b/test/http-api/inject/object.js @@ -33,8 +33,7 @@ module.exports = (http) => { expect(res.result.Links).to.be.eql([]) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should create a new object and return a base64 encoded CID', async () => { + it('should create a new object and return a base64 encoded CID', async () => { const res = await api.inject({ method: 'POST', url: '/api/v0/object/new?cid-base=base64' @@ -88,8 +87,7 @@ module.exports = (http) => { expect(res.result.Data).to.be.empty() }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should get object and return a base64 encoded CID', async () => { + it('should get object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -185,8 +183,7 @@ module.exports = (http) => { expect(res.result).to.eql(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should put data and return a base64 encoded CID', async () => { + it('should put data and return a base64 encoded CID', async () => { const form = new FormData() form.append('file', JSON.stringify({ Data: 'TEST' + Date.now(), Links: [] }), { filename: 'node.json' }) const headers = form.getHeaders() @@ -258,8 +255,7 @@ module.exports = (http) => { expect(res.result.CumulativeSize).to.equal(60 + 8) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should stat object and return a base64 encoded CID', async () => { + it('should stat object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -366,8 +362,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should list object links and return a base64 encoded CID', async () => { + it('should list object links and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -509,8 +504,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should append data to object and return a base64 encoded CID', async () => { + it('should append data to object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -624,8 +618,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should set data for object and return a base64 encoded CID', async () => { + it('should set data for object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -731,8 +724,7 @@ module.exports = (http) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should add a link to an object and return a base64 encoded CID', async () => { + it('should add a link to an object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -820,8 +812,7 @@ module.exports = (http) => { expect(res.result.Hash).to.equal('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n') }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should remove a link from an object and return a base64 encoded CID', async () => { + it('should remove a link from an object and return a base64 encoded CID', async () => { const linkName = 'TEST' + Date.now() let res = await api.inject({