feat: display error if proof verify throws, log proof

This commit is contained in:
fryorcraken.eth 2022-10-06 11:07:58 +11:00
parent a8b8fb1513
commit e7e61c67b8
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 18 additions and 10 deletions

View File

@ -324,15 +324,22 @@
messagesDiv.innerHTML += `<li>${msg.msg} - [epoch: ${msg.epoch}, proof: ${msg.proofState} ]</li>` messagesDiv.innerHTML += `<li>${msg.msg} - [epoch: ${msg.epoch}, proof: ${msg.proofState} ]</li>`
if (msg.proofState === "verifying...") { if (msg.proofState === "verifying...") {
console.log("Verifying proof") try {
const res = msg.verify() console.log("Verifying proof")
console.log("proof verified!", res) console.time("proof_verify_timer")
if (res === undefined) { const res = msg.verify()
msg.proofState = "no proof attached" console.time("proof_verify_timer")
} else if (res) { console.log("proof verified!", res)
msg.proofState = "verified." if (res === undefined) {
} else { msg.proofState = "no proof attached"
msg.proofState = "invalid!" } 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() updateMessages()
} }
@ -346,9 +353,10 @@
time.setTime(Number(timestamp)); time.setTime(Number(timestamp));
let proofState, verify; let proofState, verify;
if (typeof wakuMessage.verify === "undefined") { if (typeof wakuMessage.rateLimitProof === "undefined") {
proofState = "no proof attached"; proofState = "no proof attached";
} else { } else {
console.log("Proof received:", wakuMessage.rateLimitProof)
verify = wakuMessage.verify.bind(wakuMessage); verify = wakuMessage.verify.bind(wakuMessage);
proofState = "verifying..."; proofState = "verifying...";
} }