In order to replace the owner, first checks that the threshold is 1

This commit is contained in:
apane 2019-11-14 15:16:15 -03:00
parent 1c8f6b42c5
commit 94b89b0ad0
2 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
import { getGnosisSafeInstanceAt, SENTINEL_ADDRESS } from '~/logic/contracts/safeContracts' import { getGnosisSafeInstanceAt, SENTINEL_ADDRESS } from '~/logic/contracts/safeContracts'
import OwnerForm from './screens/OwnerForm' import OwnerForm from './screens/OwnerForm'
import ReviewReplaceOwner from './screens/Review' import ReviewReplaceOwner from './screens/Review'
import type { Safe } from '~/routes/safe/store/models/safe'
const styles = () => ({ const styles = () => ({
biggerModalWindow: { biggerModalWindow: {
@ -33,6 +34,7 @@ type Props = {
replaceSafeOwner: Function, replaceSafeOwner: Function,
enqueueSnackbar: Function, enqueueSnackbar: Function,
closeSnackbar: Function, closeSnackbar: Function,
safe: Safe,
} }
type ActiveScreen = 'checkOwner' | 'reviewReplaceOwner' type ActiveScreen = 'checkOwner' | 'reviewReplaceOwner'
@ -44,6 +46,7 @@ export const sendReplaceOwner = async (
closeSnackbar: Function, closeSnackbar: Function,
createTransaction: Function, createTransaction: Function,
replaceSafeOwner: Function, replaceSafeOwner: Function,
safe: Safe,
) => { ) => {
const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress)
const safeOwners = await gnosisSafe.getOwners() const safeOwners = await gnosisSafe.getOwners()
@ -65,7 +68,7 @@ export const sendReplaceOwner = async (
closeSnackbar, closeSnackbar,
) )
if (txHash) { if (txHash && safe.threshold === 1) {
replaceSafeOwner({ replaceSafeOwner({
safeAddress, safeAddress,
oldOwnerAddress: ownerAddressToRemove, oldOwnerAddress: ownerAddressToRemove,
@ -89,6 +92,7 @@ const ReplaceOwner = ({
replaceSafeOwner, replaceSafeOwner,
enqueueSnackbar, enqueueSnackbar,
closeSnackbar, closeSnackbar,
safe,
}: Props) => { }: Props) => {
const [activeScreen, setActiveScreen] = useState<ActiveScreen>('checkOwner') const [activeScreen, setActiveScreen] = useState<ActiveScreen>('checkOwner')
const [values, setValues] = useState<Object>({}) const [values, setValues] = useState<Object>({})
@ -121,6 +125,7 @@ const ReplaceOwner = ({
closeSnackbar, closeSnackbar,
createTransaction, createTransaction,
replaceSafeOwner, replaceSafeOwner,
safe,
) )
} catch (error) { } catch (error) {
console.error('Error while removing an owner', error) console.error('Error while removing an owner', error)

View File

@ -253,6 +253,7 @@ class ManageOwners extends React.Component<Props, State> {
userAddress={userAddress} userAddress={userAddress}
createTransaction={createTransaction} createTransaction={createTransaction}
replaceSafeOwner={replaceSafeOwner} replaceSafeOwner={replaceSafeOwner}
safe={safe}
/> />
<EditOwnerModal <EditOwnerModal
onClose={this.onHide('EditOwner')} onClose={this.onHide('EditOwner')}