Skip to content

Commit

Permalink
Merge pull request #1299 from privacy-scaling-explorations/feature/in…
Browse files Browse the repository at this point in the history
…itial-voice-credit-balance

feat(cli): add initial voice credits for poll sdk method
  • Loading branch information
0xmad authored Mar 14, 2024
2 parents e98881c + 0900e69 commit d3a9857
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cli/ts/commands/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,28 @@ export const signup = async ({
/**
* Checks if user is registered with public key
* @param IRegisteredArgs - The arguments for the register check command
* @returns user registered or not and state index
* @returns user registered or not and state index, voice credit balance
*/
export const isRegisteredUser = async ({
maciAddress,
maciPubKey,
signer,
quiet = true,
}: IRegisteredUserArgs): Promise<{ isRegistered: boolean; stateIndex?: string }> => {
}: IRegisteredUserArgs): Promise<{ isRegistered: boolean; stateIndex?: string; voiceCredits?: string }> => {
banner(quiet);

const maciContract = MACIFactory.connect(maciAddress, signer);
const publicKey = PubKey.deserialize(maciPubKey).asContractParam();

const events = await maciContract.queryFilter(maciContract.filters.SignUp(undefined, publicKey.x, publicKey.y));
const stateIndex = events[0]?.args[0].toString() as string | undefined;
const voiceCredits = events[0]?.args[3].toString() as string | undefined;

logGreen(quiet, success(`State index: ${stateIndex?.toString()}, registered: ${stateIndex !== undefined}`));

return {
isRegistered: stateIndex !== undefined,
stateIndex,
voiceCredits,
};
};

0 comments on commit d3a9857

Please sign in to comment.