Skip to content

Commit

Permalink
Merge pull request #256 from Kodylow/prefill-verify-hashes
Browse files Browse the repository at this point in the history
feat: prefills hashes if we're already in VerifiedConfigs
  • Loading branch information
okjodom authored Nov 3, 2023
2 parents 24cd50f + 5f1f463 commit 822d0c6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/guardian-ui/src/components/VerifyGuardians.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const VerifyGuardians: React.FC<Props> = ({ next }) => {
// Poll for peers and configGenParams while on this page.
useConsensusPolling();

const verifiedConfigs = peers.every(
const verifiedConfigs: boolean = peers.every(
(peer) => peer.status === ServerStatus.VerifiedConfigs
);

Expand Down Expand Up @@ -78,6 +78,16 @@ export const VerifyGuardians: React.FC<Props> = ({ next }) => {
}))
.filter((peer) => peer.id !== our_current_id.toString())
);

// If we're already at the VerifiedConfigs state, prefill all the other hashes with the correct values
if (peers[our_current_id].status === ServerStatus.VerifiedConfigs) {
const otherPeers = Object.entries(peers).filter(
([id]) => id !== our_current_id.toString()
);
setEnteredHashes(
otherPeers.map(([id]) => hashes[id as unknown as number])
);
}
} catch (err) {
setError(formatApiErrorMessage(err));
}
Expand All @@ -96,6 +106,7 @@ export const VerifyGuardians: React.FC<Props> = ({ next }) => {
});
return;
}

const isAllValid =
peersWithHash &&
peersWithHash.every(({ hash }, idx) => hash === enteredHashes[idx]);
Expand Down

0 comments on commit 822d0c6

Please sign in to comment.