Skip to content

Commit

Permalink
fix(cli-signup): changed validation for the signup data and voice cre…
Browse files Browse the repository at this point in the history
…dit data
  • Loading branch information
Crisgarner authored and 0xmad committed Jun 12, 2024
1 parent 4d98ac5 commit a099aff
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 { 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 a099aff

Please sign in to comment.