feat!: add registerMemberFromMembershipKey (#56)

* add registerMemberFromMembershipKey
* make better naming
This commit is contained in:
Sasha 2023-04-19 23:28:04 +02:00 committed by GitHub
parent 360dc829f5
commit 88a28a11e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -46,7 +46,7 @@ describe("RLN Contract abstraction", () => {
} as unknown as ethers.Contract;
const contractSpy = chai.spy.on(rlnContract["_contract"], "register");
await rlnContract.registerMember(rlnInstance, mockSignature);
await rlnContract.registerWithSignature(rlnInstance, mockSignature);
chai.expect(contractSpy).to.have.been.called();
});

View File

@ -1,7 +1,7 @@
import { ethers } from "ethers";
import { RLN_ABI } from "./constants.js";
import { RLNInstance } from "./rln.js";
import { MembershipKey, RLNInstance } from "./rln.js";
type Member = {
pubkey: string;
@ -84,13 +84,20 @@ export class RLNContract {
rlnInstance.insertMember(idCommitment);
}
public async registerMember(
public async registerWithSignature(
rlnInstance: RLNInstance,
signature: string
): Promise<ethers.Event | undefined> {
const membershipKey = await rlnInstance.generateSeededMembershipKey(
signature
);
return this.registerWithKey(membershipKey);
}
public async registerWithKey(
membershipKey: MembershipKey
): Promise<ethers.Event | undefined> {
const depositValue = await this.contract.MEMBERSHIP_DEPOSIT();
const txRegisterResponse: ethers.ContractTransaction =