-
Notifications
You must be signed in to change notification settings - Fork 456
chore: permit modifications #1325
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
Changes from 31 commits
3895517
7ab4c8c
b1c0012
3830a05
e9346c6
83b731f
7647937
a5b60f6
a504d1e
978a5b8
cbe1951
9776302
8fd5cc9
c4b62b5
45f70af
dc0c453
7a3db44
f822489
be19f8a
040f90e
c9fc883
1d76a69
b1a83aa
3b37cd6
27b8501
48672d5
a2756f7
a1897aa
a3016c7
570805b
6ec34df
9fd8b38
2312958
47297be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { Trans } from '@lingui/macro'; | ||
|
|
||
| import { Link } from '../primitives/Link'; | ||
| import { TextWithTooltip, TextWithTooltipProps } from '../TextWithTooltip'; | ||
|
|
||
| export const ApprovalTooltip = ({ ...rest }: TextWithTooltipProps) => { | ||
| return ( | ||
| <TextWithTooltip {...rest}> | ||
| <Trans> | ||
| To continue you need to grant Aave smart contracts permission to move your funds from your | ||
| wallet. Depending on the asset and wallet you use, it is done by signing the permission | ||
| message (gas free), or by submitting an approval transaction (requires gas).{' '} | ||
| <Link href="https://eips.ethereum.org/EIPS/eip-2612" underline="always"> | ||
| Learn more | ||
| </Link> | ||
| </Trans> | ||
| </TextWithTooltip> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { CheckIcon } from '@heroicons/react/outline'; | ||
| import { CogIcon } from '@heroicons/react/solid'; | ||
| import { Trans } from '@lingui/macro'; | ||
| import { | ||
| Box, | ||
| ListItemIcon, | ||
| ListItemText, | ||
| Menu, | ||
| MenuItem, | ||
| SvgIcon, | ||
| Typography, | ||
| } from '@mui/material'; | ||
| import * as React from 'react'; | ||
| import { ApprovalMethod } from 'src/store/walletSlice'; | ||
|
|
||
| interface ApprovalMethodToggleButtonProps { | ||
| currentMethod: ApprovalMethod; | ||
| setMethod: (newMethod: ApprovalMethod) => void; | ||
| } | ||
|
|
||
| export const ApprovalMethodToggleButton = ({ | ||
| currentMethod, | ||
| setMethod, | ||
| }: ApprovalMethodToggleButtonProps) => { | ||
| const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); | ||
| const open = Boolean(anchorEl); | ||
| const handleClick = (event: React.MouseEvent<HTMLDivElement>) => { | ||
| setAnchorEl(event.currentTarget); | ||
| }; | ||
| const handleClose = () => { | ||
| setAnchorEl(null); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <Box onClick={handleClick} sx={{ display: 'flex', alignItems: 'center', cursor: 'pointer' }}> | ||
| <Typography variant="subheader2" color="info.main"> | ||
| <Trans>{currentMethod}</Trans> | ||
| </Typography> | ||
| <SvgIcon sx={{ fontSize: 16, ml: 1, color: 'info.main' }}> | ||
| <CogIcon /> | ||
| </SvgIcon> | ||
| </Box> | ||
|
|
||
| <Menu | ||
| anchorEl={anchorEl} | ||
| open={open} | ||
| onClose={handleClose} | ||
| MenuListProps={{ | ||
| 'aria-labelledby': 'basic-button', | ||
| }} | ||
| keepMounted={true} | ||
| data-cy={`approveMenu_${currentMethod}`} | ||
| > | ||
| <MenuItem | ||
| selected={currentMethod === ApprovalMethod.PERMIT} | ||
| value={ApprovalMethod.PERMIT} | ||
| onClick={() => { | ||
| if (currentMethod === ApprovalMethod.APPROVE) { | ||
| setMethod(ApprovalMethod.PERMIT); | ||
| } | ||
| handleClose(); | ||
| }} | ||
| > | ||
| <ListItemText primaryTypographyProps={{ variant: 'subheader1' }}> | ||
| <Trans>{ApprovalMethod.PERMIT}</Trans> | ||
| </ListItemText> | ||
| <ListItemIcon> | ||
| <SvgIcon>{currentMethod === ApprovalMethod.PERMIT && <CheckIcon />}</SvgIcon> | ||
| </ListItemIcon> | ||
| </MenuItem> | ||
|
|
||
| <MenuItem | ||
| selected={currentMethod === ApprovalMethod.APPROVE} | ||
| value={ApprovalMethod.APPROVE} | ||
| onClick={() => { | ||
| if (currentMethod === ApprovalMethod.PERMIT) { | ||
| setMethod(ApprovalMethod.APPROVE); | ||
| } | ||
| handleClose(); | ||
| }} | ||
| > | ||
| <ListItemText primaryTypographyProps={{ variant: 'subheader1' }}> | ||
| <Trans>{ApprovalMethod.APPROVE}</Trans> | ||
| </ListItemText> | ||
| <ListItemIcon> | ||
| <SvgIcon>{currentMethod === ApprovalMethod.APPROVE && <CheckIcon />}</SvgIcon> | ||
| </ListItemIcon> | ||
| </MenuItem> | ||
| </Menu> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could these menu item components be simplified? They look identical other than the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would end up with more code to split to separate component and pass currentMethod, buttonMethod, setMethod, and handleClose as props so I think it's fine to leave as is |
||
| </> | ||
| ); | ||
| }; | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.