Skip to content

Commit

Permalink
Feat: Add block cost to block page (#1366)
Browse files Browse the repository at this point in the history
* feat: Show block cost on Block page

* chore: Bump nova SDK to latest commit

---------

Co-authored-by: Branko Bosnic <[email protected]>
  • Loading branch information
msarcev and brancoder authored Mar 29, 2024
1 parent 2c4836c commit 24f05b3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
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

0 comments on commit 24f05b3

Please sign in to comment.