chore: add getMembershipStatus method

This commit is contained in:
Danish Arora 2025-05-15 16:28:47 +05:30
parent 741fb28c09
commit b16a49e80f
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E

View File

@ -1,5 +1,5 @@
import { Logger } from "@waku/utils";
import { ethers } from "ethers";
import { Contract, ethers } from "ethers";
import { IdentityCredential } from "../identity.js";
import { DecryptedCredentials } from "../keystore/types.js";
@ -719,6 +719,19 @@ export class RLNBaseContract {
}
}
public async getMembershipStatus(
idCommitment: bigint
): Promise<"expired" | "grace" | "active"> {
const [isExpired, isInGrace] = await Promise.all([
this.contract.isExpired(idCommitment),
this.contract.isInGracePeriod(idCommitment)
]);
if (isExpired) return "expired";
if (isInGrace) return "grace";
return "active";
}
/**
* Checks if a membership is expired for the given idCommitment
* @param idCommitmentBigInt The idCommitment as bigint