bump relay-js

This commit is contained in:
Sasha 2023-04-17 19:57:27 +02:00
parent 634a4d2b00
commit 99c1558dce
No known key found for this signature in database

View File

@ -36,13 +36,13 @@
import { import {
bytesToUtf8, bytesToUtf8,
utf8ToBytes, utf8ToBytes,
} from "https://unpkg.com/@waku/byte-utils@0.0.2/bundle/index.js"; } from "https://unpkg.com/@waku/utils@0.0.4/bundle/bytes.js";
import { createRelayNode } from "https://unpkg.com/@waku/create@0.0.5/bundle/index.js"; import { createRelayNode } from "https://unpkg.com/@waku/create@0.0.12/bundle/index.js";
import { import {
waitForRemotePeer, waitForRemotePeer,
createDecoder, createDecoder,
createEncoder, createEncoder,
} from "https://unpkg.com/@waku/core@0.0.10/bundle/index.js"; } from "https://unpkg.com/@waku/core@0.0.16/bundle/index.js";
const statusDiv = document.getElementById("status"); const statusDiv = document.getElementById("status");
const messagesDiv = document.getElementById("messages"); const messagesDiv = document.getElementById("messages");
@ -58,7 +58,7 @@
// Prepare encoder and decoder, `V0` for clear text messages. // Prepare encoder and decoder, `V0` for clear text messages.
const encoder = createEncoder(contentTopic); const encoder = createEncoder({ contentTopic });
const decoder = createDecoder(contentTopic); const decoder = createDecoder(contentTopic);
try { try {
@ -69,13 +69,16 @@
// We are currently working on migrating this method to DNS Discovery. // We are currently working on migrating this method to DNS Discovery.
// //
// https://js.waku.org/functions/lib_create_waku.createPrivacyNode.html // https://js.waku.org/functions/lib_create_waku.createPrivacyNode.html
const waku = await createRelayNode({ defaultBootstrap: true }); const waku = await createRelayNode({
emitSelf: true,
defaultBootstrap: true,
});
await waku.start(); await waku.start();
// Add a hook to process all incoming messages on a specified content topic. // Add a hook to process all incoming messages on a specified content topic.
// //
// https://js.waku.org/classes/index.waku_relay.WakuRelay.html#addObserver // https://js.waku.org/classes/index.waku_relay.WakuRelay.html#addObserver
waku.relay.addObserver( waku.relay.subscribe(
decoder, decoder,
(message) => { (message) => {
// Checks there is a payload on the message. // Checks there is a payload on the message.
@ -102,7 +105,7 @@
// waku nodes (peers) and for appropriate handshakes to be done. // waku nodes (peers) and for appropriate handshakes to be done.
// //
// https://js.waku.org/functions/lib_wait_for_remote_peer.waitForRemotePeer.html // https://js.waku.org/functions/lib_wait_for_remote_peer.waitForRemotePeer.html
await waitForRemotePeer(waku); await waitForRemotePeer(waku), ["relay"];
// We are now connected to a remote peer, let's define the `sendMessage` // We are now connected to a remote peer, let's define the `sendMessage`
// function that sends the text input over Waku Relay, the gossipsub // function that sends the text input over Waku Relay, the gossipsub