Skip to content

Commit

Permalink
Merge branch 'dev' into feat/nova-visualizer/randomize-amplitude
Browse files Browse the repository at this point in the history
  • Loading branch information
msarcev authored Feb 22, 2024
2 parents f3013c7 + 0c162ae commit 18f1697
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 4 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: "8f0ff5e1e899a0d960ddfea09237739a88c3bcf1"
default: "fc9f0f56bb5cfc146993e53aa9656ded220734e1"
environment:
type: choice
description: "Select the environment to deploy to"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from "react";
import associatedOuputsMessage from "~assets/modals/stardust/address/associated-outputs.json";
import foundriesMessage from "~assets/modals/stardust/alias/foundries.json";
import stateMessage from "~assets/modals/stardust/alias/state.json";
import bicMessage from "~assets/modals/nova/account/bic.json";
import TabbedSection from "../../../hoc/TabbedSection";
import AssociatedOutputs from "./association/AssociatedOutputs";
Expand All @@ -14,6 +15,7 @@ import { IImplicitAccountCreationAddressState } from "~/helpers/nova/hooks/useIm
import { AddressType } from "@iota/sdk-wasm-nova/web";
import AccountFoundriesSection from "./account/AccountFoundriesSection";
import AccountBlockIssuanceSection from "./account/AccountBlockIssuanceSection";
import AnchorStateSection from "./anchor/AnchorStateSection";

enum DEFAULT_TABS {
AssocOutputs = "Outputs",
Expand All @@ -25,6 +27,10 @@ enum ACCOUNT_TABS {
Foundries = "Foundries",
}

enum ANCHOR_TABS {
State = "State",
}

const buildDefaultTabsOptions = (tokensCount: number, associatedOutputCount: number) => ({
[DEFAULT_TABS.AssocOutputs]: {
disabled: associatedOutputCount === 0,
Expand Down Expand Up @@ -60,6 +66,15 @@ const buildAccountAddressTabsOptions = (
},
});

const buildAnchorAddressTabsOptions = (isAnchorStateTabDisabled: boolean, isAnchorDetailsLoading: boolean) => ({
[ANCHOR_TABS.State]: {
disabled: isAnchorStateTabDisabled,
hidden: isAnchorStateTabDisabled,
isLoading: isAnchorDetailsLoading,
infoContent: stateMessage,
},
});

interface IAddressPageTabbedSectionsProps {
readonly addressState:
| IEd25519AddressState
Expand Down Expand Up @@ -104,6 +119,16 @@ export const AddressPageTabbedSections: React.FC<IAddressPageTabbedSectionsProps
]
: null;

const anchorAddressSections =
addressDetails.type === AddressType.Anchor
? [
<AnchorStateSection
key={`anchor-state-${addressDetails.bech32}`}
output={(addressState as IAnchorAddressState).anchorOutput}
/>,
]
: null;

let tabEnums = DEFAULT_TABS;
const defaultTabsOptions = buildDefaultTabsOptions(tokensCount, outputCount);
let tabOptions = defaultTabsOptions;
Expand All @@ -125,6 +150,16 @@ export const AddressPageTabbedSections: React.FC<IAddressPageTabbedSectionsProps
tabbedSections = [...defaultSections, ...(accountAddressSections ?? [])];
break;
}
case AddressType.Anchor: {
const anchorAddressState = addressState as IAnchorAddressState;
tabEnums = { ...DEFAULT_TABS, ...ANCHOR_TABS };
tabOptions = {
...defaultTabsOptions,
...buildAnchorAddressTabsOptions(anchorAddressState.anchorOutput === null, anchorAddressState.isAnchorDetailsLoading),
};
tabbedSections = [...defaultSections, ...(anchorAddressSections ?? [])];
break;
}
default: {
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { AnchorOutput, FeatureType, StateMetadataFeature } from "@iota/sdk-wasm-nova/web";
import React from "react";
import DataToggle from "~/app/components/DataToggle";

interface AnchorStateSectionProps {
/**
* The Anchor Output
*/
readonly output: AnchorOutput | null;
}

const AnchorStateSection: React.FC<AnchorStateSectionProps> = ({ output }) => {
const stateMetadata = output?.features?.find((feature) => feature.type === FeatureType.StateMetadata) as StateMetadataFeature;

return (
<div className="section">
<div className="section--data">
<div>
<div className="label">State Index</div>
<div className="value row middle margin-t-t">
<span className="margin-r-t">{output?.stateIndex}</span>
</div>
</div>
{Object.entries(stateMetadata.entries).map(([key, value], index) => (
<div key={index}>
<div className="label margin-t-m">{key}</div>
<div className="value row middle margin-t-t">
<DataToggle sourceData={value} withSpacedHex={true} />
</div>
</div>
))}
</div>
</div>
);
};

export default AnchorStateSection;
4 changes: 1 addition & 3 deletions 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="257bcff80bf0336f571f9a226ebde1acd8974104"
TARGET_COMMIT="fc9f0f56bb5cfc146993e53aa9656ded220734e1"

if [ ! -d "$SDK_DIR" ]; then
git clone -b 2.0 [email protected]:iotaledger/iota-sdk.git
Expand Down Expand Up @@ -35,5 +35,3 @@ rm package.json.bak
echo "Building wasm bindings"
yarn
yarn build


0 comments on commit 18f1697

Please sign in to comment.