Skip to content

Commit

Permalink
feat: wallet UI claim rewards (#2115)
Browse files Browse the repository at this point in the history
- new Wallet UI for claiming reward: voting reward and gas refund reward
  + refactor claiming reward hooks to be reuseable
- integrate gas refund cycle API
- update texts & images change
- refactor Icon sprite: add type
- fix Solana loop call on load page init
- add Mixpanel event for gas refund
- fix BE's gasRefundPerCentage -> gasRefundPercentage
- fix gas refund claim transaction alert & transaction informations
- fix wallet popup restrict to only able to drag inside of screen
- reload claim reward info after claimed
- refactor gas refund use swr => rtk
- fix remove some duplicated rtk middleware
  • Loading branch information
namgold authored Aug 2, 2023
1 parent 642699f commit 6c26663
Show file tree
Hide file tree
Showing 47 changed files with 1,203 additions and 848 deletions.
Binary file removed src/assets/images/gas-refund/knc-dropping.png
Binary file not shown.
Binary file removed src/assets/images/gas-refund/kncs.png
Binary file not shown.
Binary file added src/assets/images/gas-refund/kyberdao-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/gas-refund/kyberdao-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/images/gas-refund/ringwave.gif
Binary file not shown.
20 changes: 11 additions & 9 deletions src/assets/svg/dollar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
271 changes: 89 additions & 182 deletions src/assets/svg/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/Announcement/Popups/TransactionPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const SUMMARY: { [type in TRANSACTION_TYPE]: SummaryFunction } = {
[TRANSACTION_TYPE.CANCEL_LIMIT_ORDER]: summaryCancelLimitOrder,
[TRANSACTION_TYPE.TRANSFER_TOKEN]: summaryTransferToken,

[TRANSACTION_TYPE.KYBERDAO_CLAIM_GAS_REFUND]: summaryClaim,
[TRANSACTION_TYPE.KYBERDAO_CLAIM]: summary1Token,
[TRANSACTION_TYPE.KYBERDAO_UNDELEGATE]: summaryDelegateDao,
[TRANSACTION_TYPE.KYBERDAO_MIGRATE]: summary2Token,
Expand Down
9 changes: 8 additions & 1 deletion src/components/Header/groups/KyberDaoGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ const KyberDAONavGroup = () => {
<VoteIcon />
<Trans>Vote</Trans>
</StyledNavLink>
<StyledNavLink id="knc-utility" to={APP_PATHS.KYBERDAO_KNC_UTILITY} style={{ gap: '4px' }}>
<StyledNavLink
id="knc-utility"
to={APP_PATHS.KYBERDAO_KNC_UTILITY}
style={{ gap: '4px' }}
onClick={() => {
mixpanelHandler(MIXPANEL_TYPE.GAS_REFUND_SOURCE_CLICK, { source: 'KyberDAO_tab' })
}}
>
<KyberLogo width={16} height={16} />
<Trans>KNC Utility</Trans>
</StyledNavLink>
Expand Down
7 changes: 5 additions & 2 deletions src/components/Icons/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import React from 'react'

import sprite from 'assets/svg/sprite.svg'
import { ICON_ID } from 'constants/index'

export default function Icon({
id,
size,
style,
color,
...rest
}: {
id: string
id: ICON_ID
size?: number | string
color?: string
style?: React.CSSProperties
title?: string
}) {
return (
<div style={style} {...rest}>
<svg width={size || 24} height={size || 24} display="block">
<svg width={size || 24} height={size || 24} display="block" color={color}>
<use href={`${sprite}#${id}`} width={size || 24} height={size || 24} />
</svg>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/SwapForm/SwapModal/SwapDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function SwapDetails({
const theme = useTheme()
const isDarkMode = useIsDarkMode()
const { slippage, routeSummary } = useSwapFormContext()
const { gasRefundPerCentage } = useGasRefundTier()
const { gasRefundPercentage } = useGasRefundTier()

const currencyIn = routeSummary?.parsedAmountIn?.currency
const currencyOut = routeSummary?.parsedAmountOut?.currency
Expand Down Expand Up @@ -358,7 +358,7 @@ export default function SwapDetails({
lineHeight="16px"
style={{ pointerEvents: 'none' }}
>
<Trans>{gasRefundPerCentage * 100}% Refund</Trans>
<Trans>{gasRefundPercentage ? gasRefundPercentage * 100 : '--'}% Refund</Trans>
</ButtonLight>
</RowBetween>
)}
Expand Down
11 changes: 8 additions & 3 deletions src/components/SwapForm/TradeSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type Props = {
const TradeSummary: React.FC<Props> = ({ routeSummary, slippage }) => {
const { account, chainId } = useActiveWeb3React()
const theme = useTheme()
const { gasRefundPerCentage } = useGasRefundTier()
const { gasRefundPercentage } = useGasRefundTier()
const [expanded, setExpanded] = useState(true)
const [alreadyVisible, setAlreadyVisible] = useState(false)
const { parsedAmountOut, priceImpact, gasUsd } = routeSummary || {}
Expand Down Expand Up @@ -285,9 +285,14 @@ const TradeSummary: React.FC<Props> = ({ routeSummary, slippage }) => {
</MouseoverTooltip>
</TextDashed>
</RowFixed>
<NavLink to={APP_PATHS.KYBERDAO_KNC_UTILITY}>
<NavLink
to={APP_PATHS.KYBERDAO_KNC_UTILITY}
onClick={() => {
mixpanelHandler(MIXPANEL_TYPE.GAS_REFUND_SOURCE_CLICK, { source: 'Swap_page_more_info' })
}}
>
<ButtonLight padding="0px 8px" width="fit-content" fontSize={10} fontWeight={500} lineHeight="16px">
<Trans>{account ? gasRefundPerCentage * 100 : '--'}% Refund</Trans>
<Trans>{account ? gasRefundPercentage * 100 : '--'}% Refund</Trans>
</ButtonLight>
</NavLink>
</RowBetween>
Expand Down
4 changes: 3 additions & 1 deletion src/components/WalletPopup/AccountInfo/ActionButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ReactComponent as DollarIcon } from 'assets/svg/dollar.svg'
import { ButtonLight } from 'components/Button'
import SendIcon from 'components/Icons/SendIcon'
import { ClickHandlerProps } from 'components/WalletPopup/AccountInfo'
import useTheme from 'hooks/useTheme'

const ActionButton = styled(ButtonLight)`
flex: 0 1 105px;
Expand All @@ -17,6 +18,7 @@ type Props = {
className?: string
} & ClickHandlerProps
const ActionButtonGroup: React.FC<Props> = ({ onClickBuy, onClickReceive, onClickSend, className, disabledSend }) => {
const theme = useTheme()
return (
<Flex
className={className}
Expand All @@ -26,7 +28,7 @@ const ActionButtonGroup: React.FC<Props> = ({ onClickBuy, onClickReceive, onClic
}}
>
<ActionButton onClick={onClickBuy}>
<DollarIcon />
<DollarIcon color={theme.primary} />
<Text as="span" marginLeft="7px">
<Trans>Buy</Trans>
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ReactComponent as DollarIcon } from 'assets/svg/dollar.svg'
import { ButtonLight } from 'components/Button'
import SendIcon from 'components/Icons/SendIcon'
import { ClickHandlerProps } from 'components/WalletPopup/AccountInfo'
import useTheme from 'hooks/useTheme'

const MinimalActionButton = styled(ButtonLight)`
flex: 0 0 36px;
Expand All @@ -23,6 +24,7 @@ const MinimalActionButtonGroup: React.FC<Props> = ({
className,
disabledSend,
}) => {
const theme = useTheme()
return (
<Flex
className={className}
Expand All @@ -33,7 +35,7 @@ const MinimalActionButtonGroup: React.FC<Props> = ({
}}
>
<MinimalActionButton onClick={onClickBuy}>
<DollarIcon width={'24px'} height={'24px'} />
<DollarIcon width={'24px'} height={'24px'} color={theme.primary} />
</MinimalActionButton>
<MinimalActionButton onClick={onClickReceive}>
<SendIcon size={14} style={{ transform: 'rotate(180deg)' }} />
Expand Down
80 changes: 0 additions & 80 deletions src/components/WalletPopup/AccountInfo/Settings.tsx

This file was deleted.

Loading

0 comments on commit 6c26663

Please sign in to comment.