diff --git a/src/rln_contract.spec.ts b/src/rln_contract.spec.ts index d8c5d43..c6159e9 100644 --- a/src/rln_contract.spec.ts +++ b/src/rln_contract.spec.ts @@ -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(); }); diff --git a/src/rln_contract.ts b/src/rln_contract.ts index b39463f..b1b8f62 100644 --- a/src/rln_contract.ts +++ b/src/rln_contract.ts @@ -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 { const membershipKey = await rlnInstance.generateSeededMembershipKey( signature ); + + return this.registerWithKey(membershipKey); + } + + public async registerWithKey( + membershipKey: MembershipKey + ): Promise { const depositValue = await this.contract.MEMBERSHIP_DEPOSIT(); const txRegisterResponse: ethers.ContractTransaction =