Skip to content

Commit

Permalink
fix: add copy amount
Browse files Browse the repository at this point in the history
  • Loading branch information
brancoder committed Apr 22, 2024
1 parent b0f9ed0 commit a0f03a5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion client/src/app/components/CardInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface CardInfoDetail {
copyValue?: string;
}

interface CardInfoProps {
export interface CardInfoProps {
/**
* The title of the card.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ const AccountBlockIssuanceSection: React.FC<AccountBlockIssuanceSectionProps> =
title: "Block Issuance Credit",
value: formatAmount(congestion?.blockIssuanceCredits ?? "0", manaInfo, formatFull),
onClickValue: () => setFormatFull(!formatFull),
showCopyBtn: true,
copyValue: formatAmount(congestion?.blockIssuanceCredits ?? "0", manaInfo, true),
},
{
title: "Referenced Mana Cost",
value: formatAmount(congestion?.referenceManaCost ?? "0", manaInfo, formatFull),
onClickValue: () => setFormatFull(!formatFull),
showCopyBtn: true,
copyValue: formatAmount(congestion?.referenceManaCost ?? "0", manaInfo, true),
},
];
return (
Expand All @@ -42,7 +42,7 @@ const AccountBlockIssuanceSection: React.FC<AccountBlockIssuanceSectionProps> =
title={data.title}
value={data.value}
onClickValue={data.onClickValue}
showCopyBtn={data.showCopyBtn}
copyValue={data.copyValue}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ const AccountValidatorSection: React.FC<AccountValidatorSectionProps> = ({ valid
title: "Total pool stake:",
value: formatAmount(validatorDetails.poolStake, tokenInfo, isFormatBalance),
onClickValue: () => setIsFormatBalance(!isFormatBalance),
showCopyBtn: true,
copyValue: formatAmount(validatorDetails.poolStake, tokenInfo, true),
},
{
title: "Total validator stake",
value: formatAmount(validatorDetails?.validatorStake ?? 0, tokenInfo, isFormatBalance),
onClickValue: () => setIsFormatBalance(!isFormatBalance),
showCopyBtn: true,
copyValue: formatAmount(validatorDetails?.validatorStake ?? 0, tokenInfo, true),
},
{
title: "Total delegated stake",
value: formatAmount(delegatedStake, tokenInfo, isFormatBalance),
onClickValue: () => setIsFormatBalance(!isFormatBalance),
showCopyBtn: true,
copyValue: formatAmount(delegatedStake, tokenInfo, true),
},
{
title: "Fixed cost",
value: formatAmount(validatorDetails?.fixedCost, manaInfo, formatManaValuesFull),
onClickValue: () => setFormatManaValuesFull(!formatManaValuesFull),
showCopyBtn: true,
copyValue: formatAmount(validatorDetails?.fixedCost, manaInfo, true),
},
{ title: "Latest Supported Protocol Version", value: validatorDetails.latestSupportedProtocolVersion },
];
Expand All @@ -66,7 +66,7 @@ const AccountValidatorSection: React.FC<AccountValidatorSectionProps> = ({ valid
title={data.title}
value={data.value}
onClickValue={data.onClickValue}
showCopyBtn={data.showCopyBtn}
copyValue={data.copyValue}
/>
);
})}
Expand Down
24 changes: 15 additions & 9 deletions client/src/app/routes/nova/EpochPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,26 @@ const EpochPage: React.FC<RouteComponentProps<EpochPageProps>> = ({
{ title: "Progress", value: isFutureEpoch ? "0%" : `${epochProgressPercent}%` },
{ title: "Registration end", value: isFutureEpoch ? "-" : registrationTimeRemaining },
];

const delegatedStake = Number(epochCommittee?.totalStake ?? 0) - Number(epochCommittee?.totalValidatorStake ?? 0);
const epochData: CardInfoProps[] = [
{
title: "Total pool stake:",
value: formatAmount(epochCommittee?.totalStake ?? 0, tokenInfo, isFormatBalance),
onClickValue: () => setIsFormatBalance(!isFormatBalance),
showCopyBtn: true,
copyValue: formatAmount(epochCommittee?.totalStake ?? 0, tokenInfo, true),
},
{
title: "Total validator stake",
value: formatAmount(epochCommittee?.totalValidatorStake ?? 0, tokenInfo, isFormatBalance),
onClickValue: () => setIsFormatBalance(!isFormatBalance),
showCopyBtn: true,
copyValue: formatAmount(epochCommittee?.totalValidatorStake ?? 0, tokenInfo, true),
},
{
title: "Total delegated stake",
value: formatAmount(
Number(epochCommittee?.totalStake ?? 0) - Number(epochCommittee?.totalValidatorStake ?? 0),
tokenInfo,
isFormatBalance,
),
value: formatAmount(delegatedStake, tokenInfo, isFormatBalance),
onClickValue: () => setIsFormatBalance(!isFormatBalance),
showCopyBtn: true,
copyValue: formatAmount(delegatedStake, tokenInfo, true),
},
{ title: "Blocks", value: epochStats?.blockCount ?? "0" },
{ title: "Transactions", value: epochStats?.perPayloadType?.transaction ?? "0" },
Expand Down Expand Up @@ -144,7 +142,15 @@ const EpochPage: React.FC<RouteComponentProps<EpochPageProps>> = ({

{!isFutureEpoch &&
epochData.map((data, index) => {
return <CardInfo key={index} title={data.title} value={data.value} onClickValue={data.onClickValue} />;
return (
<CardInfo
key={index}
title={data.title}
value={data.value}
onClickValue={data.onClickValue}
copyValue={data.copyValue}
/>
);
})}

{isFutureEpoch && <CardInfo title="Starts in:" value={futureEpochStartsIn} />}
Expand Down
15 changes: 12 additions & 3 deletions client/src/app/routes/nova/SlotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function SlotPage({
slotCommitmentDetails?.referenceManaCost?.toString() ??
"-";
const manaBurned = slotManaBurned?.manaBurned ? formatAmount(slotManaBurned?.manaBurned, manaInfo, formatManaAmounts) : "-";
const copyManaBurned = slotManaBurned?.manaBurned ? formatAmount(slotManaBurned?.manaBurned, manaInfo, true) : "-";
const slotData: CardInfoProps[] = [
{
title: "Slot Index",
Expand All @@ -56,13 +57,13 @@ export default function SlotPage({
title: "RMC",
value: formatAmount(rmc, manaInfo, formatManaAmounts),
onClickValue: () => setFormatManaAmounts(!formatManaAmounts),
showCopyBtn: true,
copyValue: formatAmount(rmc, manaInfo, formatManaAmounts, true),
},
{
title: "Mana burned",
value: manaBurned,
onClickValue: () => setFormatManaAmounts(!formatManaAmounts),
showCopyBtn: true,
copyValue: copyManaBurned,
},
{ title: "Blocks", value: slotStats?.blockCount ?? "0" },
{ title: "Transactions", value: slotStats?.perPayloadType?.transaction ?? "0" },
Expand Down Expand Up @@ -94,7 +95,15 @@ export default function SlotPage({
</div>
<div className="card-info-wrapper">
{slotData.map((data, index) => {
return <CardInfo key={index} title={data.title} value={data.value} onClickValue={data.onClickValue} />;
return (
<CardInfo
key={index}
title={data.title}
value={data.value}
onClickValue={data.onClickValue}
copyValue={data.copyValue}
/>
);
})}
</div>
</div>
Expand Down

0 comments on commit a0f03a5

Please sign in to comment.