Skip to content

Commit

Permalink
chore: unify mention of maciAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
kittybest committed Apr 3, 2024
1 parent 5e65e8e commit 0223b37
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 74 deletions.
12 changes: 6 additions & 6 deletions cli/ts/commands/genLocalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
export const genLocalState = async ({
outputPath,
pollId,
maciContractAddress,
maciAddress,
coordinatorPrivateKey,
ethereumProvider,
endBlock,
Expand All @@ -45,13 +45,13 @@ export const genLocalState = async ({
const network = await signer.provider?.getNetwork();

// validation of the maci contract address
if (!readContractAddress("MACI", network?.name) && !maciContractAddress) {
if (!readContractAddress("MACI", network?.name) && !maciAddress) {
logError("MACI contract address is empty");
}

const maciAddress = maciContractAddress || readContractAddress("MACI", network?.name);
const maciContractAddress = maciAddress || readContractAddress("MACI", network?.name);

if (!(await contractExists(signer.provider!, maciAddress))) {
if (!(await contractExists(signer.provider!, maciContractAddress))) {
logError("MACI contract does not exist");
}

Expand All @@ -64,7 +64,7 @@ export const genLocalState = async ({
const coordinatorMaciPrivKey = PrivKey.deserialize(coordPrivKey);
const coordinatorKeypair = new Keypair(coordinatorMaciPrivKey);

const maciContract = MACIFactory.connect(maciAddress, signer);
const maciContract = MACIFactory.connect(maciContractAddress, signer);
const pollAddr = await maciContract.polls(pollId);

if (!(await contractExists(signer.provider!, pollAddr))) {
Expand Down Expand Up @@ -121,7 +121,7 @@ export const genLocalState = async ({

const maciState = await genMaciStateFromContract(
provider!,
maciAddress,
maciContractAddress,
coordinatorKeypair,
pollId,
fromBlock,
Expand Down
10 changes: 5 additions & 5 deletions cli/ts/commands/mergeMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ import {
export const mergeMessages = async ({
pollId,
quiet = true,
maciContractAddress,
maciAddress,
numQueueOps,
signer,
}: MergeMessagesArgs): Promise<void> => {
banner(quiet);
const network = await signer.provider?.getNetwork();

// maci contract validation
if (!readContractAddress("MACI", network?.name) && !maciContractAddress) {
if (!readContractAddress("MACI", network?.name) && !maciAddress) {
logError("Could not read contracts");
}
const maciAddress = maciContractAddress || readContractAddress("MACI", network?.name);
if (!(await contractExists(signer.provider!, maciAddress))) {
const maciContractAddress = maciAddress || readContractAddress("MACI", network?.name);
if (!(await contractExists(signer.provider!, maciContractAddress))) {
logError("MACI contract does not exist");
}

if (pollId < 0) {
logError("Invalid poll id");
}

const maciContract = MACIFactory.connect(maciAddress, signer);
const maciContract = MACIFactory.connect(maciContractAddress, signer);
const pollAddress = await maciContract.polls(pollId);

if (!(await contractExists(signer.provider!, pollAddress))) {
Expand Down
10 changes: 5 additions & 5 deletions cli/ts/commands/mergeSignups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
*/
export const mergeSignups = async ({
pollId,
maciContractAddress,
maciAddress,
numQueueOps,
signer,
quiet = true,
Expand All @@ -33,21 +33,21 @@ export const mergeSignups = async ({
const network = await signer.provider?.getNetwork();

// maci contract validation
if (!readContractAddress("MACI", network?.name) && !maciContractAddress) {
if (!readContractAddress("MACI", network?.name) && !maciAddress) {
logError("Could not read contracts");
}

const maciAddress = maciContractAddress || readContractAddress("MACI", network?.name);
const maciContractAddress = maciAddress || readContractAddress("MACI", network?.name);

if (!(await contractExists(signer.provider!, maciAddress))) {
if (!(await contractExists(signer.provider!, maciContractAddress))) {
logError("MACI contract does not exist");
}

if (pollId < 0) {
logError("Invalid poll id");
}

const maciContract = MACIFactory.connect(maciAddress, signer);
const maciContract = MACIFactory.connect(maciContractAddress, signer);
const pollAddress = await maciContract.polls(pollId);

if (!(await contractExists(signer.provider!, pollAddress))) {
Expand Down
10 changes: 5 additions & 5 deletions cli/ts/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const publish = async ({
nonce,
pollId,
newVoteWeight,
maciContractAddress,
maciAddress,
salt,
privateKey,
signer,
Expand All @@ -43,7 +43,7 @@ export const publish = async ({
// deserialize
const userMaciPubKey = PubKey.deserialize(pubkey);

if (!(await contractExists(signer.provider!, maciContractAddress))) {
if (!(await contractExists(signer.provider!, maciAddress))) {
logError("MACI contract does not exist");
}

Expand Down Expand Up @@ -77,7 +77,7 @@ export const publish = async ({
logError("Invalid poll id");
}

const maciContract = MACIFactory.connect(maciContractAddress, signer);
const maciContract = MACIFactory.connect(maciAddress, signer);
const pollAddress = await maciContract.getPoll(pollId);

if (!(await contractExists(signer.provider!, pollAddress))) {
Expand Down Expand Up @@ -145,7 +145,7 @@ export const publish = async ({
export const publishBatch = async ({
messages,
pollId,
maciContractAddress,
maciAddress,
publicKey,
privateKey,
signer,
Expand All @@ -167,7 +167,7 @@ export const publishBatch = async ({

const userMaciPubKey = PubKey.deserialize(publicKey);
const userMaciPrivKey = PrivKey.deserialize(privateKey);
const maciContract = MACIFactory.connect(maciContractAddress, signer);
const maciContract = MACIFactory.connect(maciAddress, signer);
const pollAddress = await maciContract.getPoll(pollId);

const pollContract = PollFactory.connect(pollAddress, signer);
Expand Down
46 changes: 23 additions & 23 deletions cli/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ program
.command("airdrop")
.description("airdrop topup credits to the coordinator")
.requiredOption("-a, --amount <amount>", "the amount of topup", parseInt)
.option("-x, --contract <contract>", "the MACI contract address")
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
.option("-o, --poll-id <pollId>", "poll id", BigInt)
.option("-t, --token-address <tokenAddress>", "the token address")
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
Expand All @@ -159,7 +159,7 @@ program

await airdrop({
amount: cmdObj.amount,
maciAddress: cmdObj.contract,
maciAddress: cmdObj.maciAddress,
pollId: cmdObj.pollId,
contractAddress: cmdObj.tokenAddress,
quiet: cmdObj.quiet,
Expand Down Expand Up @@ -286,7 +286,7 @@ program
"-p, --pubkey <pubkey>",
"the MACI public key which should replace the user's public key in the state tree",
)
.option("-x, --contract <contract>", "the MACI contract address")
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
.option("-sk, --privkey <privkey>", "your serialized MACI private key")
.requiredOption("-i, --state-index <stateIndex>", "the user's state index", BigInt)
.requiredOption("-v, --vote-option-index <voteOptionIndex>", "the vote option index", BigInt)
Expand All @@ -301,7 +301,7 @@ program
const signer = await getSigner();
const network = await signer.provider?.getNetwork();

const maciContractAddress = cmdObj.contract || readContractAddress("MACI", network?.name);
const maciAddress = cmdObj.maciAddress || readContractAddress("MACI", network?.name);
const privateKey = cmdObj.privkey || (await promptSensitiveValue("Insert your MACI private key"));

await publish({
Expand All @@ -311,7 +311,7 @@ program
nonce: cmdObj.nonce,
pollId: cmdObj.pollId,
newVoteWeight: cmdObj.newVoteWeight,
maciContractAddress,
maciAddress,
salt: cmdObj.salt,
privateKey,
quiet: cmdObj.quiet,
Expand All @@ -326,7 +326,7 @@ program
.description("merge the message accumulator queue")
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
.option("-x, --maci-contract-address <maciContractAddress>", "the MACI contract address")
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
.requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
.option("-n, --num-queue-ops <numQueueOps>", "the number of queue operations", parseInt)
.action(async (cmdObj) => {
Expand All @@ -335,7 +335,7 @@ program

await mergeMessages({
pollId: cmdObj.pollId,
maciContractAddress: cmdObj.maciContractAddress,
maciAddress: cmdObj.maciAddress,
numQueueOps: cmdObj.numQueueOps?.toString(),
quiet: cmdObj.quiet,
signer,
Expand All @@ -349,7 +349,7 @@ program
.description("merge the signups accumulator queue")
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
.option("-x, --maci-contract-address <maciContractAddress>", "the MACI contract address")
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
.requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
.option("-n, --num-queue-ops <numQueueOps>", "the number of queue operations", parseInt)
.action(async (cmdObj) => {
Expand All @@ -358,7 +358,7 @@ program

await mergeSignups({
pollId: cmdObj.pollId,
maciContractAddress: cmdObj.maciContractAddress,
maciAddress: cmdObj.maciAddress,
numQueueOps: cmdObj.numQueueOps?.toString(),
quiet: cmdObj.quiet,
signer,
Expand Down Expand Up @@ -396,11 +396,11 @@ program
const signer = await getSigner();
const network = await signer.provider?.getNetwork();

const maciContractAddress = cmdObj.maciAddress || readContractAddress("MACI", network?.name);
const maciAddress = cmdObj.maciAddress || readContractAddress("MACI", network?.name);

await signup({
maciPubKey: cmdObj.pubkey,
maciAddress: maciContractAddress,
maciAddress,
sgDataArg: cmdObj.sgData,
ivcpDataArg: cmdObj.ivcpData,
quiet: cmdObj.quiet,
Expand All @@ -421,11 +421,11 @@ program
const signer = await getSigner();
const network = await signer.provider?.getNetwork();

const maciContractAddress = cmdObj.maciAddress || readContractAddress("MACI", network?.name);
const maciAddress = cmdObj.maciAddress || readContractAddress("MACI", network?.name);

await isRegisteredUser({
maciPubKey: cmdObj.pubkey,
maciAddress: maciContractAddress,
maciAddress,
signer,
quiet: cmdObj.quiet,
});
Expand All @@ -444,11 +444,11 @@ program
const signer = await getSigner();
const network = await signer.provider?.getNetwork();

const maciContractAddress = cmdObj.maciAddress || readContractAddress("MACI", network?.name);
const maciAddress = cmdObj.maciAddress || readContractAddress("MACI", network?.name);

await getPoll({
pollId: cmdObj.poll,
maciAddress: maciContractAddress,
maciAddress,
signer,
quiet: cmdObj.quiet,
});
Expand Down Expand Up @@ -512,7 +512,7 @@ program
false,
)
.option("-s, --subsidy-file <subsidyFile>", "the subsidy file")
.option("-x, --contract <contract>", "the MACI contract address")
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
.option("-tc, --tally-contract <tallyContract>", "the tally contract address")
.option("-sc, --subsidy-contract <subsidyContract>", "the subsidy contract address")
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
Expand All @@ -529,7 +529,7 @@ program

const tallyData = JSON.parse(fs.readFileSync(cmdObj.tallyFile, { encoding: "utf8" })) as TallyData;

const maciAddress = tallyData.maci || cmdObj.contract || readContractAddress("MACI", network?.name);
const maciAddress = tallyData.maci || cmdObj.maciAddress || readContractAddress("MACI", network?.name);
const subsidyAddress = cmdObj.subsidyContract || readContractAddress(`Subsidy-${cmdObj.pollId}`, network?.name);
const tallyAddress =
tallyData.tallyAddress || cmdObj.tallyContract || readContractAddress(`Tally-${cmdObj.pollId}`, network?.name);
Expand Down Expand Up @@ -562,7 +562,7 @@ program
.command("genProofs")
.description("generate the proofs for a poll")
.option("-sk, --privkey <privkey>", "your serialized MACI private key")
.option("-x, --contract <contract>", "the MACI contract address")
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
.requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
.requiredOption(
"-t, --tally-file <tallyFile>",
Expand Down Expand Up @@ -613,7 +613,7 @@ program
subsidyWitgen: cmdObj.subsidyWitnessgen,
subsidyDatFile: cmdObj.subsidyWitnessdat,
coordinatorPrivKey: cmdObj.privkey,
maciAddress: cmdObj.contract,
maciAddress: cmdObj.maciAddress,
transactionHash: cmdObj.transactionHash,
processWasm: cmdObj.processWasm,
tallyWasm: cmdObj.tallyWasm,
Expand All @@ -637,7 +637,7 @@ program
.description("generate a local MACI state from the smart contracts events")
.requiredOption("-o, --output <outputPath>", "the path where to write the state")
.requiredOption("-p, --poll-id <pollId>", "the id of the poll", BigInt)
.option("-x, --contract <contract>", "the MACI contract address")
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
.option("-sk, --privkey <privkey>", "your serialized MACI private key")
.option("-eb, --end-block <endBlock>", "the end block number", parseInt)
.option("-sb, --start-block <startBlock>", "the start block number", parseInt)
Expand All @@ -653,7 +653,7 @@ program
await genLocalState({
outputPath: cmdObj.output.toString(),
pollId: cmdObj.pollId,
maciContractAddress: cmdObj.contract,
maciAddress: cmdObj.maciAddress,
coordinatorPrivateKey: cmdObj.privkey,
ethereumProvider: cmdObj.rpcProvider,
endBlock: cmdObj.endBlock,
Expand All @@ -680,7 +680,7 @@ program
)
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
.option("-x, --contract <contract>", "the MACI contract address")
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
.option("-p, --message-processor-address <messageProcessorAddress>", "the message processor contract address")
.option("-t, --tally-contract <tallyContract>", "the tally contract address")
.option("-s, --subsidy-contract <subsidyContract>", "the subsidy contract address")
Expand All @@ -693,7 +693,7 @@ program
pollId: cmdObj.pollId,
proofDir: cmdObj.proofDir,
subsidyEnabled: cmdObj.subsidyEnabled,
maciAddress: cmdObj.contract,
maciAddress: cmdObj.maciAddress,
messageProcessorAddress: cmdObj.messageProcessorAddress,
tallyAddress: cmdObj.tallyContract,
subsidyAddress: cmdObj.subsidyContract,
Expand Down
10 changes: 5 additions & 5 deletions cli/ts/utils/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export interface GenLocalStateArgs {
/**
* The address of the MACI contract
*/
maciContractAddress?: string;
maciAddress?: string;

/**
* The private key of the MACI coordinator
Expand Down Expand Up @@ -617,7 +617,7 @@ export interface MergeMessagesArgs {
/**
* The address of the MACI contract
*/
maciContractAddress?: string;
maciAddress?: string;

/**
* The number of queue operations to merge
Expand All @@ -642,7 +642,7 @@ export interface MergeSignupsArgs {
/**
* The address of the MACI contract
*/
maciContractAddress?: string;
maciAddress?: string;

/**
* The number of queue operations to perform
Expand Down Expand Up @@ -722,7 +722,7 @@ export interface PublishArgs extends IPublishMessage {
/**
* The address of the MACI contract
*/
maciContractAddress: string;
maciAddress: string;

/**
* The id of the poll
Expand Down Expand Up @@ -757,7 +757,7 @@ export interface IPublishBatchArgs {
/**
* The address of the MACI contract
*/
maciContractAddress: string;
maciAddress: string;

/**
* The public key of the user
Expand Down
Loading

0 comments on commit 0223b37

Please sign in to comment.