From a7ec7b7b41598347a774399929cc19de0ce80c65 Mon Sep 17 00:00:00 2001 From: Hayden Young Date: Fri, 19 Jan 2024 16:19:18 +0000 Subject: [PATCH] docs: Migrate js-ipfs examples to Helia. --- conf/jsdoc/layout.tmpl | 2 +- docs/IDENTITIES.md | 2 +- docs/jsdoc/README.md | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/conf/jsdoc/layout.tmpl b/conf/jsdoc/layout.tmpl index 4422d7c..38a0665 100644 --- a/conf/jsdoc/layout.tmpl +++ b/conf/jsdoc/layout.tmpl @@ -2,7 +2,7 @@ - OrbitDB API - v1.0 + OrbitDB API - v2.0 diff --git a/docs/IDENTITIES.md b/docs/IDENTITIES.md index 22e4a05..bba7b2d 100644 --- a/docs/IDENTITIES.md +++ b/docs/IDENTITIES.md @@ -89,7 +89,7 @@ The identity object is stored like any other [IPLD data structure](https://ipld. ```js import { createLibp2p } from 'libp2p' -import { createHelia } from 'helia' from 'ipfs-core' +import { createHelia } from 'helia' import * as Block from 'multiformats/block' import { Identities } from '@orbitdb/core' import * as dagCbor from '@ipld/dag-cbor' diff --git a/docs/jsdoc/README.md b/docs/jsdoc/README.md index b789129..c5077fe 100644 --- a/docs/jsdoc/README.md +++ b/docs/jsdoc/README.md @@ -9,19 +9,21 @@ To install OrbitDB: npm install @orbitdb/core ``` -IPFS is also required: +Helia, the Javascript version of IPFS, is also required: ```bash -npm install ipfs-core +npm install helia ``` Instantiate OrbitDB and create a database: ```js -import { create } from 'ipfs-core' +import { createLibp2p } from 'libp2p' +import { createHelia } from 'helia' import { createOrbitDB } from '@orbitdb/core' -const ipfs = await create() // IPFS is required for storage and network communication +const libp2p = await createLibp2p({ /* Libp2p options */ }) +const ipfs = await createHelia({ libp2p }) // Helia is required for storage and network communication const orbitdb = await createOrbitDB({ ipfs }) const mydb = await orbitdb.open('mydb') console.log(mydb.address) // /orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13 @@ -32,10 +34,12 @@ Open and replicate an existing database: ```js // In another process -import { create } from 'ipfs-core' +import { createLibp2p } from 'libp2p' +import { createHelia } from 'helia' import { createOrbitDB } from '@orbitdb/core' -const ipfs = await create() +const libp2p = await createLibp2p({ /* Libp2p options */ }) +const ipfs = await createHelia({ libp2p }) // Helia is required for storage and network const orbitdb = await createOrbitDB({ ipfs }) const theirdb = await orbitdb.open('/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') for await (let record of theirdb.iterator()) {