remove trash code

This commit is contained in:
fernandomg 2020-07-01 12:55:09 -03:00
parent 1a095e561b
commit bac59b9b38
2 changed files with 0 additions and 171 deletions

View File

@ -1,128 +0,0 @@
import IconButton from '@material-ui/core/IconButton'
import MenuItem from '@material-ui/core/MenuItem'
import { withStyles } from '@material-ui/core/styles'
import Close from '@material-ui/icons/Close'
import React, { useEffect, useState } from 'react'
import { styles } from './style'
import Field from 'src/components/forms/Field'
import GnoForm from 'src/components/forms/GnoForm'
import SelectField from 'src/components/forms/SelectField'
import { composeValidators, differentFrom, minValue, mustBeInteger, required } from 'src/components/forms/validator'
import Block from 'src/components/layout/Block'
import Button from 'src/components/layout/Button'
import Col from 'src/components/layout/Col'
import Hairline from 'src/components/layout/Hairline'
import Paragraph from 'src/components/layout/Paragraph'
import Row from 'src/components/layout/Row'
import { getGnosisSafeInstanceAt } from 'src/logic/contracts/safeContracts'
import { estimateTxGasCosts } from 'src/logic/safe/transactions/gasNew'
import { formatAmount } from 'src/logic/tokens/utils/formatAmount'
import { getWeb3 } from 'src/logic/wallets/getWeb3'
const THRESHOLD_FIELD_NAME = 'threshold'
const ChangeThreshold = ({ classes, onChangeThreshold, onClose, owners, safeAddress, threshold }) => {
const [gasCosts, setGasCosts] = useState('< 0.001')
useEffect(() => {
let isCurrent = true
const estimateGasCosts = async () => {
const web3 = getWeb3()
const { fromWei, toBN } = web3.utils
const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
const txData = safeInstance.contract.methods.changeThreshold('1').encodeABI()
const estimatedGasCosts = await estimateTxGasCosts(safeAddress, safeAddress, txData)
const gasCostsAsEth = fromWei(toBN(estimatedGasCosts), 'ether')
const formattedGasCosts = formatAmount(gasCostsAsEth)
if (isCurrent) {
setGasCosts(formattedGasCosts)
}
}
estimateGasCosts()
return () => {
isCurrent = false
}
}, [safeAddress])
const handleSubmit = (values) => {
const newThreshold = values[THRESHOLD_FIELD_NAME]
onClose()
onChangeThreshold(newThreshold)
}
return (
<>
<Row align="center" className={classes.heading} grow>
<Paragraph className={classes.headingText} noMargin weight="bolder">
Change required confirmations
</Paragraph>
<IconButton disableRipple onClick={onClose}>
<Close className={classes.close} />
</IconButton>
</Row>
<Hairline />
<GnoForm initialValues={{ threshold: threshold.toString() }} onSubmit={handleSubmit}>
{() => (
<>
<Block className={classes.modalContent}>
<Row>
<Paragraph weight="bolder">Any transaction requires the confirmation of:</Paragraph>
</Row>
<Row align="center" className={classes.inputRow} margin="xl">
<Col xs={2}>
<Field
data-testid="threshold-select-input"
name={THRESHOLD_FIELD_NAME}
render={(props) => (
<>
<SelectField {...props} disableError>
{[...Array(Number(owners.size))].map((x, index) => (
<MenuItem key={index} value={`${index + 1}`}>
{index + 1}
</MenuItem>
))}
</SelectField>
{props.meta.error && props.meta.touched && (
<Paragraph className={classes.errorText} color="error" noMargin>
{props.meta.error}
</Paragraph>
)}
</>
)}
validate={composeValidators(required, mustBeInteger, minValue(1), differentFrom(threshold))}
/>
</Col>
<Col xs={10}>
<Paragraph className={classes.ownersText} color="primary" noMargin size="lg">
{`out of ${owners.size} owner(s)`}
</Paragraph>
</Col>
</Row>
<Row>
<Paragraph>
{`You're about to create a transaction and will have to confirm it with your currently connected wallet. Make sure you have ${gasCosts} (fee price) ETH in this wallet to fund this confirmation.`}
</Paragraph>
</Row>
</Block>
<Hairline style={{ position: 'absolute', bottom: 85 }} />
<Row align="center" className={classes.buttonRow}>
<Button minWidth={140} onClick={onClose}>
BACK
</Button>
<Button color="primary" minWidth={140} type="submit" variant="contained">
CHANGE
</Button>
</Row>
</>
)}
</GnoForm>
</>
)
}
export default withStyles(styles as any)(ChangeThreshold)

View File

@ -1,43 +0,0 @@
import { lg, md, secondaryText, sm } from 'src/theme/variables'
export const styles = () => ({
heading: {
padding: `${sm} ${lg}`,
justifyContent: 'space-between',
boxSizing: 'border-box',
maxHeight: '75px',
},
annotation: {
letterSpacing: '-1px',
color: secondaryText,
marginRight: 'auto',
marginLeft: '20px',
},
headingText: {
fontSize: '20px',
},
close: {
height: '35px',
width: '35px',
},
modalContent: {
padding: `${md} ${lg}`,
},
ownersText: {
marginLeft: sm,
},
buttonRow: {
height: '84px',
justifyContent: 'center',
position: 'absolute',
bottom: 0,
width: '100%',
},
inputRow: {
position: 'relative',
},
errorText: {
position: 'absolute',
bottom: '-25px',
},
})