From 6597702b3eb877624703feaaf67607eddd648b0b Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Fri, 25 Aug 2023 10:56:24 +0100 Subject: [PATCH] refactor(ui/ux): small changes for a better ui/ux --- packages/actions/src/helpers/utils.ts | 2 +- packages/phase2cli/src/commands/contribute.ts | 3 ++- packages/phase2cli/src/commands/finalize.ts | 10 +++++++--- packages/phase2cli/src/lib/utils.ts | 10 ++++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/actions/src/helpers/utils.ts b/packages/actions/src/helpers/utils.ts index 7945fb83..94672483 100644 --- a/packages/actions/src/helpers/utils.ts +++ b/packages/actions/src/helpers/utils.ts @@ -446,7 +446,7 @@ export const getPublicAttestationPreambleForContributor = ( ) => `Hey, I'm ${contributorIdentifier} and I have ${ isFinalizing ? "finalized" : "contributed to" - } the ${ceremonyName} MPC Phase2 Trusted Setup ceremony.\nThe following are my contribution signatures:` + } the ${ceremonyName}${ceremonyName.toLowerCase().includes('trusted setup') || ceremonyName.toLowerCase().includes("ceremony") ? "." : " MPC Phase2 Trusted Setup ceremony."}\nThe following are my contribution signatures:` /** * Check and prepare public attestation for the contributor made only of its valid contributions. diff --git a/packages/phase2cli/src/commands/contribute.ts b/packages/phase2cli/src/commands/contribute.ts index c3b088b0..34de0991 100644 --- a/packages/phase2cli/src/commands/contribute.ts +++ b/packages/phase2cli/src/commands/contribute.ts @@ -724,7 +724,8 @@ export const listenToParticipantDocumentChanges = async ( participant, entropy, providerUserId, - false // not finalizing. + false, // not finalizing. + circuits.length ) } // Scenario (3.A). diff --git a/packages/phase2cli/src/commands/finalize.ts b/packages/phase2cli/src/commands/finalize.ts index c7184f9a..2e5c8bd8 100644 --- a/packages/phase2cli/src/commands/finalize.ts +++ b/packages/phase2cli/src/commands/finalize.ts @@ -152,6 +152,7 @@ export const handleVerifierSmartContract = async ( * @param participant - the Firestore document of the participant (coordinator). * @param beacon - the value used to compute the final contribution while finalizing the ceremony. * @param coordinatorIdentifier - the identifier of the coordinator. + * @param circuitsLength - the number of circuits in the ceremony. */ export const handleCircuitFinalization = async ( cloudFunctions: Functions, @@ -160,7 +161,8 @@ export const handleCircuitFinalization = async ( circuit: FirebaseDocumentInfo, participant: FirebaseDocumentInfo, beacon: string, - coordinatorIdentifier: string + coordinatorIdentifier: string, + circuitsLength: number ) => { // Step (1). await handleStartOrResumeContribution( @@ -171,7 +173,8 @@ export const handleCircuitFinalization = async ( participant, computeSHA256ToHex(beacon), coordinatorIdentifier, - true + true, + circuitsLength ) await sleep(2000) // workaound for descriptors. @@ -307,7 +310,8 @@ const finalize = async (opt: any) => { circuit, participant, beacon, - providerUserId + providerUserId, + circuits.length ) process.stdout.write(`\n`) diff --git a/packages/phase2cli/src/lib/utils.ts b/packages/phase2cli/src/lib/utils.ts index 3cfacc47..877c6e19 100644 --- a/packages/phase2cli/src/lib/utils.ts +++ b/packages/phase2cli/src/lib/utils.ts @@ -311,8 +311,8 @@ export const generateCustomUrlToTweetAboutParticipation = ( isFinalizing: boolean ) => 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/privacy-scaling-explorations/p0tion%20You%20can%20view%20my%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP` + ? `https://twitter.com/intent/tweet?text=I%20have%20finalized%20the%20${ceremonyName}${ceremonyName.toLowerCase().includes("trusted") || ceremonyName.toLowerCase().includes("setup") || ceremonyName.toLowerCase().includes("phase2") || ceremonyName.toLowerCase().includes("ceremony") ? "!" : "%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}${ceremonyName.toLowerCase().includes("trusted") || ceremonyName.toLowerCase().includes("setup") || ceremonyName.toLowerCase().includes("phase2") || ceremonyName.toLowerCase().includes("ceremony") ? "!" : "%20Phase%202%20Trusted%20Setup%20ceremony!"}%20You%20can%20view%20the%20steps%20to%20contribute%20here:%20https://ceremony.pse.dev%20You%20can%20view%20my%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP` /** * Return a custom progress bar. @@ -521,6 +521,7 @@ export const getLatestUpdatesFromParticipant = async ( * @param entropyOrBeaconHash - the entropy or beacon hash (only when finalizing) for the contribution. * @param contributorOrCoordinatorIdentifier - the identifier of the contributor or coordinator (only when finalizing). * @param isFinalizing - flag to discriminate between ceremony finalization (true) and contribution (false). + * @param circuitsLength - the total number of circuits in the ceremony. */ export const handleStartOrResumeContribution = async ( cloudFunctions: Functions, @@ -530,7 +531,8 @@ export const handleStartOrResumeContribution = async ( participant: FirebaseDocumentInfo, entropyOrBeaconHash: any, contributorOrCoordinatorIdentifier: string, - isFinalizing: boolean + isFinalizing: boolean, + circuitsLength: number ): Promise => { // Extract data. const { prefix: ceremonyPrefix } = ceremony.data @@ -538,7 +540,7 @@ export const handleStartOrResumeContribution = async ( const { completedContributions } = waitingQueue // = current progress. console.log( - `${theme.text.bold(`\n- Circuit # ${theme.colors.magenta(`${sequencePosition}`)}`)} (Contribution Steps)` + `${theme.text.bold(`\n- Circuit # ${theme.colors.magenta(`${sequencePosition}/${circuitsLength}`)}`)} (Contribution Steps)` ) // Get most up-to-date data from the participant document.