chore: remove rln-js (#300)

* chroe: remove rln-js

* remove ci
This commit is contained in:
Sasha 2024-02-14 01:28:35 +01:00 committed by GitHub
parent 5680fd7367
commit fa92477fff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 1 additions and 18190 deletions

View File

@ -20,8 +20,7 @@ jobs:
web-chat,
noise-js,
noise-rtc,
relay-direct-rtc,
rln-js
relay-direct-rtc
]
runs-on: ubuntu-latest
steps:

1
ci/Jenkinsfile vendored
View File

@ -43,7 +43,6 @@ pipeline {
stage('noise-js') { steps { script { buildExample() } } }
stage('noise-rtc') { steps { script { buildExample() } } }
stage('relay-direct-rtc') { steps { script { buildExample() } } }
stage('rln-js') { steps { script { buildExample() } } }
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,173 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title></title>
<link rel="apple-touch-icon" href="./favicon.png" />
<link rel="manifest" href="./manifest.json" />
<link rel="icon" href="./favicon.ico" />
<style>
* {
margin: 0;
padding: 0;
word-wrap: break-word;
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
max-width: 100%;
max-height: 100%;
}
html {
font-size: 16px;
overflow: hidden;
}
body {
display: flex;
align-items: center;
padding: 10px;
flex-direction: column;
justify-content: center;
}
.container {
width: 100%;
min-width: 300px;
max-width: 800px;
height: 100%;
display: flex;
flex-direction: column;
align-content: space-between;
}
h2 {
text-align: center;
margin-bottom: 5px;
}
h3 {
margin-bottom: 10px;
}
h3:last-of-type {
margin-bottom: 20px;
}
h2 span,
h3 span {
font-weight: normal;
}
.progress {
color: #9ea13b;
}
.success {
color: #3ba183;
}
.error {
color: #c84740;
}
button.progress {
color: white;
background-color: #9ea13b;
}
button.success {
color: white;
background-color: #3ba183;
}
button.error {
color: white;
background-color: #c84740;
}
.pairingInfo {
display: flex;
flex-direction: column;
align-items: center;
}
.pairingInfo input {
display: block;
min-width: 250px;
width: 100%;
max-width: 600px;
font-size: 1.1rem;
line-height: 1.5rem;
padding: 5px;
margin-bottom: 10px;
}
.pairingInfo button {
flex-grow: 1;
cursor: pointer;
padding: 10px;
}
.pairingInfo button + button {
margin-left: 5px;
}
.chatArea {
}
.chatArea ul {
margin-bottom: 30px;
list-style: none;
}
.chatArea ul li + li {
margin-top: 5px;
}
.chatArea div {
display: flex;
flex-direction: column;
}
.chatArea div > * {
font-size: 1.1rem;
line-height: 1.5rem;
padding: 5px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="status">
<h3>
<b>Waku Status:</b>
<span id="status" class="progress">Starting...</span>
</h3>
</div>
<div class="chatArea" id="chat-area" style="display: none">
<h2>Chat</h2>
<ul id="messages"></ul>
<div>
<input id="nick" placeholder="Choose a nickname" type="text" />
<textarea
id="text"
placeholder="Type your message here"
type="text"
></textarea>
<button id="send" type="button">Send message</button>
</div>
</div>
</div>
<script src="./index.js"></script>
</body>
</html>

View File

@ -1,19 +0,0 @@
{
"name": "Waku RLN",
"description": "Example showing Waku RLN capabilities.",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "favicon.png",
"type": "image/png",
"sizes": "192x192"
}
],
"display": "standalone",
"theme_color": "#ffffff",
"background_color": "#ffffff"
}

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
{
"name": "rln-chat",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "webpack --config webpack.config.js",
"start": "webpack-dev-server"
},
"dependencies": {
"@waku/rln": "0.1.1-0fbf6be",
"@waku/sdk": "^0.0.22",
"@waku/utils": "^0.0.14",
"ethers": "^5.7.2",
"multiaddr": "^10.0.1",
"protobufjs": "^7.2.5"
},
"devDependencies": {
"@metamask/types": "^1.1.0",
"@types/node": "^20",
"eslint": "^8",
"eslint-config-next": "13.5.6",
"typescript": "^5",
"copy-webpack-plugin": "^11.0.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
}
}

View File

@ -1,153 +0,0 @@
import protobuf from "protobufjs";
import { concat } from "@waku/utils/bytes";
import { IdentityCredential, Keystore } from "@waku/rln";
export const CONTENT_TOPIC = "/toy-chat/2/luzhou/proto";
export const CLUSTER_ID = 1;
export const MEMBERSHIP_ID = 14;
export const RLN_CREDENTIALS = IdentityCredential.fromBytes(
concat([
/* IDTrapdoor */ Keystore.fromArraylikeToBytes({
0: 182,
1: 79,
2: 126,
3: 47,
4: 227,
5: 67,
6: 22,
7: 100,
8: 128,
9: 168,
10: 33,
11: 164,
12: 240,
13: 233,
14: 91,
15: 245,
16: 75,
17: 156,
18: 224,
19: 189,
20: 174,
21: 19,
22: 104,
23: 69,
24: 190,
25: 34,
26: 222,
27: 244,
28: 119,
29: 236,
30: 43,
31: 29,
}),
/* IDNullifier */ Keystore.fromArraylikeToBytes({
0: 99,
1: 194,
2: 251,
3: 229,
4: 115,
5: 41,
6: 207,
7: 215,
8: 31,
9: 155,
10: 237,
11: 129,
12: 119,
13: 201,
14: 241,
15: 178,
16: 76,
17: 227,
18: 87,
19: 145,
20: 151,
21: 94,
22: 213,
23: 40,
24: 232,
25: 163,
26: 3,
27: 145,
28: 2,
29: 34,
30: 209,
31: 37,
}),
/* IDSecretHash */ Keystore.fromArraylikeToBytes({
0: 35,
1: 167,
2: 89,
3: 158,
4: 35,
5: 198,
6: 187,
7: 240,
8: 114,
9: 76,
10: 220,
11: 111,
12: 245,
13: 76,
14: 201,
15: 187,
16: 30,
17: 53,
18: 94,
19: 175,
20: 16,
21: 73,
22: 65,
23: 92,
24: 156,
25: 189,
26: 153,
27: 66,
28: 60,
29: 91,
30: 235,
31: 30,
}),
/* IDCommitment */ Keystore.fromArraylikeToBytes({
0: 181,
1: 107,
2: 5,
3: 148,
4: 160,
5: 49,
6: 176,
7: 143,
8: 203,
9: 53,
10: 127,
11: 44,
12: 190,
13: 133,
14: 75,
15: 42,
16: 96,
17: 153,
18: 78,
19: 63,
20: 205,
21: 66,
22: 9,
23: 72,
24: 127,
25: 210,
26: 22,
27: 133,
28: 37,
29: 28,
30: 91,
31: 4,
}),
])
);
export const ProtoChatMessage = new protobuf.Type("ChatMessage")
.add(new protobuf.Field("timestamp", 1, "uint64"))
.add(new protobuf.Field("nick", 2, "string"))
.add(new protobuf.Field("text", 3, "string"));

View File

@ -1,19 +0,0 @@
import { initUI } from "./ui";
import { initRLN } from "./rln";
import { initWaku } from "./waku";
async function run() {
const { onLoaded, onStatusChange, registerEvents } = initUI();
const { encoder, decoder, rlnContract } = await initRLN(onStatusChange);
const { onSend, onSubscribe } = await initWaku({
encoder,
decoder,
rlnContract,
onStatusChange,
});
onLoaded();
registerEvents({ onSend, onSubscribe });
}
run();

View File

@ -1,61 +0,0 @@
import { ethers } from "ethers";
import {
create,
RLNEncoder,
RLNDecoder,
RLNContract,
SEPOLIA_CONTRACT,
} from "@waku/rln";
import { createEncoder, createDecoder } from "@waku/sdk";
import { CONTENT_TOPIC, MEMBERSHIP_ID, RLN_CREDENTIALS } from "./const";
export async function initRLN(onStatusChange) {
onStatusChange("Connecting to wallet...");
const ethereum = window.ethereum;
if (!ethereum) {
const err =
"Missing or invalid Ethereum provider. Please install MetaMask.";
onStatusChange(err, "error");
throw Error(err);
}
try {
await ethereum.request({ method: "eth_requestAccounts" });
} catch (err) {
onStatusChange("Failed to access MetaMask", "error");
throw Error(err);
}
const provider = new ethers.providers.Web3Provider(ethereum, "any");
onStatusChange("Initializing RLN...");
let rlnInstance, rlnContract;
try {
rlnInstance = await create();
rlnContract = await RLNContract.init(rlnInstance, {
registryAddress: SEPOLIA_CONTRACT.address,
provider: provider.getSigner(),
});
} catch (err) {
onStatusChange("Failed to initialize RLN", "error");
throw Error(err);
}
const encoder = new RLNEncoder(
createEncoder({
ephemeral: false,
contentTopic: CONTENT_TOPIC,
}),
rlnInstance,
MEMBERSHIP_ID,
RLN_CREDENTIALS
);
const decoder = new RLNDecoder(rlnInstance, createDecoder(CONTENT_TOPIC));
onStatusChange("RLN initialized", "success");
return {
encoder,
decoder,
rlnContract,
};
}

View File

@ -1,53 +0,0 @@
const status = document.getElementById("status");
const chat = document.getElementById("chat-area");
const messages = document.getElementById("messages");
const nickInput = document.getElementById("nick");
const textInput = document.getElementById("text");
const sendButton = document.getElementById("send");
export const initUI = () => {
const onStatusChange = (newStatus, className) => {
status.innerText = newStatus;
status.className = className || "progress";
};
const onLoaded = () => {
chat.style.display = "block";
};
const _renderMessage = (nick, text, time, validation) => {
messages.innerHTML += `
<li>
(${nick})(${validation})
<strong>${text}</strong>
<i>[${new Date(time).toISOString()}]</i>
</li>
`;
};
const registerEvents = (events) => {
events.onSubscribe((nick, text, time, validation) => {
_renderMessage(nick, text, time, validation);
});
sendButton.addEventListener("click", async () => {
const nick = nickInput.value;
const text = textInput.value;
if (!nick || !text) {
console.log("Not sending message: missing nick or text.");
return;
}
await events.onSend(nick, text);
textInput.value = "";
});
};
return {
onLoaded,
registerEvents,
onStatusChange,
};
};

View File

@ -1,76 +0,0 @@
import { createLightNode, waitForRemotePeer } from "@waku/sdk";
import { ProtoChatMessage } from "./const";
export async function initWaku({
encoder,
decoder,
rlnContract,
onStatusChange,
}) {
onStatusChange("Initializing Waku...");
const node = await createLightNode({
defaultBootstrap: true,
});
onStatusChange("Waiting for peers");
await node.start();
await waitForRemotePeer(node);
const onSend = async (nick, text) => {
const timestamp = new Date();
const msg = ProtoChatMessage.create({
text,
nick,
timestamp: Math.floor(timestamp.valueOf() / 1000),
});
const payload = ProtoChatMessage.encode(msg).finish();
console.log("Sending message with proof...");
const res = await node.lightPush.send(encoder, { payload, timestamp });
console.log("Message sent:", res);
};
onStatusChange("Subscribing to content topic...");
const subscription = await node.filter.createSubscription();
const onSubscribe = async (cb) => {
await subscription.subscribe(decoder, (message) => {
try {
const { timestamp, nick, text } = ProtoChatMessage.decode(
message.payload
);
let proofStatus = "no proof";
if (message.rateLimitProof) {
console.log("Proof received: ", message.rateLimitProof);
try {
console.time("Proof verification took:");
const res = message.verify(rlnContract.roots());
console.timeEnd("Proof verification took:");
proofStatus = res ? "verified" : "not verified";
} catch (error) {
proofStatus = "invalid";
console.error("Failed to verify proof: ", error);
}
}
console.log({
nick,
text,
proofStatus,
time: new Date(timestamp).toDateString(),
});
cb(nick, text, timestamp, proofStatus);
} catch (error) {
console.error("Failed in subscription listener: ", error);
}
});
};
onStatusChange("Waku initialized", "success");
return {
onSend,
onSubscribe,
};
}

View File

@ -1,19 +0,0 @@
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "build"),
filename: "./index.js",
},
experiments: {
asyncWebAssembly: true,
},
mode: "development",
plugins: [
new CopyWebpackPlugin({
patterns: ["index.html", "favicon.ico", "favicon.png", "manifest.json"],
}),
],
};