(Fix) New owners as `UNKNOWN` (#697)

* fix: No threshold change for owners replacement

* fix: Extract added owner from addressBook

When replacing an owner, the added owner's name was the same as the removed one

* fix: Add or Update addressBook entry for the newly added owner

* Replace `.then` with `async/await`

* Optimize AddressBook entry `name` update

* fix: store added owner in the addressBook

* Revert "Optimize AddressBook entry `name` update"

This reverts commit 00a75d15

* refactor: AddressBook entry from plain JS object to immutable Record

* fix: merge instead of set for the AddressBookEntry record

* refactor: addOrUpdateAddressBookEntry redux action

changed signature to `addOrUpdateAddressBookEntry(entryAddress, entry)`
Where `entry` is an object with only the required fields to be updated

* refactor: update `addOrUpdateAddressBookEntry` call, due to signature change
This commit is contained in:
Fernando 2020-04-01 05:07:17 -03:00 committed by GitHub
parent 31a1565637
commit 315d516123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -3,12 +3,14 @@ import { withStyles } from '@material-ui/core/styles'
import { List } from 'immutable'
import { withSnackbar } from 'notistack'
import React, { useEffect, useState } from 'react'
import { useDispatch } from 'react-redux'
import OwnerForm from './screens/OwnerForm'
import ReviewAddOwner from './screens/Review'
import ThresholdForm from './screens/ThresholdForm'
import Modal from '~/components/Modal'
import { addOrUpdateAddressBookEntry } from '~/logic/addressBook/store/actions/addOrUpdateAddressBookEntry'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
import { type Owner } from '~/routes/safe/store/models/owner'
@ -77,6 +79,7 @@ const AddOwner = ({
safeName,
threshold,
}: Props) => {
const dispatch = useDispatch()
const [activeScreen, setActiveScreen] = useState<ActiveScreen>('selectOwner')
const [values, setValues] = useState<Object>({})
@ -115,8 +118,13 @@ const AddOwner = ({
const onAddOwner = async () => {
onClose()
try {
sendAddOwner(values, safeAddress, owners, enqueueSnackbar, closeSnackbar, createTransaction, addSafeOwner)
await sendAddOwner(values, safeAddress, owners, enqueueSnackbar, closeSnackbar, createTransaction, addSafeOwner)
dispatch(
addOrUpdateAddressBookEntry(values.ownerAddress, { name: values.ownerName, address: values.ownerAddress }),
)
} catch (error) {
console.error('Error while removing an owner', error)
}