mirror of
https://github.com/logos-messaging/js-rln.git
synced 2026-01-02 13:43:06 +00:00
chore: remove the storage contract references
This commit is contained in:
parent
b3708f830d
commit
c251c384c5
@ -1,4 +1,4 @@
|
||||
export const RLNv2ABI = [
|
||||
export const RLN_V2_ABI = [
|
||||
{
|
||||
type: "constructor",
|
||||
inputs: [],
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user