Skip to content

Commit bf86a3e

Browse files
committed
feat: upgrade to ipfs@0.41
1 parent a6a4f5c commit bf86a3e

40 files changed

+23464
-7470
lines changed

DEVELOPING_TUTORIALS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ If the object returned by your `validate` function has the property `fail`, the
377377
You may (optionally) use [markdown formatting](https://guides.github.com/features/mastering-markdown/) in your `fail` or `success` messages. For example, the following validation code:
378378

379379
```js
380-
} else if (result && !result.hash) {
380+
} else if (result && !result.cid) {
381381
return { fail: "That result doesn't look right. Are you sure you ran the `stat` method on your empty root directory?" }
382382
}
383383
```

package-lock.json

Lines changed: 23042 additions & 7232 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
"async": "^2.6.1",
1818
"cids": "^0.7.1",
1919
"highlight.js": "^9.12.0",
20-
"ipfs": "^0.39.0",
20+
"ipfs": "^0.41.0",
2121
"ipfs-css": "^0.6.0",
22+
"it-all": "^1.0.1",
23+
"it-concat": "^1.0.0",
2224
"meta-marked": "^0.4.2",
2325
"monaco-editor": "^0.6.1",
2426
"new-github-issue-url": "^0.2.1",

src/components/Lesson.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
import Vue from 'vue'
108108
import CID from 'cids'
109109
import pTimeout from 'p-timeout'
110+
import all from 'it-all'
110111
import newGithubIssueUrl from 'new-github-issue-url'
111112
112113
import { getTutorialByUrl, isTutorialPassed, getLesson } from '../utils/tutorials'
@@ -404,7 +405,7 @@ export default {
404405
} else {
405406
const ipfs = this.IPFSPromise.then(IPFS => {
406407
this.ipfsConstructor = IPFS
407-
return new IPFS({ repo: Math.random().toString() })
408+
return IPFS.create({ repo: Math.random().toString() })
408409
})
409410
return ipfs
410411
}
@@ -413,14 +414,14 @@ export default {
413414
// create a sample file for the user to read from, acessible at this CID:
414415
// QmWCscor6qWPdx53zEQmZvQvuWQYxx1ARRCXwYVE4s9wzJ
415416
/* eslint-disable no-new */
416-
return ipfs.add(this.ipfsConstructor.Buffer.from('You did it!'))
417+
return all(ipfs.add(this.ipfsConstructor.Buffer.from('You did it!')))
417418
},
418419
createTree: function (ipfs) {
419420
// create a sample directory for the user to read from, acessible at these CIDs:
420421
// top-level directory: QmcmnUvVV31txDfAddgAaNcNKbrtC2rC9FvkJphNWyM7gy
421422
// `fun` directory: QmPT14mWCteuybfrfvqas2L2oin1Y2NCbwzTh9cc33GM1r
422423
/* eslint-disable no-new */
423-
return ipfs.add([
424+
return all(ipfs.add([
424425
{
425426
content: this.ipfsConstructor.Buffer.from('¯\\_(ツ)_/¯'),
426427
path: 'shrug.txt'
@@ -433,7 +434,7 @@ export default {
433434
content: this.ipfsConstructor.Buffer.from('You did it!'),
434435
path: 'fun/success.txt'
435436
}
436-
], { wrapWithDirectory: true })
437+
], { wrapWithDirectory: true }))
437438
},
438439
resetCode: function () {
439440
// TRACK? User chose to reset code

src/tutorials/0002-basics/01.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ const validate = async (result, ipfs) => {
99
return { fail: 'Did not return a valid CID instance.' }
1010
}
1111

12-
const hash = 'bafyreicaoyussrycqolu4k2iaxleu2uakjlq57tuxq3djxn4wnyfp4yk3y'
13-
if (result.toString() === hash) {
12+
if (result.toString() === 'bafyreicaoyussrycqolu4k2iaxleu2uakjlq57tuxq3djxn4wnyfp4yk3y') {
1413
return { success: 'Everything works!' }
1514
} else {
1615
const obj = await ipfs.dag.get(result)

src/tutorials/0002-basics/02.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ const validate = async (result, ipfs) => {
99
return { fail: 'Did not return a valid CID instance.' }
1010
}
1111

12-
const correctHash = 'bafyreibmdfd7c5db4kls4ty57zljfhqv36gi43l6txl44pi423wwmeskwy'
13-
if (result.toString() === correctHash) {
12+
if (result.toString() === 'bafyreibmdfd7c5db4kls4ty57zljfhqv36gi43l6txl44pi423wwmeskwy') {
1413
return { success: 'Everything works!' }
1514
} else {
1615
return { fail: `Your function returned a CID, but it doesn't have the right contents. Be sure to \`put\` an object with \`bar\` as the named link and \`cid\` as its value.` }

src/tutorials/0004-mutable-file-system/02.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
const validate = async (result, ipfs) => {
2-
const correctHash = 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'
1+
import utils from '../utils'
32

3+
const validate = async (result, ipfs) => {
44
if (!result) {
55
return { fail: 'Oops! You forgot to return a result :(' }
6-
} else if (!!result & !result.hash) {
6+
} else if (!!result & !result.cid) {
77
return { fail: "That result doesn't look right. Are you sure you ran the `stat` method on your empty root directory?" }
8-
} else if (!!result && result.hash === correctHash) {
8+
} else if (!!result && result.cid.toString() === 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn') {
99
return {
1010
success: 'Success! You did it!',
11-
logDesc: "Here's the status of your root directory ( `/` ). Notice that it has a hash (CID) even though it doesn't have contents yet. Every empty IPFS node has this exact same hash, because their non-existent contents are identical!",
12-
log: result
11+
logDesc: "Here's the status of your root directory ( `/` ). Notice that it has a CID even though it doesn't have contents yet. Every empty IPFS node has this exact same CID, because their non-existent contents are identical!",
12+
log: utils.format.ipfsObject(result)
1313
}
1414
}
1515
}

src/tutorials/0004-mutable-file-system/02.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ await ipfs.files.stat('/stuff')
2121

2222
This method returns an object with some essential data about our file or directory:
2323

24-
* **hash** (a string with the cryptographic hash)
24+
* **cid** (the CID object)
2525
* **size** (an integer with the file or directory size in Bytes)
2626
* **cumulativeSize** (an integer with the size of the DAGNodes making up the file in Bytes)
2727
* **type** (a string that can be either `directory` or `file`)

src/tutorials/0004-mutable-file-system/04.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import all from 'it-all'
2+
3+
import utils from '../utils'
4+
15
const validate = async (result, ipfs) => {
26
// Validation will be done by matching filenames between the
37
// uploadedFiles array and the files in IPFS and ensuring that the type of each
@@ -27,8 +31,7 @@ const validate = async (result, ipfs) => {
2731

2832
let uploadedFiles = window.uploadedFiles || []
2933

30-
let ipfsFiles = await ipfs.files.ls('/', { long: true })
31-
let log = JSON.stringify(ipfsFiles, null, 2)
34+
let ipfsFiles = await all(ipfs.files.ls('/'))
3235

3336
let uploadedFilenames = uploadedFiles.map(file => file.name.toString()).sort()
3437
let ipfsFilenames = ipfsFiles.map(file => file.name.toString()).sort()
@@ -39,7 +42,7 @@ const validate = async (result, ipfs) => {
3942
return {
4043
success: 'Success! You did it!',
4144
logDesc: 'This is the data that is now in your root directory in IPFS:',
42-
log: log
45+
log: ipfsFiles.map(utils.format.ipfsObject)
4346
}
4447
}
4548

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Let's see `files.ls` in action! List the contents of your root directory ( `/` ). Be sure to use the `{ long: true }` option to ensure you can see all of the details about the files you've uploaded.
1+
Let's see `files.ls` in action! List the contents of your root directory ( `/` ).
22

33
_Note: We've already included the code for adding your files to MFS, so you can
44
focus on listing the contents of your directory._

0 commit comments

Comments
 (0)