mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-02-24 07:43:15 +00:00
chore: add getMembershipStatus method
This commit is contained in:
parent
741fb28c09
commit
b16a49e80f
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user