orbitdb-archive / orbit-db-identity-provider

Default identity provider for OrbitDB
MIT License
31 stars 17 forks source link

OrbitDB - Ipfs is not defined Examples Browser #56

Closed locoalien closed 4 years ago

locoalien commented 4 years ago

I have had problems in the last days, to run the OrbitDB examples.

The problem that appears in the web browser is the following:

Uncaught ReferenceError: Ipfs is not defined

Specifically in the file "example.js" // Create IPFS instance const ipfs = new Ipfs({ repo: '/orbitdb/examples/browser/new/ipfs/0.33.1', start: true, preload: { enabled: false }, EXPERIMENTAL: { pubsub: true, }, config: { Addresses: { Swarm: [ // Use IPFS dev signal server // '/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star', '/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star', // Use local signal server // '/ip4/0.0.0.0/tcp/9090/wss/p2p-webrtc-star', ] }, } })

You can see the problem in the following image:

orbitdb

The problem is due to the fact that there is a new version of the IPFS library, therefore the way to create the IPFS class instance has changed.

Solution:

To solve the problem, the example has been modified to be able to run the program correctly in the browser.

To solve the problem it is necessary to follow the following steps: 1)Modify the file "browser.html", with the dependencies in the correct path. Before:

before

After:

after

2) The file "example.js" should be modified, with the new form of the latest version of IPFS.

Before:

1before

After:

2after

Once the previous steps have been carried out, we can now correctly run the example with the latest version of IPFS.

finish

Have a nice day :)