From f864f62fa7ea81628161737e8df2a955eedcde9e Mon Sep 17 00:00:00 2001 From: Fernando Date: Tue, 17 Dec 2019 15:36:06 -0300 Subject: [PATCH] Bug #352: Owner shown multiple times (#367) * Ensure lowercased string comparison for owners' addresses * Use `sameAddress` for addresses comparison --- src/routes/safe/store/actions/fetchSafe.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/safe/store/actions/fetchSafe.js b/src/routes/safe/store/actions/fetchSafe.js index 55eb19fa..427a905c 100644 --- a/src/routes/safe/store/actions/fetchSafe.js +++ b/src/routes/safe/store/actions/fetchSafe.js @@ -12,6 +12,7 @@ import { loadFromStorage } from '~/utils/storage' import removeSafeOwner from '~/routes/safe/store/actions/removeSafeOwner' import addSafeOwner from '~/routes/safe/store/actions/addSafeOwner' import updateSafeThreshold from '~/routes/safe/store/actions/updateSafeThreshold' +import { sameAddress } from '~/logic/wallets/ethAddresses' const buildOwnersFrom = ( safeOwners: string[], @@ -59,16 +60,17 @@ export const checkAndUpdateSafe = (safeAddress: string) => async (dispatch: Redu localSafe.threshold = threshold.toNumber() dispatch(updateSafeThreshold({ safeAddress, threshold: threshold.toNumber() })) + // If the remote owners does not contain a local address, we remove that local owner localOwners.forEach((localAddress) => { - if (!remoteOwners.includes(localAddress)) { + if (remoteOwners.findIndex((remoteAddress) => sameAddress(remoteAddress, localAddress)) !== -1) { dispatch(removeSafeOwner({ safeAddress, ownerAddress: localAddress })) } }) // If the remote has an owner that we don't have locally, we add it remoteOwners.forEach((remoteAddress) => { - if (!localOwners.includes(remoteAddress)) { + if (localOwners.findIndex((localAddress) => sameAddress(remoteAddress, localAddress)) !== -1) { dispatch(addSafeOwner({ safeAddress, ownerAddress: remoteAddress, ownerName: 'UNKNOWN' })) } })