Skip to content

Commit 649de5f

Browse files
authored
Merge branch 'develop' into dev-tools/faucet-object-count
2 parents 61d7f56 + 72833a9 commit 649de5f

File tree

58 files changed

+304
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+304
-116
lines changed

.changeset/four-pets-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@iota/apps-ui-kit': patch
3+
---
4+
5+
Add eslint config. Resolve eslint errors/warnings.

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ module.exports = {
9393
'@typescript-eslint/no-explicit-any': 'off',
9494
},
9595
},
96+
{
97+
files: ['apps/ui-kit/**/*'],
98+
rules: {
99+
'@typescript-eslint/consistent-type-imports': ['error'],
100+
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
101+
'@typescript-eslint/no-explicit-any': 'off',
102+
},
103+
},
96104
{
97105
files: ['sdk/graphql-transport/**/*'],
98106
rules: {

apps/core/src/hooks/useGetNextEpochCommitteeMember.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ import { useMaxCommitteeSize } from './useMaxCommitteeSize';
77

88
export function useGetNextEpochCommitteeMember(validatorAddress: string): {
99
isValidatorExpectedToBeInTheCommittee: boolean;
10+
isLoading: boolean;
1011
} {
11-
const { data: systemState } = useIotaClientQuery('getLatestIotaSystemState');
12-
const { data: maxCommitteeSize } = useMaxCommitteeSize();
12+
const { data: systemState, isLoading: isSystemStateLoading } = useIotaClientQuery(
13+
'getLatestIotaSystemState',
14+
);
15+
const { data: maxCommitteeSize, isLoading: isMaxCommitteeSizeLoading } = useMaxCommitteeSize();
16+
17+
const isLoading = isSystemStateLoading || isMaxCommitteeSizeLoading;
1318

1419
const isValidatorExpectedToBeInTheCommittee = useMemo(() => {
1520
if (!systemState || !maxCommitteeSize) return false;
@@ -23,5 +28,5 @@ export function useGetNextEpochCommitteeMember(validatorAddress: string): {
2328
.some((v) => v.iotaAddress === validatorAddress);
2429
}, [systemState, maxCommitteeSize, validatorAddress]);
2530

26-
return { isValidatorExpectedToBeInTheCommittee };
31+
return { isValidatorExpectedToBeInTheCommittee, isLoading };
2732
}

apps/explorer/src/components/module/PkgModulesWrapper.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Modifications Copyright (c) 2024 IOTA Stiftung
33
// SPDX-License-Identifier: Apache-2.0
44

5-
import { useCallback, useEffect, useState } from 'react';
5+
import { useEffect, useState } from 'react';
66
import { type Direction } from 'react-resizable-panels';
77

88
import { SplitPanes, useSearchParamsMerged, VerticalList } from '~/components/ui';
@@ -56,15 +56,6 @@ export function PkgModulesWrapper({
5656
const filteredModules = query
5757
? moduleNames.filter((name) => name.toLowerCase().includes(query.toLowerCase()))
5858
: [];
59-
60-
const submitSearch = useCallback(() => {
61-
if (filteredModules.length === 1) {
62-
setSearchParams({
63-
module: filteredModules[0],
64-
});
65-
}
66-
}, [filteredModules, setSearchParams]);
67-
6859
const onChangeModule = (newModule: string) => {
6960
setSearchParams(
7061
{
@@ -98,17 +89,11 @@ export function PkgModulesWrapper({
9889
label: item,
9990
}));
10091

101-
function handleSearchKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
102-
if (e.key === 'Enter') {
103-
submitSearch();
104-
}
105-
}
10692
return (
10793
<div className="flex h-full flex-col items-stretch gap-md--rs md:flex-row md:flex-nowrap">
10894
<div className="flex w-full flex-col md:min-h-[560px] md:w-1/5">
10995
<div className="relative z-[1]">
11096
<Search
111-
onKeyDown={handleSearchKeyDown}
11297
searchValue={query}
11398
onSearchValueChange={(value) => setQuery(value?.trim() ?? '')}
11499
placeholder="Search"

apps/explorer/src/lib/ui/utils/generateValidatorsTableColumns.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import clsx from 'clsx';
1616
import { ValidatorLink } from '~/components/ui';
1717

1818
interface GenerateValidatorsTableColumnsArgs {
19-
activeValidators?: IotaValidatorSummary[];
19+
allValidators?: IotaValidatorSummary[];
2020
committeeMembers?: string[];
2121
atRiskValidators?: [string, string][];
2222
maxCommitteeSize?: number;
@@ -90,7 +90,7 @@ function ValidatorWithImage({
9090
}
9191

9292
export function generateValidatorsTableColumns({
93-
activeValidators = [],
93+
allValidators = [],
9494
committeeMembers = [],
9595
atRiskValidators = [],
9696
maxCommitteeSize,
@@ -101,8 +101,8 @@ export function generateValidatorsTableColumns({
101101
highlightValidatorName,
102102
currentEpoch,
103103
}: GenerateValidatorsTableColumnsArgs): ColumnDef<IotaValidatorSummaryExtended>[] {
104-
const sortedActiveValidators = activeValidators.toSorted(sortByStakingBalanceDesc);
105-
const topValidators = sortedActiveValidators.slice(0, maxCommitteeSize);
104+
const validatorsSortedByStake = allValidators.toSorted(sortByStakingBalanceDesc);
105+
const topValidators = validatorsSortedByStake.slice(0, maxCommitteeSize);
106106

107107
let columns: ColumnDef<IotaValidatorSummaryExtended>[] = [
108108
{

apps/explorer/src/pages/validators/Validators.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function ValidatorPageResult(): JSX.Element {
5858
const { data: pendingActiveValidatorsId } = useGetDynamicFields(
5959
data?.pendingActiveValidatorsId || '',
6060
);
61+
6162
const pendingValidatorsObjectIdsData = pendingActiveValidatorsId?.pages[0]?.data || [];
6263
const pendingValidatorsObjectIds = pendingValidatorsObjectIdsData.map((item) => item.objectId);
6364
const normalizedIds = pendingValidatorsObjectIds.map((id) => normalizeIotaAddress(id));
@@ -67,7 +68,7 @@ function ValidatorPageResult(): JSX.Element {
6768
showContent: true,
6869
});
6970

70-
const sanitizePendingValidatorsData = sanitizePendingValidators(pendingValidatorsData);
71+
const sanitizedPendingValidatorsData = sanitizePendingValidators(pendingValidatorsData);
7172

7273
const { data: validatorsApy } = useGetValidatorsApy();
7374
const { data: totalSupplyData } = useIotaClientQuery('getTotalSupply', {
@@ -128,9 +129,9 @@ function ValidatorPageResult(): JSX.Element {
128129
return formatPercentageDisplay(ratio);
129130
})();
130131

131-
const tableData = data
132+
const activeAndPendingValidators = data
132133
? Number(data.pendingActiveValidatorsSize) > 0
133-
? activeValidators?.concat(sanitizePendingValidatorsData)
134+
? activeValidators?.concat(sanitizedPendingValidatorsData)
134135
: activeValidators
135136
: [];
136137

@@ -150,7 +151,7 @@ function ValidatorPageResult(): JSX.Element {
150151
];
151152

152153
return generateValidatorsTableColumns({
153-
activeValidators: data.activeValidators,
154+
allValidators: activeAndPendingValidators,
154155
committeeMembers: data.committeeMembers.map((validator) => validator.iotaAddress),
155156
atRiskValidators: data.atRiskValidators,
156157
maxCommitteeSize,
@@ -160,7 +161,7 @@ function ValidatorPageResult(): JSX.Element {
160161
includeColumns,
161162
currentEpoch: data.epoch,
162163
});
163-
}, [data, validatorEvents, validatorsApy, maxCommitteeSize]);
164+
}, [data, activeAndPendingValidators, validatorEvents, validatorsApy, maxCommitteeSize]);
164165

165166
const [formattedTotalStakedAmount, totalStakedSymbol] = useFormatCoin({ balance: totalStaked });
166167
const [formattedlastEpochRewardOnAllValidatorsAmount, lastEpochRewardOnAllValidatorsSymbol] =
@@ -269,14 +270,14 @@ function ValidatorPageResult(): JSX.Element {
269270
)}
270271
{isSuccess &&
271272
isMaxCommitteeSizeSuccess &&
272-
tableData &&
273+
activeAndPendingValidators &&
273274
tableColumns && (
274275
<TableCard
275276
sortTable
276277
defaultSorting={[
277278
{ id: 'stakingPoolIotaBalance', desc: true },
278279
]}
279-
data={tableData}
280+
data={activeAndPendingValidators}
280281
columns={tableColumns}
281282
areHeadersCentered={false}
282283
/>

apps/ui-kit/src/lib/components/atoms/badge/Badge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import cx from 'classnames';
5-
import { BadgeType } from './badge.enums';
5+
import type { BadgeType } from './badge.enums';
66
import { BACKGROUND_COLORS, BADGE_TEXT_CLASS, BORDER_COLORS, TEXT_COLORS } from './badge.classes';
77

88
interface BadgeProps {

apps/ui-kit/src/lib/components/atoms/button/button-variants/ButtonPill.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { ButtonHtmlType } from '../button.enums';
5-
import { ButtonVariantProps } from './buttonVariants.types';
5+
import type { ButtonVariantProps } from './buttonVariants.types';
66

77
export function ButtonPill({
88
htmlType = ButtonHtmlType.Button,

apps/ui-kit/src/lib/components/atoms/button/button-variants/ButtonUnstyled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { ButtonHtmlType } from '../button.enums';
5-
import { ButtonVariantProps } from './buttonVariants.types';
5+
import type { ButtonVariantProps } from './buttonVariants.types';
66
import cx from 'classnames';
77

88
export function ButtonUnstyled({

apps/ui-kit/src/lib/components/atoms/button/button-variants/buttonVariants.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2024 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { ButtonProps } from '../Button';
4+
import type { ButtonProps } from '../Button';
55

66
type ButtonPickedProps = Pick<ButtonProps, 'htmlType' | 'testId'>;
77
type PropsFromButtonElement = Omit<React.HTMLProps<HTMLButtonElement>, 'type'>;

apps/ui-kit/src/lib/components/atoms/info-box/InfoBox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import cx from 'classnames';
5-
import { InfoBoxStyle, InfoBoxType } from './infoBox.enums';
5+
import type { InfoBoxType } from './infoBox.enums';
6+
import { InfoBoxStyle } from './infoBox.enums';
67
import { BACKGROUND_COLORS, ICON_COLORS } from './infoBox.classes';
78

89
export interface InfoBoxProps {

apps/ui-kit/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// Copyright (c) 2024 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { ReactNode } from 'react';
4+
import type { ReactNode } from 'react';
55
import cx from 'classnames';
66
import { Copy, Info } from '@iota/apps-ui-icons';
77
import { ValueSize } from './keyValue.enums';
8-
import { Tooltip, TooltipPosition } from '../tooltip';
8+
import type { TooltipPosition } from '../tooltip';
9+
import { Tooltip } from '../tooltip';
910
import { ButtonUnstyled } from '../button';
1011

1112
interface KeyValueProps {

apps/ui-kit/src/lib/components/atoms/label-text/LabelText.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import cx from 'classnames';
55
import { LabelTextSize } from './labelText.enums';
66
import { LABEL_TEXT_SIZE, SUPPORTING_TEXT_SIZE, TEXT_SIZE } from './labelText.classes';
77
import { Info } from '@iota/apps-ui-icons';
8-
import { TooltipPosition, Tooltip } from '../tooltip';
8+
import type { TooltipPosition } from '../tooltip';
9+
import { Tooltip } from '../tooltip';
910

1011
interface LabelTextProps {
1112
/**

apps/ui-kit/src/lib/components/atoms/list-item/ListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2024 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { PropsWithChildren } from 'react';
4+
import type { PropsWithChildren } from 'react';
55
import cx from 'classnames';
66
import { ArrowRight } from '@iota/apps-ui-icons';
77
import { Button, ButtonSize, ButtonType } from '@/components';

apps/ui-kit/src/lib/components/atoms/tooltip/Tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2024 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { PropsWithChildren } from 'react';
4+
import type { PropsWithChildren } from 'react';
55
import cx from 'classnames';
66
import { TooltipPosition } from './tooltip.enums';
77
import { TOOLTIP_POSITION } from './tooltip.classes';

apps/ui-kit/src/lib/components/molecules/account/Account.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
import cx from 'classnames';
55
import { ButtonUnstyled } from '../../atoms/button';
6-
import { Badge, BadgeType } from '../../atoms';
6+
import type { BadgeType } from '../../atoms';
7+
import { Badge } from '../../atoms';
78
import {
89
LockLocked,
910
LockUnlocked,

apps/ui-kit/src/lib/components/molecules/card/CardBody.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) 2024 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33
import cx from 'classnames';
4-
5-
import { ReactNode } from 'react';
6-
import { Tooltip, TooltipPosition } from '../../atoms';
4+
import type { ReactNode } from 'react';
5+
import { Tooltip } from '../../atoms';
6+
import type { TooltipPosition } from '../../atoms';
77

88
export type CardBodyProps = {
99
title: string;

apps/ui-kit/src/lib/components/molecules/display-stats/DisplayStats.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright (c) 2024 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { ReactNode } from 'react';
5-
import { Tooltip, TooltipPosition } from '../../atoms';
4+
import type { ReactNode } from 'react';
5+
import type { TooltipPosition } from '../../atoms';
6+
import { Tooltip } from '../../atoms';
67
import { Info } from '@iota/apps-ui-icons';
78
import { DisplayStatsType, DisplayStatsSize } from './displayStats.enums';
89
import cx from 'classnames';

apps/ui-kit/src/lib/components/molecules/input/Input.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
import { forwardRef, Fragment, useEffect, useRef, useState } from 'react';
55
import cx from 'classnames';
6-
import { InputWrapper, InputWrapperProps } from './InputWrapper';
6+
import type { InputWrapperProps } from './InputWrapper';
7+
import { InputWrapper } from './InputWrapper';
78
import {
89
BORDER_CLASSES,
910
INPUT_CLASSES,
@@ -15,7 +16,7 @@ import { InputType } from './input.enums';
1516
import { SecondaryText } from '../../atoms/secondary-text';
1617
import { Close, VisibilityOff, VisibilityOn } from '@iota/apps-ui-icons';
1718
import { ButtonUnstyled } from '../../atoms/button';
18-
import { InputPropsByType, NumericFormatInputProps } from './input.types';
19+
import type { InputPropsByType, NumericFormatInputProps } from './input.types';
1920
import { NumericFormat } from 'react-number-format';
2021

2122
export interface BaseInputProps extends InputWrapperProps {

apps/ui-kit/src/lib/components/molecules/input/TextArea.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { forwardRef, useEffect, useState } from 'react';
5-
import { InputWrapper, InputWrapperProps } from './InputWrapper';
5+
import type { InputWrapperProps } from './InputWrapper';
6+
import { InputWrapper } from './InputWrapper';
67
import {
78
BORDER_CLASSES,
89
INPUT_CLASSES,

apps/ui-kit/src/lib/components/molecules/input/input.types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) 2024 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { ComponentProps } from 'react';
5-
import { InputType } from '.';
6-
import { NumericFormat } from 'react-number-format';
4+
import type { ComponentProps } from 'react';
5+
import type { InputType } from '.';
6+
import type { NumericFormat } from 'react-number-format';
77

88
type InputElementProps = Omit<
99
React.ComponentProps<'input'>,

apps/ui-kit/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
UNSELECTED_TEXT,
1515
} from './navbarItem.classes';
1616
import { Badge, BadgeType } from '../../atoms';
17-
import { NavbarItemProps } from './NavbarItem';
17+
import type { NavbarItemProps } from './NavbarItem';
1818

1919
export function NavbarItemHorizontal({
2020
icon,

apps/ui-kit/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
UNSELECTED_TEXT,
1111
} from './navbarItem.classes';
1212
import { Badge, BadgeType } from '../../atoms';
13-
import { NavbarItemProps } from './NavbarItem';
13+
import type { NavbarItemProps } from './NavbarItem';
1414

1515
export function NavbarItemVertical({
1616
icon,

apps/ui-kit/src/lib/components/molecules/search/Search.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ export interface SearchProps {
4343
* Are the suggestions loading.
4444
*/
4545
isLoading: boolean;
46-
/**
47-
* Callback when a key is pressed.
48-
*/
49-
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
5046
/**
5147
* The type of the search bar. Can be 'outlined' or 'filled'.
5248
*/
@@ -64,7 +60,6 @@ export function Search({
6460
onSuggestionClick,
6561
placeholder,
6662
isLoading = false,
67-
onKeyDown,
6863
type = SearchBarType.Outlined,
6964
renderSuggestion,
7065
}: SearchProps): React.JSX.Element {
@@ -157,9 +152,6 @@ export function Search({
157152
}
158153
}
159154
}
160-
if (onKeyDown) {
161-
onKeyDown(event);
162-
}
163155
};
164156

165157
return (

0 commit comments

Comments
 (0)