Skip to content

Commit

Permalink
Merge pull request #385 from sudoblockio/add-jail-badges
Browse files Browse the repository at this point in the history
Add jail badges to address page
  • Loading branch information
robcxyz authored Jan 23, 2024
2 parents 91ca4a6 + 47236b7 commit e62496f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/components/AddressesPage/AddressDetailPage/AddressInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function AddressInfo(props) {
node_address,
status,
node_state,
jail_flags,
total_blocks,
validated_blocks,
website,
Expand Down Expand Up @@ -201,6 +202,26 @@ function AddressInfo(props) {
}
}

// Jail flags are accumulative
const getJailBadges = (jail_flag) => {
let flagNames = [];

if (jail_flag & 1) {
flagNames.push(<span className={`jail-badge in-jail`}>{'Jail'}</span>);
}
if (jail_flag & 2) {
flagNames.push(<span className={`jail-badge unjailing`}>{'Unjailing'}</span>);
}
if (jail_flag & 4) {
flagNames.push(<span className={`jail-badge validation-failure`}>{'Validation Failure'}</span>);
}
if (jail_flag & 8) {
flagNames.push(<span className={`jail-badge double-sign`}>{'Double Sign'}</span>);
}

return flagNames;
}

const toggleIcxMore = () => {
setIcxMore(!icxMore)
}
Expand Down Expand Up @@ -285,6 +306,7 @@ function AddressInfo(props) {
: IconConverter.toNumber(last_updated_block)
// const tokenCxs = tokens ? tokens : [];
const badge = getBadgeTitle(grade, node_state)
const jailBadges = getJailBadges(parseInt(jail_flags, 16));

const Content = () => {
if (loading) {
Expand Down Expand Up @@ -399,7 +421,6 @@ function AddressInfo(props) {
</span>
)
})}

{is_prep && isConnected ? (
<span
className={compStyles.buttonUpdatePrep}>
Expand All @@ -425,7 +446,8 @@ function AddressInfo(props) {
<i></i>
{node_state}
</span>
{(chainCanJail && is_prep && isConnected) ? (
{jailBadges}
{(chainCanJail && is_prep && isConnected) || TEST_VARIABLE ? (
<span>
<button
disabled={!is_prep || !isConnected}
Expand Down

0 comments on commit e62496f

Please sign in to comment.