Skip to content

Commit

Permalink
Merge pull request #1557 from privacy-scaling-explorations/fix/cli-si…
Browse files Browse the repository at this point in the history
…gnup-script

fix(cli): changed validation for the signup data and voice credit data
  • Loading branch information
0xmad authored Jun 12, 2024
2 parents 4d98ac5 + 6192759 commit 896b575
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cli/ts/commands/signup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type ContractTransactionReceipt, isBytesLike } from "ethers";
import { MACI__factory as MACIFactory } from "maci-contracts/typechain-types";
import { PubKey } from "maci-domainobjs";

import type { IParseSignupEventsArgs, IRegisteredUserArgs, ISignupData, SignupArgs } from "../utils/interfaces";
import type { ContractTransactionReceipt } from "ethers";

import { banner } from "../utils/banner";
import { contractExists } from "../utils/contracts";
Expand Down Expand Up @@ -38,14 +38,12 @@ export const signup = async ({
const sgData = sgDataArg || DEFAULT_SG_DATA;
const ivcpData = ivcpDataArg || DEFAULT_IVCP_DATA;

const regex32ByteHex = /^0x[a-fA-F0-9]{64}$/;

// we validate that the signup data and voice credit data is valid
if (!sgData.match(regex32ByteHex)) {
if (!isBytesLike(sgData)) {
logError("invalid signup gateway data");
}

if (!ivcpData.match(regex32ByteHex)) {
if (!isBytesLike(ivcpData)) {
logError("invalid initial voice credit proxy data");
}

Expand Down

0 comments on commit 896b575

Please sign in to comment.