Skip to content

Commit

Permalink
chore: migrate other examples to @waku/sdk (#242)
Browse files Browse the repository at this point in the history
* migrate eth-pm

* migrate light-chat

* migrate relay-react-chat

* migrate store-react-chat

* revert
  • Loading branch information
weboko committed Jun 23, 2023
1 parent 1575056 commit 3ada67d
Show file tree
Hide file tree
Showing 10 changed files with 20,207 additions and 15,752 deletions.
629 changes: 466 additions & 163 deletions examples/eth-pm/package-lock.json

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions examples/eth-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
"@ethersproject/providers": "5.7.0",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@waku/core": "^0.0.16",
"@waku/create": "^0.0.12",
"@waku/interfaces": "^0.0.11",
"@waku/message-encryption": "^0.0.14",
"@waku/utils": "0.0.4",
"@waku/sdk": "^0.0.16",
"@waku/interfaces": "^0.0.15",
"@waku/message-encryption": "^0.0.18",
"@waku/utils": "0.0.8",
"ethers": "5.7.1",
"fontsource-roboto": "^4.0.0",
"protobufjs": "^7.1.2",
Expand Down
3 changes: 1 addition & 2 deletions examples/eth-pm/src/waku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { PrivateMessage, PublicKeyMessage } from "./messaging/wire";
import { validatePublicKeyMessage } from "./crypto";
import { Message } from "./messaging/Messages";
import { equals } from "uint8arrays/equals";
import { waitForRemotePeer } from "@waku/core";
import { createRelayNode } from "@waku/create";
import { waitForRemotePeer, createRelayNode } from "@waku/sdk";
import { bytesToHex, hexToBytes } from "@waku/utils/bytes";
import type { DecodedMessage } from "@waku/message-encryption";

Expand Down
13 changes: 7 additions & 6 deletions examples/light-chat/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as utils from "https://unpkg.com/@waku/utils@0.0.5/bundle/bytes.js";
import * as wakuCreate from "https://unpkg.com/@waku/create@0.0.13/bundle/index.js";
import {
createLightNode,
bytesToUtf8,
utf8ToBytes,
waitForRemotePeer,
createDecoder,
createEncoder,
} from "https://unpkg.com/@waku/core@0.0.17/bundle/index.js";
} from "https://unpkg.com/@waku/sdk@0.0.16/bundle/index.js";

const CONTENT_TOPIC = "/toy-chat/2/huilong/proto";

Expand Down Expand Up @@ -47,7 +48,7 @@ async function initWakuContext({ contentTopic, onMessageReceived }) {
.add(new protobuf.Field("nick", 2, "string"))
.add(new protobuf.Field("text", 3, "bytes"));

const node = await wakuCreate.createLightNode({ defaultBootstrap: true });
const node = await createLightNode({ defaultBootstrap: true });

await node.start();
await waitForRemotePeer(node);
Expand All @@ -59,7 +60,7 @@ async function initWakuContext({ contentTopic, onMessageReceived }) {
const messageObj = ChatMessage.decode(wakuMessage.payload);
onMessageReceived({
...messageObj,
text: utils.bytesToUtf8(messageObj.text),
text: bytesToUtf8(messageObj.text),
});
}
);
Expand All @@ -84,7 +85,7 @@ async function initWakuContext({ contentTopic, onMessageReceived }) {
const protoMessage = ChatMessage.create({
nick,
timestamp: Date.now(),
text: utils.utf8ToBytes(text),
text: utf8ToBytes(text),
});

await node.lightPush.send(Encoder, {
Expand Down
Loading

0 comments on commit 3ada67d

Please sign in to comment.