Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(suite): unify staking files #15108

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import {
ExternalOutput,
AddressDisplayOptions,
} from '@suite-common/wallet-types';
import {
MIN_ETH_AMOUNT_FOR_STAKING,
MIN_ETH_BALANCE_FOR_STAKING,
MIN_ETH_FOR_WITHDRAWALS,
} from '@suite-common/wallet-constants';
import { selectDevice, ComposeActionContext } from '@suite-common/wallet-core';

import { Dispatch, GetState } from 'src/types/suite';
Expand All @@ -31,11 +36,6 @@ import {
prepareStakeEthTx,
prepareUnstakeEthTx,
} from 'src/utils/suite/stake';
import {
MIN_ETH_AMOUNT_FOR_STAKING,
MIN_ETH_BALANCE_FOR_STAKING,
MIN_ETH_FOR_WITHDRAWALS,
} from 'src/constants/suite/ethStaking';
import { NetworkSymbol } from '@suite-common/wallet-config';

const calculate = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled from 'styled-components';
import { Translation } from 'src/components/suite';
import { Button, Tooltip } from '@trezor/components';
import { BigNumber } from '@trezor/utils/src/bigNumber';
import { MIN_ETH_AMOUNT_FOR_STAKING } from 'src/constants/suite/ethStaking';
import { MIN_ETH_AMOUNT_FOR_STAKING } from '@suite-common/wallet-constants';
import { NetworkSymbol } from '@suite-common/wallet-config';

const Flex = styled.div`
Expand Down
7 changes: 5 additions & 2 deletions packages/suite/src/components/suite/UnstakingTxAmount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import { getUnstakeAmountByEthereumDataHex, isUnstakeTx } from '@suite-common/suite-utils';
import { WalletAccountTransaction } from '@suite-common/wallet-types';
import { formatNetworkAmount } from '@suite-common/wallet-utils';
import {
formatNetworkAmount,
isUnstakeTx,
getUnstakeAmountByEthereumDataHex,
} from '@suite-common/wallet-utils';
import { FormattedCryptoAmount } from './FormattedCryptoAmount';

interface UnstakingTxAmountProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ import {
SendState,
} from '@suite-common/wallet-core';
import { FormState, StakeFormState } from '@suite-common/wallet-types';
import { constructTransactionReviewOutputs, isRbfTransaction } from '@suite-common/wallet-utils';
import {
constructTransactionReviewOutputs,
isRbfTransaction,
getTxStakeNameByDataHex,
} from '@suite-common/wallet-utils';
import { useSelector } from 'src/hooks/suite';
import { selectIsActionAbortable } from 'src/reducers/suite/suiteReducer';
import { getTransactionReviewModalActionText } from 'src/utils/suite/transactionReview';
import { Modal, Translation } from 'src/components/suite';
import { TransactionReviewSummary } from './TransactionReviewSummary';
import { TransactionReviewOutputList } from './TransactionReviewOutputList/TransactionReviewOutputList';
import { TransactionReviewEvmExplanation } from './TransactionReviewEvmExplanation';
import { getTxStakeNameByDataHex } from '@suite-common/suite-utils';
import { ConfirmOnDevice } from '@trezor/product-components';
import { networks } from '@suite-common/wallet-config';
import { selectAccountIncludingChosenInCoinmarket } from 'src/reducers/wallet/selectedAccountReducer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
validateReserveOrBalance,
} from 'src/utils/suite/validation';
import { FIAT_INPUT, CRYPTO_INPUT } from 'src/types/wallet/stakeForms';
import { MIN_ETH_FOR_WITHDRAWALS } from 'src/constants/suite/ethStaking';
import { MIN_ETH_FOR_WITHDRAWALS } from '@suite-common/wallet-constants';
import { spacingsPx } from '@trezor/theme';
import { validateStakingMax } from 'src/utils/suite/stake';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
isNftTokenTransfer,
isTxFeePaid,
roundTimestampToNearestPastHour,
isStakeTypeTx,
} from '@suite-common/wallet-utils';
import { BigNumber } from '@trezor/utils/src/bigNumber';
import { FormattedNftAmount } from 'src/components/suite/FormattedNftAmount';
Expand All @@ -24,7 +25,6 @@ import {
selectHistoricFiatRatesByTimestamp,
} from '@suite-common/wallet-core';
import { Timestamp, TokenAddress } from '@suite-common/wallet-types';
import { isStakeTypeTx } from '@suite-common/suite-utils';

const MainContainer = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getAccountTransactions,
findTransaction,
getConfirmations,
isStakeTypeTx,
} from '@suite-common/wallet-utils';

import {
Expand All @@ -24,7 +25,6 @@ import {
import { goto } from 'src/actions/suite/routerActions';
import { useDispatch, useSelector } from 'src/hooks/suite';
import { getTxAnchor } from 'src/utils/suite/anchor';
import { isStakeTypeTx } from '@suite-common/suite-utils';

type TransactionRendererProps = NotificationViewProps &
NotificationRendererProps<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Translation, FormattedCryptoAmount } from 'src/components/suite';
import { WalletAccountTransaction } from 'src/types/wallet';
import { StakeType } from '@suite-common/wallet-types/src/stake';
import { StakeType } from '@suite-common/wallet-types';

import { Badge, Icon } from '@trezor/components';
import styled from 'styled-components';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Translation } from 'src/components/suite';
import { getTxHeaderSymbol } from '@suite-common/wallet-utils';
import { getTxHeaderSymbol, isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-utils';
import { WalletAccountTransaction } from 'src/types/wallet';
import { AccountTransaction } from '@trezor/connect';
import { UnstakingTxAmount } from 'src/components/suite/UnstakingTxAmount';
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-core';

interface TransactionHeaderProps {
transaction: WalletAccountTransaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import {
getTargetAmount,
getTxHeaderSymbol,
getTxOperation,
isSupportedEthStakingNetworkSymbol,
} from '@suite-common/wallet-utils';
import { TransactionHeader } from './TransactionHeader';
import { WalletAccountTransaction } from 'src/types/wallet';
import { BigNumber } from '@trezor/utils/src/bigNumber';
import { BlurWrapper } from './TransactionItemBlurWrapper';
import { spacingsPx } from '@trezor/theme';
import { InstantStakeBadge } from './InstantStakeBadge';
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-core';

const Wrapper = styled.span`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { variables, Button, Card, Link, Tooltip } from '@trezor/components';
import { Translation } from 'src/components/suite';
import { useDispatch, useSelector } from 'src/hooks/suite';
import { openModal } from 'src/actions/suite/modalActions';
import { formatNetworkAmount, isTestnet, isTxFeePaid } from '@suite-common/wallet-utils';
import {
formatNetworkAmount,
isTestnet,
isTxFeePaid,
isStakeTypeTx,
} from '@suite-common/wallet-utils';
import { AccountLabels } from 'src/types/suite/metadata';
import { WalletAccountTransaction } from 'src/types/wallet';
import { AccountType, Network } from '@suite-common/wallet-config';
Expand Down Expand Up @@ -34,7 +39,6 @@ import { SUBPAGE_NAV_HEIGHT } from 'src/constants/suite/layout';
import { BlurWrapper } from './TransactionItemBlurWrapper';
import { selectSelectedAccount } from 'src/reducers/wallet/selectedAccountReducer';
import { getInstantStakeType } from 'src/utils/suite/stake';
import { isStakeTypeTx } from '@suite-common/suite-utils';
import { HELP_CENTER_REPLACE_BY_FEE } from '@trezor/urls';

