Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Not a valid OrbitDB address: /orbitdb (on Linux) #638

Closed
FedericoPonzi opened this issue Jun 2, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@FedericoPonzi
Copy link

commented Jun 2, 2019

Hello world,
I'm trying to develop a very basic app up and running, with typescript/react and orbit db.
Since I had some problems having it run with typescript, I first wanted to have something working and then iterate on it later.
This is my index.tsx:

import * as React from "react";
import * as ReactDOM from "react-dom";

import * as IPFS from "ipfs"
//import { OrbitDB } from 'orbit-db'
const OrbitDB = require('orbit-db') // in this way it works, if I use the import notation it throws a undefined for the imported class. Maybe I can send later a different issue If I cannot get it working
import { Hello } from "./components/Hello";

// OrbitDB uses Pubsub which is an experimental feature
// and need to be turned on manually.
// Note that these options need to be passed to IPFS in
// all examples even if not specified so.
const ipfsOptions = {
    EXPERIMENTAL: {
      pubsub: true
    }
  }
  
  // Create IPFS instance
  const ipfs = new IPFS(ipfsOptions)
  ipfs.on('error', (e) => console.error(e))
  
  ipfs.on('ready', async () => {
    //console.log(`Orbit ${OrbitDB}`)
    const orbitdb = await OrbitDB.createInstance(ipfs)
  
    // Create / Open a database
    const db = await orbitdb.log('hello')
    console.log("db opened.")
    await db.load()
    console.log("Loaded.")
  
    // Listen for updates from peers
    db.events.on('replicated', (address: any) => {
      console.log(address)
      console.log(db.iterator({ limit: -1 }).collect())
    })
  
    // Add an entry
    const hash = await db.add('world')
    console.log(hash)
  
    // Query
    const result = db.iterator({ limit: -1 }).collect()
    console.log(JSON.stringify(result, null, 2))
    
  })
  
ReactDOM.render(
    <Hello compiler="Typescript" framework="React" />,
    document.getElementById("example")
);

I've created a repo with the full code here: https://github.com/FedericoPonzi/sNoteLess
As you can see, the relevant code is the hello world from the README.md of Orbit-DB. The kind of address I get from the log function looks like this:

/orbitdb/bafyreicerijt5g2q4x3oswpf6zxkqbe7mb7w7vqqu2myvh4nqpddrekcey/hello

And I think that since the hash dosen't start with neither zd nor Qm it fails with this error:

orbit-db-address.js:44 Uncaught (in promise) Error: Not a valid OrbitDB address: /orbitdb/bafyreicerijt5g2q4x3oswpf6zxkqbe7mb7w7vqqu2myvh4nqpddrekcey/hello
    at Function.parse (orbit-db-address.js:44)
    at OrbitDB._determineAddress (OrbitDB.js:257)
    at async OrbitDB.create (OrbitDB.js:277)

Thanks for the help!
p.s. I'm on Linux.

@FedericoPonzi FedericoPonzi changed the title Not a valid OrbitDB address: /orbitdb Error: Not a valid OrbitDB address: /orbitdb (on Linux) Jun 2, 2019

@shamb0t

This comment has been minimized.

Copy link
Member

commented Jun 2, 2019

Hi @FedericoPonzi which version of IPFS are you using? We are still working on updating to 0.36.x, can you try with npm i ipfs@0.34.4?

@FedericoPonzi

This comment has been minimized.

Copy link
Author

commented Jun 2, 2019

Thanks for the fast response, that fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.