mirror of https://github.com/waku-org/js-rln.git
feat!: add registerMemberFromMembershipKey (#56)
* add registerMemberFromMembershipKey * make better naming
This commit is contained in:
parent
360dc829f5
commit
88a28a11e3
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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 =
|
||||
|
|
Loading…
Reference in New Issue