From 2ecbfda6840e4e03711d1f541a7e94d0a443fb2e Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Fri, 19 Jul 2024 14:17:49 +0300 Subject: [PATCH 01/34] refactor(reward): top card for connected wallet --- .../InputDescriptionStyles.ts | 12 +++++-- .../rewardsListContent/RewardsListContent.tsx | 14 +++++--- .../rewardsListContent/RewardsListsEmpty.tsx | 2 +- features/rewards/features/top-card/styles.tsx | 20 +++++++++++ features/rewards/features/top-card/wallet.tsx | 36 ++++++++----------- .../address-badge/address-badge.tsx | 11 +++--- 6 files changed, 62 insertions(+), 33 deletions(-) diff --git a/features/rewards/components/inputDescription/InputDescriptionStyles.ts b/features/rewards/components/inputDescription/InputDescriptionStyles.ts index b874bbfdd..1dca41906 100644 --- a/features/rewards/components/inputDescription/InputDescriptionStyles.ts +++ b/features/rewards/components/inputDescription/InputDescriptionStyles.ts @@ -1,10 +1,18 @@ import styled from 'styled-components'; export const WrapperStyle = styled.div` + flex: 1; padding: ${({ theme }) => theme.spaceMap.sm}px; + margin-right: ${({ theme }) => theme.spaceMap.xl}px; + border-radius: ${({ theme }) => theme.spaceMap.sm}px; - color: #ffac2f; + background-color: rgb(255, 172, 47, 0.1); + color: #ffac2f; text-align: center; - margin-top: 16px; + + ${({ theme }) => theme.mediaQueries.md} { + margin-right: 0; + margin-top: ${({ theme }) => theme.spaceMap.xl}px; + } `; diff --git a/features/rewards/components/rewardsListContent/RewardsListContent.tsx b/features/rewards/components/rewardsListContent/RewardsListContent.tsx index e74523842..ff5d9de6e 100644 --- a/features/rewards/components/rewardsListContent/RewardsListContent.tsx +++ b/features/rewards/components/rewardsListContent/RewardsListContent.tsx @@ -1,7 +1,13 @@ import { FC } from 'react'; import { Loader, Divider } from '@lidofinance/lido-ui'; +import { useSTETHBalance } from '@lido-sdk/react'; +import { Zero } from '@ethersproject/constants'; + +import { STRATEGY_LAZY } from 'consts/swr-strategies'; import { useRewardsHistory } from 'features/rewards/hooks'; import { ErrorBlockNoSteth } from 'features/rewards/components/errorBlocks/ErrorBlockNoSteth'; +import { RewardsTable } from 'features/rewards/components/rewardsTable'; +import { useDappStatus } from 'shared/hooks/use-dapp-status'; import { RewardsListsEmpty } from './RewardsListsEmpty'; import { RewardsListErrorMessage } from './RewardsListErrorMessage'; @@ -10,12 +16,9 @@ import { TableWrapperStyle, ErrorWrapper, } from './RewardsListContentStyles'; -import { RewardsTable } from 'features/rewards/components/rewardsTable'; -import { useSTETHBalance } from '@lido-sdk/react'; -import { STRATEGY_LAZY } from 'consts/swr-strategies'; -import { Zero } from '@ethersproject/constants'; export const RewardsListContent: FC = () => { + const { isDappActive } = useDappStatus(); const { error, initialLoading, @@ -29,7 +32,8 @@ export const RewardsListContent: FC = () => { useSTETHBalance(STRATEGY_LAZY); const hasSteth = stethBalance?.gt(Zero); - if (!data && !initialLoading && !error) return ; + if (!isDappActive || (!data && !initialLoading && !error)) + return ; // showing loading when canceling requests and empty response if ( (!data && !error) || diff --git a/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx b/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx index d418e9745..9aa9330dd 100644 --- a/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx +++ b/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx @@ -8,7 +8,7 @@ export const RewardsListsEmpty: FC = () => { <> - Connect your wallet to see the stats. + Connect your wallet to view your staking stats. ); diff --git a/features/rewards/features/top-card/styles.tsx b/features/rewards/features/top-card/styles.tsx index 2b03a3d26..d567d537f 100644 --- a/features/rewards/features/top-card/styles.tsx +++ b/features/rewards/features/top-card/styles.tsx @@ -1,5 +1,6 @@ import styled, { css } from 'styled-components'; import { WalletCardStyle } from 'shared/wallet/card/styles'; +import { AddressBadge } from 'shared/wallet/components/address-badge/address-badge'; export const WalletStyle = styled(WalletCardStyle)` background: linear-gradient( @@ -11,6 +12,25 @@ export const WalletStyle = styled(WalletCardStyle)` padding: 0 0 24px 0; `; +export const WalletContentStyle = styled.div` + display: flex; + flex-wrap: nowrap; + flex-direction: row; + align-items: center; + justify-content: space-between; + + padding: ${({ theme }) => theme.spaceMap.xxl}px; + + ${({ theme }) => theme.mediaQueries.md} { + align-items: end; + flex-direction: column-reverse; + } +`; + +export const WalletContentAddressBadgeStyle = styled(AddressBadge)` + background: #00000033; +`; + export const ConnectWalletStyle = styled(WalletCardStyle)` padding: 27px 27px 47px 27px; text-align: center; diff --git a/features/rewards/features/top-card/wallet.tsx b/features/rewards/features/top-card/wallet.tsx index b845facf3..53ec384ec 100644 --- a/features/rewards/features/top-card/wallet.tsx +++ b/features/rewards/features/top-card/wallet.tsx @@ -2,38 +2,32 @@ import { FC } from 'react'; import { ThemeProvider, themeDark } from '@lidofinance/lido-ui'; import { InputDescription } from 'features/rewards/components/inputDescription'; -import { AddressInput } from 'features/rewards/components/addressInput'; -import { InputWrapper } from 'features/rewards/components/inputWrapper'; import { useRewardsHistory } from 'features/rewards/hooks'; -import { WalletStyle } from './styles'; +import { + WalletStyle, + WalletContentStyle, + WalletContentAddressBadgeStyle, +} from './styles'; const INPUT_DESC_TEXT = 'Current balance may differ from last balance in the table due to rounding.'; export const Wallet: FC = () => { - const { - address, - addressError, - isAddressResolving, - inputValue, - setInputValue, - } = useRewardsHistory(); + const { address } = useRewardsHistory(); return ( - - - + + {INPUT_DESC_TEXT} - - + + + ); }; diff --git a/shared/wallet/components/address-badge/address-badge.tsx b/shared/wallet/components/address-badge/address-badge.tsx index 918ca5379..90f97e66b 100644 --- a/shared/wallet/components/address-badge/address-badge.tsx +++ b/shared/wallet/components/address-badge/address-badge.tsx @@ -1,19 +1,22 @@ import { useBreakpoint, IdenticonBadgeProps } from '@lidofinance/lido-ui'; -import { AddressBadgeStyle } from './styles'; import { Component } from 'types'; +import { AddressBadgeStyle } from './styles'; export type AddressBadgeComponent = Component< 'div', - Omit & { address?: string | null } + Omit & { address?: string | null } & { + symbolsMobile?: number; + symbolsDesktop?: number; + } >; export const AddressBadge: AddressBadgeComponent = (props) => { - const { address, ...rest } = props; + const { address, symbolsMobile = 3, symbolsDesktop = 6, ...rest } = props; const isMobile = useBreakpoint('md'); return ( From 624e61be80b74ba0308f2114803d33e42ae5851f Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Fri, 19 Jul 2024 14:46:08 +0300 Subject: [PATCH 02/34] refactor: text color and margin --- features/rewards/components/stats/Item.tsx | 1 + features/rewards/components/stats/Stats.tsx | 6 +----- features/rewards/components/stats/Title.tsx | 1 - features/rewards/features/top-card/top-card.tsx | 1 + 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/features/rewards/components/stats/Item.tsx b/features/rewards/components/stats/Item.tsx index f47158b84..057337509 100644 --- a/features/rewards/components/stats/Item.tsx +++ b/features/rewards/components/stats/Item.tsx @@ -9,6 +9,7 @@ export const Item = ({ children, ...rest }: BoxProps) => ( width={['100%', '100%', 'initial']} display={['flex', 'flex', 'initial']} justifyContent={['space-between', 'space-between', null]} + marginBottom={['6px']} {...rest} > {children} diff --git a/features/rewards/components/stats/Stats.tsx b/features/rewards/components/stats/Stats.tsx index 9bff50b72..47e6c3b74 100644 --- a/features/rewards/components/stats/Stats.tsx +++ b/features/rewards/components/stats/Stats.tsx @@ -71,11 +71,7 @@ export const Stats: React.FC = () => { <Link href={`${config.rootOrigin}/ethereum#apr`}> - <Box - data-testid="moreInfo" - color="secondary" - style={{ textDecoration: 'underline' }} - > + <Box data-testid="moreInfo" style={{ textDecoration: 'underline' }}> More info </Box> </Link> diff --git a/features/rewards/components/stats/Title.tsx b/features/rewards/components/stats/Title.tsx index 14dd8176f..554af581b 100644 --- a/features/rewards/components/stats/Title.tsx +++ b/features/rewards/components/stats/Title.tsx @@ -8,7 +8,6 @@ type TitleProps = BoxProps & { // TODO: refactoring to style files export const Title = ({ children, hideMobile, ...rest }: TitleProps) => ( <Box - color="secondary" fontSize="14px" fontStyle="normal" fontWeight="normal" diff --git a/features/rewards/features/top-card/top-card.tsx b/features/rewards/features/top-card/top-card.tsx index c86ea39f2..548f441b7 100644 --- a/features/rewards/features/top-card/top-card.tsx +++ b/features/rewards/features/top-card/top-card.tsx @@ -18,6 +18,7 @@ export const TopCard: FC = () => { {!isDappActive && <Fallback />} {isDappActive && <Wallet />} + <StatsWrapper> <Stats /> </StatsWrapper> From addae41bc267de0818e3742e607b9c8bf67fe62e Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Wed, 31 Jul 2024 13:47:43 +0300 Subject: [PATCH 03/34] refactor(rewards page): move to stETH balance --- .../description-about-rounding-block.tsx | 13 ++++ .../description-about-rounding-block/index.ts | 1 + .../styles.ts} | 5 +- .../inputDescription/InputDescription.tsx | 7 -- .../components/inputDescription/index.ts | 1 - features/rewards/components/stats/Stats.tsx | 22 ------- features/rewards/features/top-card/styles.tsx | 11 ++-- features/rewards/features/top-card/wallet.tsx | 65 +++++++++++++++---- pages/rewards.tsx | 5 -- 9 files changed, 73 insertions(+), 57 deletions(-) create mode 100644 features/rewards/components/description-about-rounding-block/description-about-rounding-block.tsx create mode 100644 features/rewards/components/description-about-rounding-block/index.ts rename features/rewards/components/{inputDescription/InputDescriptionStyles.ts => description-about-rounding-block/styles.ts} (75%) delete mode 100644 features/rewards/components/inputDescription/InputDescription.tsx delete mode 100644 features/rewards/components/inputDescription/index.ts diff --git a/features/rewards/components/description-about-rounding-block/description-about-rounding-block.tsx b/features/rewards/components/description-about-rounding-block/description-about-rounding-block.tsx new file mode 100644 index 000000000..7a8c53850 --- /dev/null +++ b/features/rewards/components/description-about-rounding-block/description-about-rounding-block.tsx @@ -0,0 +1,13 @@ +import { FC, PropsWithChildren } from 'react'; + +import { DescriptionAboutRoundingBlockStyled } from './styles'; + +export const DescriptionAboutRoundingBlock: FC<PropsWithChildren> = ({ + children, +}) => { + return ( + <DescriptionAboutRoundingBlockStyled> + {children} + </DescriptionAboutRoundingBlockStyled> + ); +}; diff --git a/features/rewards/components/description-about-rounding-block/index.ts b/features/rewards/components/description-about-rounding-block/index.ts new file mode 100644 index 000000000..bca33dde5 --- /dev/null +++ b/features/rewards/components/description-about-rounding-block/index.ts @@ -0,0 +1 @@ +export * from './description-about-rounding-block'; diff --git a/features/rewards/components/inputDescription/InputDescriptionStyles.ts b/features/rewards/components/description-about-rounding-block/styles.ts similarity index 75% rename from features/rewards/components/inputDescription/InputDescriptionStyles.ts rename to features/rewards/components/description-about-rounding-block/styles.ts index 1dca41906..3d42d0bb4 100644 --- a/features/rewards/components/inputDescription/InputDescriptionStyles.ts +++ b/features/rewards/components/description-about-rounding-block/styles.ts @@ -1,9 +1,9 @@ import styled from 'styled-components'; -export const WrapperStyle = styled.div` +export const DescriptionAboutRoundingBlockStyled = styled.div` flex: 1; padding: ${({ theme }) => theme.spaceMap.sm}px; - margin-right: ${({ theme }) => theme.spaceMap.xl}px; + margin-top: ${({ theme }) => theme.spaceMap.md}px; border-radius: ${({ theme }) => theme.spaceMap.sm}px; @@ -12,7 +12,6 @@ export const WrapperStyle = styled.div` text-align: center; ${({ theme }) => theme.mediaQueries.md} { - margin-right: 0; margin-top: ${({ theme }) => theme.spaceMap.xl}px; } `; diff --git a/features/rewards/components/inputDescription/InputDescription.tsx b/features/rewards/components/inputDescription/InputDescription.tsx deleted file mode 100644 index a20fa44dc..000000000 --- a/features/rewards/components/inputDescription/InputDescription.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { FC, PropsWithChildren } from 'react'; - -import { WrapperStyle } from './InputDescriptionStyles'; - -export const InputDescription: FC<PropsWithChildren> = ({ children }) => { - return <WrapperStyle>{children}</WrapperStyle>; -}; diff --git a/features/rewards/components/inputDescription/index.ts b/features/rewards/components/inputDescription/index.ts deleted file mode 100644 index 264c3cb95..000000000 --- a/features/rewards/components/inputDescription/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './InputDescription'; diff --git a/features/rewards/components/stats/Stats.tsx b/features/rewards/components/stats/Stats.tsx index 47e6c3b74..1a2019a4a 100644 --- a/features/rewards/components/stats/Stats.tsx +++ b/features/rewards/components/stats/Stats.tsx @@ -5,7 +5,6 @@ import { useRewardsHistory } from 'features/rewards/hooks'; import EthSymbol from 'features/rewards/components/EthSymbol'; import NumberFormat from 'features/rewards/components/NumberFormat'; import { useStethEthRate } from 'features/rewards/hooks/use-steth-eth-rate'; -import { useRewardsBalanceData } from 'features/rewards/hooks/use-rewards-balance-data'; import { Item } from './Item'; import { Stat } from './Stat'; @@ -19,30 +18,9 @@ export const Stats: React.FC = () => { initialLoading: pending, } = useRewardsHistory(); const { data: stEthEth } = useStethEthRate(); - const { data: balanceData } = useRewardsBalanceData(); return ( <> - <Item data-testid="stEthBalanceBlock"> - <Title mb="8px">stETH balance - - - - - - <Box display="inline-block" pr="3px"> - {currency.symbol} - </Box> - <NumberFormat - number={balanceData?.stEthCurrencyBalance} - currency - pending={pending} - /> - - stETH rewarded diff --git a/features/rewards/features/top-card/styles.tsx b/features/rewards/features/top-card/styles.tsx index 29d7e119d..42fd5e65e 100644 --- a/features/rewards/features/top-card/styles.tsx +++ b/features/rewards/features/top-card/styles.tsx @@ -13,18 +13,15 @@ export const WalletStyle = styled(WalletCardStyle)` `; export const WalletContentStyle = styled.div` + padding: ${({ theme }) => theme.spaceMap.xxl}px; +`; + +export const WalletContentRowStyle = styled.div` display: flex; flex-wrap: nowrap; flex-direction: row; align-items: center; justify-content: space-between; - - padding: ${({ theme }) => theme.spaceMap.xxl}px; - - ${({ theme }) => theme.mediaQueries.md} { - align-items: end; - flex-direction: column-reverse; - } `; export const WalletContentAddressBadgeStyle = styled(AddressBadge)` diff --git a/features/rewards/features/top-card/wallet.tsx b/features/rewards/features/top-card/wallet.tsx index 53ec384ec..41059a52c 100644 --- a/features/rewards/features/top-card/wallet.tsx +++ b/features/rewards/features/top-card/wallet.tsx @@ -1,31 +1,72 @@ import { FC } from 'react'; -import { ThemeProvider, themeDark } from '@lidofinance/lido-ui'; +import { Box, ThemeProvider, themeDark } from '@lidofinance/lido-ui'; -import { InputDescription } from 'features/rewards/components/inputDescription'; +import EthSymbol from 'features/rewards/components/EthSymbol'; +import NumberFormat from 'features/rewards/components/NumberFormat'; +import { Title } from 'features/rewards/components/stats/Title'; +import { DescriptionAboutRoundingBlock } from 'features/rewards/components/description-about-rounding-block'; import { useRewardsHistory } from 'features/rewards/hooks'; +import { useRewardsBalanceData } from 'features/rewards/hooks/use-rewards-balance-data'; +import { FlexCenter } from 'features/stake/stake-form/wallet/styles'; +import { CardBalance } from 'shared/wallet'; import { WalletStyle, WalletContentStyle, WalletContentAddressBadgeStyle, + WalletContentRowStyle, } from './styles'; -const INPUT_DESC_TEXT = - 'Current balance may differ from last balance in the table due to rounding.'; - export const Wallet: FC = () => { - const { address } = useRewardsHistory(); + const { data: balanceData } = useRewardsBalanceData(); + const { currencyObject: currency, address, loading } = useRewardsHistory(); return ( - {INPUT_DESC_TEXT} - + + + stETH balance + + } + loading={loading} + value={ +
+ + +
+ } + > + + <Box display="inline-block" pr="3px"> + {currency.symbol} + </Box> + <NumberFormat + number={balanceData?.stEthCurrencyBalance} + currency + pending={loading} + /> + +
+ + +
+ + + Current balance may differ from last balance in the table due to + rounding. +
diff --git a/pages/rewards.tsx b/pages/rewards.tsx index 06063e494..609d89a62 100644 --- a/pages/rewards.tsx +++ b/pages/rewards.tsx @@ -6,12 +6,8 @@ import { TopCard, RewardsList } from 'features/rewards/features'; import RewardsHistoryProvider from 'providers/rewardsHistory'; import { Layout } from 'shared/components'; -import { Fallback } from 'shared/wallet'; -import { useDappStatus } from 'shared/hooks/use-dapp-status'; const Rewards: FC = () => { - const { isWalletConnected, isDappActive } = useDappStatus(); - return ( { /> - {isWalletConnected && !isDappActive && } From 703f447f6b4b2ee7f8614f327859e378a061280c Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Wed, 31 Jul 2024 14:19:20 +0300 Subject: [PATCH 04/34] feat(rewards): remove AddressInput --- .../components/addressInput/AddressInput.tsx | 38 ------------------- .../rewards/components/addressInput/index.ts | 1 - .../rewards/components/addressInput/types.ts | 7 ---- 3 files changed, 46 deletions(-) delete mode 100644 features/rewards/components/addressInput/AddressInput.tsx delete mode 100644 features/rewards/components/addressInput/index.ts delete mode 100644 features/rewards/components/addressInput/types.ts diff --git a/features/rewards/components/addressInput/AddressInput.tsx b/features/rewards/components/addressInput/AddressInput.tsx deleted file mode 100644 index 88bfd0022..000000000 --- a/features/rewards/components/addressInput/AddressInput.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { FC } from 'react'; -import { Input, Loader, Identicon } from '@lidofinance/lido-ui'; -import CopyAddressUrl from 'features/rewards/components/CopyAddressUrl'; -import { isValidAnyAddress } from 'features/rewards/utils'; - -import { AddressInputProps } from './types'; - -export const AddressInput: FC = (props) => { - const { - inputValue, - isAddressResolving, - handleInputChange, - address, - addressError, - } = props; - - return ( - handleInputChange(e.target.value)} - placeholder="Ethereum address" - leftDecorator={ - isAddressResolving ? ( - - ) : address ? ( - - ) : null - } - rightDecorator={address ? : null} - spellCheck="false" - error={ - (inputValue.length > 0 && !isValidAnyAddress(inputValue)) || - addressError - } - /> - ); -}; diff --git a/features/rewards/components/addressInput/index.ts b/features/rewards/components/addressInput/index.ts deleted file mode 100644 index 1845571c0..000000000 --- a/features/rewards/components/addressInput/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './AddressInput'; diff --git a/features/rewards/components/addressInput/types.ts b/features/rewards/components/addressInput/types.ts deleted file mode 100644 index 063bc0b23..000000000 --- a/features/rewards/components/addressInput/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type AddressInputProps = { - inputValue: string; - isAddressResolving: boolean; - handleInputChange: (value: string) => void; - address: string; - addressError: string; -}; From c0530046c477fdc9d717c855347e55de8d7167da Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Wed, 31 Jul 2024 14:34:39 +0300 Subject: [PATCH 05/34] feat(rewards): add connect button instead of rewards table --- .../rewardsListContent/RewardsListsEmpty.tsx | 38 ++++++++++++++++--- .../RewardsListsEmptyStyles.ts | 4 ++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx b/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx index d83c42966..992928e4a 100644 --- a/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx +++ b/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx @@ -1,15 +1,43 @@ -import { FC } from 'react'; +import { FC, useCallback } from 'react'; +import { useConnect } from 'reef-knot/core-react'; +import { wrapWithEventTrack } from '@lidofinance/analytics-matomo'; +import { Button, Divider } from '@lidofinance/lido-ui'; -import { Divider } from '@lidofinance/lido-ui'; - -import { RewardsListEmptyWrapper } from './RewardsListsEmptyStyles'; +import { useUserConfig } from 'config/user-config'; +import { MATOMO_CLICK_EVENTS } from 'consts/matomo-click-events'; +import { + RewardsListEmptyText, + RewardsListEmptyWrapper, +} from './RewardsListsEmptyStyles'; export const RewardsListsEmpty: FC = () => { + const { isWalletConnectionAllowed } = useUserConfig(); + + const { connect } = useConnect(); + + const handleClick = wrapWithEventTrack( + MATOMO_CLICK_EVENTS.connectWallet, + useCallback(() => { + if (!isWalletConnectionAllowed) return; + void connect(); + }, [isWalletConnectionAllowed, connect]), + ); + return ( <> - Connect your wallet to view your staking stats. + + Connect your wallet to view your staking stats. + + ); diff --git a/features/rewards/components/rewardsListContent/RewardsListsEmptyStyles.ts b/features/rewards/components/rewardsListContent/RewardsListsEmptyStyles.ts index 3dd077d9c..d57529b74 100644 --- a/features/rewards/components/rewardsListContent/RewardsListsEmptyStyles.ts +++ b/features/rewards/components/rewardsListContent/RewardsListsEmptyStyles.ts @@ -3,3 +3,7 @@ import styled from 'styled-components'; export const RewardsListEmptyWrapper = styled.div` text-align: center; `; + +export const RewardsListEmptyText = styled.p` + margin-bottom: ${({ theme }) => theme.spaceMap.md}px; +`; From 7b3ca133cf4cd6f48c00e0bba028238a540fb016 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Wed, 31 Jul 2024 14:52:44 +0300 Subject: [PATCH 06/34] fix(rewards): wallet text color --- features/rewards/features/top-card/styles.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/features/rewards/features/top-card/styles.tsx b/features/rewards/features/top-card/styles.tsx index 42fd5e65e..925c68004 100644 --- a/features/rewards/features/top-card/styles.tsx +++ b/features/rewards/features/top-card/styles.tsx @@ -22,6 +22,8 @@ export const WalletContentRowStyle = styled.div` flex-direction: row; align-items: center; justify-content: space-between; + + color: var(--lido-color-text); `; export const WalletContentAddressBadgeStyle = styled(AddressBadge)` From d034f3f7bff41e79ce00507ebad3acdae3125be8 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Fri, 2 Aug 2024 16:34:43 +0300 Subject: [PATCH 07/34] refactor: wallet block --- .../description-about-rounding-block.tsx | 13 ------------- .../description-about-rounding-block/index.ts | 1 - .../description-about-rounding-block/styles.ts | 17 ----------------- features/rewards/features/top-card/wallet.tsx | 17 +++++------------ 4 files changed, 5 insertions(+), 43 deletions(-) delete mode 100644 features/rewards/components/description-about-rounding-block/description-about-rounding-block.tsx delete mode 100644 features/rewards/components/description-about-rounding-block/index.ts delete mode 100644 features/rewards/components/description-about-rounding-block/styles.ts diff --git a/features/rewards/components/description-about-rounding-block/description-about-rounding-block.tsx b/features/rewards/components/description-about-rounding-block/description-about-rounding-block.tsx deleted file mode 100644 index 7a8c53850..000000000 --- a/features/rewards/components/description-about-rounding-block/description-about-rounding-block.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { FC, PropsWithChildren } from 'react'; - -import { DescriptionAboutRoundingBlockStyled } from './styles'; - -export const DescriptionAboutRoundingBlock: FC = ({ - children, -}) => { - return ( - - {children} - - ); -}; diff --git a/features/rewards/components/description-about-rounding-block/index.ts b/features/rewards/components/description-about-rounding-block/index.ts deleted file mode 100644 index bca33dde5..000000000 --- a/features/rewards/components/description-about-rounding-block/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './description-about-rounding-block'; diff --git a/features/rewards/components/description-about-rounding-block/styles.ts b/features/rewards/components/description-about-rounding-block/styles.ts deleted file mode 100644 index 3d42d0bb4..000000000 --- a/features/rewards/components/description-about-rounding-block/styles.ts +++ /dev/null @@ -1,17 +0,0 @@ -import styled from 'styled-components'; - -export const DescriptionAboutRoundingBlockStyled = styled.div` - flex: 1; - padding: ${({ theme }) => theme.spaceMap.sm}px; - margin-top: ${({ theme }) => theme.spaceMap.md}px; - - border-radius: ${({ theme }) => theme.spaceMap.sm}px; - - background-color: rgb(255, 172, 47, 0.1); - color: #ffac2f; - text-align: center; - - ${({ theme }) => theme.mediaQueries.md} { - margin-top: ${({ theme }) => theme.spaceMap.xl}px; - } -`; diff --git a/features/rewards/features/top-card/wallet.tsx b/features/rewards/features/top-card/wallet.tsx index 41059a52c..d7ccca0e0 100644 --- a/features/rewards/features/top-card/wallet.tsx +++ b/features/rewards/features/top-card/wallet.tsx @@ -1,10 +1,8 @@ import { FC } from 'react'; import { Box, ThemeProvider, themeDark } from '@lidofinance/lido-ui'; -import EthSymbol from 'features/rewards/components/EthSymbol'; import NumberFormat from 'features/rewards/components/NumberFormat'; import { Title } from 'features/rewards/components/stats/Title'; -import { DescriptionAboutRoundingBlock } from 'features/rewards/components/description-about-rounding-block'; import { useRewardsHistory } from 'features/rewards/hooks'; import { useRewardsBalanceData } from 'features/rewards/hooks/use-rewards-balance-data'; import { FlexCenter } from 'features/stake/stake-form/wallet/styles'; @@ -36,18 +34,18 @@ export const Wallet: FC = () => { loading={loading} value={
- + + stETH +
} > - <Box display="inline-block" pr="3px"> - {currency.symbol} - </Box> + <Box display="inline-block">{currency.symbol}</Box> <NumberFormat number={balanceData?.stEthCurrencyBalance} currency @@ -59,14 +57,9 @@ export const Wallet: FC = () => { <WalletContentAddressBadgeStyle address={address as `0x${string}`} symbolsMobile={6} - symbolsDesktop={12} + symbolsDesktop={6} /> </WalletContentRowStyle> - - <DescriptionAboutRoundingBlock> - Current balance may differ from last balance in the table due to - rounding. - </DescriptionAboutRoundingBlock> </WalletContentStyle> </ThemeProvider> </WalletStyle> From 34e390693a501ffe882ebf5bdf623ccda13e99e1 Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Fri, 2 Aug 2024 16:37:28 +0300 Subject: [PATCH 08/34] refactor: stats block --- features/rewards/components/stats/Stat.tsx | 4 ++-- features/rewards/components/stats/Stats.tsx | 25 ++++++++++----------- features/rewards/components/stats/Title.tsx | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/features/rewards/components/stats/Stat.tsx b/features/rewards/components/stats/Stat.tsx index f7785f6d9..f290a1376 100644 --- a/features/rewards/components/stats/Stat.tsx +++ b/features/rewards/components/stats/Stat.tsx @@ -7,11 +7,11 @@ export const Stat = ({ children, ...rest }: BoxProps) => ( <Box fontStyle="normal" fontWeight={[null, null, 600]} - fontSize={['14px', '14px', '20px']} + fontSize={['12px', '12px', '16px']} lineHeight="20px" color="text" height="20px" - mb="6px" + mb="2px" display={'flex'} {...rest} > diff --git a/features/rewards/components/stats/Stats.tsx b/features/rewards/components/stats/Stats.tsx index 1a2019a4a..7127a4c38 100644 --- a/features/rewards/components/stats/Stats.tsx +++ b/features/rewards/components/stats/Stats.tsx @@ -2,7 +2,6 @@ import { Box, Link } from '@lidofinance/lido-ui'; import { config } from 'config'; import { useRewardsHistory } from 'features/rewards/hooks'; -import EthSymbol from 'features/rewards/components/EthSymbol'; import NumberFormat from 'features/rewards/components/NumberFormat'; import { useStethEthRate } from 'features/rewards/hooks/use-steth-eth-rate'; @@ -22,15 +21,15 @@ export const Stats: React.FC = () => { return ( <> <Item data-testid="stEthRewardedBlock"> - <Title mb="8px">stETH rewarded - - + stETH earned + + + stETH + - <Box display="inline-block" pr="3px"> - {currency.symbol} - </Box> + <Box display="inline-block">{currency.symbol}</Box> <NumberFormat number={data?.totals.currencyRewards} currency @@ -40,7 +39,7 @@ export const Stats: React.FC = () => { </Item> <Item data-testid="averageAprBlock"> <Title mb="8px">Average APR - + {parseFloat(data?.averageApr || '0') ? ( ) : ( @@ -49,15 +48,13 @@ export const Stats: React.FC = () => { <Link href={`${config.rootOrigin}/ethereum#apr`}> - <Box data-testid="moreInfo" style={{ textDecoration: 'underline' }}> - More info - </Box> + <Box data-testid="moreInfo">More info</Box> </Link>
stETH price - + {currency.symbol} @@ -68,12 +65,14 @@ export const Stats: React.FC = () => { /> - <EthSymbol /> <NumberFormat number={stEthEth?.toString()} StEthEth pending={pending} /> + <Box display="inline-block" pl={'3px'}> + ETH + </Box> diff --git a/features/rewards/components/stats/Title.tsx b/features/rewards/components/stats/Title.tsx index 554af581b..8e1269c24 100644 --- a/features/rewards/components/stats/Title.tsx +++ b/features/rewards/components/stats/Title.tsx @@ -8,7 +8,7 @@ type TitleProps = BoxProps & { // TODO: refactoring to style files export const Title = ({ children, hideMobile, ...rest }: TitleProps) => ( Date: Mon, 5 Aug 2024 10:42:29 +0300 Subject: [PATCH 09/34] refactor(rewards): hide left filters --- .../components/rewardsListHeader/RewardsListHeader.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/features/rewards/components/rewardsListHeader/RewardsListHeader.tsx b/features/rewards/components/rewardsListHeader/RewardsListHeader.tsx index 9781d558e..f41fe5b5d 100644 --- a/features/rewards/components/rewardsListHeader/RewardsListHeader.tsx +++ b/features/rewards/components/rewardsListHeader/RewardsListHeader.tsx @@ -11,8 +11,12 @@ export const RewardsListHeader: FC = () => { return ( Reward history - - {!error && data && data?.events.length > 0 && } + {!error && data && data?.events.length > 0 && ( + <> + + + + )} ); }; From c2d645bd1c2dc0788bda9103aa8ee8b4c4e73d56 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Mon, 5 Aug 2024 11:17:24 +0300 Subject: [PATCH 10/34] refactor(rewards): filters layout --- features/rewards/components/CurrencySelector.tsx | 4 ++++ features/rewards/components/export/Exportstyled.ts | 5 +++++ features/rewards/components/rewardsListHeader/styles.ts | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/features/rewards/components/CurrencySelector.tsx b/features/rewards/components/CurrencySelector.tsx index 0de84f3ed..16f9cf297 100644 --- a/features/rewards/components/CurrencySelector.tsx +++ b/features/rewards/components/CurrencySelector.tsx @@ -11,6 +11,10 @@ const StyledSelect = styled(Select)` height: 32px; width: 72px; + ${({ theme }) => theme.mediaQueries.lg} { + width: 100%; + } + border-radius: 6px; & > span { diff --git a/features/rewards/components/export/Exportstyled.ts b/features/rewards/components/export/Exportstyled.ts index 42bcaa6be..930675c72 100644 --- a/features/rewards/components/export/Exportstyled.ts +++ b/features/rewards/components/export/Exportstyled.ts @@ -7,4 +7,9 @@ export const ButtonStyle = styled(Button)` min-width: unset; padding: 0 15px; font-size: 12px; + color: var(--lido-color-text); + + &::before { + border-color: var(--lido-color-border); + } `; diff --git a/features/rewards/components/rewardsListHeader/styles.ts b/features/rewards/components/rewardsListHeader/styles.ts index 98190d54b..ca4af30c3 100644 --- a/features/rewards/components/rewardsListHeader/styles.ts +++ b/features/rewards/components/rewardsListHeader/styles.ts @@ -4,7 +4,7 @@ export const RewardsListHeaderStyle = styled.div` display: flex; flex-wrap: wrap; align-items: center; - gap: 20px 32px; + gap: 20px 28px; height: 32px; align-items: center; @@ -39,7 +39,7 @@ export const LeftOptionsWrapper = styled.div` } ${({ theme }) => theme.mediaQueries.md} { - flex-direction: column; + flex-direction: row; } `; From 5256147d0e0a89bac29575e16280e41b4700a90d Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Mon, 5 Aug 2024 11:17:49 +0300 Subject: [PATCH 11/34] refactor(rewards): connect button --- features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx b/features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx index 65ee3b46f..6c5c2bb64 100644 --- a/features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx +++ b/features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx @@ -26,7 +26,7 @@ export const ErrorBlockNoSteth = ({ hasSteth }: ErrorBlockNoStethProps) => { {!hasSteth && ( - + )} From 6fd46fa5fc936e1d61ba969bd60042108626e34c Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Mon, 5 Aug 2024 11:31:25 +0300 Subject: [PATCH 12/34] refactor(rewards): inline loader --- shared/wallet/card/card.tsx | 6 +++--- shared/wallet/card/styles.tsx | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/shared/wallet/card/card.tsx b/shared/wallet/card/card.tsx index cc8c4cd3e..68a3b3566 100644 --- a/shared/wallet/card/card.tsx +++ b/shared/wallet/card/card.tsx @@ -1,4 +1,3 @@ -import { InlineLoader } from '@lidofinance/lido-ui'; import { Component } from 'types'; import { useWalletModal } from '../wallet-modal/use-wallet-modal'; import { AddressBadge } from '../components/address-badge/address-badge'; @@ -11,6 +10,7 @@ import { WalletCardExtraStyle, WalletCardAccountStyle, WalletCardContentStyle, + InlineLoaderStyled, } from './styles'; import { WalletCardBalanceComponent, @@ -44,11 +44,11 @@ export const CardBalance: WalletCardBalanceComponent = (props) => { {title} - {loading ? : value} + {loading ? : value} {hasExtra && ( - {loading ? : extra} + {loading ? : extra} )} {hasChildren && ( diff --git a/shared/wallet/card/styles.tsx b/shared/wallet/card/styles.tsx index aa6940c92..81bf97020 100644 --- a/shared/wallet/card/styles.tsx +++ b/shared/wallet/card/styles.tsx @@ -1,5 +1,9 @@ import styled from 'styled-components'; -import { Block } from '@lidofinance/lido-ui'; +import { Block, InlineLoader } from '@lidofinance/lido-ui'; + +export const InlineLoaderStyled = styled(InlineLoader)` + max-width: 120px; +`; export const WalletCardStyle = styled((props) => )` margin-bottom: ${({ theme }) => -theme.borderRadiusesMap.xl}px; From 2e80a5a32583c772e884927c76d5c6618e31c7b9 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Mon, 5 Aug 2024 11:44:47 +0300 Subject: [PATCH 13/34] refactor(rewards): inline loader --- features/rewards/components/NumberFormat.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/rewards/components/NumberFormat.tsx b/features/rewards/components/NumberFormat.tsx index c3c8cd6d8..116bb3e02 100644 --- a/features/rewards/components/NumberFormat.tsx +++ b/features/rewards/components/NumberFormat.tsx @@ -48,7 +48,11 @@ type Props = Partial & { const NumberFormat = (props: Props) => { if (props.pending) - return ; + return ( + + ); return props.number ? ( Date: Mon, 5 Aug 2024 11:52:21 +0300 Subject: [PATCH 14/34] fix(rewards): hide filter after disconnect --- .../components/rewardsListHeader/RewardsListHeader.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/features/rewards/components/rewardsListHeader/RewardsListHeader.tsx b/features/rewards/components/rewardsListHeader/RewardsListHeader.tsx index f41fe5b5d..d156454c4 100644 --- a/features/rewards/components/rewardsListHeader/RewardsListHeader.tsx +++ b/features/rewards/components/rewardsListHeader/RewardsListHeader.tsx @@ -1,5 +1,6 @@ import { FC } from 'react'; import { useRewardsHistory } from 'features/rewards/hooks'; +import { useDappStatus } from 'shared/hooks/use-dapp-status'; import { LeftOptions } from './LeftOptions'; import { RightOptions } from './RightOptions'; @@ -7,11 +8,12 @@ import { RewardsListHeaderStyle } from './styles'; import { TitleStyle } from './styles'; export const RewardsListHeader: FC = () => { + const { isDappActive } = useDappStatus(); const { error, data } = useRewardsHistory(); return ( Reward history - {!error && data && data?.events.length > 0 && ( + {isDappActive && !error && data && data?.events.length > 0 && ( <> From b57369309a181ddb8e1e2378e71de9baeca37576 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Mon, 5 Aug 2024 12:13:48 +0300 Subject: [PATCH 15/34] fix(rewards): remove 'Only Show Rewards' checkbox, add 'Include transfers' checkbox --- features/rewards/components/NumberFormat.tsx | 2 +- .../rewardsListHeader/LeftOptions.tsx | 28 +++++++++---------- .../rewardsListHeader/RightOptions.tsx | 4 +-- features/rewards/hooks/useRewardsDataLoad.ts | 6 ++-- providers/rewardsHistory.tsx | 16 +++++------ 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/features/rewards/components/NumberFormat.tsx b/features/rewards/components/NumberFormat.tsx index 116bb3e02..1c69066fd 100644 --- a/features/rewards/components/NumberFormat.tsx +++ b/features/rewards/components/NumberFormat.tsx @@ -50,7 +50,7 @@ const NumberFormat = (props: Props) => { if (props.pending) return ( ); diff --git a/features/rewards/components/rewardsListHeader/LeftOptions.tsx b/features/rewards/components/rewardsListHeader/LeftOptions.tsx index 5383d2c75..fef130268 100644 --- a/features/rewards/components/rewardsListHeader/LeftOptions.tsx +++ b/features/rewards/components/rewardsListHeader/LeftOptions.tsx @@ -1,19 +1,30 @@ import { FC } from 'react'; import { Tooltip, Checkbox } from '@lidofinance/lido-ui'; -import { LeftOptionsWrapper } from './styles'; import { useRewardsHistory } from 'features/rewards/hooks/useRewardsHistory'; +import { LeftOptionsWrapper } from './styles'; export const LeftOptions: FC = () => { const { isUseArchiveExchangeRate, - isOnlyRewards, + isIncludeTransfers, setIsUseArchiveExchangeRate, - setIsOnlyRewards, + setIsIncludeTransfers, } = useRewardsHistory(); return ( + + setIsIncludeTransfers(!isIncludeTransfers)} + data-testid="includeTransfersCheckbox" + label="Include transfers" + /> + - - setIsOnlyRewards(!isOnlyRewards)} - data-testid="onlyRewardsCheckbox" - label="Only Show Rewards" - /> - ); }; diff --git a/features/rewards/components/rewardsListHeader/RightOptions.tsx b/features/rewards/components/rewardsListHeader/RightOptions.tsx index 0b5252024..5b5632b6d 100644 --- a/features/rewards/components/rewardsListHeader/RightOptions.tsx +++ b/features/rewards/components/rewardsListHeader/RightOptions.tsx @@ -11,7 +11,7 @@ export const RightOptions: FC = () => { currencyObject, setCurrency, isUseArchiveExchangeRate, - isOnlyRewards, + isIncludeTransfers, } = useRewardsHistory(); return ( @@ -20,7 +20,7 @@ export const RightOptions: FC = () => { currency={currencyObject} address={address} archiveRate={isUseArchiveExchangeRate} - onlyRewards={isOnlyRewards} + onlyRewards={!isIncludeTransfers} /> ); diff --git a/features/rewards/hooks/useRewardsDataLoad.ts b/features/rewards/hooks/useRewardsDataLoad.ts index 064219e8a..5696098cf 100644 --- a/features/rewards/hooks/useRewardsDataLoad.ts +++ b/features/rewards/hooks/useRewardsDataLoad.ts @@ -7,7 +7,7 @@ import { useLaggyDataWrapper } from './use-laggy-data-wrapper'; type UseRewardsDataLoad = (props: { address: string; currency: string; - isOnlyRewards: boolean; + isIncludeTransfers: boolean; isUseArchiveExchangeRate: boolean; skip: number; limit: number; @@ -23,7 +23,7 @@ export const useRewardsDataLoad: UseRewardsDataLoad = (props) => { const { address, currency, - isOnlyRewards, + isIncludeTransfers, isUseArchiveExchangeRate, skip, limit, @@ -32,7 +32,7 @@ export const useRewardsDataLoad: UseRewardsDataLoad = (props) => { const requestOptions = { address, currency, - onlyRewards: isOnlyRewards, + onlyRewards: !isIncludeTransfers, archiveRate: isUseArchiveExchangeRate, skip, limit, diff --git a/providers/rewardsHistory.tsx b/providers/rewardsHistory.tsx index 05dbb6ced..fe25eea3f 100644 --- a/providers/rewardsHistory.tsx +++ b/providers/rewardsHistory.tsx @@ -34,11 +34,11 @@ export type RewardsHistoryValue = { address: string; addressError: string; inputValue: string; - isOnlyRewards: boolean; + isIncludeTransfers: boolean; isUseArchiveExchangeRate: boolean; isLagging: boolean; setInputValue: (value: string) => void; - setIsOnlyRewards: (value: boolean) => void; + setIsIncludeTransfers: (value: boolean) => void; setIsUseArchiveExchangeRate: (value: boolean) => void; setPage: (page: number) => void; setCurrency: (value: string) => void; @@ -56,7 +56,7 @@ const RewardsHistoryProvider: FC = (props) => { if (currencyValue) setCurrency(currencyValue); }, []); - const [isOnlyRewards, setIsOnlyRewards] = useState(false); + const [isIncludeTransfers, setIsIncludeTransfers] = useState(false); const [isUseArchiveExchangeRate, setIsUseArchiveExchangeRate] = useState(true); const [page, setPage] = useState(0); @@ -75,7 +75,7 @@ const RewardsHistoryProvider: FC = (props) => { const { data, error, loading, initialLoading, isLagging } = useRewardsDataLoad({ address, - isOnlyRewards, + isIncludeTransfers, isUseArchiveExchangeRate, currency, skip, @@ -84,7 +84,7 @@ const RewardsHistoryProvider: FC = (props) => { useEffect(() => { setPage(0); - }, [isUseArchiveExchangeRate, isOnlyRewards]); + }, [isUseArchiveExchangeRate, isIncludeTransfers]); const currencyObject = getCurrency(currency); @@ -99,8 +99,8 @@ const RewardsHistoryProvider: FC = (props) => { limit, page, setPage, - isOnlyRewards, - setIsOnlyRewards, + isIncludeTransfers, + setIsIncludeTransfers, setIsUseArchiveExchangeRate, isUseArchiveExchangeRate, setCurrency, @@ -121,7 +121,7 @@ const RewardsHistoryProvider: FC = (props) => { inputValue, isAddressResolving, isLagging, - isOnlyRewards, + isIncludeTransfers, isUseArchiveExchangeRate, limit, loading, From 5dce3fc9f16a9e85b96d6caefc86c4059eb3a9c8 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Mon, 5 Aug 2024 12:40:58 +0300 Subject: [PATCH 16/34] fix(rewards): remove InputWrapper component --- .../rewards/components/inputWrapper/InputWrapper.tsx | 11 ----------- .../components/inputWrapper/InputWrapperStyles.ts | 7 ------- features/rewards/components/inputWrapper/index.ts | 1 - 3 files changed, 19 deletions(-) delete mode 100644 features/rewards/components/inputWrapper/InputWrapper.tsx delete mode 100644 features/rewards/components/inputWrapper/InputWrapperStyles.ts delete mode 100644 features/rewards/components/inputWrapper/index.ts diff --git a/features/rewards/components/inputWrapper/InputWrapper.tsx b/features/rewards/components/inputWrapper/InputWrapper.tsx deleted file mode 100644 index 4de38fd82..000000000 --- a/features/rewards/components/inputWrapper/InputWrapper.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { FC, PropsWithChildren } from 'react'; -import { BlockProps } from '@lidofinance/lido-ui'; - -import { InputWrapperStyle } from './InputWrapperStyles'; - -export const InputWrapper: FC> = ({ - children, - ...rest -}) => { - return {children}; -}; diff --git a/features/rewards/components/inputWrapper/InputWrapperStyles.ts b/features/rewards/components/inputWrapper/InputWrapperStyles.ts deleted file mode 100644 index 268743da1..000000000 --- a/features/rewards/components/inputWrapper/InputWrapperStyles.ts +++ /dev/null @@ -1,7 +0,0 @@ -import styled from 'styled-components'; -import { Block } from '@lidofinance/lido-ui'; - -export const InputWrapperStyle = styled(Block)` - background: transparent; - padding-bottom: 24px; -`; diff --git a/features/rewards/components/inputWrapper/index.ts b/features/rewards/components/inputWrapper/index.ts deleted file mode 100644 index ff6f77010..000000000 --- a/features/rewards/components/inputWrapper/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './InputWrapper'; From 8648ee486f349c82fd5b8a3d9d7a9ae3a16d8676 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Mon, 5 Aug 2024 13:00:05 +0300 Subject: [PATCH 17/34] refactor(rewards): paddings --- features/rewards/components/stats/Stats.tsx | 4 +++- features/rewards/features/top-card/wallet.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/features/rewards/components/stats/Stats.tsx b/features/rewards/components/stats/Stats.tsx index 7127a4c38..b28e1d894 100644 --- a/features/rewards/components/stats/Stats.tsx +++ b/features/rewards/components/stats/Stats.tsx @@ -29,7 +29,9 @@ export const Stats: React.FC = () => { - <Box display="inline-block">{currency.symbol}</Box> + <Box display="inline-block" pr={'3px'}> + {currency.symbol} + </Box> <NumberFormat number={data?.totals.currencyRewards} currency diff --git a/features/rewards/features/top-card/wallet.tsx b/features/rewards/features/top-card/wallet.tsx index d7ccca0e0..3f16d3946 100644 --- a/features/rewards/features/top-card/wallet.tsx +++ b/features/rewards/features/top-card/wallet.tsx @@ -45,7 +45,9 @@ export const Wallet: FC = () => { } > <Title data-testid="stEthBalanceIn$" hideMobile> - <Box display="inline-block">{currency.symbol}</Box> + <Box display="inline-block" pr={'3px'}> + {currency.symbol} + </Box> <NumberFormat number={balanceData?.stEthCurrencyBalance} currency From d93d073777bb72a3fbff5491759ec3de04809d5a Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Mon, 5 Aug 2024 13:07:10 +0300 Subject: [PATCH 18/34] refactor(rewards): stake now wrapper width --- features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx b/features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx index 6c5c2bb64..f2d09ec0f 100644 --- a/features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx +++ b/features/rewards/components/errorBlocks/ErrorBlockNoSteth.tsx @@ -25,7 +25,7 @@ export const ErrorBlockNoSteth = ({ hasSteth }: ErrorBlockNoStethProps) => { </Box> <LocalLink href={HOME_PATH}> {!hasSteth && ( - <Box width="150px"> + <Box> <Button size={'xs'}>Stake now</Button> </Box> )} From feea85f734c6f6ef41201e2eba24ded0bcabbffc Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Mon, 5 Aug 2024 13:33:46 +0300 Subject: [PATCH 19/34] fix: tests --- test/consts.ts | 110 ------------------------------------------------- 1 file changed, 110 deletions(-) diff --git a/test/consts.ts b/test/consts.ts index 295fc7eaa..3b8f03ef7 100644 --- a/test/consts.ts +++ b/test/consts.ts @@ -13,8 +13,6 @@ export interface PostRequest { schema: object; } -const FLOAT_REGEX = /^\d+(\.\d+)?$/; - const LIDO_STATS_SCHEMA = { type: 'object', properties: { @@ -164,46 +162,6 @@ const LIDO_STATS_SCHEMA = { }; export const GET_REQUESTS: GetRequest[] = [ - { - uri: '/api/oneinch-rate', - schema: { - type: 'object', - properties: { - rate: { type: 'number', min: 0 }, - toReceive: { type: 'string' }, - }, - required: ['rate', 'toReceive'], - additionalProperties: false, - }, - }, - { - uri: `/api/short-lido-stats?chainId=${CONFIG.STAND_CONFIG.chainId}`, - schema: { - type: 'object', - properties: { - uniqueAnytimeHolders: { type: 'string' }, - uniqueHolders: { type: 'string' }, - totalStaked: { type: 'string' }, - marketCap: { type: 'number' }, - }, - required: [ - 'totalStaked', - 'marketCap', - 'uniqueAnytimeHolders', - 'uniqueHolders', - ], - additionalProperties: false, - }, - }, - { - uri: '/api/eth-apr', - isDeprecated: true, - schema: { type: 'string', pattern: FLOAT_REGEX }, - }, - { - uri: '/api/totalsupply', - schema: { type: 'string', pattern: FLOAT_REGEX }, - }, { uri: '/api/lidostats', isDeprecated: true, @@ -214,74 +172,6 @@ export const GET_REQUESTS: GetRequest[] = [ isDeprecated: true, schema: LIDO_STATS_SCHEMA, }, - { - uri: '/api/eth-price', - schema: { - type: 'object', - properties: { - price: { - type: 'number', - min: 0, - }, - }, - required: ['price'], - additionalProperties: false, - }, - }, - { - uri: '/api/rewards?address=0x87c0e047F4e4D3e289A56a36570D4CB957A37Ef1¤cy=usd&onlyRewards=false&archiveRate=true&skip=0&limit=10', - skipTestnet: true, // api/rewards don't work on testnet - schema: { - type: 'object', - properties: { - averageApr: { type: 'string' }, - ethToStEthRatio: { type: 'number' }, - events: { - type: 'array', - items: [ - { - type: 'object', - additionalProperties: true, - }, - ], - }, - stETHCurrencyPrice: { - type: 'object', - properties: { - eth: { type: 'number' }, - usd: { type: 'number' }, - }, - required: ['eth', 'usd'], - additionalProperties: false, - }, - totalItems: { type: 'number' }, - totals: { - type: 'object', - properties: { - currencyRewards: { type: 'string' }, - ethRewards: { type: 'string' }, - }, - }, - required: [ - 'averageApr', - 'ethToStEthRatio', - 'events', - 'stETHCurrencyPrice', - 'totalItems', - 'totals', - ], - additionalProperties: false, - }, - }, - }, - { - uri: '/api/sma-steth-apr', - isDeprecated: true, - schema: { - type: 'string', - pattern: FLOAT_REGEX, - }, - }, ]; export const POST_REQUESTS: PostRequest[] = [ From b0fb6296173e0a97278204ae9ceadedefbdf1ef2 Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Tue, 6 Aug 2024 11:51:58 +0300 Subject: [PATCH 20/34] feat(rewards): reset stats after disconnect --- features/rewards/components/stats/Stats.tsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/features/rewards/components/stats/Stats.tsx b/features/rewards/components/stats/Stats.tsx index b28e1d894..34c9a6b24 100644 --- a/features/rewards/components/stats/Stats.tsx +++ b/features/rewards/components/stats/Stats.tsx @@ -4,6 +4,7 @@ import { config } from 'config'; import { useRewardsHistory } from 'features/rewards/hooks'; import NumberFormat from 'features/rewards/components/NumberFormat'; import { useStethEthRate } from 'features/rewards/hooks/use-steth-eth-rate'; +import { useDappStatus } from 'shared/hooks/use-dapp-status'; import { Item } from './Item'; import { Stat } from './Stat'; @@ -17,13 +18,17 @@ export const Stats: React.FC = () => { initialLoading: pending, } = useRewardsHistory(); const { data: stEthEth } = useStethEthRate(); + const { isDappActive } = useDappStatus(); return ( <> <Item data-testid="stEthRewardedBlock"> <Title mb="8px">stETH earned - + stETH @@ -33,7 +38,7 @@ export const Stats: React.FC = () => { {currency.symbol} @@ -43,7 +48,11 @@ export const Stats: React.FC = () => { Average APR {parseFloat(data?.averageApr || '0') ? ( - + ) : ( '-' )} @@ -61,14 +70,16 @@ export const Stats: React.FC = () => { {currency.symbol} <NumberFormat - number={stEthEth?.toString()} + number={isDappActive ? stEthEth?.toString() : undefined} StEthEth pending={pending} /> From 368dc6c2cf87e9938507f9aa1d7ab732419f8878 Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Tue, 6 Aug 2024 12:00:11 +0300 Subject: [PATCH 21/34] revert: tests --- test/consts.ts | 110 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/test/consts.ts b/test/consts.ts index 3b8f03ef7..295fc7eaa 100644 --- a/test/consts.ts +++ b/test/consts.ts @@ -13,6 +13,8 @@ export interface PostRequest { schema: object; } +const FLOAT_REGEX = /^\d+(\.\d+)?$/; + const LIDO_STATS_SCHEMA = { type: 'object', properties: { @@ -162,6 +164,46 @@ const LIDO_STATS_SCHEMA = { }; export const GET_REQUESTS: GetRequest[] = [ + { + uri: '/api/oneinch-rate', + schema: { + type: 'object', + properties: { + rate: { type: 'number', min: 0 }, + toReceive: { type: 'string' }, + }, + required: ['rate', 'toReceive'], + additionalProperties: false, + }, + }, + { + uri: `/api/short-lido-stats?chainId=${CONFIG.STAND_CONFIG.chainId}`, + schema: { + type: 'object', + properties: { + uniqueAnytimeHolders: { type: 'string' }, + uniqueHolders: { type: 'string' }, + totalStaked: { type: 'string' }, + marketCap: { type: 'number' }, + }, + required: [ + 'totalStaked', + 'marketCap', + 'uniqueAnytimeHolders', + 'uniqueHolders', + ], + additionalProperties: false, + }, + }, + { + uri: '/api/eth-apr', + isDeprecated: true, + schema: { type: 'string', pattern: FLOAT_REGEX }, + }, + { + uri: '/api/totalsupply', + schema: { type: 'string', pattern: FLOAT_REGEX }, + }, { uri: '/api/lidostats', isDeprecated: true, @@ -172,6 +214,74 @@ export const GET_REQUESTS: GetRequest[] = [ isDeprecated: true, schema: LIDO_STATS_SCHEMA, }, + { + uri: '/api/eth-price', + schema: { + type: 'object', + properties: { + price: { + type: 'number', + min: 0, + }, + }, + required: ['price'], + additionalProperties: false, + }, + }, + { + uri: '/api/rewards?address=0x87c0e047F4e4D3e289A56a36570D4CB957A37Ef1¤cy=usd&onlyRewards=false&archiveRate=true&skip=0&limit=10', + skipTestnet: true, // api/rewards don't work on testnet + schema: { + type: 'object', + properties: { + averageApr: { type: 'string' }, + ethToStEthRatio: { type: 'number' }, + events: { + type: 'array', + items: [ + { + type: 'object', + additionalProperties: true, + }, + ], + }, + stETHCurrencyPrice: { + type: 'object', + properties: { + eth: { type: 'number' }, + usd: { type: 'number' }, + }, + required: ['eth', 'usd'], + additionalProperties: false, + }, + totalItems: { type: 'number' }, + totals: { + type: 'object', + properties: { + currencyRewards: { type: 'string' }, + ethRewards: { type: 'string' }, + }, + }, + required: [ + 'averageApr', + 'ethToStEthRatio', + 'events', + 'stETHCurrencyPrice', + 'totalItems', + 'totals', + ], + additionalProperties: false, + }, + }, + }, + { + uri: '/api/sma-steth-apr', + isDeprecated: true, + schema: { + type: 'string', + pattern: FLOAT_REGEX, + }, + }, ]; export const POST_REQUESTS: PostRequest[] = [ From 9c3484d85d33d685882b3e0e6cc16ae3be45a007 Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Tue, 6 Aug 2024 12:22:33 +0300 Subject: [PATCH 22/34] feat: add `mock-qa-rewards-address` for rewards table --- features/rewards/hooks/useGetCurrentAddress.ts | 7 ++++++- utils/qa.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/features/rewards/hooks/useGetCurrentAddress.ts b/features/rewards/hooks/useGetCurrentAddress.ts index 9f46299be..3a0e672c1 100644 --- a/features/rewards/hooks/useGetCurrentAddress.ts +++ b/features/rewards/hooks/useGetCurrentAddress.ts @@ -6,6 +6,7 @@ import { useSDK } from '@lido-sdk/react'; import { resolveEns, isValidEns, isValidAddress } from 'features/rewards/utils'; import { useCurrentStaticRpcProvider } from 'shared/hooks/use-current-static-rpc-provider'; +import { overrideWithQAMockString } from 'utils/qa'; type UseGetCurrentAddress = () => { address: string; @@ -86,7 +87,11 @@ export const useGetCurrentAddress: UseGetCurrentAddress = () => { return; } // From a connected wallet - if (account) setInputValue(account); + if (account) { + setInputValue( + overrideWithQAMockString(account, 'mock-qa-rewards-address'), + ); + } } }, [account, query.address, isReady, setInputValue]); diff --git a/utils/qa.ts b/utils/qa.ts index e5e56bda3..f7b46c421 100644 --- a/utils/qa.ts +++ b/utils/qa.ts @@ -20,6 +20,16 @@ export const overrideWithQAMockNumber = (value: number, key: string) => { return value; }; +export const overrideWithQAMockString = (value: string, key: string) => { + if (config.enableQaHelpers && typeof window !== 'undefined') { + const mock = localStorage.getItem(key); + if (mock) { + return mock; + } + } + return value; +}; + export const overrideWithQAMockArray = <TArrayElement>( value: TArrayElement[], key: string, From 0f515cb2131ea51af78f9d1989ca9f3831a15e6c Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Tue, 6 Aug 2024 12:39:47 +0300 Subject: [PATCH 23/34] refactor(useStethEthRate): return const rate for chain != {mainnet, sepolia, holesky} --- features/rewards/hooks/use-steth-eth-rate.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/features/rewards/hooks/use-steth-eth-rate.ts b/features/rewards/hooks/use-steth-eth-rate.ts index 414e0f3be..6d774aab4 100644 --- a/features/rewards/hooks/use-steth-eth-rate.ts +++ b/features/rewards/hooks/use-steth-eth-rate.ts @@ -1,9 +1,10 @@ +import { constants } from 'ethers'; import { useLidoSWR, useSDK } from '@lido-sdk/react'; +import { CHAINS } from 'consts/chains'; import { STRATEGY_LAZY } from 'consts/swr-strategies'; -import { useMainnetStaticRpcProvider } from 'shared/hooks/use-mainnet-static-rpc-provider'; import { stEthEthRequest } from 'features/rewards/fetchers/requesters'; -import { constants } from 'ethers'; +import { useMainnetStaticRpcProvider } from 'shared/hooks/use-mainnet-static-rpc-provider'; export const useStethEthRate = () => { const { chainId } = useSDK(); @@ -12,12 +13,16 @@ export const useStethEthRate = () => { const swrResult = useLidoSWR( `steth-eth-${chainId}`, async () => { - if (chainId !== 1) { - return constants.WeiPerEther; - } else { + if ( + [CHAINS.Mainnet, CHAINS.Sepolia, CHAINS.Holesky].indexOf( + chainId as CHAINS, + ) > -1 + ) { const stEthEth = await stEthEthRequest(mainnetStaticRpcProvider); return stEthEth; } + + return constants.WeiPerEther; }, STRATEGY_LAZY, ); From d501173497676d7d0688643df413ba638ce0b31a Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Tue, 6 Aug 2024 13:06:57 +0300 Subject: [PATCH 24/34] fix: using useStethEthRate --- features/rewards/components/stats/Stats.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/rewards/components/stats/Stats.tsx b/features/rewards/components/stats/Stats.tsx index 34c9a6b24..3896eb03a 100644 --- a/features/rewards/components/stats/Stats.tsx +++ b/features/rewards/components/stats/Stats.tsx @@ -17,7 +17,7 @@ export const Stats: React.FC = () => { data, initialLoading: pending, } = useRewardsHistory(); - const { data: stEthEth } = useStethEthRate(); + const stEthEth = useStethEthRate(); const { isDappActive } = useDappStatus(); return ( From 49aee983fdacd7ff64f3deb27df3077984b3d829 Mon Sep 17 00:00:00 2001 From: Anton Shalimov <a.shalimof@yandex.ru> Date: Tue, 6 Aug 2024 15:44:38 +0300 Subject: [PATCH 25/34] fix(rewards): wording --- features/rewards/components/stats/Stats.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/rewards/components/stats/Stats.tsx b/features/rewards/components/stats/Stats.tsx index 3896eb03a..3307ce9d6 100644 --- a/features/rewards/components/stats/Stats.tsx +++ b/features/rewards/components/stats/Stats.tsx @@ -23,7 +23,7 @@ export const Stats: React.FC = () => { return ( <> <Item data-testid="stEthRewardedBlock"> - <Title mb="8px">stETH earned + stETH rewarded Date: Wed, 7 Aug 2024 08:55:56 +0300 Subject: [PATCH 26/34] fix(rewards): open wallet by click on AddressBadge --- features/rewards/features/top-card/styles.tsx | 1 + features/rewards/features/top-card/wallet.tsx | 3 +++ 2 files changed, 4 insertions(+) diff --git a/features/rewards/features/top-card/styles.tsx b/features/rewards/features/top-card/styles.tsx index 925c68004..7ba12c78e 100644 --- a/features/rewards/features/top-card/styles.tsx +++ b/features/rewards/features/top-card/styles.tsx @@ -28,6 +28,7 @@ export const WalletContentRowStyle = styled.div` export const WalletContentAddressBadgeStyle = styled(AddressBadge)` background: #00000033; + cursor: pointer; `; export const ConnectWalletStyle = styled(WalletCardStyle)` diff --git a/features/rewards/features/top-card/wallet.tsx b/features/rewards/features/top-card/wallet.tsx index 3f16d3946..d2bf33360 100644 --- a/features/rewards/features/top-card/wallet.tsx +++ b/features/rewards/features/top-card/wallet.tsx @@ -7,6 +7,7 @@ import { useRewardsHistory } from 'features/rewards/hooks'; import { useRewardsBalanceData } from 'features/rewards/hooks/use-rewards-balance-data'; import { FlexCenter } from 'features/stake/stake-form/wallet/styles'; import { CardBalance } from 'shared/wallet'; +import { useWalletModal } from 'shared/wallet/wallet-modal/use-wallet-modal'; import { WalletStyle, @@ -18,6 +19,7 @@ import { export const Wallet: FC = () => { const { data: balanceData } = useRewardsBalanceData(); const { currencyObject: currency, address, loading } = useRewardsHistory(); + const { openModal } = useWalletModal(); return ( @@ -60,6 +62,7 @@ export const Wallet: FC = () => { address={address as `0x${string}`} symbolsMobile={6} symbolsDesktop={6} + onClick={() => openModal({})} /> From b8de7f2e38ebd8d9aeac9c05550198ca54f10a40 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Wed, 7 Aug 2024 09:00:44 +0300 Subject: [PATCH 27/34] fix(layout): remove Y micro scroll --- shared/components/layout/main/styles.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/components/layout/main/styles.tsx b/shared/components/layout/main/styles.tsx index 75189f9fa..fad7cad81 100644 --- a/shared/components/layout/main/styles.tsx +++ b/shared/components/layout/main/styles.tsx @@ -3,6 +3,6 @@ import styled from 'styled-components'; export const MainStyle = styled(Container)` position: relative; - margin-top: ${({ theme }) => theme.spaceMap.sm}px; - margin-bottom: ${({ theme }) => theme.spaceMap.sm}px; + padding-top: ${({ theme }) => theme.spaceMap.sm}px; + padding-bottom: ${({ theme }) => theme.spaceMap.sm}px; `; From 1714f3e8c0e58d0eee7dae60dbfdc224dbc54b26 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Wed, 7 Aug 2024 09:08:43 +0300 Subject: [PATCH 28/34] fix(rewards): text --- .../rewards/components/rewardsListContent/RewardsListsEmpty.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx b/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx index 992928e4a..d249d5b80 100644 --- a/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx +++ b/features/rewards/components/rewardsListContent/RewardsListsEmpty.tsx @@ -28,7 +28,7 @@ export const RewardsListsEmpty: FC = () => { - Connect your wallet to view your staking stats. + Connect your wallet to view your staking stats