Skip to content

Commit

Permalink
Merge pull request privacy-scaling-explorations#1771 from privacy-sca…
Browse files Browse the repository at this point in the history
…ling-explorations/feat/get-voice-credits-on-signup

feat: return voice credits on signup
  • Loading branch information
0xmad authored Aug 15, 2024
2 parents dda41cf + d1b7e3d commit 90c8bd9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/cli/ts/commands/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const signup = async ({
const maciContract = MACIFactory.connect(maciAddress, signer);

let stateIndex = "";
let voiceCredits = "";
let receipt: ContractTransactionReceipt | null = null;

try {
Expand All @@ -88,7 +89,7 @@ export const signup = async ({
if (receipt?.logs) {
const [log] = receipt.logs;
const { args } = iface.parseLog(log as unknown as { topics: string[]; data: string }) || { args: [] };
[stateIndex] = args;
[stateIndex, , , voiceCredits] = args;
logGreen(quiet, success(`State index: ${stateIndex.toString()}`));
} else {
logError("Unable to retrieve the transaction receipt");
Expand All @@ -99,6 +100,7 @@ export const signup = async ({

return {
stateIndex: stateIndex ? stateIndex.toString() : "",
voiceCredits: voiceCredits ? Number.parseInt(voiceCredits, 10) : 0,
hash: receipt!.hash,
};
};
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/ts/utils/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,11 @@ export interface ISignupData {
*/
stateIndex: string;

/**
* The voice credits of the user
*/
voiceCredits: number;

/**
* The signup transaction hash
*/
Expand Down

0 comments on commit 90c8bd9

Please sign in to comment.