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

Integrate new p2panda-js 0.2.0 API in demo #28

Closed
adzialocha opened this issue Oct 1, 2021 · 4 comments · Fixed by #30
Closed

Integrate new p2panda-js 0.2.0 API in demo #28

adzialocha opened this issue Oct 1, 2021 · 4 comments · Fixed by #30
Assignees

Comments

@adzialocha
Copy link
Member

adzialocha commented Oct 1, 2021

Currently we're mocking the (outdated) p2panda-js API inside of beep-boop here: https://github.com/p2panda/beep-boop/tree/main/src/p2panda-api. We will soon release the real p2panda-js 0.2.0 API (see https://github.com/p2panda/p2panda/tree/main/p2panda-js#usage) which should be used instead in this demo.

@adzialocha adzialocha changed the title Integrate new p2panda-js 0.2.0 API in demo Integrate new p2panda-js 0.2.0 API in demo Oct 1, 2021
@sophiiistika
Copy link
Member

sophiiistika commented Oct 12, 2021

For working with the unpublished p2panda-js version:

cd p2panda
git pull origin main
cd p2panda-js
npm install
npm run build
npm link

And in the beep-boop repo:
npm link p2panda-js

In case a wasm error is thrown, copy the ***.module.wasm file from p2panda-js/lib into beep-boop/dist. After that, run in the beep-boop repo:
npx serve dist

@sophiiistika
Copy link
Member

Two issues I found that I can’t resolve

  • loading issue:
    p2panda-js requires wasm. that means p2panda-js will try to import it over the network, but the code (e.g. createKeyPair()) can’t or won’t wait for wasm to be imported. For that, keyPair.ts and session.ts from p2panda-js probably can be improved.
  • null pointer error:
    after calling the privateKey() we get this error

Screenshot 2021-10-29 at 14 51 00

@adzialocha
Copy link
Member Author

adzialocha commented Nov 3, 2021

loading issue: p2panda-js requires wasm

To solve the issue with Webpack not importing the .wasm file of p2panda-js we just found a solution (not elegant, but working for now):

  1. Install the CopyWebpackPlugin as a dev dependency

  2. Add the following config under plugins in the webpack file (CopyPlugin needs to be imported first):

    new CopyPlugin({
      patterns: [
        { from: 'node_modules/p2panda-js/lib/*.wasm', to: '[name][ext]' },
      ],
    }),
  3. Restart the npm run serve task. Webpack will now copy the needed .wasm file into the dist folder.

I'm making a ticket about this issue, we should evaluate if this is a fine solution for people using Webpack as a bundler or if we need to rewrite our bundling strategy in p2panda-js 😢 p2panda/p2panda#126

@adzialocha
Copy link
Member Author

adzialocha commented Nov 3, 2021

null pointer error: after calling the privateKey() we get this error

This might be related to this invalid syntax here: https://github.com/p2panda/beep-boop/blob/Integrate-new-p2panda-js-0.2.0-API/src/App.tsx#L50 : createKeyPair is a Promise and not a Class so the new keyword does not make sense here. Maybe this resolves the issue? 👍

@cafca cafca linked a pull request Dec 6, 2021 that will close this issue
@cafca cafca closed this as completed Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants