From e7e61c67b8b5778b4a6876a44570f6c874b9dc30 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Thu, 6 Oct 2022 11:07:58 +1100 Subject: [PATCH 1/3] feat: display error if proof verify throws, log proof --- rln-js/index.html | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/rln-js/index.html b/rln-js/index.html index baf96ef..c4518fa 100644 --- a/rln-js/index.html +++ b/rln-js/index.html @@ -324,15 +324,22 @@ messagesDiv.innerHTML += `
  • ${msg.msg} - [epoch: ${msg.epoch}, proof: ${msg.proofState} ]
  • ` if (msg.proofState === "verifying...") { - console.log("Verifying proof") - const res = msg.verify() - console.log("proof verified!", res) - if (res === undefined) { - msg.proofState = "no proof attached" - } else if (res) { - msg.proofState = "verified." - } else { - msg.proofState = "invalid!" + try { + console.log("Verifying proof") + console.time("proof_verify_timer") + const res = msg.verify() + console.time("proof_verify_timer") + console.log("proof verified!", res) + if (res === undefined) { + msg.proofState = "no proof attached" + } else if (res) { + msg.proofState = "verified." + } else { + msg.proofState = "invalid!" + } + } catch (e) { + msg.proofState = "Error encountered, check console" + console.error("Error verifying proof:", e) } updateMessages() } @@ -346,9 +353,10 @@ time.setTime(Number(timestamp)); let proofState, verify; - if (typeof wakuMessage.verify === "undefined") { + if (typeof wakuMessage.rateLimitProof === "undefined") { proofState = "no proof attached"; } else { + console.log("Proof received:", wakuMessage.rateLimitProof) verify = wakuMessage.verify.bind(wakuMessage); proofState = "verifying..."; } From e24cdb054061bc59cd6ed637d7d1849388656973 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Thu, 6 Oct 2022 11:11:43 +1100 Subject: [PATCH 2/3] feat: remove set nick button, ensure send button is enabled once subscribed --- rln-js/index.html | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/rln-js/index.html b/rln-js/index.html index c4518fa..57ad322 100644 --- a/rln-js/index.html +++ b/rln-js/index.html @@ -53,7 +53,6 @@
    -
    @@ -115,7 +114,6 @@ const dialButton = document.getElementById('dial') const nicknameInput = document.getElementById('nick-input') - const setNickButton = document.getElementById('set-nick') const textInput = document.getElementById('textInput'); const sendButton = document.getElementById('sendButton'); @@ -123,7 +121,7 @@ const messagesDiv = document.getElementById('messages') - let membershipId, membershipKey, encoder, node, nodeConnected, nick, rlnInstance; + let membershipId, membershipKey, encoder, node, nodeConnected, rlnInstance; let retrievedRLNEvents = false; const rlnInstancePromise = create(); @@ -172,12 +170,10 @@ && identityKeyInput.value && commitmentKeyInput.value); - const readyToSend = (membershipKey && membershipId && nodeConnected && nick) + const readyToSend = (membershipKey && membershipId && nodeConnected && nicknameInput.value) textInput.disabled = !readyToSend; sendButton.disabled = !readyToSend; - setNickButton.disabled = !nicknameInput.value; - dialButton.disabled = !(node && node.isStarted() && retrievedRLNEvents) retrieveRLNDetailsButton.disabled = !rlnInstance && !retrievedRLNEvents; @@ -311,10 +307,6 @@ // Waku nicknameInput.onchange = updateFields - setNickButton.onclick = () => { - nick = nicknameInput.value; - updateFields() - } let messages = []; @@ -397,12 +389,13 @@ await node.filter.subscribe([decoder], callback) statusDiv.innerHTML = '

    Waku node subscribed.

    '; nodeConnected = true; + updateFields() } sendButton.onclick = async () => { const text = utils.utf8ToBytes(textInput.value); const timestamp = new Date(); - const msg = ProtoChatMessage.create({text, nick, timestamp: timestamp.valueOf()}); + const msg = ProtoChatMessage.create({text, nick: nicknameInput.value, timestamp: timestamp.valueOf()}); const payload = ProtoChatMessage.encode(msg).finish(); console.log("Sending message with proof...") sendingStatusSpan.innerText = 'sending...' From defa1c459d640e6dfaf69f0fb93453364c0c60dd Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Thu, 6 Oct 2022 11:12:21 +1100 Subject: [PATCH 3/3] feat: do not remove "download blob" message It shifts everything up and can be confusing. --- rln-js/index.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/rln-js/index.html b/rln-js/index.html index 57ad322..509765d 100644 --- a/rln-js/index.html +++ b/rln-js/index.html @@ -132,9 +132,6 @@ rlnInstance = _rlnInstance statusSpan.innerText = 'WASM Blob download in progress... done!' updateFields() - setTimeout(() => { - statusSpan.innerText = '' - }, 5000) }) const ContentTopic = "/toy-chat/2/luzhou/proto";