Skip to content

Commit

Permalink
Remove unused hooks and move useGetTimeBeforeEpochNumber to core (Mys…
Browse files Browse the repository at this point in the history
…tenLabs#11191)

## Description 

Describe the changes or additions included in this PR.

- Moved useGetTimeBeforeEpochNumber
- Deleted unused hooks in wallet - `useSuiObjectFields`,
`useWaitForElement `, `useReferenceGasPrice`
  • Loading branch information
Jibz-Mysten authored Apr 21, 2023
1 parent 98be335 commit a4a2722
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { useSystemState } from './useSystemState';
import { useGetSystemState } from './useGetSystemState';

// Get time between current epoch and specified epoch
// Get the period between the current epoch and next epoch
export function useGetTimeBeforeEpochNumber(epoch: number) {
const data = useSystemState();
const data = useGetSystemState();
// Current epoch
const currentEpoch = Number(data.data?.epoch || 0);
const currentEpochStartTime = Number(data.data?.epochStartTimestampMs || 0);
Expand Down
1 change: 1 addition & 0 deletions apps/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './hooks/useGetNormalizedMoveStruct';
export * from './PostHogAnalyticsProvider';
export * from './utils/formatPercentageDisplay';
export * from './hooks/useGetSystemState';
export * from './hooks/useGetTimeBeforeEpochNumber';
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import {
formatPercentageDisplay,
useGetRollingAverageApys,
useGetTimeBeforeEpochNumber,
} from '@mysten/core';
import { SUI_TYPE_ARG } from '@mysten/sui.js';

import { useGetTimeBeforeEpochNumber } from '_app/staking/useGetTimeBeforeEpochNumber';
import { ValidatorLogo } from '_app/staking/validators/ValidatorLogo';
import { TxnAmount } from '_components/receipt-card/TxnAmount';
import { NUM_OF_EPOCH_BEFORE_EARNING } from '_src/shared/constants';
Expand Down
2 changes: 0 additions & 2 deletions apps/wallet/src/ui/app/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ export { default as useAppSelector } from './useAppSelector';
export { default as useInitializedGuard } from './useInitializedGuard';
export { default as useFullscreenGuard } from './useFullscreenGuard';
export { default as useMediaUrl, parseIpfsUrl } from './useMediaUrl';
export { default as useSuiObjectFields } from './useSuiObjectFields';
export { default as useOnClickOutside } from './useOnClickOutside';
export { default as useOnKeyboardEvent } from './useOnKeyboardEvent';
export { default as useFileExtensionType } from './useFileExtensionType';
export { default as useNFTBasicData } from './useNFTBasicData';
export { useWaitForElement } from './useWaitForElement';
export { useGetNFTMeta } from './useGetNFTMeta';
export { useTransactionDryRun } from './useTransactionDryRun';
export { useGetTxnRecipientAddress } from './useGetTxnRecipientAddress';
Expand Down
11 changes: 0 additions & 11 deletions apps/wallet/src/ui/app/hooks/useReferenceGasPrice.ts

This file was deleted.

55 changes: 0 additions & 55 deletions apps/wallet/src/ui/app/hooks/useSuiObjectFields.ts

This file was deleted.

23 changes: 0 additions & 23 deletions apps/wallet/src/ui/app/hooks/useWaitForElement.ts

This file was deleted.

3 changes: 1 addition & 2 deletions apps/wallet/src/ui/app/staking/home/StakedCard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { useFormatCoin } from '@mysten/core';
import { useFormatCoin, useGetTimeBeforeEpochNumber } from '@mysten/core';
import { SUI_TYPE_ARG, type SuiAddress } from '@mysten/sui.js';
import { cx, cva, type VariantProps } from 'class-variance-authority';
import { Link } from 'react-router-dom';

import { useGetTimeBeforeEpochNumber } from '../useGetTimeBeforeEpochNumber';
import { ValidatorLogo } from '../validators/ValidatorLogo';
import { NUM_OF_EPOCH_BEFORE_EARNING } from '_src/shared/constants';
import { CountDownTimer } from '_src/ui/app/shared/countdown-timer';
Expand Down
7 changes: 5 additions & 2 deletions apps/wallet/src/ui/app/staking/stake/StakeForm.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { useCoinDecimals, useFormatCoin } from '@mysten/core';
import {
useCoinDecimals,
useFormatCoin,
useGetTimeBeforeEpochNumber,
} from '@mysten/core';
import { Field, Form, useFormikContext } from 'formik';
import { memo, useCallback, useMemo } from 'react';

import { parseAmount } from '../../helpers';
import { useTransactionGasBudget, useActiveAddress } from '../../hooks';
import { useGetTimeBeforeEpochNumber } from '../useGetTimeBeforeEpochNumber';
import { type FormValues } from './StakingCard';
import { createStakeTransaction } from './utils/transaction';
import { Card } from '_app/shared/card';
Expand Down
3 changes: 1 addition & 2 deletions apps/wallet/src/ui/app/staking/stake/UnstakeForm.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { useFormatCoin } from '@mysten/core';
import { useFormatCoin, useGetTimeBeforeEpochNumber } from '@mysten/core';
import { SUI_TYPE_ARG } from '@mysten/sui.js';
import { Form } from 'formik';
import { useMemo } from 'react';

import { useTransactionGasBudget, useActiveAddress } from '../../hooks';
import { GAS_SYMBOL } from '../../redux/slices/sui-objects/Coin';
import { Heading } from '../../shared/heading';
import { useGetTimeBeforeEpochNumber } from '../useGetTimeBeforeEpochNumber';
import { createUnstakeTransaction } from './utils/transaction';
import { Card } from '_app/shared/card';
import { Text } from '_app/shared/text';
Expand Down

0 comments on commit a4a2722

Please sign in to comment.