Skip to content

Commit

Permalink
Merge pull request #178 from privacy-scaling-explorations/fix/ux
Browse files Browse the repository at this point in the history
  • Loading branch information
daodesigner authored Aug 25, 2023
2 parents 9322363 + 6597702 commit 6e0176d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/actions/src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion packages/phase2cli/src/commands/contribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,8 @@ export const listenToParticipantDocumentChanges = async (
participant,
entropy,
providerUserId,
false // not finalizing.
false, // not finalizing.
circuits.length
)
}
// Scenario (3.A).
Expand Down
10 changes: 7 additions & 3 deletions packages/phase2cli/src/commands/finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const handleVerifierSmartContract = async (
* @param participant <FirebaseDocumentInfo> - the Firestore document of the participant (coordinator).
* @param beacon <string> - the value used to compute the final contribution while finalizing the ceremony.
* @param coordinatorIdentifier <string> - the identifier of the coordinator.
* @param circuitsLength <number> - the number of circuits in the ceremony.
*/
export const handleCircuitFinalization = async (
cloudFunctions: Functions,
Expand All @@ -160,7 +161,8 @@ export const handleCircuitFinalization = async (
circuit: FirebaseDocumentInfo,
participant: FirebaseDocumentInfo,
beacon: string,
coordinatorIdentifier: string
coordinatorIdentifier: string,
circuitsLength: number
) => {
// Step (1).
await handleStartOrResumeContribution(
Expand All @@ -171,7 +173,8 @@ export const handleCircuitFinalization = async (
participant,
computeSHA256ToHex(beacon),
coordinatorIdentifier,
true
true,
circuitsLength
)

await sleep(2000) // workaound for descriptors.
Expand Down Expand Up @@ -307,7 +310,8 @@ const finalize = async (opt: any) => {
circuit,
participant,
beacon,
providerUserId
providerUserId,
circuits.length
)

process.stdout.write(`\n`)
Expand Down
10 changes: 6 additions & 4 deletions packages/phase2cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -521,6 +521,7 @@ export const getLatestUpdatesFromParticipant = async (
* @param entropyOrBeaconHash <string> - the entropy or beacon hash (only when finalizing) for the contribution.
* @param contributorOrCoordinatorIdentifier <string> - the identifier of the contributor or coordinator (only when finalizing).
* @param isFinalizing <boolean> - flag to discriminate between ceremony finalization (true) and contribution (false).
* @param circuitsLength <number> - the total number of circuits in the ceremony.
*/
export const handleStartOrResumeContribution = async (
cloudFunctions: Functions,
Expand All @@ -530,15 +531,16 @@ export const handleStartOrResumeContribution = async (
participant: FirebaseDocumentInfo,
entropyOrBeaconHash: any,
contributorOrCoordinatorIdentifier: string,
isFinalizing: boolean
isFinalizing: boolean,
circuitsLength: number
): Promise<void> => {
// Extract data.
const { prefix: ceremonyPrefix } = ceremony.data
const { waitingQueue, avgTimings, prefix: circuitPrefix, sequencePosition } = circuit.data
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.
Expand Down

0 comments on commit 6e0176d

Please sign in to comment.