Skip to content

Commit

Permalink
fix: show validator tab if account has staking feature
Browse files Browse the repository at this point in the history
  • Loading branch information
brancoder committed Feb 26, 2024
1 parent bb32fc0 commit 77e905d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 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: "56b19d4c12c1bf23bc716b47c36018d37d5b3168"
default: "aa1b1de58731dbbf9dd0f5e2960fd11b0056b633"
environment:
type: choice
description: "Select the environment to deploy to"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const buildAccountAddressTabsOptions = (
isBlockIssuer: boolean,
isCongestionLoading: boolean,
foundriesCount: number,
hasValidatorDetails: boolean,
hasStakingFeature: boolean,
isAccountFoundriesLoading: boolean,
isValidatorDetailsLoading: boolean,
) => ({
Expand All @@ -94,8 +94,8 @@ const buildAccountAddressTabsOptions = (
infoContent: bicMessage,
},
[ACCOUNT_TABS.Validation]: {
disabled: !hasValidatorDetails,
hidden: !hasValidatorDetails,
disabled: !hasStakingFeature,
hidden: !hasStakingFeature,
isLoading: isValidatorDetailsLoading,
infoContent: validatorMessage,
},
Expand Down Expand Up @@ -201,7 +201,7 @@ export const AddressPageTabbedSections: React.FC<IAddressPageTabbedSectionsProps
accountAddressState.blockIssuerFeature !== null,
accountAddressState.isCongestionLoading,
accountAddressState.accountOutput?.foundryCounter ?? 0,
accountAddressState.validatorDetails !== null,
accountAddressState.stakingFeature !== null,
accountAddressState.isFoundriesLoading,
accountAddressState.isValidatorDetailsLoading,
),
Expand Down
33 changes: 24 additions & 9 deletions client/src/helpers/nova/hooks/useAccountAddressState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CongestionResponse,
FeatureType,
OutputResponse,
StakingFeature,
ValidatorResponse,
} from "@iota/sdk-wasm-nova/web";
import { IAddressDetails } from "~/models/api/nova/IAddressDetails";
Expand All @@ -27,6 +28,7 @@ export interface IAccountAddressState {
totalBalance: number | null;
availableBalance: number | null;
blockIssuerFeature: BlockIssuerFeature | null;
stakingFeature: StakingFeature | null;
validatorDetails: ValidatorResponse | null;
addressBasicOutputs: OutputResponse[] | null;
addressNftOutputs: OutputResponse[] | null;
Expand All @@ -47,6 +49,7 @@ const initialState = {
totalBalance: null,
availableBalance: null,
blockIssuerFeature: null,
stakingFeature: null,
validatorDetails: null,
addressBasicOutputs: null,
addressNftOutputs: null,
Expand Down Expand Up @@ -78,6 +81,7 @@ export const useAccountAddressState = (address: AccountAddress): [IAccountAddres
);

const { accountOutput, isLoading: isAccountDetailsLoading } = useAccountDetails(network, address.accountId);

const { totalBalance, availableBalance } = useAddressBalance(network, state.addressDetails, accountOutput);
const [addressBasicOutputs, isBasicOutputsLoading] = useAddressBasicOutputs(network, state.addressDetails?.bech32 ?? null);
const [addressNftOutputs, isNftOutputsLoading] = useAddressNftOutputs(network, state.addressDetails?.bech32 ?? null);
Expand Down Expand Up @@ -118,15 +122,26 @@ export const useAccountAddressState = (address: AccountAddress): [IAccountAddres
isValidatorDetailsLoading,
};

if (accountOutput && !state.blockIssuerFeature) {
const blockIssuerFeature = accountOutput?.features?.find(
(feature) => feature.type === FeatureType.BlockIssuer,
) as BlockIssuerFeature;
if (blockIssuerFeature) {
updatedState = {
...updatedState,
blockIssuerFeature,
};
if (accountOutput) {
if (!state.blockIssuerFeature) {
const blockIssuerFeature = accountOutput?.features?.find(
(feature) => feature.type === FeatureType.BlockIssuer,
) as BlockIssuerFeature;
if (blockIssuerFeature) {
updatedState = {
...updatedState,
blockIssuerFeature,
};
}
}
if (!state.stakingFeature) {
const stakingFeature = accountOutput?.features?.find((feature) => feature.type === FeatureType.Staking) as StakingFeature;
if (stakingFeature) {
updatedState = {
...updatedState,
stakingFeature,
};
}
}
}

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="56b19d4c12c1bf23bc716b47c36018d37d5b3168"
TARGET_COMMIT="aa1b1de58731dbbf9dd0f5e2960fd11b0056b633"

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

0 comments on commit 77e905d

Please sign in to comment.