Skip to content

Commit

Permalink
Merge pull request #58 from privacy-scaling-explorations/fix/ui
Browse files Browse the repository at this point in the history
fix(ux): added more verbose messages to inform the user of waiting times and errors
  • Loading branch information
ctrlc03 committed Jun 13, 2023
2 parents d450e69 + 80d9858 commit bdd6d0f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
10 changes: 9 additions & 1 deletion packages/phase2cli/src/commands/contribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,17 @@ const contribute = async () => {
const spinner = customSpinner(`Verifying your participant status...`, `clock`)
spinner.start()

// Check that the user's document is created
const userDoc = await getDocumentById(firestoreDatabase, commonTerms.collections.users.name, user.uid)
const userData = userDoc.data()
if (!userData) {
spinner.fail(`Unfortunately we could not find a user document with your information. This likely means that you did not pass the GitHub reputation checks and therefore are not elegible to contribute to any ceremony. Please contact the coordinator if you believe this to be an error.`)
process.exit(0)
}

// Check the user's current participant readiness for contribution status (eligible, already contributed, timed out).
const canParticipantContributeToCeremony = await checkParticipantForCeremony(firebaseFunctions, selectedCeremony.id)

await sleep(2000) // wait for CF execution.

// Get updated participant data.
Expand Down
37 changes: 22 additions & 15 deletions packages/phase2cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export const generateCustomUrlToTweetAboutParticipation = (
) =>
isFinalizing
? `https://twitter.com/intent/tweet?text=I%20have%20finalized%20the%20${ceremonyName}%20Phase%202%20Trusted%20Setup%20ceremony!%20You%20can%20view%20my%20final%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP%20#PSE`
: `https://twitter.com/intent/tweet?text=I%20contributed%20to%20the%20${ceremonyName}%20Phase%202%20Trusted%20Setup%20ceremony!%20You%20can%20contribute%20here:%20https://github.com/quadratic-funding/mpc-phase2-suite%20You%20can%20view%20my%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP`
: `https://twitter.com/intent/tweet?text=I%20contributed%20to%20the%20${ceremonyName}%20Phase%202%20Trusted%20Setup%20ceremony!%20You%20can%20contribute%20here:%20https://github.com/privacy-scaling-explorations/p0tion%20You%20can%20view%20my%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP`

/**
* Return a custom progress bar.
Expand Down Expand Up @@ -543,8 +543,8 @@ export const handleStartOrResumeContribution = async (
const spinner = customSpinner(
`${
participantData.contributionStep === ParticipantContributionStep.DOWNLOADING
? `Preparing to begin the contribution...`
: `Preparing to resume contribution`
? `Preparing to begin the contribution. Please note that the contribution can take a long time depending on the size of the circuits and your internet connection.`
: `Preparing to resume contribution. Please note that the contribution can take a long time depending on the size of the circuits and your internet connection.`
}`,
`clock`
)
Expand Down Expand Up @@ -687,7 +687,7 @@ export const handleStartOrResumeContribution = async (
if (isFinalizing || participantData.contributionStep === ParticipantContributionStep.UPLOADING) {
spinner.text = `Uploading ${isFinalizing ? "final" : "your"} contribution ${
!isFinalizing ? theme.text.bold(`#${nextZkeyIndex}`) : ""
} to storage...`
} to storage. Please note that this step might take a while depending on your connection speed and the zKey's size`
spinner.start()

if (!isFinalizing)
Expand All @@ -712,7 +712,7 @@ export const handleStartOrResumeContribution = async (
spinner.succeed(
`${
isFinalizing ? `Contribution` : `Contribution ${theme.text.bold(`#${nextZkeyIndex}`)}`
} correctly saved on storage`
} correctly saved to storage`
)

// Advance to next contribution step (VERIFYING) if not finalizing.
Expand All @@ -735,7 +735,7 @@ export const handleStartOrResumeContribution = async (
const { seconds, minutes, hours } = getSecondsMinutesHoursFromMillis(avgTimings.verifyCloudFunction)

process.stdout.write(
`${theme.symbols.info} Your contribution is under verification ${
`${theme.symbols.info} Your contribution is under verification. Please note that this step can take up to one hour, depending on the cicuit size ${
avgTimings.verifyCloudFunction > 0
? `(~ ${theme.text.bold(
`${convertToDoubleDigits(hours)}:${convertToDoubleDigits(minutes)}:${convertToDoubleDigits(
Expand All @@ -746,14 +746,21 @@ export const handleStartOrResumeContribution = async (
}`
)

// Execute contribution verification.
await verifyContribution(
cloudFunctions,
ceremony.id,
circuit,
bucketName,
contributorOrCoordinatorIdentifier,
String(process.env.FIREBASE_CF_URL_VERIFY_CONTRIBUTION)
)
try {
// Execute contribution verification.
await verifyContribution(
cloudFunctions,
ceremony.id,
circuit,
bucketName,
contributorOrCoordinatorIdentifier,
String(process.env.FIREBASE_CF_URL_VERIFY_CONTRIBUTION)
)
} catch(error: any) {
process.stdout.write(
`\n${theme.symbols.error} ${theme.text.bold("Unfortunately there was an error with the contribution verification. Please restart phase2cli and try again. If the problem persists, please contact the ceremony coordinator.")}\n`
)
}

}
}

0 comments on commit bdd6d0f

Please sign in to comment.