Skip to content

Commit d93d288

Browse files
committed
Fix incorrect error handling of invalid proof
A proof could be invalid without raising a rust error, this case was not handled
1 parent a444d74 commit d93d288

File tree

1 file changed

+14
-9
lines changed
  • mithril-explorer/src/components/CertifyCardanoTransactionsModal

1 file changed

+14
-9
lines changed

mithril-explorer/src/components/CertifyCardanoTransactionsModal/index.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,16 @@ export default function CertifyCardanoTransactionsModal({
8080
useEffect(() => {
8181
if (currentStep === validationSteps.validatingProof && certificate !== undefined) {
8282
verifyTransactionProofAgainstCertificate(client, transactionsProofs, certificate)
83-
.then(() =>
84-
// Artificial wait to give the user a feel of the workload under-hood
85-
setTimeout(() => {
86-
setCurrentStep(validationSteps.validatingCertificateChain);
87-
}, 250),
88-
)
83+
.then((proofValid) => {
84+
if (proofValid) {
85+
// Artificial wait to give the user a feel of the workload under-hood
86+
return setTimeout(() => {
87+
setCurrentStep(validationSteps.validatingCertificateChain);
88+
}, 250);
89+
} else {
90+
setCurrentStep(validationSteps.done);
91+
}
92+
})
8993
.catch((err) => handleError(err));
9094
}
9195
}, [client, currentStep, transactionsProofs, certificate]);
@@ -111,10 +115,11 @@ export default function CertifyCardanoTransactionsModal({
111115
transactionsProofs,
112116
certificate,
113117
);
118+
const isProofValid =
119+
(await client.verify_message_match_certificate(protocolMessage, certificate)) === true;
114120

115-
if ((await client.verify_message_match_certificate(protocolMessage, certificate)) === true) {
116-
setIsProofValid(true);
117-
}
121+
setIsProofValid(isProofValid);
122+
return isProofValid;
118123
}
119124

120125
function handleError(error) {

0 commit comments

Comments
 (0)