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

chore: migrate other examples to @waku/sdk #242

Merged
merged 6 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
weboko marked this conversation as resolved.
Show resolved Hide resolved
"@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/[email protected]/bundle/bytes.js";
import * as wakuCreate from "https://unpkg.com/@waku/[email protected]/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