Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/token-locking' into feat/analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu committed Mar 26, 2024
2 parents 29a166a + dbc3629 commit 65de67b
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 14 deletions.
28 changes: 28 additions & 0 deletions public/images/barcode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions public/images/safe-miles.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions src/components/Claim/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useState, type ReactElement, ChangeEvent } from 'react'
import PaperContainer from '../PaperContainer'

import TitleStar from '@/public/images/leaderboard-title-star.svg'
import StarIcon from '@/public/images/star.svg'
import { maxDecimals, minMaxValue, mustBeFloat } from '@/utils/validation'
import { useIsTokenPaused } from '@/hooks/useIsTokenPaused'
import { useSafeTokenAllocation } from '@/hooks/useSafeTokenAllocation'
Expand Down Expand Up @@ -59,7 +60,7 @@ const ClaimOverview = (): ReactElement => {
const isWrongChain = useIsWrongChain()
const router = useRouter()

const [amount, setAmount] = useState('')
const [amount, setAmount] = useState('0')
const [isMaxAmountSelected, setIsMaxAmountSelected] = useState(false)
const [amountError, setAmountError] = useState<string>()
const [creatingTxs, setCreatingTxs] = useState(false)
Expand Down Expand Up @@ -173,11 +174,11 @@ const ClaimOverview = (): ReactElement => {
gap: 1,
}}
>
<Stack direction="row" spacing={2} alignItems="center">
<SvgIcon fontSize="large" component={TitleStar} />
<Stack direction="row" spacing={2} alignItems="center" fontSize={38}>
<SvgIcon component={StarIcon} inheritViewBox fontSize="inherit" />
<Box>
<Typography variant="subtitle1" fontWeight={700}>
Claim your tokens as rewards
Claim your tokens as rewards!
</Typography>
<Typography variant="body2">You get more tokens if you are active in activity program.</Typography>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ClaimCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ClaimCard = ({
return (
<Paper sx={{ p: 3, backgroundColor: 'background.default', position: 'relative' }}>
<Typography marginBottom={3} fontWeight={700}>
{isClaimable ? 'Claim now' : 'Claim at the end of the season'}
{isClaimable ? 'Claim now' : 'Claim in future (vesting)'}

{!isClaimable && (
<Tooltip
Expand Down
2 changes: 1 addition & 1 deletion src/components/InfoAlert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ReactElement } from 'react'

export const InfoAlert = ({ children, ...props }: BoxProps): ReactElement => {
return (
<Box display="flex" gap={1} color="text.secondary" {...props}>
<Box display="flex" gap={1} color="border.main" {...props}>
<InfoOutlined
sx={{
height: '16px',
Expand Down
6 changes: 2 additions & 4 deletions src/components/OverviewLinks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ const SafeDaoCard = () => {
<SvgIcon component={Hat} inheritViewBox color="info" />
</div>
<Box>
<Typography variant="h3" fontWeight={700}>
What is
<br />
Safe{`{DAO}`}?
<Typography variant="h3" fontWeight={700} mt={5}>
What is Safe DAO?
</Typography>
<Link href={AppRoutes.safedao} component={NextLink} ref={linkRef}>
Learn more
Expand Down
4 changes: 2 additions & 2 deletions src/components/SelectedDelegate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export const SelectedDelegate = ({
</Card>
{hint && (
<InfoAlert mt={2}>
<Typography variant="body2">
You only delegate your voting power and not the ownership of your Safe Tokens.
<Typography variant="body2" color="text.secondary">
You only delegate your voting power and not the ownership over your tokens.
</Typography>
</InfoAlert>
)}
Expand Down
12 changes: 11 additions & 1 deletion src/components/TockenUnlocking/UnlockTokenWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SafeToken from '@/public/images/token.svg'
import { getBoostFunction } from '@/utils/boost'
import { floorNumber, getBoostFunction } from '@/utils/boost'
import css from './styles.module.css'
import { Stack, Grid, Typography, TextField, InputAdornment, Button, CircularProgress } from '@mui/material'
import { formatUnits, parseUnits } from 'ethers/lib/utils'
Expand All @@ -17,6 +17,7 @@ import { SEASON2_START } from '../TokenLocking/BoostGraph/graphConstants'
import Track from '../Track'
import { LOCK_EVENTS } from '@/analytics/lockEvents'
import { trackSafeAppEvent } from '@/utils/analytics'
import MilesReceipt from '@/components/TokenLocking/MilesReceipt'

export const UnlockTokenWidget = ({
lockHistory,
Expand All @@ -25,6 +26,7 @@ export const UnlockTokenWidget = ({
lockHistory: LockHistory[]
currentlyLocked: BigNumberish
}) => {
const [receiptOpen, setReceiptOpen] = useState<boolean>(false)
const [unlockAmount, setUnlockAmount] = useState('0')
const [unlockAmountError, setUnlockAmountError] = useState<string>()

Expand Down Expand Up @@ -71,6 +73,7 @@ export const UnlockTokenWidget = ({
try {
await sdk.txs.send({ txs: [unlockTx] })
trackSafeAppEvent(LOCK_EVENTS.UNLOCK_SUCCESS.action)
setReceiptOpen(true)
} catch (err) {
console.error(err)
}
Expand Down Expand Up @@ -141,6 +144,13 @@ export const UnlockTokenWidget = ({
/>
</Grid>
</Grid>
<MilesReceipt
open={receiptOpen}
onClose={() => setReceiptOpen(false)}
amount={unlockAmount}
newFinalBoost={floorNumber(newBoostFunction({ x: SEASON2_START }), 2)}
isUnlock
/>
</Stack>
)
}
11 changes: 10 additions & 1 deletion src/components/TokenLocking/LockTokenWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useSafeAppsSDK } from '@gnosis.pm/safe-apps-react-sdk'
import { useState, ChangeEvent, useMemo, useCallback } from 'react'
import { BigNumberish } from 'ethers'
import { useChainId } from '@/hooks/useChainId'
import { getBoostFunction } from '@/utils/boost'
import { floorNumber, getBoostFunction } from '@/utils/boost'
import { useLockHistory } from '@/hooks/useLockHistory'
import { useDebounce } from '@/hooks/useDebounce'
import { SEASON2_START } from './BoostGraph/graphConstants'
Expand All @@ -22,8 +22,10 @@ import { BoostBreakdown } from './BoostBreakdown'
import Track from '../Track'
import { LOCK_EVENTS } from '@/analytics/lockEvents'
import { trackSafeAppEvent } from '@/utils/analytics'
import MilesReceipt from '@/components/TokenLocking/MilesReceipt'

export const LockTokenWidget = ({ safeBalance }: { safeBalance: BigNumberish | undefined }) => {
const [receiptOpen, setReceiptOpen] = useState<boolean>(false)
const { sdk } = useSafeAppsSDK()
const chainId = useChainId()
const startTime = CHAIN_START_TIMESTAMPS[chainId]
Expand Down Expand Up @@ -85,6 +87,7 @@ export const LockTokenWidget = ({ safeBalance }: { safeBalance: BigNumberish | u
try {
await sdk.txs.send({ txs: [approveTx, lockTx] })
trackSafeAppEvent(LOCK_EVENTS.LOCK_SUCCESS.action)
setReceiptOpen(true)
} catch (error) {
console.error(error)
}
Expand Down Expand Up @@ -166,6 +169,12 @@ export const LockTokenWidget = ({ safeBalance }: { safeBalance: BigNumberish | u
</Grid>
</Grid>
</Stack>
<MilesReceipt
open={receiptOpen}
onClose={() => setReceiptOpen(false)}
amount={amount}
newFinalBoost={floorNumber(newBoostFunction({ x: SEASON2_START }), 2)}
/>
</>
)
}
Loading

0 comments on commit 65de67b

Please sign in to comment.