Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add block cost to block page #1366

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nova-build-temp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
TARGET_COMMIT:
description: "Target Commit Hash for the SDK"
required: false
default: "7e2b3547851280a310735861241ab3e0d239aa5a"
default: "5d8c3042c87fbde300269f55da90dd4d8c60f2f1"
environment:
type: choice
description: "Select the environment to deploy to"
Expand Down
2 changes: 1 addition & 1 deletion api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion client/src/app/routes/nova/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Block: React.FC<RouteComponentProps<BlockProps>> = ({
params: { network, blockId },
},
}) => {
const { tokenInfo, bech32Hrp } = useNetworkInfoNova((s) => s.networkInfo);
const { tokenInfo, bech32Hrp, protocolInfo } = useNetworkInfoNova((s) => s.networkInfo);
const [isFormattedBalance, setIsFormattedBalance] = useState(true);
const [block, isLoading, blockError] = useBlock(network, blockId);
const [blockMetadata] = useBlockMetadata(network, blockId);
Expand All @@ -49,6 +49,7 @@ const Block: React.FC<RouteComponentProps<BlockProps>> = ({
const [transactionId, setTransactionId] = useState<string | null>(null);
const { transactionMetadata } = useTransactionMetadata(network, transactionId);
const [pageTitle, setPageTitle] = useState<string>("Block");
let blockCost: number | null = null;

function updatePageTitle(type: PayloadType | undefined): void {
let title = null;
Expand Down Expand Up @@ -97,6 +98,10 @@ const Block: React.FC<RouteComponentProps<BlockProps>> = ({
transferTotal={transferTotal ?? undefined}
/>,
);

if (protocolInfo?.parameters?.workScoreParameters) {
blockCost = Utils.blockWorkScore(block, protocolInfo?.parameters.workScoreParameters);
}
}

if (transactionMetadata) {
Expand Down Expand Up @@ -137,6 +142,12 @@ const Block: React.FC<RouteComponentProps<BlockProps>> = ({
<div className="label">Issuing Time</div>
<div className="value code">{DateHelper.formatShort(Number(block.header.issuingTime) / 1000000)}</div>
</div>
{blockCost !== null && (
<div className="section--data">
<div className="label">Block cost</div>
<div className="value code">{formatAmount(blockCost, tokenInfo, true)}</div>
</div>
)}
<div className="section--data">
<div className="label">Slot Commitment</div>
<div className="value code highlight">
Expand Down
2 changes: 1 addition & 1 deletion setup_nova.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
SDK_DIR="iota-sdk"
TARGET_COMMIT="7e2b3547851280a310735861241ab3e0d239aa5a"
TARGET_COMMIT="5d8c3042c87fbde300269f55da90dd4d8c60f2f1"

if [ ! -d "$SDK_DIR" ]; then
git clone -b 2.0 [email protected]:iotaledger/iota-sdk.git
Expand Down
Loading