diff --git a/package.json b/package.json index 5e75340cac..555d3ec5de 100644 --- a/package.json +++ b/package.json @@ -68,8 +68,8 @@ "execa": "^1.0.0", "form-data": "^2.3.3", "hat": "0.0.3", - "interface-ipfs-core": "~0.84.2", - "ipfsd-ctl": "~0.39.5", + "interface-ipfs-core": "~0.86.0", + "ipfsd-ctl": "ipfs/js-ipfsd-ctl#update-dag-pb-to-not-have-cid-property", "ncp": "^2.0.0", "qs": "^6.5.2", "rimraf": "^2.6.2", @@ -98,19 +98,20 @@ "hoek": "^5.0.4", "human-to-milliseconds": "^1.0.0", "interface-datastore": "~0.6.0", - "ipfs-api": "^26.1.0", + "ipfs-api": "ipfs/js-ipfs-api", "ipfs-bitswap": "~0.21.0", "ipfs-block": "~0.8.0", "ipfs-block-service": "~0.15.1", - "ipfs-http-response": "~0.2.0", + "ipfs-http-response": "~0.2.1", "ipfs-mfs": "~0.4.2", "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.25.0", "ipfs-unixfs": "~0.1.16", "ipfs-unixfs-engine": "~0.33.0", - "ipld": "~0.19.3", + "ipld": "~0.20.0", + "ipld-bitcoin": "~0.1.8", + "ipld-dag-pb": "~0.15.0", "ipld-bitcoin": "~0.1.8", - "ipld-dag-pb": "~0.14.11", "ipld-ethereum": "^2.0.1", "ipld-git": "~0.2.2", "ipld-zcash": "~0.1.6", diff --git a/src/cli/commands/object/get.js b/src/cli/commands/object/get.js index 80190d8d96..ccc4b466ab 100644 --- a/src/cli/commands/object/get.js +++ b/src/cli/commands/object/get.js @@ -1,6 +1,11 @@ 'use strict' const print = require('../../utils').print +const { + util: { + cid + } +} = require('ipld-dag-pb') module.exports = { command: 'get ', @@ -11,6 +16,10 @@ module.exports = { 'data-encoding': { type: 'string', default: 'base64' + }, + 'cid-base': { + default: 'base58btc', + describe: 'CID base to use.' } }, @@ -19,26 +28,33 @@ module.exports = { if (err) { throw err } - const nodeJSON = node.toJSON() - - if (Buffer.isBuffer(node.data)) { - nodeJSON.data = node.data.toString(argv['data-encoding'] || undefined) - } - - const answer = { - Data: nodeJSON.data, - Hash: nodeJSON.multihash, - Size: nodeJSON.size, - Links: nodeJSON.links.map((l) => { - return { - Name: l.name, - Size: l.size, - Hash: l.multihash - } - }) - } - print(JSON.stringify(answer)) + cid(node, (err, result) => { + if (err) { + throw err + } + + let data = node.data + + if (Buffer.isBuffer(data)) { + data = node.data.toString(argv.dataEncoding || undefined) + } + + const answer = { + Data: data, + Hash: result.toBaseEncodedString(argv.cidBase), + Size: node.size, + Links: node.links.map((l) => { + return { + Name: l.name, + Size: l.size, + Hash: l.cid.toBaseEncodedString(argv.cidBase) + } + }) + } + + print(JSON.stringify(answer)) + }) }) } } diff --git a/src/cli/commands/object/links.js b/src/cli/commands/object/links.js index d657820fb4..9a3a3e203e 100644 --- a/src/cli/commands/object/links.js +++ b/src/cli/commands/object/links.js @@ -7,7 +7,12 @@ module.exports = { describe: 'Outputs the links pointed to by the specified object', - builder: {}, + builder: { + 'cid-base': { + default: 'base58btc', + describe: 'CID base to use.' + } + }, handler (argv) { argv.ipfs.object.links(argv.key, { @@ -18,9 +23,7 @@ module.exports = { } links.forEach((link) => { - link = link.toJSON() - - print(`${link.multihash} ${link.size} ${link.name}`) + print(`${link.cid.toBaseEncodedString(argv.cidBase)} ${link.size} ${link.name}`) }) }) } diff --git a/src/cli/commands/object/new.js b/src/cli/commands/object/new.js index f96db85fb2..36ab5a3659 100644 --- a/src/cli/commands/object/new.js +++ b/src/cli/commands/object/new.js @@ -4,13 +4,23 @@ const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') const print = require('../../utils').print +const { + util: { + cid + } +} = require('ipld-dag-pb') module.exports = { command: 'new [