diff --git a/src/routes/safe/store/actions/fetchSafe.js b/src/routes/safe/store/actions/fetchSafe.js index a5e46efe..bc432893 100644 --- a/src/routes/safe/store/actions/fetchSafe.js +++ b/src/routes/safe/store/actions/fetchSafe.js @@ -7,7 +7,7 @@ import type { SafeProps } from '~/routes/safe/store/models/safe' import addSafe from '~/routes/safe/store/actions/addSafe' import { getSafeName, getLocalSafe } from '~/logic/safe/utils' import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' -import { getBalanceInEtherOf } from '~/logic/wallets/getWeb3' +import { getBalanceInEtherOf, getWeb3 } from '~/logic/wallets/getWeb3' import { sameAddress } from '~/logic/wallets/ethAddresses' import removeSafeOwner from '~/routes/safe/store/actions/removeSafeOwner' import addSafeOwner from '~/routes/safe/store/actions/addSafeOwner' @@ -33,7 +33,8 @@ const buildOwnersFrom = ( }) }) -export const buildSafe = async (safeAddress: string, safeName: string) => { +export const buildSafe = async (safeAdd: string, safeName: string) => { + const safeAddress = getWeb3().utils.toChecksumAddress(safeAdd) const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) const ethBalance = await getBalanceInEtherOf(safeAddress) @@ -53,7 +54,8 @@ export const buildSafe = async (safeAddress: string, safeName: string) => { return safe } -export const checkAndUpdateSafe = (safeAddress: string) => async (dispatch: ReduxDispatch<*>) => { +export const checkAndUpdateSafe = (safeAdd: string) => async (dispatch: ReduxDispatch<*>) => { + const safeAddress = getWeb3().utils.toChecksumAddress(safeAdd) // Check if the owner's safe did change and update them const [gnosisSafe, localSafe] = await Promise.all([getGnosisSafeInstanceAt(safeAddress), getLocalSafe(safeAddress)]) @@ -90,8 +92,9 @@ export const checkAndUpdateSafe = (safeAddress: string) => async (dispatch: Redu } // eslint-disable-next-line consistent-return -export default (safeAddress: string) => async (dispatch: ReduxDispatch) => { +export default (safeAdd: string) => async (dispatch: ReduxDispatch) => { try { + const safeAddress = getWeb3().utils.toChecksumAddress(safeAdd) const safeName = (await getSafeName(safeAddress)) || 'LOADED SAFE' const safeProps: SafeProps = await buildSafe(safeAddress, safeName) diff --git a/src/routes/safe/store/actions/loadDefaultSafe.js b/src/routes/safe/store/actions/loadDefaultSafe.js index ce151385..d5b3cc88 100644 --- a/src/routes/safe/store/actions/loadDefaultSafe.js +++ b/src/routes/safe/store/actions/loadDefaultSafe.js @@ -3,12 +3,14 @@ import type { Dispatch as ReduxDispatch } from 'redux' import { type GlobalState } from '~/store/index' import { getDefaultSafe } from '~/logic/safe/utils' import setDefaultSafe from './setDefaultSafe' +import { getWeb3 } from '~/logic/wallets/getWeb3' const loadDefaultSafe = () => async (dispatch: ReduxDispatch) => { try { const defaultSafe: string = await getDefaultSafe() - - dispatch(setDefaultSafe(defaultSafe)) + const checksumed = + defaultSafe && defaultSafe.length > 0 ? getWeb3().utils.toChecksumAddress(defaultSafe) : defaultSafe + dispatch(setDefaultSafe(checksumed)) } catch (err) { // eslint-disable-next-line console.error('Error while getting default Safe from storage:', err) diff --git a/src/routes/safe/store/reducer/safe.js b/src/routes/safe/store/reducer/safe.js index e9c6f241..64884098 100644 --- a/src/routes/safe/store/reducer/safe.js +++ b/src/routes/safe/store/reducer/safe.js @@ -13,6 +13,7 @@ import { REPLACE_SAFE_OWNER } from '~/routes/safe/store/actions/replaceSafeOwner import { EDIT_SAFE_OWNER } from '~/routes/safe/store/actions/editSafeOwner' import { SET_DEFAULT_SAFE } from '~/routes/safe/store/actions/setDefaultSafe' import { UPDATE_SAFE_THRESHOLD } from '~/routes/safe/store/actions/updateSafeThreshold' +import { getWeb3 } from '~/logic/wallets/getWeb3' export const SAFE_REDUCER_ID = 'safes' @@ -20,7 +21,10 @@ export type SafeReducerState = Map export const buildSafe = (storedSafe: SafeProps) => { const names = storedSafe.owners.map((owner: OwnerProps) => owner.name) - const addresses = storedSafe.owners.map((owner: OwnerProps) => owner.address) + const addresses = storedSafe.owners.map((owner: OwnerProps) => { + const checksumed = getWeb3().utils.toChecksumAddress(owner.address) + return checksumed + }) const owners = buildOwnersFrom(Array.from(names), Array.from(addresses)) const activeTokens = Set(storedSafe.activeTokens) const blacklistedTokens = Set(storedSafe.blacklistedTokens) diff --git a/src/routes/safe/store/selectors/index.js b/src/routes/safe/store/selectors/index.js index 49f71fb4..dfbe69c0 100644 --- a/src/routes/safe/store/selectors/index.js +++ b/src/routes/safe/store/selectors/index.js @@ -18,6 +18,7 @@ import { type Transaction } from '~/routes/safe/store/models/transaction' import { type Confirmation } from '~/routes/safe/store/models/confirmation' import { SAFE_REDUCER_ID } from '~/routes/safe/store/reducer/safe' import type { IncomingTransaction } from '~/routes/safe/store/models/incomingTransaction' +import { getWeb3 } from '~/logic/wallets/getWeb3' export type RouterProps = { match: Match, @@ -60,8 +61,10 @@ const incomingTransactionsSelector = (state: GlobalState): IncomingTransactionsS const oneTransactionSelector = (state: GlobalState, props: TransactionProps) => props.transaction -export const safeParamAddressSelector = (state: GlobalState, props: RouterProps) => - props.match.params[SAFE_PARAM_ADDRESS] || '' +export const safeParamAddressSelector = (state: GlobalState, props: RouterProps) => { + const urlAdd = props.match.params[SAFE_PARAM_ADDRESS] + return urlAdd ? getWeb3().utils.toChecksumAddress(urlAdd) : '' +} type TxSelectorType = Selector> @@ -156,8 +159,8 @@ export const safeSelector: Selector if (!address) { return undefined } - - const safe = safes.get(address) + const checksumed = getWeb3().utils.toChecksumAddress(address) + const safe = safes.get(checksumed) return safe },