chore: remove the storage contract references

This commit is contained in:
Danish Arora 2025-01-27 16:46:05 +05:30
parent b3708f830d
commit c251c384c5
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
4 changed files with 22 additions and 42 deletions

View File

@ -1,4 +1,4 @@
export const RLNv2ABI = [
export const RLN_V2_ABI = [
{
type: "constructor",
inputs: [],

View File

@ -1,7 +1,8 @@
import { RLNv2ABI } from "./abis/rlnv2";
import { RLN_V2_ABI } from "./abis/rlnv2";
export { RLN_V2_ABI as RLN_V2_ABI };
export const SEPOLIA_CONTRACT = {
chainId: 11155111,
address: "0xCB33Aa5B38d79E3D9Fa8B10afF38AA201399a7e3",
abi: RLNv2ABI
abi: RLN_V2_ABI
};

View File

@ -6,9 +6,9 @@ import type { IdentityCredential } from "../identity.js";
import type { DecryptedCredentials } from "../keystore/index.js";
import type { RLNInstance } from "../rln.js";
import { MerkleRootTracker } from "../root_tracker.js";
import { zeroPadLE } from "../utils/index.js";
import { zeroPadLE } from "../utils/bytes.js";
import { RLN_REGISTRY_ABI, RLN_STORAGE_ABI } from "./constants.js";
import { RLN_V2_ABI } from "./abis/rlnv2.js";
const log = debug("waku:rln:contract");
@ -53,7 +53,6 @@ export class RLNContract {
): Promise<RLNContract> {
const rlnContract = new RLNContract(rlnInstance, options);
await rlnContract.initStorageContract(options.signer);
await rlnContract.fetchMembers(rlnInstance);
rlnContract.subscribeToMembers(rlnInstance);
@ -68,36 +67,12 @@ export class RLNContract {
this.registryContract = new ethers.Contract(
registryAddress,
RLN_REGISTRY_ABI,
RLN_V2_ABI,
signer
);
this.merkleRootTracker = new MerkleRootTracker(5, initialRoot);
}
private async initStorageContract(
signer: Signer,
options: RLNStorageOptions = {}
): Promise<void> {
const storageIndex = options?.storageIndex
? options.storageIndex
: await this.registryContract.usingStorageIndex();
const storageAddress = await this.registryContract.storages(storageIndex);
if (!storageAddress || storageAddress === ethers.constants.AddressZero) {
throw Error("No RLN Storage initialized on registry contract.");
}
this.storageIndex = storageIndex;
this.storageContract = new ethers.Contract(
storageAddress,
RLN_STORAGE_ABI,
signer
);
this._membersFilter = this.storageContract.filters.MemberRegistered();
this.deployBlock = await this.storageContract.deployedBlockNumber();
}
public get registry(): ethers.Contract {
if (!this.registryContract) {
throw Error("Registry contract was not initialized");
@ -345,9 +320,18 @@ function* takeN<T>(array: T[], size: number): Iterable<T[]> {
}
}
function ignoreErrors<T>(promise: Promise<T>, defaultValue: T): Promise<T> {
return promise.catch((err) => {
log(`Ignoring an error during query: ${err?.message}`);
async function ignoreErrors<T>(
promise: Promise<T>,
defaultValue: T
): Promise<T> {
try {
return await promise;
} catch (err: unknown) {
if (err instanceof Error) {
log(`Ignoring an error during query: ${err.message}`);
} else {
log(`Ignoring an unknown error during query`);
}
return defaultValue;
});
}
}

View File

@ -1,9 +1,5 @@
import { RLNDecoder, RLNEncoder } from "./codec.js";
import {
RLN_REGISTRY_ABI,
RLN_STORAGE_ABI,
SEPOLIA_CONTRACT
} from "./contract/index.js";
import { RLN_V2_ABI, SEPOLIA_CONTRACT } from "./contract/index.js";
import { RLNContract } from "./contract/index.js";
import { createRLN } from "./create.js";
import { IdentityCredential } from "./identity.js";
@ -23,8 +19,7 @@ export {
RLNDecoder,
MerkleRootTracker,
RLNContract,
RLN_STORAGE_ABI,
RLN_REGISTRY_ABI,
RLN_V2_ABI,
SEPOLIA_CONTRACT,
extractMetaMaskSigner
};