From d07080ebe47f031a52a06ee1da2f1cccdf5dcd70 Mon Sep 17 00:00:00 2001 From: Danish Arora Date: Sat, 8 Mar 2025 21:58:02 +0530 Subject: [PATCH] chore: fix --- .../rln/src/contract/rln_light_contract.ts | 26 +++++++------------ packages/rln/src/rln_light.ts | 2 +- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/packages/rln/src/contract/rln_light_contract.ts b/packages/rln/src/contract/rln_light_contract.ts index 49f1a89e52..5a378aa07d 100644 --- a/packages/rln/src/contract/rln_light_contract.ts +++ b/packages/rln/src/contract/rln_light_contract.ts @@ -3,7 +3,6 @@ import { ethers } from "ethers"; import type { IdentityCredential } from "../identity.js"; import type { DecryptedCredentials } from "../keystore/index.js"; -import { RLNLightInstance } from "../rln_light.js"; import { RLN_ABI } from "./abi.js"; import { DEFAULT_RATE_LIMIT, RATE_LIMIT_PARAMS } from "./constants.js"; @@ -69,13 +68,12 @@ export class RLNLightContract { * Allows injecting a mocked contract for testing purposes. */ public static async init( - rlnLightInstance: RLNLightInstance, options: RLNContractInitOptions ): Promise { const rlnContract = new RLNLightContract(options); - await rlnContract.fetchMembers(rlnLightInstance); - rlnContract.subscribeToMembers(rlnLightInstance); + await rlnContract.fetchMembers(); + rlnContract.subscribeToMembers(); return rlnContract; } @@ -213,10 +211,7 @@ export class RLNLightContract { return this._membersExpiredFilter; } - public async fetchMembers( - rlnLightInstance: RLNLightInstance, - options: FetchMembersOptions = {} - ): Promise { + public async fetchMembers(options: FetchMembersOptions = {}): Promise { const registeredMemberEvents = await queryFilter(this.contract, { fromBlock: this.deployBlock, ...options, @@ -238,13 +233,10 @@ export class RLNLightContract { ...removedMemberEvents, ...expiredMemberEvents ]; - this.processEvents(rlnLightInstance, events); + this.processEvents(events); } - public processEvents( - rlnLightInstance: RLNLightInstance, - events: ethers.Event[] - ): void { + public processEvents(events: ethers.Event[]): void { const toRemoveTable = new Map(); const toInsertTable = new Map(); @@ -286,7 +278,7 @@ export class RLNLightContract { }); } - public subscribeToMembers(rlnLightInstance: RLNLightInstance): void { + public subscribeToMembers(): void { this.contract.on( this.membersFilter, ( @@ -295,7 +287,7 @@ export class RLNLightContract { _index: ethers.BigNumber, event: ethers.Event ) => { - this.processEvents(rlnLightInstance, [event]); + this.processEvents([event]); } ); @@ -307,7 +299,7 @@ export class RLNLightContract { _index: ethers.BigNumber, event: ethers.Event ) => { - this.processEvents(rlnLightInstance, [event]); + this.processEvents([event]); } ); @@ -319,7 +311,7 @@ export class RLNLightContract { _index: ethers.BigNumber, event: ethers.Event ) => { - this.processEvents(rlnLightInstance, [event]); + this.processEvents([event]); } ); } diff --git a/packages/rln/src/rln_light.ts b/packages/rln/src/rln_light.ts index 08e76427dc..20dabcb13e 100644 --- a/packages/rln/src/rln_light.ts +++ b/packages/rln/src/rln_light.ts @@ -97,7 +97,7 @@ export class RLNLightInstance { this._credentials = credentials; this._signer = signer!; - this._contract = await RLNLightContract.init(this, { + this._contract = await RLNLightContract.init({ address: address!, signer: signer!, rateLimit: rateLimit