Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 74edafd

Browse files
vmxdaviddias
authored andcommitted
chore: update to js-ipld 0.19 (#1668)
BREAKING CHANGE: dag-cbor nodes now represent links as CID objects The API for [dag-cbor](https://github.com./ipld/js-ipld-dag-cbor) changed. Links are no longer represented as JSON objects (`{"/": "base-encoded-cid"}`, but as [CID objects](https://github.com./ipld/js-cid). `ipfs.dag.get()` and now always return links as CID objects. `ipfs.dag.put()` also expects links to be represented as CID objects. The old-style JSON objects representation is still supported, but deprecated. Prior to this change: ```js const cid = new CID('QmXed8RihWcWFXRRmfSRG9yFjEbXNxu1bDwgCFAN8Dxcq5') // Link as JSON object representation const putCid = await ipfs.dag.put({link: {'/': cid.toBaseEncodedString()}}) const result = await ipfs.dag.get(putCid) console.log(result.value) ``` Output: ```js { link: { '/': <Buffer 12 20 8a…> } } ``` Now: ```js const cid = new CID('QmXed8RihWcWFXRRmfSRG9yFjEbXNxu1bDwgCFAN8Dxcq5') // Link as CID object const putCid = await ipfs.dag.put({link: cid}) const result = await ipfs.dag.get(putCid) console.log(result.value) ``` Output: ```js { link: CID { codec: 'dag-pb', version: 0, multihash: <Buffer 12 20 8a…> } } ``` See ipld/ipld#44 for more information on why this change was made.
1 parent 588891c commit 74edafd

File tree

5 files changed

+99
-51
lines changed

5 files changed

+99
-51
lines changed

examples/traverse-ipld-graphs/get-path-accross-formats.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ createNode((err, ipfs) => {
3636
const myData = {
3737
name: 'David',
3838
likes: ['js-ipfs', 'icecream', 'steak'],
39-
hobbies: [{ '/': cidPBNode.toBaseEncodedString() }]
39+
hobbies: [cidPBNode]
4040
}
4141

4242
ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha3-512' }, (err, cid) => {

package.json

+52-47
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@
5959
},
6060
"homepage": "https://github.com./ipfs/js-ipfs#readme",
6161
"devDependencies": {
62-
"aegir": "^15.1.0",
63-
"chai": "^4.1.2",
64-
"delay": "^3.0.0",
65-
"detect-node": "^2.0.3",
62+
"aegir": "^17.0.1",
63+
"chai": "^4.2.0",
64+
"delay": "^4.1.0",
65+
"detect-node": "^2.0.4",
6666
"dir-compare": "^1.4.0",
6767
"dirty-chai": "^2.0.1",
68-
"execa": "~0.10.0",
69-
"form-data": "^2.3.2",
68+
"execa": "^1.0.0",
69+
"form-data": "^2.3.3",
7070
"hat": "0.0.3",
71-
"interface-ipfs-core": "~0.78.0",
72-
"ipfsd-ctl": "~0.39.3",
71+
"interface-ipfs-core": "~0.83.0",
72+
"ipfsd-ctl": "~0.39.5",
7373
"ncp": "^2.0.0",
7474
"qs": "^6.5.2",
7575
"rimraf": "^2.6.2",
@@ -78,95 +78,100 @@
7878
"dependencies": {
7979
"@nodeutils/defaults-deep": "^1.1.0",
8080
"async": "^2.6.1",
81-
"big.js": "^5.1.2",
81+
"big.js": "^5.2.2",
8282
"binary-querystring": "~0.1.2",
83-
"bl": "^2.0.1",
83+
"bl": "^2.1.2",
8484
"boom": "^7.2.0",
8585
"bs58": "^4.0.1",
8686
"byteman": "^1.3.5",
8787
"cid-tool": "~0.1.0",
88-
"cids": "~0.5.3",
89-
"debug": "^3.1.0",
88+
"cids": "~0.5.5",
89+
"debug": "^4.1.0",
9090
"err-code": "^1.1.2",
91-
"file-type": "^8.1.0",
91+
"file-type": "^10.2.0",
9292
"fnv1a": "^1.0.1",
9393
"fsm-event": "^2.1.0",
9494
"get-folder-size": "^2.0.0",
95-
"glob": "^7.1.2",
95+
"glob": "^7.1.3",
9696
"hapi": "^16.6.2",
9797
"hapi-set-header": "^1.0.2",
98-
"hoek": "^5.0.3",
98+
"hoek": "^5.0.4",
9999
"human-to-milliseconds": "^1.0.0",
100100
"interface-datastore": "~0.6.0",
101-
"ipfs-api": "^24.0.0",
102-
"ipfs-bitswap": "~0.20.3",
103-
"ipfs-block": "~0.7.1",
104-
"ipfs-block-service": "~0.14.0",
105-
"ipfs-http-response": "~0.1.2",
106-
"ipfs-mfs": "~0.4.0",
101+
"ipfs-api": "^26.0.3",
102+
"ipfs-bitswap": "~0.21.0",
103+
"ipfs-block": "~0.8.0",
104+
"ipfs-block-service": "~0.15.1",
105+
"ipfs-http-response": "~0.2.0",
106+
"ipfs-mfs": "~0.4.2",
107107
"ipfs-multipart": "~0.1.0",
108-
"ipfs-repo": "~0.24.0",
109-
"ipfs-unixfs": "~0.1.15",
110-
"ipfs-unixfs-engine": "~0.32.3",
111-
"ipld": "~0.17.3",
112-
"ipld-dag-pb": "~0.14.6",
108+
"ipfs-repo": "~0.25.0",
109+
"ipfs-unixfs": "~0.1.16",
110+
"ipfs-unixfs-engine": "~0.33.0",
111+
"ipld-dag-pb": "~0.14.11",
113112
"ipns": "~0.3.0",
114-
"is-ipfs": "~0.4.2",
113+
"ipld": "~0.19.1",
114+
"ipld-bitcoin": "~0.1.8",
115+
"ipld-ethereum": "^2.0.1",
116+
"ipld-git": "~0.2.2",
117+
"ipld-raw": "^2.0.1",
118+
"ipld-zcash": "~0.1.6",
119+
"is-ipfs": "~0.4.7",
115120
"is-pull-stream": "~0.0.0",
116121
"is-stream": "^1.1.0",
117122
"joi": "^13.4.0",
118123
"joi-browser": "^13.4.0",
119124
"joi-multiaddr": "^2.0.0",
120-
"libp2p": "~0.23.0",
125+
"libp2p": "~0.23.1",
121126
"libp2p-bootstrap": "~0.9.3",
122-
"libp2p-crypto": "~0.13.0",
123-
"libp2p-kad-dht": "~0.10.1",
124-
"libp2p-keychain": "~0.3.1",
127+
"libp2p-crypto": "~0.14.0",
128+
"libp2p-kad-dht": "~0.10.6",
129+
"libp2p-keychain": "~0.3.3",
125130
"libp2p-mdns": "~0.12.0",
126-
"libp2p-mplex": "~0.8.0",
131+
"libp2p-mplex": "~0.8.2",
127132
"libp2p-record": "~0.6.0",
128133
"libp2p-secio": "~0.10.0",
129-
"libp2p-tcp": "~0.12.0",
130-
"libp2p-webrtc-star": "~0.15.3",
131-
"libp2p-websocket-star": "~0.8.1",
134+
"libp2p-tcp": "~0.13.0",
135+
"libp2p-webrtc-star": "~0.15.5",
136+
"libp2p-websocket-star": "~0.9.0",
132137
"libp2p-websockets": "~0.12.0",
133-
"lodash": "^4.17.10",
134-
"mafmt": "^6.0.0",
135-
"mime-types": "^2.1.19",
138+
"lodash": "^4.17.11",
139+
"mafmt": "^6.0.2",
140+
"mime-types": "^2.1.21",
136141
"mkdirp": "~0.5.1",
137142
"multiaddr": "^5.0.0",
138143
"multiaddr-to-uri": "^4.0.0",
139144
"multibase": "~0.5.0",
140-
"multihashes": "~0.4.13",
145+
"multihashes": "~0.4.14",
141146
"once": "^1.4.0",
142147
"peer-book": "~0.8.0",
143148
"peer-id": "~0.12.0",
144149
"peer-info": "~0.14.1",
145-
"progress": "^2.0.0",
150+
"progress": "^2.0.1",
146151
"promisify-es6": "^1.0.3",
147152
"pull-abortable": "^4.1.1",
148-
"pull-defer": "~0.2.2",
153+
"pull-defer": "~0.2.3",
149154
"pull-file": "^1.1.0",
150155
"pull-ndjson": "~0.1.1",
151156
"pull-paramap": "^1.2.2",
152157
"pull-pushable": "^2.2.0",
153158
"pull-sort": "^1.0.1",
154-
"pull-stream": "^3.6.8",
159+
"pull-stream": "^3.6.9",
155160
"pull-stream-to-stream": "^1.3.4",
156161
"pull-zip": "^2.0.1",
157162
"read-pkg-up": "^4.0.0",
158-
"readable-stream": "2.3.6",
163+
"readable-stream": "3.0.6",
159164
"receptacle": "^1.3.2",
160165
"stream-to-pull-stream": "^1.7.2",
161-
"tar-stream": "^1.6.1",
166+
"tar-stream": "^1.6.2",
162167
"temp": "~0.8.3",
163168
"update-notifier": "^2.5.0",
164-
"yargs": "^12.0.1",
169+
"yargs": "^12.0.2",
165170
"yargs-promise": "^1.1.0"
166171
},
167172
"optionalDependencies": {
168-
"prom-client": "^11.1.1",
169-
"prometheus-gc-stats": "~0.5.1"
173+
"prom-client": "^11.1.3",
174+
"prometheus-gc-stats": "~0.6.0"
170175
},
171176
"contributors": [
172177
"0xflotus <[email protected]>",

src/cli/utils.js

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ const Progress = require('progress')
1111
const byteman = require('byteman')
1212
const promisify = require('promisify-es6')
1313

14+
// All known IPLD formats
15+
const ipldBitcoin = require('ipld-bitcoin')
16+
const ipldDagCbor = require('ipld-dag-cbor')
17+
const ipldDagPb = require('ipld-dag-pb')
18+
const ipldEthAccountSnapshot = require('ipld-ethereum').ethAccountSnapshot
19+
const ipldEthBlock = require('ipld-ethereum').ethBlock
20+
const ipldEthBlockList = require('ipld-ethereum').ethBlockList
21+
const ipldEthStateTrie = require('ipld-ethereum').ethStateTrie
22+
const ipldEthStorageTrie = require('ipld-ethereum').ethStorageTrie
23+
const ipldEthTrie = require('ipld-ethereum').ethTxTrie
24+
const ipldEthTx = require('ipld-ethereum').ethTx
25+
const ipldGit = require('ipld-git')
26+
const ipldRaw = require('ipld-raw')
27+
const ipldZcash = require('ipld-zcash')
28+
1429
exports = module.exports
1530

1631
exports.isDaemonOn = isDaemonOn

src/core/index.js

+26-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ const debug = require('debug')
1515
const extend = require('deep-extend')
1616
const EventEmitter = require('events')
1717

18+
// All known IPLD formats
19+
const ipldBitcoin = require('ipld-bitcoin')
20+
const ipldDagCbor = require('ipld-dag-cbor')
21+
const ipldDagPb = require('ipld-dag-pb')
22+
const ipldEthAccountSnapshot = require('ipld-ethereum').ethAccountSnapshot
23+
const ipldEthBlock = require('ipld-ethereum').ethBlock
24+
const ipldEthBlockList = require('ipld-ethereum').ethBlockList
25+
const ipldEthStateTrie = require('ipld-ethereum').ethStateTrie
26+
const ipldEthStorageTrie = require('ipld-ethereum').ethStorageTrie
27+
const ipldEthTrie = require('ipld-ethereum').ethTxTrie
28+
const ipldEthTx = require('ipld-ethereum').ethTx
29+
const ipldGit = require('ipld-git')
30+
const ipldRaw = require('ipld-raw')
31+
const ipldZcash = require('ipld-zcash')
32+
1833
const config = require('./config')
1934
const boot = require('./boot')
2035
const components = require('./components')
@@ -72,7 +87,9 @@ class IPFS extends EventEmitter {
7287
multiaddr: multiaddr,
7388
multibase: multibase,
7489
multihash: multihash,
75-
CID: CID
90+
CID: CID,
91+
dagPB: ipldDagPb,
92+
dagCBOR: ipldDagCbor
7693
}
7794

7895
// IPFS Core Internals
@@ -82,7 +99,14 @@ class IPFS extends EventEmitter {
8299
this._libp2pNode = undefined
83100
this._bitswap = undefined
84101
this._blockService = new BlockService(this._repo)
85-
this._ipld = new Ipld(this._blockService)
102+
this._ipld = new Ipld({
103+
blockService: this._blockService,
104+
formats: [
105+
ipldBitcoin, ipldDagCbor, ipldDagPb, ipldEthAccountSnapshot,
106+
ipldEthBlock, ipldEthBlockList, ipldEthStateTrie, ipldEthStorageTrie,
107+
ipldEthTrie, ipldEthTx, ipldGit, ipldRaw, ipldZcash
108+
]
109+
})
86110
this._preload = preload(this)
87111
this._mfsPreload = mfsPreload(this)
88112
this._ipns = new IPNS(null, this)

test/core/init.spec.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const isIPFS = require('is-ipfs')
1515
const multiaddr = require('multiaddr')
1616
const multibase = require('multibase')
1717
const multihash = require('multihashes')
18+
const ipldDagCbor = require('ipld-dag-cbor')
19+
const ipldDagPb = require('ipld-dag-pb')
1820
const CID = require('cids')
1921
const IPFS = require('../../src/core')
2022

@@ -120,7 +122,9 @@ describe('init', () => {
120122
multiaddr: multiaddr,
121123
multibase: multibase,
122124
multihash: multihash,
123-
CID: CID
125+
CID: CID,
126+
dagPB: ipldDagPb,
127+
dagCBOR: ipldDagCbor
124128
})
125129
})
126130

0 commit comments

Comments
 (0)