Merge branch 'development' of github.com:gnosis/safe-react into development

This commit is contained in:
Mati Dastugue 2021-02-18 13:42:01 -03:00
commit 5839139b1e
3 changed files with 11 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "safe-react", "name": "safe-react",
"version": "3.0.0", "version": "3.0.1",
"description": "Allowing crypto users manage funds in a safer way", "description": "Allowing crypto users manage funds in a safer way",
"website": "https://github.com/gnosis/safe-react#readme", "website": "https://github.com/gnosis/safe-react#readme",
"bugs": { "bugs": {

View File

@ -2,7 +2,7 @@ import IconButton from '@material-ui/core/IconButton'
import MenuItem from '@material-ui/core/MenuItem' import MenuItem from '@material-ui/core/MenuItem'
import { makeStyles } from '@material-ui/core/styles' import { makeStyles } from '@material-ui/core/styles'
import Close from '@material-ui/icons/Close' import Close from '@material-ui/icons/Close'
import React, { useEffect, useState } from 'react' import React, { ReactElement, useEffect, useState } from 'react'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { List } from 'immutable' import { List } from 'immutable'
@ -44,12 +44,13 @@ export const ChangeThresholdModal = ({
owners, owners,
safeAddress, safeAddress,
threshold = 1, threshold = 1,
}: ChangeThresholdModalProps): React.ReactElement => { }: ChangeThresholdModalProps): ReactElement => {
const classes = useStyles() const classes = useStyles()
const dispatch = useDispatch() const dispatch = useDispatch()
const [data, setData] = useState('') const [data, setData] = useState('')
const [manualSafeTxGas, setManualSafeTxGas] = useState(0) const [manualSafeTxGas, setManualSafeTxGas] = useState(0)
const [manualGasPrice, setManualGasPrice] = useState<string | undefined>() const [manualGasPrice, setManualGasPrice] = useState<string | undefined>()
const [editedThreshold, setEditedThreshold] = useState<number>(threshold)
const { const {
gasCostFormatted, gasCostFormatted,
@ -71,7 +72,7 @@ export const ChangeThresholdModal = ({
let isCurrent = true let isCurrent = true
const calculateChangeThresholdData = async () => { const calculateChangeThresholdData = async () => {
const safeInstance = await getGnosisSafeInstanceAt(safeAddress) const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
const txData = safeInstance.methods.changeThreshold(threshold).encodeABI() const txData = safeInstance.methods.changeThreshold(editedThreshold).encodeABI()
if (isCurrent) { if (isCurrent) {
setData(txData) setData(txData)
} }
@ -81,7 +82,7 @@ export const ChangeThresholdModal = ({
return () => { return () => {
isCurrent = false isCurrent = false
} }
}, [safeAddress, threshold]) }, [safeAddress, editedThreshold])
const getParametersStatus = () => (threshold > 1 ? 'ETH_DISABLED' : 'ENABLED') const getParametersStatus = () => (threshold > 1 ? 'ETH_DISABLED' : 'ENABLED')
@ -135,7 +136,7 @@ export const ChangeThresholdModal = ({
</IconButton> </IconButton>
</Row> </Row>
<Hairline /> <Hairline />
<GnoForm initialValues={{ threshold: threshold.toString(), txParameters }} onSubmit={handleSubmit}> <GnoForm initialValues={{ threshold: editedThreshold.toString(), txParameters }} onSubmit={handleSubmit}>
{() => ( {() => (
<> <>
<Block className={classes.modalContent}> <Block className={classes.modalContent}>
@ -147,6 +148,9 @@ export const ChangeThresholdModal = ({
<Field <Field
data-testid="threshold-select-input" data-testid="threshold-select-input"
name={THRESHOLD_FIELD_NAME} name={THRESHOLD_FIELD_NAME}
onChange={({ target }) => {
setEditedThreshold(parseInt(target.value))
}}
render={(props) => ( render={(props) => (
<> <>
<SelectField {...props} disableError> <SelectField {...props} disableError>
@ -177,7 +181,6 @@ export const ChangeThresholdModal = ({
<TxParametersDetail <TxParametersDetail
txParameters={txParameters} txParameters={txParameters}
onEdit={toggleEditMode} onEdit={toggleEditMode}
compact={true}
parametersStatus={getParametersStatus()} parametersStatus={getParametersStatus()}
isTransactionCreation={isCreation} isTransactionCreation={isCreation}
isTransactionExecution={isExecution} isTransactionExecution={isExecution}

View File

@ -50,13 +50,6 @@ export const EditableTxParameters = ({
toggleEditMode((prev) => !prev) toggleEditMode((prev) => !prev)
} }
// Sends a callback with the last values of txParameters
useEffect(() => {
if (!isEditMode && closeEditModalCallback) {
closeEditModalCallback(txParameters)
}
}, [isEditMode, closeEditModalCallback, txParameters])
const closeEditFormHandler = (txParameters?: TxParameters) => { const closeEditFormHandler = (txParameters?: TxParameters) => {
if (txParameters) { if (txParameters) {
setUseManualValues(true) setUseManualValues(true)
@ -65,6 +58,7 @@ export const EditableTxParameters = ({
setEthGasLimit(txParameters.ethGasLimit) setEthGasLimit(txParameters.ethGasLimit)
setEthGasPrice(txParameters.ethGasPrice) setEthGasPrice(txParameters.ethGasPrice)
setEthNonce(txParameters.ethNonce) setEthNonce(txParameters.ethNonce)
closeEditModalCallback && closeEditModalCallback(txParameters)
} }
toggleStatus() toggleStatus()
} }