Skip to content

Commit 2e7cbf2

Browse files
feat(Wallet): mf-6516 disable permit (#12104)
* feat(Wallet): mf-6516 disable permit * fixup! feat(Wallet): mf-6516 disable permit * fixup! fixup! feat(Wallet): mf-6516 disable permit * refactor: abort with error --------- Co-authored-by: guanbinrui <guanbinrui@mask.io>
1 parent d491e7a commit 2e7cbf2

File tree

17 files changed

+217
-5
lines changed

17 files changed

+217
-5
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { Trans } from '@lingui/react/macro'
2+
import { Icons } from '@masknet/icons'
3+
import { disablePermitSettings } from '@masknet/shared-base'
4+
import { useValueRef } from '@masknet/shared-base-ui'
5+
import { makeStyles } from '@masknet/theme'
6+
import { Box, ListItem, Switch, Typography } from '@mui/material'
7+
import { ConfirmModal } from '../../../modals/modal-controls.js'
8+
import { useStyles as useSharedStyles } from './useStyles.js'
9+
10+
const useStyles = makeStyles()((theme) => ({
11+
texts: {
12+
display: 'flex',
13+
flexDirection: 'column',
14+
gap: 16,
15+
},
16+
text: {
17+
color: theme.palette.maskColor.third,
18+
lineHeight: '18px',
19+
fontSize: 14,
20+
fontWeight: 700,
21+
},
22+
}))
23+
24+
export function DisablePermit() {
25+
const { classes: sharedClasses } = useSharedStyles()
26+
const { classes, theme } = useStyles()
27+
const disabled = useValueRef(disablePermitSettings)
28+
29+
return (
30+
<ListItem className={sharedClasses.item}>
31+
<Box className={sharedClasses.itemBox}>
32+
<Icons.DangerOutline size={20} />
33+
<Typography className={sharedClasses.itemText}>
34+
<Trans>Disable Permit</Trans>
35+
</Typography>
36+
<Icons.Questions
37+
color={theme.palette.maskColor.second}
38+
size={20}
39+
onClick={() => {
40+
ConfirmModal.openAndWaitForClose({
41+
title: <Trans>About Permit</Trans>,
42+
buttonLabel: <Trans>Okay</Trans>,
43+
message: (
44+
<Typography component="div" className={classes.texts}>
45+
<Trans>
46+
<Typography className={classes.text}>
47+
Permit allows users to authorize an address to access their ERC-20 tokens
48+
without requiring a separate approval transaction, providing a more
49+
efficient way to manage token permissions.
50+
</Typography>
51+
52+
<Typography className={classes.text}>
53+
However, if the authorized limit is exceeded or the Permit expires, the
54+
authorization automatically becomes invalid. Despite this, security risks
55+
remain.
56+
</Typography>
57+
58+
<Typography className={classes.text}>
59+
To prevent potential misuse, you can disable the Permit feature.
60+
</Typography>
61+
</Trans>
62+
</Typography>
63+
),
64+
})
65+
}}
66+
/>
67+
</Box>
68+
<Box className={sharedClasses.itemBox}>
69+
<Switch
70+
checked={disabled}
71+
onChange={(e) => {
72+
disablePermitSettings.value = e.target.checked
73+
}}
74+
/>
75+
</Box>
76+
</ListItem>
77+
)
78+
}

packages/mask/popups/pages/Wallet/WalletSettings/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { ShowPrivateKey } from './ShowPrivateKey.js'
2323
import { useStyles } from './useStyles.js'
2424
import { HidingScamTx } from './HidingScamTx.js'
2525
import { Trans, useLingui } from '@lingui/react/macro'
26+
import { DisablePermit } from './DisablePermit.js'
2627

2728
function getPathIndex(path?: string) {
2829
const rawIndex = path?.split('/').pop()
@@ -84,6 +85,7 @@ export const Component = memo(function WalletSettings() {
8485
<Rename />
8586
<Contacts />
8687
<HidingScamTx />
88+
<DisablePermit />
8789
{wallet.owner ? null : <ConnectedOrigins />}
8890
<AutoLock />
8991
<ChangeCurrency />

packages/mask/popups/pages/Wallet/WalletSettings/useStyles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const useStyles = makeStyles()((theme) => ({
4141
},
4242
itemText: {
4343
marginLeft: 6,
44+
marginRight: 2,
4445
fontSize: 14,
4546
color: theme.palette.maskColor.main,
4647
},

packages/mask/shared-ui/locale/en-US.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mask/shared-ui/locale/en-US.po

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mask/shared-ui/locale/ja-JP.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mask/shared-ui/locale/ja-JP.po

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mask/shared-ui/locale/ko-KR.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mask/shared-ui/locale/ko-KR.po

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mask/shared-ui/locale/zh-CN.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)