From bdb86296495accce3fc8cc5c52b678fa88b8d492 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Thu, 11 Jan 2024 08:14:08 +0100 Subject: [PATCH 1/7] feat: Add bech32 address helper for nova and improve AddressView --- .../src/app/components/nova/AddressView.tsx | 15 +++- .../src/helpers/nova/bech32AddressHelper.ts | 87 +++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 client/src/helpers/nova/bech32AddressHelper.ts diff --git a/client/src/app/components/nova/AddressView.tsx b/client/src/app/components/nova/AddressView.tsx index fefd76b22..6e3a19ec2 100644 --- a/client/src/app/components/nova/AddressView.tsx +++ b/client/src/app/components/nova/AddressView.tsx @@ -1,18 +1,31 @@ import React from "react"; import { Address, AddressType } from "@iota/sdk-wasm-nova/web"; +import { useNetworkInfoNova } from "~/helpers/nova/networkInfo"; +import { Bech32AddressHelper } from "~/helpers/nova/bech32AddressHelper"; +import TruncatedId from "../stardust/TruncatedId"; interface AddressViewProps { address: Address; } const AddressView: React.FC = ({ address }) => { + const { name: networkName, bech32Hrp } = useNetworkInfoNova( + (s) => s.networkInfo, + ); + const addressDetails = Bech32AddressHelper.buildAddress(bech32Hrp, address); + const link = `/${networkName}/addr/${addressDetails.bech32}`; + return (
{getAddressTypeName(address.type)}
- {JSON.stringify(address)} +
); diff --git a/client/src/helpers/nova/bech32AddressHelper.ts b/client/src/helpers/nova/bech32AddressHelper.ts new file mode 100644 index 000000000..471ce0cc5 --- /dev/null +++ b/client/src/helpers/nova/bech32AddressHelper.ts @@ -0,0 +1,87 @@ +import { Bech32Helper } from "@iota/iota.js"; +import { Address, AddressType, AccountAddress, Ed25519Address, NftAddress } from "@iota/sdk-wasm-nova/web"; +import { Converter } from "../stardust/convertUtils"; +import { HexHelper } from "../stardust/hexHelper"; +import { IBech32AddressDetails } from "~models/api/IBech32AddressDetails"; + +export class Bech32AddressHelper { + /** + * Build the address details. + * @param hrp The human readable part of the address. + * @param address The address to source the data from. + * @param typeHint The type of the address. + * @returns The parts of the address. + */ + public static buildAddress(hrp: string, address: string | Address, typeHint?: number): IBech32AddressDetails { + return typeof address === "string" + ? this.buildAddressFromString(hrp, address, typeHint) + : this.buildAddressFromTypes(hrp, address); + } + + private static buildAddressFromString(hrp: string, address: string, typeHint?: number): IBech32AddressDetails { + let bech32; + let hex; + let type; + + if (Bech32Helper.matches(address, hrp)) { + try { + const result = Bech32Helper.fromBech32(address, hrp); + if (result) { + bech32 = address; + type = result.addressType; + hex = Converter.bytesToHex(result.addressBytes, true); + } + } catch { + } + } + + if (!bech32) { + // We assume this is hex and either use the hint or assume ed25519 for now + hex = address; + type = typeHint ?? AddressType.Ed25519; + bech32 = Bech32Helper.toBech32(type, Converter.hexToBytes(hex), hrp); + } + + return { + bech32, + hex, + type, + typeLabel: Bech32AddressHelper.typeLabel(type) + }; + } + + private static buildAddressFromTypes(hrp: string, address: Address): IBech32AddressDetails { + let hex: string = ""; + + if (address.type === AddressType.Ed25519) { + hex = HexHelper.stripPrefix( + (address as Ed25519Address).pubKeyHash + ); + } else if (address.type === AddressType.Account) { + hex = HexHelper.stripPrefix( + (address as AccountAddress).accountId + ); + } else if (address.type === AddressType.Nft) { + hex = HexHelper.stripPrefix( + (address as NftAddress).nftId + ); + } + + return this.buildAddressFromString(hrp, hex, address.type); + } + + /** + * Convert the address type number to a label. + * @param addressType The address type to get the label for. + * @returns The label. + */ + private static typeLabel(addressType?: number): string | undefined { + if (addressType === AddressType.Ed25519) { + return "Ed25519"; + } else if (addressType === AddressType.Account) { + return "Account"; + } else if (addressType === AddressType.Nft) { + return "NFT"; + } + } +} From 9bf64aefa52750645290917cb1f5f8d570361f05 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Thu, 11 Jan 2024 08:48:48 +0100 Subject: [PATCH 2/7] feat: Add isPreExpanded and isLinksDisabled props to OutputView --- client/src/app/components/nova/OutputView.tsx | 42 +++++++++++++------ client/src/app/routes/nova/OutputPage.tsx | 1 + 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/client/src/app/components/nova/OutputView.tsx b/client/src/app/components/nova/OutputView.tsx index c7b74150b..7bd2db6ec 100644 --- a/client/src/app/components/nova/OutputView.tsx +++ b/client/src/app/components/nova/OutputView.tsx @@ -12,18 +12,25 @@ interface OutputViewProps { outputId: string; output: Output; showCopyAmount: boolean; + isPreExpanded?: boolean; + isLinksDisabled?: boolean; } const OutputView: React.FC = ({ outputId, output, showCopyAmount, + isPreExpanded, + isLinksDisabled, }) => { - const [isExpanded, setIsExpanded] = React.useState(false); + const [isExpanded, setIsExpanded] = React.useState(isPreExpanded ?? false); const [isFormattedBalance, setIsFormattedBalance] = React.useState(true); - const networkInfo = useNetworkInfoNova(s => s.networkInfo); + const networkInfo = useNetworkInfoNova((s) => s.networkInfo); - const outputIdTransactionPart = `${outputId.slice(0, 8)}....${outputId.slice(-8, -4)}`; + const outputIdTransactionPart = `${outputId.slice( + 0, + 8, + )}....${outputId.slice(-8, -4)}`; const outputIdIndexPart = outputId.slice(-4); return ( @@ -45,15 +52,26 @@ const OutputView: React.FC = ({
( - - {outputIdTransactionPart} - - {outputIdIndexPart} - - + {isLinksDisabled ? ( +
+ + {outputIdTransactionPart} + + + {outputIdIndexPart} + +
+ ) : ( + + {outputIdTransactionPart} + + {outputIdIndexPart} + + + )} )
diff --git a/client/src/app/routes/nova/OutputPage.tsx b/client/src/app/routes/nova/OutputPage.tsx index 964b345a2..7b7eaf04f 100644 --- a/client/src/app/routes/nova/OutputPage.tsx +++ b/client/src/app/routes/nova/OutputPage.tsx @@ -68,6 +68,7 @@ const OutputPage: React.FC> = ({ outputId={outputId} output={output} showCopyAmount={true} + isPreExpanded={true} /> From 56ee851a86f47416f7a38a3fda61a8a716c530b7 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Thu, 11 Jan 2024 10:25:16 +0100 Subject: [PATCH 3/7] feat: Add FeaturesView for nova and render features in OutputView --- .../src/app/components/nova/FeaturesView.tsx | 201 ++++++++++++++++++ client/src/app/components/nova/OutputView.tsx | 178 +++++++++++----- 2 files changed, 324 insertions(+), 55 deletions(-) create mode 100644 client/src/app/components/nova/FeaturesView.tsx diff --git a/client/src/app/components/nova/FeaturesView.tsx b/client/src/app/components/nova/FeaturesView.tsx new file mode 100644 index 000000000..e3cc66cb2 --- /dev/null +++ b/client/src/app/components/nova/FeaturesView.tsx @@ -0,0 +1,201 @@ +import { + BlockIssuerFeature, + Feature, + FeatureType, + IssuerFeature, + MetadataFeature, + NativeTokenFeature, + SenderFeature, + StakingFeature, + TagFeature, +} from "@iota/sdk-wasm-nova/web"; +// will this import work ? why isnt it exported from web ? +import { Ed25519BlockIssuerKey } from "@iota/sdk-wasm-nova/web/lib/types/block/output/block-issuer-key"; +import classNames from "classnames"; +import React, { useState } from "react"; +import AddressView from "./AddressView"; +import DropdownIcon from "~assets/dropdown-arrow.svg?react"; +import DataToggle from "../DataToggle"; + +interface FeatureViewProps { + /** + * The feature. + */ + feature: Feature; + + /** + * Is the feature pre-expanded. + */ + isPreExpanded?: boolean; + + /** + * Is the feature immutable. + */ + isImmutable: boolean; +} + +const FeatureView: React.FC = ({ + feature, + isImmutable, + isPreExpanded, +}) => { + const [isExpanded, setIsExpanded] = useState( + isPreExpanded ?? false, + ); + + return ( +
+
setIsExpanded(!isExpanded)} + > +
+ +
+
+ {getFeatureTypeName(feature.type, isImmutable)} +
+
+ {isExpanded && ( +
+ {feature.type === FeatureType.Sender && ( + + )} + {feature.type === FeatureType.Issuer && ( + + )} + {feature.type === FeatureType.Metadata && ( +
+ +
+ )} + {feature.type === FeatureType.StateMetadata && ( +
+ State metadata unimplemented +
+ )} + {feature.type === FeatureType.Tag && ( +
+ {(feature as TagFeature).tag && ( + + )} +
+ )} + {feature.type === FeatureType.NativeToken && ( +
+
Token id:
+
+ {(feature as NativeTokenFeature).id} +
+
Amount:
+
+ {Number((feature as NativeTokenFeature).amount)} +
+
+ )} + {feature.type === FeatureType.BlockIssuer && ( +
+
Expiry Slot:
+
+ {(feature as BlockIssuerFeature).expirySlot} +
+
+ Block issuer keys: +
+ {Array.from( + ( + feature as BlockIssuerFeature + ).blockIssuerKeys.values(), + ).map((blockIssuerKey, idx) => ( +
+ { + ( + blockIssuerKey as Ed25519BlockIssuerKey + ).publicKey + } +
+ ))} +
+ )} + {feature.type === FeatureType.Staking && ( +
+
Staked amount:
+
+ {Number( + (feature as StakingFeature).stakedAmount, + )} +
+
Fixed cost:
+
+ {Number((feature as StakingFeature).fixedCost)} +
+
Start epoch:
+
+ {Number((feature as StakingFeature).startEpoch)} +
+
End epoch:
+
+ {Number((feature as StakingFeature).endEpoch)} +
+
+ )} +
+ )} +
+ ); +}; + +function getFeatureTypeName(type: FeatureType, isImmutable: boolean): string { + let name: string = ""; + + switch (type) { + case FeatureType.Sender: + name = "Sender"; + break; + case FeatureType.Issuer: + name = "Issuer"; + break; + case FeatureType.Metadata: + name = "Metadata"; + break; + case FeatureType.StateMetadata: + name = "State Metadata"; + break; + case FeatureType.Tag: + name = "Tag"; + break; + case FeatureType.NativeToken: + name = "Native Token"; + break; + case FeatureType.BlockIssuer: + name = "Block Issuer"; + break; + case FeatureType.Staking: + name = "Staking"; + break; + } + + if (name) { + return isImmutable ? `Immutable ${name}` : name; + } + + return "Unknown Feature"; +} + +export default FeatureView; diff --git a/client/src/app/components/nova/OutputView.tsx b/client/src/app/components/nova/OutputView.tsx index 7bd2db6ec..c945067df 100644 --- a/client/src/app/components/nova/OutputView.tsx +++ b/client/src/app/components/nova/OutputView.tsx @@ -1,11 +1,20 @@ import React from "react"; import DropdownIcon from "~assets/dropdown-arrow.svg?react"; import classNames from "classnames"; -import { Output, OutputType, CommonOutput } from "@iota/sdk-wasm-nova/web"; +import { + Output, + OutputType, + CommonOutput, + AccountOutput, + AnchorOutput, + FoundryOutput, + NftOutput, +} from "@iota/sdk-wasm-nova/web"; import UnlockConditionView from "./UnlockConditionView"; import CopyButton from "../CopyButton"; import { Link } from "react-router-dom"; import { useNetworkInfoNova } from "~/helpers/nova/networkInfo"; +import FeatureView from "./FeaturesView"; import "./OutputView.scss"; interface OutputViewProps { @@ -33,64 +42,68 @@ const OutputView: React.FC = ({ )}....${outputId.slice(-8, -4)}`; const outputIdIndexPart = outputId.slice(-4); - return ( -
+ const header = ( +
setIsExpanded(!isExpanded)} + className="card--value card-header--wrapper" + >
setIsExpanded(!isExpanded)} - className="card--value card-header--wrapper" + className={classNames("card--content--dropdown", { + opened: isExpanded, + })} > -
- -
-
- -
- ( - {isLinksDisabled ? ( -
- - {outputIdTransactionPart} - - - {outputIdIndexPart} - -
- ) : ( - - {outputIdTransactionPart} - - {outputIdIndexPart} - - - )} - ) - -
-
- {showCopyAmount && ( -
- { - setIsFormattedBalance(!isFormattedBalance); - e.stopPropagation(); - }} + +
+
+ +
+ ( + {isLinksDisabled ? ( +
+ + {outputIdTransactionPart} + + + {outputIdIndexPart} + +
+ ) : ( + - {output.amount} - -
- )} - {showCopyAmount && } + {outputIdTransactionPart} + + {outputIdIndexPart} + + + )} + ) + +
+ {showCopyAmount && ( +
+ { + setIsFormattedBalance(!isFormattedBalance); + e.stopPropagation(); + }} + > + {output.amount} + +
+ )} + {showCopyAmount && } +
+ ); + + return ( +
+ {header} {isExpanded && (
{(output as CommonOutput).unlockConditions?.map( @@ -102,6 +115,61 @@ const OutputView: React.FC = ({ /> ), )} + {output.type !== OutputType.Delegation && + (output as CommonOutput).features?.map( + (feature, idx) => ( + + ), + )} + {output.type === OutputType.Account && + (output as AccountOutput).immutableFeatures?.map( + (immutableFeature, idx) => ( + + ), + )} + {output.type === OutputType.Anchor && + (output as AnchorOutput).immutableFeatures?.map( + (immutableFeature, idx) => ( + + ), + )} + {output.type === OutputType.Nft && + (output as NftOutput).immutableFeatures?.map( + (immutableFeature, idx) => ( + + ), + )} + {output.type === OutputType.Foundry && + (output as FoundryOutput).immutableFeatures?.map( + (immutableFeature, idx) => ( + + ), + )}
)}
From 25f0211172b738acd7328ca418cc82d2b3f13edf Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Thu, 11 Jan 2024 11:43:31 +0100 Subject: [PATCH 4/7] feat: Add top level fields for OutputView --- client/src/app/components/nova/OutputView.tsx | 180 +++++++++++++++++- 1 file changed, 178 insertions(+), 2 deletions(-) diff --git a/client/src/app/components/nova/OutputView.tsx b/client/src/app/components/nova/OutputView.tsx index c945067df..7017f1869 100644 --- a/client/src/app/components/nova/OutputView.tsx +++ b/client/src/app/components/nova/OutputView.tsx @@ -4,17 +4,25 @@ import classNames from "classnames"; import { Output, OutputType, + BasicOutput, CommonOutput, AccountOutput, AnchorOutput, FoundryOutput, NftOutput, + TokenSchemeType, + SimpleTokenScheme, + DelegationOutput, + AddressType, } from "@iota/sdk-wasm-nova/web"; import UnlockConditionView from "./UnlockConditionView"; import CopyButton from "../CopyButton"; import { Link } from "react-router-dom"; import { useNetworkInfoNova } from "~/helpers/nova/networkInfo"; import FeatureView from "./FeaturesView"; +import TruncatedId from "../stardust/TruncatedId"; +import { TransactionsHelper } from "~/helpers/stardust/transactionsHelper"; +import { Bech32AddressHelper } from "~/helpers/nova/bech32AddressHelper"; import "./OutputView.scss"; interface OutputViewProps { @@ -34,8 +42,9 @@ const OutputView: React.FC = ({ }) => { const [isExpanded, setIsExpanded] = React.useState(isPreExpanded ?? false); const [isFormattedBalance, setIsFormattedBalance] = React.useState(true); - const networkInfo = useNetworkInfoNova((s) => s.networkInfo); + const { name: networkName, bech32Hrp } = useNetworkInfoNova((s) => s.networkInfo); + const aliasOrNftBech32 = buildAddressForAliasOrNft(outputId, output, bech32Hrp); const outputIdTransactionPart = `${outputId.slice( 0, 8, @@ -71,7 +80,7 @@ const OutputView: React.FC = ({
) : ( {outputIdTransactionPart} @@ -101,11 +110,154 @@ const OutputView: React.FC = ({ ); + const topLevelFields = ( + + {output.type === OutputType.Account && ( + +
Account address:
+
+ +
+
Foundry counter:
+
+ {(output as AccountOutput).foundryCounter} +
+
+ )} + {output.type === OutputType.Anchor && ( + +
Anchor Id:
+
+ +
+
Staten index:
+
+ {(output as AnchorOutput).stateIndex} +
+
+ )} + {output.type === OutputType.Nft && ( + +
Nft address:
+
+ +
+
+ )} + {output.type === OutputType.Foundry && ( + +
Serial number:
+
+ {(output as FoundryOutput).serialNumber} +
+
Token scheme type:
+
+ {(output as FoundryOutput).tokenScheme.type} +
+ {(output as FoundryOutput).tokenScheme.type === + TokenSchemeType.Simple && ( + +
Minted tokens:
+
+ {Number( + ( + (output as FoundryOutput) + .tokenScheme as SimpleTokenScheme + ).mintedTokens, + )} +
+
Melted tokens:
+
+ {Number( + ( + (output as FoundryOutput) + .tokenScheme as SimpleTokenScheme + ).meltedTokens, + )} +
+
Maximum supply:
+
+ {Number( + ( + (output as FoundryOutput) + .tokenScheme as SimpleTokenScheme + ).maximumSupply, + )} +
+
+ )} +
+ )} + {output.type === OutputType.Basic || + output.type === OutputType.Account || + output.type === OutputType.Anchor || + (output.type === OutputType.Nft && ( + +
Stored mana:
+
+ {(output as BasicOutput).mana?.toString()} +
+
+ ))} + {output.type === OutputType.Delegation && ( + +
Delegated amount:
+
+ {Number((output as DelegationOutput).delegatedAmount)} +
+
Delegation Id:
+
+ {(output as DelegationOutput).delegationId} +
+
Validator Id:
+
+ {(output as DelegationOutput).validatorId} +
+
Start epoch:
+
+ {(output as DelegationOutput).startEpoch} +
+
End epoch:
+
+ {(output as DelegationOutput).endEpoch} +
+
+ )} +
+ ); + return (
{header} {isExpanded && (
+ {topLevelFields} {(output as CommonOutput).unlockConditions?.map( (unlockCondition, idx) => ( = ({ ); }; +function buildAddressForAliasOrNft(outputId: string, output: Output, bech32Hrp: string) { + let address: string = ""; + let addressType: number = 0; + + if (output.type === OutputType.Account) { + const aliasId = TransactionsHelper.buildIdHashForNft( + (output as AccountOutput).accountId, + outputId, + ); + address = aliasId; + addressType = AddressType.Account; + } else if (output.type === OutputType.Nft) { + const nftId = TransactionsHelper.buildIdHashForAlias( + (output as NftOutput).nftId, + outputId, + ); + address = nftId; + addressType = AddressType.Nft; + } + + return Bech32AddressHelper.buildAddress(bech32Hrp, address, addressType) + .bech32; +} + function getOutputTypeName(type: OutputType): string { switch (type) { case OutputType.Basic: From 786f39544985c09eaaa139c7455a4131590e6b4a Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Fri, 12 Jan 2024 14:27:29 +0100 Subject: [PATCH 5/7] fix: Fix error parsing blockIssuerKeys --- client/src/app/components/nova/FeaturesView.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/app/components/nova/FeaturesView.tsx b/client/src/app/components/nova/FeaturesView.tsx index e3cc66cb2..c9001036d 100644 --- a/client/src/app/components/nova/FeaturesView.tsx +++ b/client/src/app/components/nova/FeaturesView.tsx @@ -119,9 +119,7 @@ const FeatureView: React.FC = ({ Block issuer keys:
{Array.from( - ( - feature as BlockIssuerFeature - ).blockIssuerKeys.values(), + (feature as BlockIssuerFeature).blockIssuerKeys, ).map((blockIssuerKey, idx) => (
{ From 6b0e933c5d655b8478d8ae11486faa503e66e3a5 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Mon, 15 Jan 2024 13:23:30 +0100 Subject: [PATCH 6/7] chore: Bump sdk-nova to latest commit --- api/package-lock.json | 4 +++- client/package-lock.json | 2 +- setup_nova.sh | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/package-lock.json b/api/package-lock.json index 6fc4f6198..46280d5fc 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -64,10 +64,11 @@ }, "../iota-sdk/bindings/nodejs": { "name": "@iota/sdk-nova", - "version": "1.1.3", + "version": "1.1.4", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { + "@babel/traverse": "^7.23.2", "@types/node": "^18.15.12", "class-transformer": "^0.5.1", "prebuild-install": "^7.1.1", @@ -11313,6 +11314,7 @@ "@iota/sdk-nova": { "version": "file:../iota-sdk/bindings/nodejs", "requires": { + "@babel/traverse": "^7.23.2", "@napi-rs/cli": "^1.0.0", "@types/jest": "^29.4.0", "@types/node": "^18.15.12", diff --git a/client/package-lock.json b/client/package-lock.json index cc8e515b3..2ba6e335f 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -102,7 +102,7 @@ }, "../iota-sdk/bindings/wasm": { "name": "@iota/sdk-wasm-nova", - "version": "1.1.1", + "version": "1.1.2", "license": "Apache-2.0", "dependencies": { "class-transformer": "^0.5.1", diff --git a/setup_nova.sh b/setup_nova.sh index 9847b59fc..db0390697 100755 --- a/setup_nova.sh +++ b/setup_nova.sh @@ -1,6 +1,6 @@ #!/bin/bash SDK_DIR="iota-sdk" -TARGET_COMMIT="6628d8ade72a14d0f25eae859590f0bdcea0cf83" +TARGET_COMMIT="8d31e6b6648c1dbd8dcc3777e35bf9865bf2f983" if [ ! -d "$SDK_DIR" ]; then git clone -b 2.0 git@github.com:iotaledger/iota-sdk.git From c3b67fd1021834773c1e8406edd4ab343a0f3d31 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Wed, 17 Jan 2024 15:56:37 +0100 Subject: [PATCH 7/7] feat: Fix nesting for Stored mana field + Fix label of Unlock conditions --- client/src/app/components/nova/OutputView.tsx | 14 +++++------ .../components/nova/UnlockConditionView.tsx | 25 +++++++++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/client/src/app/components/nova/OutputView.tsx b/client/src/app/components/nova/OutputView.tsx index fcd881f01..697bb71eb 100644 --- a/client/src/app/components/nova/OutputView.tsx +++ b/client/src/app/components/nova/OutputView.tsx @@ -155,15 +155,15 @@ const OutputView: React.FC = ({ outputId, output, showCopyAmoun )} )} - {output.type === OutputType.Basic || + {(output.type === OutputType.Basic || output.type === OutputType.Account || output.type === OutputType.Anchor || - (output.type === OutputType.Nft && ( - -
Stored mana:
-
{(output as BasicOutput).mana?.toString()}
-
- ))} + output.type === OutputType.Nft) && ( + +
Stored mana:
+
{(output as BasicOutput).mana?.toString()}
+
+ )} {output.type === OutputType.Delegation && (
Delegated amount:
diff --git a/client/src/app/components/nova/UnlockConditionView.tsx b/client/src/app/components/nova/UnlockConditionView.tsx index 8e15ebbc3..52b16ead9 100644 --- a/client/src/app/components/nova/UnlockConditionView.tsx +++ b/client/src/app/components/nova/UnlockConditionView.tsx @@ -81,22 +81,33 @@ const UnlockConditionView: React.FC = ({ unlockConditi }; function getUnlockConditionTypeName(type: UnlockConditionType): string { + let name = null; + switch (type) { case UnlockConditionType.Address: - return "Address"; + name = "Address"; + break; case UnlockConditionType.StorageDepositReturn: - return "Storage deposit return"; + name = "Storage Deposit Return"; + break; case UnlockConditionType.Timelock: - return "Timelock"; + name = "Timelock"; + break; case UnlockConditionType.Expiration: - return "Expiration"; + name = "Expiration"; + break; case UnlockConditionType.GovernorAddress: - return "Governor address"; + name = "Governor Address"; + break; case UnlockConditionType.StateControllerAddress: - return "State controller address"; + name = "State Controller Address"; + break; case UnlockConditionType.ImmutableAccountAddress: - return "Immutable account address"; + name = "Immutable Account Address"; + break; } + + return name !== null ? `${name} Unlock Condition` : "Unknown Unlock condition"; } export default UnlockConditionView;