Skip to content

Commit c4c5ee1

Browse files
committed
Fix explorer crash when proving a transaction throw an error
It was due to showing the `TransactionCertificationResult` before a certificate could even be retrieved, leading to a `t is undefined` error.
1 parent 693385b commit c4c5ee1

File tree

1 file changed

+18
-1
lines changed
  • mithril-explorer/src/components/CertifyCardanoTransactionsModal

1 file changed

+18
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default function CertifyCardanoTransactionsModal({
3737
const [isCertificateChainValid, setIsCertificateChainValid] = useState(true);
3838
const [currentStep, setCurrentStep] = useState(validationSteps.ready);
3939
const [currentTab, setCurrentTab] = useState(getTabForStep(validationSteps.ready));
40+
const [currentError, setCurrentError] = useState(undefined);
4041

4142
useEffect(() => {
4243
setShowLoadingWarning(false);
@@ -124,6 +125,7 @@ export default function CertifyCardanoTransactionsModal({
124125

125126
function handleError(error) {
126127
console.error("Cardano Transactions Certification Error:", error);
128+
setCurrentError(error);
127129
setCurrentStep(validationSteps.done);
128130
}
129131

@@ -219,14 +221,29 @@ export default function CertifyCardanoTransactionsModal({
219221
)}
220222
</Tab.Pane>
221223
<Tab.Pane eventKey={getTabForStep(validationSteps.done)}>
222-
{currentStep === validationSteps.done && (
224+
{currentStep === validationSteps.done && currentError === undefined && (
223225
<TransactionCertificationResult
224226
isSuccess={isProofValid && isCertificateChainValid}
225227
certificate={certificate}
226228
certifiedTransactions={transactionsProofs.transactions_hashes}
227229
nonCertifiedTransactions={transactionsProofs.non_certified_transactions}
228230
/>
229231
)}
232+
{currentStep === validationSteps.done && currentError !== undefined && (
233+
<Alert variant="danger" className="mb-2">
234+
<Alert.Heading>
235+
<i className="text-danger bi bi-shield-slash"></i> Mithril could not
236+
certify the transactions
237+
</Alert.Heading>
238+
<p className="mb-2">
239+
An error occurred during the verification process. Please try again.
240+
</p>
241+
<hr />
242+
<pre className="mb-0">
243+
<code>{currentError.toString()}</code>
244+
</pre>
245+
</Alert>
246+
)}
230247
</Tab.Pane>
231248
</Tab.Content>
232249
</Col>

0 commit comments

Comments
 (0)