diff --git a/examples/rln-js/src/rln.js b/examples/rln-js/src/rln.js index 527af3c..11d1a36 100644 --- a/examples/rln-js/src/rln.js +++ b/examples/rln-js/src/rln.js @@ -9,7 +9,12 @@ import { } from "@waku/rln"; import { createEncoder, createDecoder } from "@waku/sdk"; -import { CONTENT_TOPIC, MEMBERSHIP_ID, RLN_CREDENTIALS } from "./const"; +import { + CONTENT_TOPIC, + MEMBERSHIP_ID, + RLN_CREDENTIALS, + CLUSTER_ID, +} from "./const"; export async function initRLN(onStatusChange) { onStatusChange("Connecting to wallet..."); @@ -40,16 +45,21 @@ export async function initRLN(onStatusChange) { onStatusChange("Failed to initialize RLN", "error"); throw Error(err); } + const encoder = new RLNEncoder( createEncoder({ ephemeral: false, contentTopic: CONTENT_TOPIC, + pubsubTopicShardInfo: { clusterId: CLUSTER_ID }, }), rlnInstance, MEMBERSHIP_ID, RLN_CREDENTIALS ); - const decoder = new RLNDecoder(rlnInstance, createDecoder(CONTENT_TOPIC)); + const decoder = new RLNDecoder( + rlnInstance, + createDecoder(CONTENT_TOPIC, { clusterId: CLUSTER_ID }) + ); onStatusChange("RLN initialized", "success"); diff --git a/examples/rln-js/src/waku.js b/examples/rln-js/src/waku.js index 90ab1f5..c5f6169 100644 --- a/examples/rln-js/src/waku.js +++ b/examples/rln-js/src/waku.js @@ -1,6 +1,6 @@ import { createLightNode, waitForRemotePeer } from "@waku/sdk"; -import { ProtoChatMessage } from "./const"; +import { CLUSTER_ID, ProtoChatMessage } from "./const"; export async function initWaku({ encoder, @@ -11,6 +11,7 @@ export async function initWaku({ onStatusChange("Initializing Waku..."); const node = await createLightNode({ defaultBootstrap: true, + shardInfo: { clusterId: CLUSTER_ID, contentTopics: [CONTENT_TOPIC] }, }); onStatusChange("Waiting for peers"); await node.start(); @@ -31,7 +32,10 @@ export async function initWaku({ }; onStatusChange("Subscribing to content topic..."); - const subscription = await node.filter.createSubscription(); + const subscription = await node.filter.createSubscription({ + clusterId: CLUSTER_ID, + shard: contentTopicToShardIndex(CONTENT_TOPIC), + }); const onSubscribe = async (cb) => { await subscription.subscribe(decoder, (message) => { try {