chore: condense generation and import signature

into one button

having two buttons:
- one for generating new credentials, then
registering on contract
- other for importing credentials that already
exist

removing two and only having one:
- generates credentials
- checks if pubKey matches in the smart contract
  - if exists, automatically hydrates
membershipId
  - if does not exist, enables action of
registering your new membershipId
This commit is contained in:
danisharora099 2022-12-12 13:57:32 +05:30
parent 05e8308ef0
commit f430d67513
No known key found for this signature in database
GPG Key ID: FBD2BF500037F135
1 changed files with 7 additions and 27 deletions

View File

@ -44,18 +44,20 @@
<div class="row">
<div class="w50">
<h4>You can either generate new credentials:</h4>
<button disabled id="generate-credentials" type="button">
Generate RLN Credentials
</button>
<h4>Generate new, or import existing, credentials from wallet:</h4>
<br />
<div id="import-from-wallet">
<button id="import-from-wallet-button" type="button">
Fetch credentials from wallet
</button>
</div>
<br />
<button disabled id="register-button" type="button">
Register Credentials in Contract
</button>
</div>
<div class="w50">
<h4>Or import existing ones:</h4>
<h4>Import existing credentials manually:</h4>
<div>
<label for="membership-id"
>Membership ID (your index in the RLN smart contract):</label
@ -69,11 +71,6 @@
Import RLN Credentials
</button>
</div>
<div id="import-from-wallet">
<button disabled id="import-from-wallet-button" type="button">
Import RLN Credentials from Wallet
</button>
</div>
</div>
</div>
<div class="row rcenter mu1">
@ -165,9 +162,6 @@
);
// Credentials Elements
const generateCredsButton = document.getElementById(
"generate-credentials"
);
const membershipIdInput = document.getElementById("membership-id");
const identityKeyInput = document.getElementById("id-key");
@ -247,8 +241,6 @@
}
}
generateCredsButton.disabled = !rlnInstance;
registerButton.disabled = !(
membershipKey &&
retrievedRLNEvents &&
@ -273,18 +265,6 @@
// Blockchain
generateCredsButton.onclick = async () => {
// sign message with ethers
const signer = provider.getSigner();
const signature = await signer.signMessage(signatureMessage);
// provide the signature as a seed
membershipKey = rlnInstance.generateSeededMembershipKey(signature);
updateFields();
};
membershipIdInput.onchange = updateFields;
identityKeyInput.onchange = updateFields;
commitmentKeyInput.onchange = updateFields;