diff --git a/client/src/app/components/nova/block/BlockTangleState.scss b/client/src/app/components/nova/block/BlockTangleState.scss new file mode 100644 index 000000000..541b5d85d --- /dev/null +++ b/client/src/app/components/nova/block/BlockTangleState.scss @@ -0,0 +1,51 @@ +@import "../../../../scss/fonts"; +@import "../../../../scss/mixins"; +@import "../../../../scss/media-queries"; +@import "../../../../scss/variables"; +@import "../../../../scss/themes"; + +.blocks-tangle-state { + display: flex; + align-items: center; + + @include tablet-down { + margin-top: 4px; + } + + .block-tangle-state { + @include font-size(12px); + + display: flex; + align-items: center; + height: 24px; + margin-right: 8px; + padding: 0 8px; + border: 0; + border-radius: 6px; + outline: none; + background-color: $gray-light; + color: $gray-midnight; + font-family: $inter; + font-weight: 500; + letter-spacing: 0.5px; + white-space: nowrap; + + @include phone-down { + height: 32px; + } + + &.block-tangle-state__confirmed { + background-color: var(--message-confirmed-bg); + color: $mint-green-7; + } + + &.block-tangle-state__conflicting { + background-color: var(--message-conflicting-bg); + } + + &.block-tangle-state__pending { + background-color: var(--light-bg); + color: #8493ad; + } + } +} diff --git a/client/src/app/components/nova/block/BlockTangleState.tsx b/client/src/app/components/nova/block/BlockTangleState.tsx new file mode 100644 index 000000000..825885655 --- /dev/null +++ b/client/src/app/components/nova/block/BlockTangleState.tsx @@ -0,0 +1,69 @@ +import classNames from "classnames"; +import React, { useEffect, useState } from "react"; +import Tooltip from "../../Tooltip"; +import { BlockState, u64 } from "@iota/sdk-wasm-nova/web"; +import { BlockFailureReason, BLOCK_FAILURE_REASON_STRINGS } from "@iota/sdk-wasm-nova/web/lib/types/models/block-failure-reason"; +import "./BlockTangleState.scss"; +import { DateHelper } from "~/helpers/dateHelper"; + +export interface BlockTangleStateProps { + /** + * The Block status. + */ + status: BlockState; + + /** + * The issuing time. + */ + issuingTime: u64; + + /** + * The failure reason. + */ + failureReason?: BlockFailureReason; +} + +const BlockTangleState: React.FC = ({ status, issuingTime, failureReason }) => { + const [readableTimestamp, setReadableTimestamp] = useState(); + + useEffect(() => { + const timestamp = DateHelper.format(DateHelper.milliseconds(Number(issuingTime) / 1000000)); + setReadableTimestamp(timestamp); + }, [issuingTime]); + + return ( +
+ {status && ( + +
+ {failureReason ? ( + + + {status} + + + ) : ( + {status} + )} +
+
+ {readableTimestamp} +
+
+ )} +
+ ); +}; + +export default BlockTangleState; diff --git a/client/src/app/components/nova/block/section/TransactionMetadataSection.scss b/client/src/app/components/nova/block/section/TransactionMetadataSection.scss new file mode 100644 index 000000000..c87daebc3 --- /dev/null +++ b/client/src/app/components/nova/block/section/TransactionMetadataSection.scss @@ -0,0 +1,42 @@ +@import "../../../../../scss/fonts"; +@import "../../../../../scss/mixins"; +@import "../../../../../scss/media-queries"; +@import "../../../../../scss/variables"; +@import "../../../../../scss/themes"; + +.transaction-tangle-state { + @include font-size(12px); + + display: flex; + align-items: center; + height: 24px; + margin-right: 8px; + padding: 0 8px; + border: 0; + border-radius: 6px; + outline: none; + background-color: $gray-light; + color: $gray-midnight; + font-family: $inter; + font-weight: 500; + letter-spacing: 0.5px; + white-space: nowrap; + + @include phone-down { + height: 32px; + } + + &.transaction-tangle-state__confirmed { + background-color: var(--message-confirmed-bg); + color: $mint-green-7; + } + + &.transaction-tangle-state__conflicting { + background-color: var(--message-conflicting-bg); + } + + &.transaction-tangle-state__pending { + background-color: var(--light-bg); + color: #8493ad; + } +} diff --git a/client/src/app/components/nova/block/section/TransactionMetadataSection.tsx b/client/src/app/components/nova/block/section/TransactionMetadataSection.tsx index 7d3098f24..621e4fd03 100644 --- a/client/src/app/components/nova/block/section/TransactionMetadataSection.tsx +++ b/client/src/app/components/nova/block/section/TransactionMetadataSection.tsx @@ -1,5 +1,7 @@ -import { TransactionMetadata } from "@iota/sdk-wasm-nova/web"; +import classNames from "classnames"; +import { TRANSACTION_FAILURE_REASON_STRINGS, TransactionMetadata } from "@iota/sdk-wasm-nova/web"; import React from "react"; +import "./TransactionMetadataSection.scss"; import Spinner from "../../../Spinner"; import TruncatedId from "~/app/components/stardust/TruncatedId"; @@ -29,12 +31,28 @@ const TransactionMetadataSection: React.FC = ({
Transaction Status
-
{metadata.transactionState}
+
+
+ {metadata.transactionState} +
+
{metadata.transactionFailureReason && (
Failure Reason
-
{metadata.transactionFailureReason}
+
{TRANSACTION_FAILURE_REASON_STRINGS[metadata.transactionFailureReason]}
)} diff --git a/client/src/app/routes/nova/Block.tsx b/client/src/app/routes/nova/Block.tsx index c1beac903..624d6837b 100644 --- a/client/src/app/routes/nova/Block.tsx +++ b/client/src/app/routes/nova/Block.tsx @@ -20,6 +20,7 @@ import taggedDataPayloadInfo from "~assets/modals/stardust/block/tagged-data-pay import transactionPayloadInfo from "~assets/modals/stardust/block/transaction-payload.json"; import { useBlockMetadata } from "~/helpers/nova/hooks/useBlockMetadata"; import TransactionMetadataSection from "~/app/components/nova/block/section/TransactionMetadataSection"; +import BlockTangleState from "~/app/components/nova/block/BlockTangleState"; export interface BlockProps { /** @@ -106,10 +107,7 @@ const Block: React.FC> = ({
Issuing Time
-
- {/* Convert nanoseconds to milliseconds */} - {DateHelper.formatShort(Number(block.header.issuingTime) / 1000000)} -
+
{DateHelper.formatShort(Number(block.header.issuingTime) / 1000000)}
Slot commitment
@@ -226,6 +224,13 @@ const Block: React.FC> = ({ {isLoading && }
+ {blockMetadata.metadata && block?.header && ( + + )}
{blockContent}
diff --git a/client/src/scss/forms.scss b/client/src/scss/forms.scss index 48312fffb..f25ba8720 100644 --- a/client/src/scss/forms.scss +++ b/client/src/scss/forms.scss @@ -245,3 +245,7 @@ button { } } } + +.capitalize-text { + text-transform: capitalize; +} diff --git a/setup_nova.sh b/setup_nova.sh index db0390697..dd0a7ca12 100755 --- a/setup_nova.sh +++ b/setup_nova.sh @@ -1,6 +1,6 @@ #!/bin/bash SDK_DIR="iota-sdk" -TARGET_COMMIT="8d31e6b6648c1dbd8dcc3777e35bf9865bf2f983" +TARGET_COMMIT="1866c6e9ba1c96ee1d9a800d8d3c769a18069d34" if [ ! -d "$SDK_DIR" ]; then git clone -b 2.0 git@github.com:iotaledger/iota-sdk.git