Skip to content

Commit df9ac7a

Browse files
dev-pvltomasklim
authored andcommitted
chore(suite): unify staking files
1 parent 0dbc399 commit df9ac7a

File tree

47 files changed

+277
-259
lines changed

Some content is hidden

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

47 files changed

+277
-259
lines changed

packages/suite/src/actions/wallet/stake/stakeFormEthereumActions.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import {
2020
ExternalOutput,
2121
AddressDisplayOptions,
2222
} from '@suite-common/wallet-types';
23+
import {
24+
MIN_ETH_AMOUNT_FOR_STAKING,
25+
MIN_ETH_BALANCE_FOR_STAKING,
26+
MIN_ETH_FOR_WITHDRAWALS,
27+
} from '@suite-common/wallet-constants';
2328
import { selectDevice, ComposeActionContext } from '@suite-common/wallet-core';
2429

2530
import { Dispatch, GetState } from 'src/types/suite';
@@ -31,11 +36,6 @@ import {
3136
prepareStakeEthTx,
3237
prepareUnstakeEthTx,
3338
} from 'src/utils/suite/stake';
34-
import {
35-
MIN_ETH_AMOUNT_FOR_STAKING,
36-
MIN_ETH_BALANCE_FOR_STAKING,
37-
MIN_ETH_FOR_WITHDRAWALS,
38-
} from 'src/constants/suite/ethStaking';
3939
import { NetworkSymbol } from '@suite-common/wallet-config';
4040

4141
const calculate = (

packages/suite/src/components/suite/FormFractionButtons.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import styled from 'styled-components';
22
import { Translation } from 'src/components/suite';
33
import { Button, Tooltip } from '@trezor/components';
44
import { BigNumber } from '@trezor/utils/src/bigNumber';
5-
import { MIN_ETH_AMOUNT_FOR_STAKING } from 'src/constants/suite/ethStaking';
5+
import { MIN_ETH_AMOUNT_FOR_STAKING } from '@suite-common/wallet-constants';
66
import { NetworkSymbol } from '@suite-common/wallet-config';
77

88
const Flex = styled.div`

packages/suite/src/components/suite/UnstakingTxAmount.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React from 'react';
2-
import { getUnstakeAmountByEthereumDataHex, isUnstakeTx } from '@suite-common/suite-utils';
32
import { WalletAccountTransaction } from '@suite-common/wallet-types';
4-
import { formatNetworkAmount } from '@suite-common/wallet-utils';
3+
import {
4+
formatNetworkAmount,
5+
isUnstakeTx,
6+
getUnstakeAmountByEthereumDataHex,
7+
} from '@suite-common/wallet-utils';
58
import { FormattedCryptoAmount } from './FormattedCryptoAmount';
69

710
interface UnstakingTxAmountProps {

packages/suite/src/components/suite/modals/ReduxModal/TransactionReviewModal/TransactionReviewModalContent.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ import {
1212
SendState,
1313
} from '@suite-common/wallet-core';
1414
import { FormState, StakeFormState } from '@suite-common/wallet-types';
15-
import { constructTransactionReviewOutputs, isRbfTransaction } from '@suite-common/wallet-utils';
15+
import {
16+
constructTransactionReviewOutputs,
17+
isRbfTransaction,
18+
getTxStakeNameByDataHex,
19+
} from '@suite-common/wallet-utils';
1620
import { useSelector } from 'src/hooks/suite';
1721
import { selectIsActionAbortable } from 'src/reducers/suite/suiteReducer';
1822
import { getTransactionReviewModalActionText } from 'src/utils/suite/transactionReview';
1923
import { Modal, Translation } from 'src/components/suite';
2024
import { TransactionReviewSummary } from './TransactionReviewSummary';
2125
import { TransactionReviewOutputList } from './TransactionReviewOutputList/TransactionReviewOutputList';
2226
import { TransactionReviewEvmExplanation } from './TransactionReviewEvmExplanation';
23-
import { getTxStakeNameByDataHex } from '@suite-common/suite-utils';
2427
import { ConfirmOnDevice } from '@trezor/product-components';
2528
import { networks } from '@suite-common/wallet-config';
2629
import { selectAccountIncludingChosenInCoinmarket } from 'src/reducers/wallet/selectedAccountReducer';

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/StakeModal/StakeEthForm/Inputs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
validateReserveOrBalance,
1414
} from 'src/utils/suite/validation';
1515
import { FIAT_INPUT, CRYPTO_INPUT } from 'src/types/wallet/stakeForms';
16-
import { MIN_ETH_FOR_WITHDRAWALS } from 'src/constants/suite/ethStaking';
16+
import { MIN_ETH_FOR_WITHDRAWALS } from '@suite-common/wallet-constants';
1717
import { spacingsPx } from '@trezor/theme';
1818
import { validateStakingMax } from 'src/utils/suite/stake';
1919

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/AdvancedTxDetails/AmountDetails.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
isNftTokenTransfer,
1515
isTxFeePaid,
1616
roundTimestampToNearestPastHour,
17+
isStakeTypeTx,
1718
} from '@suite-common/wallet-utils';
1819
import { BigNumber } from '@trezor/utils/src/bigNumber';
1920
import { FormattedNftAmount } from 'src/components/suite/FormattedNftAmount';
@@ -24,7 +25,6 @@ import {
2425
selectHistoricFiatRatesByTimestamp,
2526
} from '@suite-common/wallet-core';
2627
import { Timestamp, TokenAddress } from '@suite-common/wallet-types';
27-
import { isStakeTypeTx } from '@suite-common/suite-utils';
2828

2929
const MainContainer = styled.div`
3030
display: flex;

packages/suite/src/components/suite/notifications/NotificationRenderer/TransactionRenderer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getAccountTransactions,
1414
findTransaction,
1515
getConfirmations,
16+
isStakeTypeTx,
1617
} from '@suite-common/wallet-utils';
1718

