fix: epoch

This commit is contained in:
fryorcraken.eth 2022-10-10 09:02:18 -05:00
parent 47ee93b7f5
commit 83c4809c70
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 91 additions and 87 deletions

View File

@ -5,102 +5,102 @@
<meta charset='UTF-8'/> <meta charset='UTF-8'/>
<meta content='width=device-width, initial-scale=1.0' name='viewport'/> <meta content='width=device-width, initial-scale=1.0' name='viewport'/>
<title>JS-Waku light node example</title> <title>JS-Waku light node example</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"> <link href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css" rel="stylesheet">
<link rel="stylesheet" href="style.css"> <link href="style.css" rel="stylesheet">
</head> </head>
<body> <body>
<div class="row rcenter"> <div class="row rcenter">
<h1>Waku RLN</h1> <h1>Waku RLN</h1>
<button id='connect-wallet' type='button'>Connect Wallet</button> <button id='connect-wallet' type='button'>Connect Wallet</button>
</div> </div>
<span id='status'></span> <span id='status'></span>
<h2 class="mu1">Blockchain</h2> <h2 class="mu1">Blockchain</h2>
<hr /> <hr/>
<div class="row rcenter"> <div class="row rcenter">
<h4>Address</h4> <h4>Address</h4>
<code id="address" class="value"></code> <code class="value" id="address"></code>
</div> </div>
<div class="row mu1 rcenter"> <div class="row mu1 rcenter">
<h4>Contract Data</h4> <h4>Contract Data</h4>
<button disabled id='retrieve-rln-details' type='button'> <button disabled id='retrieve-rln-details' type='button'>
Retrieve contract state from blockchain Retrieve contract state from blockchain
</button> </button>
</div> </div>
<div class="row rcenter"> <div class="row rcenter">
<h4>Latest membership id on contract</h4> <h4>Latest membership id on contract</h4>
<code id="latest-membership-id" class="value">Not loaded yet</code> <code class="value" id="latest-membership-id">Not loaded yet</code>
</div> </div>
<h2 class="mu1">Credentials</h2> <h2 class="mu1">Credentials</h2>
<hr /> <hr/>
<div class="row"> <div class="row">
<div class="w50"> <div class="w50">
<h4>You can either generate new credentials:</h4> <h4>You can either generate new credentials:</h4>
<button disabled id='generate-credentials' type='button'>Generate RLN Credentials</button> <button disabled id='generate-credentials' type='button'>Generate RLN Credentials</button>
<br /> <br/>
<br /> <br/>
<button disabled id='register-button' type='button'>Register Credentials in Contract</button> <button disabled id='register-button' type='button'>Register Credentials in Contract</button>
</div> </div>
<div class="w50"> <div class="w50">
<h4>Or import existing ones:</h4> <h4>Or import existing ones:</h4>
<label for="membership-id">Membership ID (your index in the RLN smart contract):</label> <label for="membership-id">Membership ID (your index in the RLN smart contract):</label>
<input id="membership-id" name="membership-id" type="text" /> <input id="membership-id" name="membership-id" type="text"/>
<label for="id-key">RLN Identity Key (hex string):</label> <label for="id-key">RLN Identity Key (hex string):</label>
<input id="id-key" name="id-key" type="text" /> <input id="id-key" name="id-key" type="text"/>
<label for="commitment-key">RLN Commitment Key (hex string):</label> <label for="commitment-key">RLN Commitment Key (hex string):</label>
<input id="commitment-key" name="commitment-key" type="text" /> <input id="commitment-key" name="commitment-key" type="text"/>
<button disabled id='import-button' type='button'>Import RLN Credentials</button> <button disabled id='import-button' type='button'>Import RLN Credentials</button>
</div> </div>
</div> </div>
<div class="row rcenter mu1"> <div class="row rcenter mu1">
<h4>Membership id</h4> <h4>Membership id</h4>
<code id="id" class="value">none</code> <code class="value" id="id">none</code>
</div> </div>
<div class="row rcenter"> <div class="row rcenter">
<h4>Key</h4> <h4>Key</h4>
<code id="key" class="value">none</code> <code class="value" id="key">none</code>
</div> </div>
<div class="row rcenter"> <div class="row rcenter">
<h4>Commitment</h4> <h4>Commitment</h4>
<code id="commitment" class="value">none</code> <code class="value" id="commitment">none</code>
</div> </div>
<h2 class="mu1">Waku</h2> <h2 class="mu1">Waku</h2>
<hr /> <hr/>
<div id="waku-status"></div> <div id="waku-status"></div>
<div class="row rcenter mu1 mf"> <div class="row rcenter mu1 mf">
<label for='remote-multiaddr'>Remote peer's multiaddr</label> <label for='remote-multiaddr'>Remote peer's multiaddr</label>
<input id='remote-multiaddr' <input id='remote-multiaddr'
type='text' type='text'
value="/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm"> value="/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm">
<button disabled id='dial' type='button'>Dial</button> <button disabled id='dial' type='button'>Dial</button>
</div> </div>
<div class="row rcenter mf"> <div class="row rcenter mf">
<label for='nick-input'>Your nickname</label> <label for='nick-input'>Your nickname</label>
<input id='nick-input' placeholder='Choose a nickname' type='text' class="p100"> <input class="p100" id='nick-input' placeholder='Choose a nickname' type='text'>
</div> </div>
<div class="row rcenter mf"> <div class="row rcenter mf">
<label for='textInput'>Message text</label> <label for='textInput'>Message text</label>
<input disabled id='textInput' placeholder='Type your message here' type='text' class="p100"> <input class="p100" disabled id='textInput' placeholder='Type your message here' type='text'>
<button disabled id='sendButton' type='button'>Send message using Light Push</button> <button disabled id='sendButton' type='button'>Send message using Light Push</button>
</div> </div>
<span id='sending-status'></span> <span id='sending-status'></span>
<h4 class="mu1">Messages</h4> <h4 class="mu1">Messages</h4>
<div id="messages"></div> <div id="messages"></div>
<script type='module'> <script type='module'>
import {utils} from 'https://unpkg.com/js-waku@0.29.0-29436ea/bundle/index.js'; import {utils} from 'https://unpkg.com/js-waku@0.29.0-29436ea/bundle/index.js';
@ -118,7 +118,7 @@
MembershipKey, MembershipKey,
RLNDecoder, RLNDecoder,
RLNEncoder RLNEncoder
} from "https://unpkg.com/@waku/rln@0.0.12/bundle/index.js"; } from "https://unpkg.com/@waku/rln@0.0.12-ccac829/bundle/index.js";
import {ethers} from "https://unpkg.com/ethers@5.0.7/dist/ethers-all.esm.min.js" import {ethers} from "https://unpkg.com/ethers@5.0.7/dist/ethers-all.esm.min.js"
@ -357,7 +357,7 @@
console.log("Verifying proof") console.log("Verifying proof")
console.time("proof_verify_timer") console.time("proof_verify_timer")
const res = msg.verify() const res = msg.verify()
console.time("proof_verify_timer") console.timeEnd("proof_verify_timer")
console.log("proof verified!", res) console.log("proof verified!", res)
if (res === undefined) { if (res === undefined) {
msg.proofState = "no proof attached" msg.proofState = "no proof attached"
@ -432,7 +432,11 @@
sendButton.onclick = async () => { sendButton.onclick = async () => {
const text = utils.utf8ToBytes(textInput.value); const text = utils.utf8ToBytes(textInput.value);
const timestamp = new Date(); const timestamp = new Date();
const msg = ProtoChatMessage.create({text, nick: nicknameInput.value, timestamp: Math.floor(timestamp.valueOf() / 1000)}); const msg = ProtoChatMessage.create({
text,
nick: nicknameInput.value,
timestamp: Math.floor(timestamp.valueOf() / 1000)
});
const payload = ProtoChatMessage.encode(msg).finish(); const payload = ProtoChatMessage.encode(msg).finish();
console.log("Sending message with proof...") console.log("Sending message with proof...")
sendingStatusSpan.innerText = 'sending...' sendingStatusSpan.innerText = 'sending...'