mirror of
https://github.com/logos-messaging/js-rln.git
synced 2026-01-02 13:43:06 +00:00
fix: variable naming
This commit is contained in:
parent
1ca5b7e99a
commit
44fc3c2b68
@ -74,10 +74,10 @@ describe("RLN Contract abstraction - RLN v2", () => {
|
||||
provider
|
||||
);
|
||||
const rlnContract = await RLNContract.init(rlnInstance, {
|
||||
registryAddress: SEPOLIA_CONTRACT.address,
|
||||
address: SEPOLIA_CONTRACT.address,
|
||||
signer: voidSigner,
|
||||
storageIndex: 0,
|
||||
registryContract: mockedRegistryContract as unknown as ethers.Contract
|
||||
rateLimit: 0,
|
||||
contract: mockedRegistryContract as unknown as ethers.Contract
|
||||
});
|
||||
|
||||
await rlnContract.fetchMembers(rlnInstance, {
|
||||
@ -159,10 +159,10 @@ describe("RLN Contract abstraction - RLN v2", () => {
|
||||
provider
|
||||
);
|
||||
const rlnContract = await RLNContract.init(rlnInstance, {
|
||||
registryAddress: SEPOLIA_CONTRACT.address,
|
||||
signer: voidSigner,
|
||||
storageIndex: 0,
|
||||
registryContract: mockedRegistryContract as unknown as ethers.Contract
|
||||
address: SEPOLIA_CONTRACT.address,
|
||||
rateLimit: 0,
|
||||
contract: mockedRegistryContract as unknown as ethers.Contract
|
||||
});
|
||||
|
||||
const registerSpy = chai.spy.on(mockedRegistryContract, "register");
|
||||
|
||||
@ -25,8 +25,8 @@ interface Member {
|
||||
|
||||
interface RLNContractOptions {
|
||||
signer: ethers.Signer;
|
||||
registryAddress: string;
|
||||
storageIndex: number;
|
||||
address: string;
|
||||
rateLimit: number;
|
||||
}
|
||||
|
||||
interface FetchMembersOptions {
|
||||
@ -36,7 +36,7 @@ interface FetchMembersOptions {
|
||||
}
|
||||
|
||||
interface RLNContractInitOptions extends RLNContractOptions {
|
||||
registryContract?: ethers.Contract;
|
||||
contract?: ethers.Contract;
|
||||
}
|
||||
|
||||
export class RLNContract {
|
||||
@ -44,7 +44,7 @@ export class RLNContract {
|
||||
private merkleRootTracker: MerkleRootTracker;
|
||||
|
||||
private deployBlock: undefined | number;
|
||||
private storageIndex: number;
|
||||
private rateLimit: number;
|
||||
private _membersFilter: ethers.EventFilter;
|
||||
private _membersRemovedFilter: ethers.EventFilter;
|
||||
|
||||
@ -57,20 +57,19 @@ export class RLNContract {
|
||||
rlnInstance: RLNInstance,
|
||||
options: RLNContractInitOptions
|
||||
) {
|
||||
const { registryAddress, signer, storageIndex, registryContract } = options;
|
||||
const { address, signer, rateLimit, contract } = options;
|
||||
|
||||
if (storageIndex === undefined) {
|
||||
throw new Error("storageIndex must be provided in RLNContractOptions.");
|
||||
if (rateLimit === undefined) {
|
||||
throw new Error("rateLimit must be provided in RLNContractOptions.");
|
||||
}
|
||||
|
||||
this.storageIndex = storageIndex;
|
||||
this.rateLimit = rateLimit;
|
||||
|
||||
const initialRoot = rlnInstance.zerokit.getMerkleRoot();
|
||||
|
||||
// Use the injected registryContract if provided; otherwise, instantiate a new one.
|
||||
this.contract =
|
||||
registryContract ||
|
||||
new ethers.Contract(registryAddress, RLN_V2_ABI, signer);
|
||||
contract || new ethers.Contract(address, RLN_V2_ABI, signer);
|
||||
this.merkleRootTracker = new MerkleRootTracker(5, initialRoot);
|
||||
|
||||
// Initialize event filters for MembershipRegistered and MembershipRemoved
|
||||
@ -249,7 +248,7 @@ export class RLNContract {
|
||||
const txRegisterResponse: ethers.ContractTransaction =
|
||||
await this.contract.register(
|
||||
identity.IDCommitmentBigInt,
|
||||
this.storageIndex,
|
||||
this.rateLimit,
|
||||
[],
|
||||
{ gasLimit: 300000 }
|
||||
);
|
||||
@ -307,7 +306,7 @@ export class RLNContract {
|
||||
permit.r,
|
||||
permit.s,
|
||||
identity.IDCommitmentBigInt,
|
||||
this.storageIndex,
|
||||
this.rateLimit,
|
||||
idCommitmentsToErase.map((id) => ethers.BigNumber.from(id))
|
||||
);
|
||||
const txRegisterReceipt = await txRegisterResponse.wait();
|
||||
|
||||
16
src/rln.ts
16
src/rln.ts
@ -70,7 +70,7 @@ type StartRLNOptions = {
|
||||
/**
|
||||
* If not set - will use default SEPOLIA_CONTRACT address.
|
||||
*/
|
||||
registryAddress?: string;
|
||||
address?: string;
|
||||
/**
|
||||
* Credentials to use for generating proofs and connecting to the contract and network.
|
||||
* If provided used for validating the network chainId and connecting to registry contract.
|
||||
@ -116,7 +116,7 @@ export class RLNInstance {
|
||||
try {
|
||||
const { credentials, keystore } =
|
||||
await RLNInstance.decryptCredentialsIfNeeded(options.credentials);
|
||||
const { signer, registryAddress } = await this.determineStartOptions(
|
||||
const { signer, address } = await this.determineStartOptions(
|
||||
options,
|
||||
credentials
|
||||
);
|
||||
@ -128,9 +128,9 @@ export class RLNInstance {
|
||||
this._credentials = credentials;
|
||||
this._signer = signer!;
|
||||
this._contract = await RLNContract.init(this, {
|
||||
registryAddress: registryAddress!,
|
||||
address: address!,
|
||||
signer: signer!,
|
||||
storageIndex: 0
|
||||
rateLimit: 0
|
||||
});
|
||||
this.started = true;
|
||||
} finally {
|
||||
@ -143,12 +143,12 @@ export class RLNInstance {
|
||||
credentials: KeystoreEntity | undefined
|
||||
): Promise<StartRLNOptions> {
|
||||
let chainId = credentials?.membership.chainId;
|
||||
const registryAddress =
|
||||
const address =
|
||||
credentials?.membership.address ||
|
||||
options.registryAddress ||
|
||||
options.address ||
|
||||
SEPOLIA_CONTRACT.address;
|
||||
|
||||
if (registryAddress === SEPOLIA_CONTRACT.address) {
|
||||
if (address === SEPOLIA_CONTRACT.address) {
|
||||
chainId = SEPOLIA_CONTRACT.chainId;
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ export class RLNInstance {
|
||||
|
||||
return {
|
||||
signer,
|
||||
registryAddress
|
||||
address
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user