Bug #352: Owner shown multiple times (#367)

* Ensure lowercased string comparison for owners' addresses

* Use `sameAddress` for addresses comparison
This commit is contained in:
Fernando 2019-12-17 15:36:06 -03:00 committed by Agustin Pane
parent a1546aaa0f
commit f864f62fa7
1 changed files with 4 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import { loadFromStorage } from '~/utils/storage'
import removeSafeOwner from '~/routes/safe/store/actions/removeSafeOwner' import removeSafeOwner from '~/routes/safe/store/actions/removeSafeOwner'
import addSafeOwner from '~/routes/safe/store/actions/addSafeOwner' import addSafeOwner from '~/routes/safe/store/actions/addSafeOwner'
import updateSafeThreshold from '~/routes/safe/store/actions/updateSafeThreshold' import updateSafeThreshold from '~/routes/safe/store/actions/updateSafeThreshold'
import { sameAddress } from '~/logic/wallets/ethAddresses'
const buildOwnersFrom = ( const buildOwnersFrom = (
safeOwners: string[], safeOwners: string[],
@ -59,16 +60,17 @@ export const checkAndUpdateSafe = (safeAddress: string) => async (dispatch: Redu
localSafe.threshold = threshold.toNumber() localSafe.threshold = threshold.toNumber()
dispatch(updateSafeThreshold({ safeAddress, threshold: threshold.toNumber() })) dispatch(updateSafeThreshold({ safeAddress, threshold: threshold.toNumber() }))
// If the remote owners does not contain a local address, we remove that local owner // If the remote owners does not contain a local address, we remove that local owner
localOwners.forEach((localAddress) => { localOwners.forEach((localAddress) => {
if (!remoteOwners.includes(localAddress)) { if (remoteOwners.findIndex((remoteAddress) => sameAddress(remoteAddress, localAddress)) !== -1) {
dispatch(removeSafeOwner({ safeAddress, ownerAddress: localAddress })) dispatch(removeSafeOwner({ safeAddress, ownerAddress: localAddress }))
} }
}) })
// If the remote has an owner that we don't have locally, we add it // If the remote has an owner that we don't have locally, we add it
remoteOwners.forEach((remoteAddress) => { remoteOwners.forEach((remoteAddress) => {
if (!localOwners.includes(remoteAddress)) { if (localOwners.findIndex((localAddress) => sameAddress(remoteAddress, localAddress)) !== -1) {
dispatch(addSafeOwner({ safeAddress, ownerAddress: remoteAddress, ownerName: 'UNKNOWN' })) dispatch(addSafeOwner({ safeAddress, ownerAddress: remoteAddress, ownerName: 'UNKNOWN' }))
} }
}) })