1819
import {
@@ -24,7 +25,6 @@ import {
2425
import { goto } from 'src/actions/suite/routerActions';
2526
import { useDispatch, useSelector } from 'src/hooks/suite';
2627
import { getTxAnchor } from 'src/utils/suite/anchor';
27-
import { isStakeTypeTx } from '@suite-common/suite-utils';
2828

2929
type TransactionRendererProps = NotificationViewProps &
3030
NotificationRendererProps<

packages/suite/src/components/wallet/TransactionItem/InstantStakeBadge.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Translation, FormattedCryptoAmount } from 'src/components/suite';
22
import { WalletAccountTransaction } from 'src/types/wallet';
3-
import { StakeType } from '@suite-common/wallet-types/src/stake';
3+
import { StakeType } from '@suite-common/wallet-types';
44

55
import { Badge, Icon } from '@trezor/components';
66
import styled from 'styled-components';

packages/suite/src/components/wallet/TransactionItem/TransactionHeader.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Translation } from 'src/components/suite';
2-
import { getTxHeaderSymbol } from '@suite-common/wallet-utils';
2+
import { getTxHeaderSymbol, isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-utils';
33
import { WalletAccountTransaction } from 'src/types/wallet';
44
import { AccountTransaction } from '@trezor/connect';
55
import { UnstakingTxAmount } from 'src/components/suite/UnstakingTxAmount';
6-
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-core';
76

87
interface TransactionHeaderProps {
98
transaction: WalletAccountTransaction;

packages/suite/src/components/wallet/TransactionItem/TransactionHeading.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import {
1313
getTargetAmount,
1414
getTxHeaderSymbol,
1515
getTxOperation,
16+
isSupportedEthStakingNetworkSymbol,
1617
} from '@suite-common/wallet-utils';
1718
import { TransactionHeader } from './TransactionHeader';
1819
import { WalletAccountTransaction } from 'src/types/wallet';
1920
import { BigNumber } from '@trezor/utils/src/bigNumber';
2021
import { BlurWrapper } from './TransactionItemBlurWrapper';
2122
import { spacingsPx } from '@trezor/theme';
2223
import { InstantStakeBadge } from './InstantStakeBadge';
23-
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-core';
2424

2525
const Wrapper = styled.span`
2626
display: flex;

packages/suite/src/components/wallet/TransactionItem/TransactionItem.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { variables, Button, Card, Link, Tooltip } from '@trezor/components';
66
import { Translation } from 'src/components/suite';
77
import { useDispatch, useSelector } from 'src/hooks/suite';
88
import { openModal } from 'src/actions/suite/modalActions';
9-
import { formatNetworkAmount, isTestnet, isTxFeePaid } from '@suite-common/wallet-utils';
9+
import {
10+
formatNetworkAmount,
11+
isTestnet,
12+
isTxFeePaid,
13+
isStakeTypeTx,
14+
} from '@suite-common/wallet-utils';
1015
import { AccountLabels } from 'src/types/suite/metadata';
1116
import { WalletAccountTransaction } from 'src/types/wallet';
1217
import { AccountType, Network } from '@suite-common/wallet-config';
@@ -34,7 +39,6 @@ import { SUBPAGE_NAV_HEIGHT } from 'src/constants/suite/layout';
3439
import { BlurWrapper } from './TransactionItemBlurWrapper';
3540
import { selectSelectedAccount } from 'src/reducers/wallet/selectedAccountReducer';
3641
import { getInstantStakeType } from 'src/utils/suite/stake';
37-
import { isStakeTypeTx } from '@suite-common/suite-utils';
3842
import { HELP_CENTER_REPLACE_BY_FEE } from '@trezor/urls';
3943

4044
// eslint-disable-next-line local-rules/no-override-ds-component

packages/suite/src/components/wallet/WalletLayout/AccountBanners/AccountBanners.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { EvmExplanationBanner } from './EvmExplanationBanner';
1515
import { TaprootBanner } from './TaprootBanner';
1616
import { Context } from '@suite-common/message-system';
1717
import { useSelector } from 'src/hooks/suite';
18-
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-core';
18+
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-utils';
1919

2020
const BannersWrapper = styled.div`
2121
display: flex;

packages/suite/src/components/wallet/WalletLayout/AccountBanners/StakeEthBanner.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import { useDispatch, useSelector } from 'src/hooks/suite';
66
import { setFlag } from 'src/actions/suite/suiteActions';
77
import { selectSuiteFlags } from '../../../../reducers/suite/suiteReducer';
88
import { Account } from '@suite-common/wallet-types';
9-
import {
10-
selectPoolStatsApyData,
11-
isSupportedEthStakingNetworkSymbol,
12-
} from '@suite-common/wallet-core';
13-
import { MIN_ETH_AMOUNT_FOR_STAKING } from 'src/constants/suite/ethStaking';
9+
import { selectPoolStatsApyData } from '@suite-common/wallet-core';
10+
import { MIN_ETH_AMOUNT_FOR_STAKING } from '@suite-common/wallet-constants';
11+
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-utils';
1412
import { useTheme } from 'styled-components';
1513

1614
interface StakeEthBannerProps {

packages/suite/src/components/wallet/WalletLayout/AccountsMenu/AcccountSection.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import { AccountItemsGroup } from './AccountItemsGroup';
33
import { AccountItem } from './AccountItem';
44
import { useSelector } from 'src/hooks/suite';
55
import { selectCoinDefinitions } from '@suite-common/token-definitions';
6-
import {
7-
isSupportedEthStakingNetworkSymbol,
8-
selectAccountHasStaked,
9-
} from '@suite-common/wallet-core';
6+
import { selectAccountHasStaked } from '@suite-common/wallet-core';
7+
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-utils';
108
import { getTokens } from 'src/utils/wallet/tokenUtils';
119

1210
interface AccountSectionProps {

packages/suite/src/constants/suite/ethStaking.ts

-8
This file was deleted.

packages/suite/src/hooks/wallet/useStakeEthForm.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ import { useFormDraft } from './useFormDraft';
2424

2525
import { fromWei } from 'web3-utils';
2626
import { useStakeCompose } from './form/useStakeCompose';
27-
import {
28-
MIN_ETH_AMOUNT_FOR_STAKING,
29-
MIN_ETH_BALANCE_FOR_STAKING,
30-
MIN_ETH_FOR_WITHDRAWALS,
31-
} from 'src/constants/suite/ethStaking';
3227
import { selectLocalCurrency } from 'src/reducers/wallet/settingsReducer';
3328

3429
import { signTransaction } from 'src/actions/wallet/stakeActions';
@@ -39,6 +34,11 @@ import {
3934
StakeContextValues,
4035
selectFiatRatesByFiatRateKey,
4136
} from '@suite-common/wallet-core';
37+
import {
38+
MIN_ETH_AMOUNT_FOR_STAKING,
39+
MIN_ETH_BALANCE_FOR_STAKING,
40+
MIN_ETH_FOR_WITHDRAWALS,
41+
} from '@suite-common/wallet-constants';
4242
import { selectNetwork } from '@everstake/wallet-sdk/ethereum';
4343
import { useFees } from './form/useFees';
4444

packages/suite/src/reducers/wallet/selectedAccountReducer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { accountsActions } from '@suite-common/wallet-core';
2+
import { MIN_ETH_BALANCE_FOR_STAKING } from '@suite-common/wallet-constants';
23
import type { Action } from 'src/types/suite';
34
import type { SelectedAccountStatus } from '@suite-common/wallet-types';
4-
import { MIN_ETH_BALANCE_FOR_STAKING } from 'src/constants/suite/ethStaking';
55
import { State as CoinmarketState } from 'src/reducers/wallet/coinmarketReducer';
66

77
export type State = SelectedAccountStatus;

packages/suite/src/utils/suite/stake.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ import {
44
StakeType,
55
WalletAccountTransaction,
66
} from '@suite-common/wallet-types';
7-
import { DEFAULT_PAYMENT } from '@suite-common/wallet-constants';
7+
import {
8+
DEFAULT_PAYMENT,
9+
STAKE_GAS_LIMIT_RESERVE,
10+
MIN_ETH_AMOUNT_FOR_STAKING,
11+
MAX_ETH_AMOUNT_FOR_STAKING,
12+
} from '@suite-common/wallet-constants';
813
import { NetworkSymbol } from '@suite-common/wallet-config';
914
import { selectNetwork } from '@everstake/wallet-sdk/ethereum';
1015
import { fromWei, numberToHex, toWei } from 'web3-utils';
1116
import { getEthereumEstimateFeeParams, isPending, sanitizeHex } from '@suite-common/wallet-utils';
1217
import TrezorConnect, { EthereumTransaction, Success, InternalTransfer } from '@trezor/connect';
1318
import { BigNumber } from '@trezor/utils/src/bigNumber';
14-
import { STAKE_GAS_LIMIT_RESERVE, ValidatorsQueue } from '@suite-common/wallet-core';
19+
import { ValidatorsQueue } from '@suite-common/wallet-core';
1520
import { BlockchainEstimatedFee } from '@trezor/connect/src/types/api/blockchainEstimateFee';
16-
import {
17-
MIN_ETH_AMOUNT_FOR_STAKING,
18-
MAX_ETH_AMOUNT_FOR_STAKING,
19-
} from 'src/constants/suite/ethStaking';
2021
import { TranslationFunction } from 'src/hooks/suite/useTranslation';
2122

2223
// source is a required parameter for some functions in the Everstake Wallet SDK.

packages/suite/src/views/dashboard/StakeEthCard/StakeEthCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import { Translation, StakingFeature } from 'src/components/suite';
1616
import { StakeEthCardFooter } from './StakeEthCardFooter/StakeEthCardFooter';
1717
import { useDevice, useDiscovery, useDispatch, useSelector } from 'src/hooks/suite';
1818
import { useAccounts } from 'src/hooks/wallet';
19-
import { MIN_ETH_BALANCE_FOR_STAKING } from 'src/constants/suite/ethStaking';
2019
import { spacings } from '@trezor/theme';
2120
import { selectEnabledNetworks } from 'src/reducers/wallet/settingsReducer';
2221
import { selectSuiteFlags } from 'src/reducers/suite/suiteReducer';
2322
import { setFlag } from 'src/actions/suite/suiteActions';
2423
import { selectPoolStatsApyData } from '@suite-common/wallet-core';
24+
import { MIN_ETH_BALANCE_FOR_STAKING } from '@suite-common/wallet-constants';
2525
import { hasBitcoinOnlyFirmware } from '@trezor/device-utils';
2626

2727
const bannerSymbol = 'eth';

packages/suite/src/views/wallet/staking/components/EthStakingDashboard/components/PayoutCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Translation } from 'src/components/suite';
66
import { AccentP, CardBottomContent, GreyP } from './styled';
77
import { selectSelectedAccount } from 'src/reducers/wallet/selectedAccountReducer';
88
import { useSelector } from 'src/hooks/suite';
9-
import { BACKUP_REWARD_PAYOUT_DAYS } from 'src/constants/suite/ethStaking';
9+
import { BACKUP_REWARD_PAYOUT_DAYS } from '@suite-common/wallet-constants';
1010
import { getAccountAutocompoundBalance } from '@suite-common/wallet-utils';
1111

1212
interface PayoutCardProps {

suite-common/suite-utils/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"@suite-common/wallet-types": "workspace:*",
2121
"@trezor/connect": "workspace:*",
2222
"@trezor/urls": "workspace:*",
23-
"date-fns": "^2.30.0",
24-
"web3-utils": "^4.3.1"
23+
"date-fns": "^2.30.0"
2524
}
2625
}

suite-common/suite-utils/src/__fixtures__/stake.ts

-22
This file was deleted.

suite-common/suite-utils/src/__tests__/stake.test.ts

-11
This file was deleted.

suite-common/suite-utils/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export * from './build';
55
export * from './resolveStaticPath';
66
export * from './comparison';
77
export * from './txsPerPage';
8-
export * from './stake';
98
export * from './parseFirmwareChangelog';
109
export * from './uppercaseType';
1110
export * from './protocol';

suite-common/suite-utils/src/stake.ts

-49
This file was deleted.

0 commit comments

Comments
 (0)