// eslint-disable-next-line local-rules/no-override-ds-component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EvmExplanationBanner } from './EvmExplanationBanner';
import { TaprootBanner } from './TaprootBanner';
import { Context } from '@suite-common/message-system';
import { useSelector } from 'src/hooks/suite';
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-core';
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-utils';

const BannersWrapper = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import { useDispatch, useSelector } from 'src/hooks/suite';
import { setFlag } from 'src/actions/suite/suiteActions';
import { selectSuiteFlags } from '../../../../reducers/suite/suiteReducer';
import { Account } from '@suite-common/wallet-types';
import {
selectPoolStatsApyData,
isSupportedEthStakingNetworkSymbol,
} from '@suite-common/wallet-core';
import { MIN_ETH_AMOUNT_FOR_STAKING } from 'src/constants/suite/ethStaking';
import { selectPoolStatsApyData } from '@suite-common/wallet-core';
import { MIN_ETH_AMOUNT_FOR_STAKING } from '@suite-common/wallet-constants';
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-utils';
import { useTheme } from 'styled-components';

interface StakeEthBannerProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { AccountItemsGroup } from './AccountItemsGroup';
import { AccountItem } from './AccountItem';
import { useSelector } from 'src/hooks/suite';
import { selectCoinDefinitions } from '@suite-common/token-definitions';
import {
isSupportedEthStakingNetworkSymbol,
selectAccountHasStaked,
} from '@suite-common/wallet-core';
import { selectAccountHasStaked } from '@suite-common/wallet-core';
import { isSupportedEthStakingNetworkSymbol } from '@suite-common/wallet-utils';
import { getTokens } from 'src/utils/wallet/tokenUtils';

