Create Waku

This commit is contained in:
Franck Royer 2021-07-28 12:20:43 +10:00
parent 1e64ac8f7c
commit 2ae9a6ca00
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
4 changed files with 38307 additions and 13 deletions

38259
examples/min-js-web-chat/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"js-waku": "../../build/main",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",

View File

@ -1,22 +1,29 @@
import logo from './logo.svg';
import './App.css';
import { Waku } from 'js-waku';
import * as React from 'react';
function App() {
const [waku, setWaku] = React.useState(undefined);
const [wakuStarting, setWakuStarting] = React.useState(false);
React.useEffect(() => {
if (!!waku) return;
if (wakuStarting) return;
setWakuStarting(true);
Waku.create().then((waku) => {
setWaku(waku);
setWakuStarting(false);
});
}, [waku, wakuStarting]);
const wakuStatus = !!waku ? 'Started' : wakuStarting ? 'Loading' : 'Error';
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
<p>{wakuStatus}</p>
</header>
</div>
);

View File

@ -0,0 +1,27 @@
# Received and Send messages using Waku Relay
Waku Relay is a gossip protocol that enables you to send and receive messages.
You can find Waku Relay's specifications on [Vac RFC](https://rfc.vac.dev/spec/11/).
Before starting, you need to choose a _Content Topic_ for your dApp.
Check out the [choose a content topic guide](choose-content-topic.md) to learn more about content topics.
For the purpose of this guide, we are using a unique content topic: `/relay-guide/1/chat/proto`.
# Installation
You can install [js-waku](https://npmjs.com/package/js-waku) using your favorite package manager:
```shell
npm install js-waku
```
# Create Waku instance
In order to interact with the Waku network, you first need a Waku instance:
```js
import { Waku } from 'js-waku';
const wakuNode = await Waku.create();
```