mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-03-28 17:53:49 +00:00
chore: fix
This commit is contained in:
parent
b73929be99
commit
d07080ebe4
@ -3,7 +3,6 @@ import { ethers } from "ethers";
|
|||||||
|
|
||||||
import type { IdentityCredential } from "../identity.js";
|
import type { IdentityCredential } from "../identity.js";
|
||||||
import type { DecryptedCredentials } from "../keystore/index.js";
|
import type { DecryptedCredentials } from "../keystore/index.js";
|
||||||
import { RLNLightInstance } from "../rln_light.js";
|
|
||||||
|
|
||||||
import { RLN_ABI } from "./abi.js";
|
import { RLN_ABI } from "./abi.js";
|
||||||
import { DEFAULT_RATE_LIMIT, RATE_LIMIT_PARAMS } from "./constants.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.
|
* Allows injecting a mocked contract for testing purposes.
|
||||||
*/
|
*/
|
||||||
public static async init(
|
public static async init(
|
||||||
rlnLightInstance: RLNLightInstance,
|
|
||||||
options: RLNContractInitOptions
|
options: RLNContractInitOptions
|
||||||
): Promise<RLNLightContract> {
|
): Promise<RLNLightContract> {
|
||||||
const rlnContract = new RLNLightContract(options);
|
const rlnContract = new RLNLightContract(options);
|
||||||
|
|
||||||
await rlnContract.fetchMembers(rlnLightInstance);
|
await rlnContract.fetchMembers();
|
||||||
rlnContract.subscribeToMembers(rlnLightInstance);
|
rlnContract.subscribeToMembers();
|
||||||
|
|
||||||
return rlnContract;
|
return rlnContract;
|
||||||
}
|
}
|
||||||
@ -213,10 +211,7 @@ export class RLNLightContract {
|
|||||||
return this._membersExpiredFilter;
|
return this._membersExpiredFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async fetchMembers(
|
public async fetchMembers(options: FetchMembersOptions = {}): Promise<void> {
|
||||||
rlnLightInstance: RLNLightInstance,
|
|
||||||
options: FetchMembersOptions = {}
|
|
||||||
): Promise<void> {
|
|
||||||
const registeredMemberEvents = await queryFilter(this.contract, {
|
const registeredMemberEvents = await queryFilter(this.contract, {
|
||||||
fromBlock: this.deployBlock,
|
fromBlock: this.deployBlock,
|
||||||
...options,
|
...options,
|
||||||
@ -238,13 +233,10 @@ export class RLNLightContract {
|
|||||||
...removedMemberEvents,
|
...removedMemberEvents,
|
||||||
...expiredMemberEvents
|
...expiredMemberEvents
|
||||||
];
|
];
|
||||||
this.processEvents(rlnLightInstance, events);
|
this.processEvents(events);
|
||||||
}
|
}
|
||||||
|
|
||||||
public processEvents(
|
public processEvents(events: ethers.Event[]): void {
|
||||||
rlnLightInstance: RLNLightInstance,
|
|
||||||
events: ethers.Event[]
|
|
||||||
): void {
|
|
||||||
const toRemoveTable = new Map<number, number[]>();
|
const toRemoveTable = new Map<number, number[]>();
|
||||||
const toInsertTable = new Map<number, ethers.Event[]>();
|
const toInsertTable = new Map<number, ethers.Event[]>();
|
||||||
|
|
||||||
@ -286,7 +278,7 @@ export class RLNLightContract {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public subscribeToMembers(rlnLightInstance: RLNLightInstance): void {
|
public subscribeToMembers(): void {
|
||||||
this.contract.on(
|
this.contract.on(
|
||||||
this.membersFilter,
|
this.membersFilter,
|
||||||
(
|
(
|
||||||
@ -295,7 +287,7 @@ export class RLNLightContract {
|
|||||||
_index: ethers.BigNumber,
|
_index: ethers.BigNumber,
|
||||||
event: ethers.Event
|
event: ethers.Event
|
||||||
) => {
|
) => {
|
||||||
this.processEvents(rlnLightInstance, [event]);
|
this.processEvents([event]);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -307,7 +299,7 @@ export class RLNLightContract {
|
|||||||
_index: ethers.BigNumber,
|
_index: ethers.BigNumber,
|
||||||
event: ethers.Event
|
event: ethers.Event
|
||||||
) => {
|
) => {
|
||||||
this.processEvents(rlnLightInstance, [event]);
|
this.processEvents([event]);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -319,7 +311,7 @@ export class RLNLightContract {
|
|||||||
_index: ethers.BigNumber,
|
_index: ethers.BigNumber,
|
||||||
event: ethers.Event
|
event: ethers.Event
|
||||||
) => {
|
) => {
|
||||||
this.processEvents(rlnLightInstance, [event]);
|
this.processEvents([event]);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,7 +97,7 @@ export class RLNLightInstance {
|
|||||||
|
|
||||||
this._credentials = credentials;
|
this._credentials = credentials;
|
||||||
this._signer = signer!;
|
this._signer = signer!;
|
||||||
this._contract = await RLNLightContract.init(this, {
|
this._contract = await RLNLightContract.init({
|
||||||
address: address!,
|
address: address!,
|
||||||
signer: signer!,
|
signer: signer!,
|
||||||
rateLimit: rateLimit
|
rateLimit: rateLimit
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user