(Fix) Lowercased safes address in URL (#631)

* Return checksummed addrress from `safeParamAddressFromState` selector

* Update `yarn.lock`

* Remove redundant `toChecksumAddress` call

Co-authored-by: Mikhail Mikheev <mmvsha73@gmail.com>
This commit is contained in:
Fernando 2020-03-09 11:08:28 -03:00 committed by GitHub
parent 558b9f69f7
commit 30cbada633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -111,10 +111,15 @@ export const safeCancellationTransactionsSelector: TxSelectorType = createSelect
},
)
export const safeParamAddressFromStateSelector = (state: GlobalState): string => {
export const safeParamAddressFromStateSelector = (state: GlobalState): string | null => {
const match = matchPath(state.router.location.pathname, { path: `${SAFELIST_ADDRESS}/:safeAddress` })
return match ? match.params.safeAddress : null
if (match) {
const web3 = getWeb3()
return web3.utils.toChecksumAddress(match.params.safeAddress)
}
return null
}
type IncomingTxSelectorType = OutputSelector<GlobalState, RouterProps, List<IncomingTransaction>>
@ -156,14 +161,12 @@ export type SafeSelectorProps = Safe | typeof undefined
export const safeSelector: OutputSelector<GlobalState, RouterProps, SafeSelectorProps> = createSelector(
safesMapSelector,
safeParamAddressFromStateSelector,
(safes: Map<string, Safe>, address: string) => {
(safes: Map<string, Safe>, address: string | null) => {
if (!address) {
return undefined
}
const checksumed = getWeb3().utils.toChecksumAddress(address)
const safe = safes.get(checksumed)
return safe
return safes.get(address)
},
)

View File

@ -52,6 +52,7 @@ const finalCreateStore = composeEnhancers(
export type GlobalState = {
providers: ProviderState,
router: RouterHistory,
safes: SafeState,
tokens: TokensState,
transactions: TransactionsState,