Skip to content

Commit

Permalink
feat(cli): add start block for signup event parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmad committed Apr 3, 2024
1 parent e7ec721 commit f06f42d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cli/ts/commands/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ export const isRegisteredUser = async ({
maciAddress,
maciPubKey,
signer,
startBlock,
quiet = true,
}: 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 events = await maciContract.queryFilter(
maciContract.filters.SignUp(undefined, publicKey.x, publicKey.y),
startBlock,
);
const stateIndex = events[0]?.args[0].toString() as string | undefined;
const voiceCredits = events[0]?.args[3].toString() as string | undefined;

Expand Down
5 changes: 5 additions & 0 deletions cli/ts/utils/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,11 @@ export interface IRegisteredUserArgs {
*/
maciAddress: string;

/**
* Start block for event parsing
*/
startBlock?: number;

/**
* Whether to log the output
*/
Expand Down

0 comments on commit f06f42d

Please sign in to comment.