interface AccountSectionProps {
Expand Down
8 changes: 0 additions & 8 deletions packages/suite/src/constants/suite/ethStaking.ts

This file was deleted.

10 changes: 5 additions & 5 deletions packages/suite/src/hooks/wallet/useStakeEthForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ import { useFormDraft } from './useFormDraft';

import { fromWei } from 'web3-utils';
import { useStakeCompose } from './form/useStakeCompose';
import {
MIN_ETH_AMOUNT_FOR_STAKING,
MIN_ETH_BALANCE_FOR_STAKING,
MIN_ETH_FOR_WITHDRAWALS,
} from 'src/constants/suite/ethStaking';
import { selectLocalCurrency } from 'src/reducers/wallet/settingsReducer';

import { signTransaction } from 'src/actions/wallet/stakeActions';
Expand All @@ -39,6 +34,11 @@ import {
StakeContextValues,
selectFiatRatesByFiatRateKey,
} from '@suite-common/wallet-core';
import {
MIN_ETH_AMOUNT_FOR_STAKING,
MIN_ETH_BALANCE_FOR_STAKING,
MIN_ETH_FOR_WITHDRAWALS,
} from '@suite-common/wallet-constants';
import { selectNetwork } from '@everstake/wallet-sdk/ethereum';
import { useFees } from './form/useFees';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { accountsActions } from '@suite-common/wallet-core';
import { MIN_ETH_BALANCE_FOR_STAKING } from '@suite-common/wallet-constants';
import type { Action } from 'src/types/suite';
import type { SelectedAccountStatus } from '@suite-common/wallet-types';
import { MIN_ETH_BALANCE_FOR_STAKING } from 'src/constants/suite/ethStaking';
import { State as CoinmarketState } from 'src/reducers/wallet/coinmarketReducer';

export type State = SelectedAccountStatus;
Expand Down
13 changes: 7 additions & 6 deletions packages/suite/src/utils/suite/stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import {
StakeType,
WalletAccountTransaction,
} from '@suite-common/wallet-types';
import { DEFAULT_PAYMENT } from '@suite-common/wallet-constants';
import {
DEFAULT_PAYMENT,
STAKE_GAS_LIMIT_RESERVE,
MIN_ETH_AMOUNT_FOR_STAKING,
MAX_ETH_AMOUNT_FOR_STAKING,
} from '@suite-common/wallet-constants';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { selectNetwork } from '@everstake/wallet-sdk/ethereum';
import { fromWei, numberToHex, toWei } from 'web3-utils';
import { getEthereumEstimateFeeParams, isPending, sanitizeHex } from '@suite-common/wallet-utils';
import TrezorConnect, { EthereumTransaction, Success, InternalTransfer } from '@trezor/connect';
import { BigNumber } from '@trezor/utils/src/bigNumber';
import { STAKE_GAS_LIMIT_RESERVE, ValidatorsQueue } from '@suite-common/wallet-core';
import { ValidatorsQueue } from '@suite-common/wallet-core';
import { BlockchainEstimatedFee } from '@trezor/connect/src/types/api/blockchainEstimateFee';
import {
MIN_ETH_AMOUNT_FOR_STAKING,
MAX_ETH_AMOUNT_FOR_STAKING,
} from 'src/constants/suite/ethStaking';
import { TranslationFunction } from 'src/hooks/suite/useTranslation';

// source is a required parameter for some functions in the Everstake Wallet SDK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import { Translation, StakingFeature } from 'src/components/suite';
import { StakeEthCardFooter } from './StakeEthCardFooter/StakeEthCardFooter';
import { useDevice, useDiscovery, useDispatch, useSelector } from 'src/hooks/suite';
import { useAccounts } from 'src/hooks/wallet';
import { MIN_ETH_BALANCE_FOR_STAKING } from 'src/constants/suite/ethStaking';
import { spacings } from '@trezor/theme';
import { selectEnabledNetworks } from 'src/reducers/wallet/settingsReducer';
import { selectSuiteFlags } from 'src/reducers/suite/suiteReducer';
import { setFlag } from 'src/actions/suite/suiteActions';
import { selectPoolStatsApyData } from '@suite-common/wallet-core';
import { MIN_ETH_BALANCE_FOR_STAKING } from '@suite-common/wallet-constants';
import { hasBitcoinOnlyFirmware } from '@trezor/device-utils';

const bannerSymbol = 'eth';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Translation } from 'src/components/suite';
import { AccentP, CardBottomContent, GreyP } from './styled';
import { selectSelectedAccount } from 'src/reducers/wallet/selectedAccountReducer';
import { useSelector } from 'src/hooks/suite';
import { BACKUP_REWARD_PAYOUT_DAYS } from 'src/constants/suite/ethStaking';
import { BACKUP_REWARD_PAYOUT_DAYS } from '@suite-common/wallet-constants';
import { getAccountAutocompoundBalance } from '@suite-common/wallet-utils';

interface PayoutCardProps {
Expand Down
3 changes: 1 addition & 2 deletions suite-common/suite-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@suite-common/wallet-types": "workspace:*",
"@trezor/connect": "workspace:*",
"@trezor/urls": "workspace:*",
"date-fns": "^2.30.0",
"web3-utils": "^4.3.1"
"date-fns": "^2.30.0"
}
}
22 changes: 0 additions & 22 deletions suite-common/suite-utils/src/__fixtures__/stake.ts

This file was deleted.

11 changes: 0 additions & 11 deletions suite-common/suite-utils/src/__tests__/stake.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion suite-common/suite-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * from './build';
export * from './resolveStaticPath';
export * from './comparison';
export * from './txsPerPage';
export * from './stake';
export * from './parseFirmwareChangelog';
export * from './uppercaseType';
export * from './protocol';
Expand Down
49 changes: 0 additions & 49 deletions suite-common/suite-utils/src/stake.ts

This file was deleted.

Loading
Loading