From 0900e69fb5bde930cab760e7a4ec150e61f1af17 Mon Sep 17 00:00:00 2001 From: 0xmad <0xmad@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:49:06 -0500 Subject: [PATCH] feat(cli): add initial voice credits from signup event --- cli/ts/commands/signup.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/ts/commands/signup.ts b/cli/ts/commands/signup.ts index 67347ade98..d14f56fcfa 100644 --- a/cli/ts/commands/signup.ts +++ b/cli/ts/commands/signup.ts @@ -89,14 +89,14 @@ 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); @@ -104,11 +104,13 @@ export const isRegisteredUser = async ({ 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, }; };