Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Use hash history #638

Merged
merged 6 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type DecodedTxData = {
customTx?: boolean,
creationTx?: boolean,
data: string,
upgradeTx: boolean,
}

const getSafeVersion = (data: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/safe/store/models/safe.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type SafeProps = {
blacklistedTokens: Set<string>,
ethBalance?: string,
nonce: number,
latestIncomingTxBlock: number,
latestIncomingTxBlock?: number,
recurringUser?: boolean,
}

Expand Down
1 change: 1 addition & 0 deletions src/routes/safe/store/models/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type TransactionStatus =
| 'cancelled'
| 'awaiting_execution'
| 'pending'
| 'third-party-app'

export type TransactionProps = {
nonce: ?number,
Expand Down
26 changes: 13 additions & 13 deletions src/routes/safe/store/selectors/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import { List, Map, Set } from 'immutable'
import { type Match, matchPath } from 'react-router-dom'
import { type Selector, createSelector, createStructuredSelector } from 'reselect'
import { type OutputSelector, createSelector, createStructuredSelector } from 'reselect'

import { getWeb3 } from '~/logic/wallets/getWeb3'
import { SAFELIST_ADDRESS, SAFE_PARAM_ADDRESS } from '~/routes/routes'
Expand Down Expand Up @@ -37,17 +37,17 @@ const safesStateSelector = (state: GlobalState): Map<string, *> => state[SAFE_RE

export const safesMapSelector = (state: GlobalState): Map<string, Safe> => state[SAFE_REDUCER_ID].get('safes')

export const safesListSelector: Selector<GlobalState, {}, List<Safe>> = createSelector(
export const safesListSelector: OutputSelector<GlobalState, {}, List<Safe>> = createSelector(
safesMapSelector,
(safes: Map<string, Safe>): List<Safe> => safes.toList(),
)

export const safesCountSelector: Selector<GlobalState, {}, number> = createSelector(
export const safesCountSelector: OutputSelector<GlobalState, {}, number> = createSelector(
safesMapSelector,
(safes: Map<string, Safe>): number => safes.size,
)

export const defaultSafeSelector: Selector<GlobalState, {}, string> = createSelector(
export const defaultSafeSelector: OutputSelector<GlobalState, {}, string> = createSelector(
safesStateSelector,
(safeState: Map<string, *>): string => safeState.get('defaultSafe'),
)
Expand All @@ -67,7 +67,7 @@ export const safeParamAddressSelector = (state: GlobalState, props: RouterProps)
return urlAdd ? getWeb3().utils.toChecksumAddress(urlAdd) : ''
}

type TxSelectorType = Selector<GlobalState, RouterProps, List<Transaction>>
type TxSelectorType = OutputSelector<GlobalState, RouterProps, List<Transaction>>

export const safeTransactionsSelector: TxSelectorType = createSelector(
transactionsSelector,
Expand Down Expand Up @@ -117,7 +117,7 @@ export const safeParamAddressFromStateSelector = (state: GlobalState): string =>
return match ? match.params.safeAddress : null
}

type IncomingTxSelectorType = Selector<GlobalState, RouterProps, List<IncomingTransaction>>
type IncomingTxSelectorType = OutputSelector<GlobalState, RouterProps, List<IncomingTransaction>>

export const safeIncomingTransactionsSelector: IncomingTxSelectorType = createSelector(
incomingTransactionsSelector,
Expand All @@ -135,7 +135,7 @@ export const safeIncomingTransactionsSelector: IncomingTxSelectorType = createSe
},
)

export const confirmationsTransactionSelector: Selector<GlobalState, TransactionProps, number> = createSelector(
export const confirmationsTransactionSelector: OutputSelector<GlobalState, TransactionProps, number> = createSelector(
oneTransactionSelector,
(tx: Transaction) => {
if (!tx) {
Expand All @@ -153,7 +153,7 @@ export const confirmationsTransactionSelector: Selector<GlobalState, Transaction

export type SafeSelectorProps = Safe | typeof undefined

export const safeSelector: Selector<GlobalState, RouterProps, SafeSelectorProps> = createSelector(
export const safeSelector: OutputSelector<GlobalState, RouterProps, SafeSelectorProps> = createSelector(
safesMapSelector,
safeParamAddressFromStateSelector,
(safes: Map<string, Safe>, address: string) => {
Expand All @@ -167,7 +167,7 @@ export const safeSelector: Selector<GlobalState, RouterProps, SafeSelectorProps>
},
)

export const safeActiveTokensSelector: Selector<GlobalState, RouterProps, List<string>> = createSelector(
export const safeActiveTokensSelector: OutputSelector<GlobalState, RouterProps, List<string>> = createSelector(
safeSelector,
(safe: Safe) => {
if (!safe) {
Expand All @@ -178,7 +178,7 @@ export const safeActiveTokensSelector: Selector<GlobalState, RouterProps, List<s
},
)

export const safeBlacklistedTokensSelector: Selector<GlobalState, RouterProps, List<string>> = createSelector(
export const safeBlacklistedTokensSelector: OutputSelector<GlobalState, RouterProps, List<string>> = createSelector(
safeSelector,
(safe: Safe) => {
if (!safe) {
Expand All @@ -195,7 +195,7 @@ export const safeActiveTokensSelectorBySafe = (safeAddress: string, safes: Map<s
export const safeBlacklistedTokensSelectorBySafe = (safeAddress: string, safes: Map<string, Safe>): List<string> =>
safes.get(safeAddress).get('blacklistedTokens')

export const safeBalancesSelector: Selector<GlobalState, RouterProps, Map<string, string>> = createSelector(
export const safeBalancesSelector: OutputSelector<GlobalState, RouterProps, Map<string, string>> = createSelector(
safeSelector,
(safe: Safe) => {
if (!safe) {
Expand All @@ -206,7 +206,7 @@ export const safeBalancesSelector: Selector<GlobalState, RouterProps, Map<string
},
)

export const getActiveTokensAddressesForAllSafes: Selector<GlobalState, any, Set<string>> = createSelector(
export const getActiveTokensAddressesForAllSafes: OutputSelector<GlobalState, any, Set<string>> = createSelector(
safesListSelector,
(safes: List<Safe>) => {
const addresses = Set().withMutations(set => {
Expand All @@ -221,7 +221,7 @@ export const getActiveTokensAddressesForAllSafes: Selector<GlobalState, any, Set
},
)

export const getBlacklistedTokensAddressesForAllSafes: Selector<GlobalState, any, Set<string>> = createSelector(
export const getBlacklistedTokensAddressesForAllSafes: OutputSelector<GlobalState, any, Set<string>> = createSelector(
safesListSelector,
(safes: List<Safe>) => {
const addresses = Set().withMutations(set => {
Expand Down
4 changes: 2 additions & 2 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import { connectRouter, routerMiddleware } from 'connected-react-router'
import { createBrowserHistory } from 'history'
import { createHashHistory } from 'history'
import { type CombinedReducer, type Store, applyMiddleware, combineReducers, compose, createStore } from 'redux'
import thunk from 'redux-thunk'

Expand Down Expand Up @@ -35,7 +35,7 @@ import transactions, {
type State as TransactionsState,
} from '~/routes/safe/store/reducer/transactions'

export const history = createBrowserHistory({ basename: '/app/' })
export const history = createHashHistory({ hashType: 'slash' })

// eslint-disable-next-line
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
Expand Down