Skip to content

Commit

Permalink
Update explorer to new CardanoTransaction signed entity beacon
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Fauvel <[email protected]>
Co-authored-by: Damien Lachaume <[email protected]>
  • Loading branch information
3 people committed Jun 4, 2024
1 parent a5b5e4c commit 96d8bcf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ export default function CardanoTransactionsSnapshotsList(props) {
<Card.Title>{cardanoTransactionsSnapshot.hash}</Card.Title>
<ListGroup variant="flush" className="data-list-group">
<ListGroup.Item>
Epoch: {cardanoTransactionsSnapshot.beacon.epoch}
Epoch: {cardanoTransactionsSnapshot.epoch}
</ListGroup.Item>
<ListGroup.Item>
Immutable file number:{" "}
{cardanoTransactionsSnapshot.beacon.immutable_file_number}
Block Number:{" "}
{cardanoTransactionsSnapshot.block_number}
</ListGroup.Item>
<ListGroup.Item>
Merkle Root: {cardanoTransactionsSnapshot.merkle_root}
Expand Down
26 changes: 3 additions & 23 deletions mithril-explorer/src/components/CertificateModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { selectedAggregator } from "@/store/settingsSlice";
import RawJsonButton from "#/RawJsonButton";
import Stake from "#/Stake";
import ProtocolParameters from "#/ProtocolParameters";
import SignedEntityType from "#/SignedEntityType";
import SignerTable from "#/SignerTable";
import VerifyCertificateModal from "#/VerifyCertificate/VerifyCertificateModal";

export default function CertificateModal({
hash,
hideButtons = false,
onHashChange = (hash) => {},
onHashChange = (hash) => { },
}) {
const [certificate, setCertificate] = useState({});
const [charts, setCharts] = useState({
Expand Down Expand Up @@ -72,28 +73,7 @@ export default function CertificateModal({
<Row md={1} xl="auto">
<Col xl={4} className="mb-3">
<h4>Beacon</h4>
<Table className="mb-3">
<tbody>
<tr>
<td>
<em>Network:</em>
</td>
<td>{certificate.beacon.network}</td>
</tr>
<tr>
<td>
<em>Epoch:</em>
</td>
<td>{certificate.beacon.epoch}</td>
</tr>
<tr>
<td>
<em>Immutable File Number:</em>
</td>
<td>{certificate.beacon.immutable_file_number}</td>
</tr>
</tbody>
</Table>
<SignedEntityType signedEntityType={certificate.signed_entity_type} table />
<h4>Protocol Parameters</h4>
<ProtocolParameters
className="mb-3"
Expand Down
57 changes: 41 additions & 16 deletions mithril-explorer/src/components/SignedEntityType.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import { ListGroup } from "react-bootstrap";
import { ListGroup, Table } from "react-bootstrap";

export default function SignedEntityType({ signedEntityType }) {
export default function SignedEntityType({ signedEntityType, table = false }) {
const [entityName, setEntityName] = useState("");
const [beacon, setBeacon] = useState({});

Expand All @@ -13,25 +13,50 @@ export default function SignedEntityType({ signedEntityType }) {
setBeacon({
epoch: signedEntityType[type_name],
});
} else if (type_name === "CardanoTransactions") {
setBeacon({
epoch: signedEntityType[type_name][0],
block_number: signedEntityType[type_name][1],
});
} else {
setBeacon(signedEntityType[type_name] ?? {});
}
}, [signedEntityType]);

return (
<ListGroup>
<ListGroup.Item>
<h6>{entityName}</h6>
</ListGroup.Item>
<ListGroup.Item>
<ListGroup horizontal="xxl">

return table ?
(
<Table className="mb-3">
<tbody>
<tr>
<td colSpan={2}>
<h6>{entityName}</h6>
</td>
</tr>
{Object.entries(beacon).map(([key, value]) => (
<ListGroup.Item key={key}>
{key}: {value}
</ListGroup.Item>
<tr key={key}>
<td>
<em>{key}:</em>
</td>
<td>{value}</td>
</tr>
))}
</ListGroup>
</ListGroup.Item>
</ListGroup>
);
</tbody>
</Table>
) : (
<ListGroup>
<ListGroup.Item>
<h6>{entityName}</h6 >
</ListGroup.Item >
<ListGroup.Item>
<ListGroup horizontal="xxl">
{Object.entries(beacon).map(([key, value]) => (
<ListGroup.Item key={key}>
{key}: {value}
</ListGroup.Item>
))}
</ListGroup>
</ListGroup.Item>
</ListGroup >
);
}

0 comments on commit 96d8bcf

Please sign in to comment.