WIP: code cleanup and fix typings
This commit is contained in:
parent
3eba845314
commit
ebf8d149a2
|
@ -4,7 +4,11 @@ import TableRow from '@material-ui/core/TableRow'
|
||||||
import TableSortLabel from '@material-ui/core/TableSortLabel'
|
import TableSortLabel from '@material-ui/core/TableSortLabel'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
|
|
||||||
export const cellWidth = (width) => {
|
interface CellWidth {
|
||||||
|
maxWidth: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const cellWidth = (width: string | number): CellWidth | undefined => {
|
||||||
if (!width) {
|
if (!width) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,17 +32,11 @@ export const WALLET_PROVIDER = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ETHEREUM_NETWORK_IDS = {
|
export const ETHEREUM_NETWORK_IDS = {
|
||||||
// $FlowFixMe
|
|
||||||
1: ETHEREUM_NETWORK.MAINNET,
|
1: ETHEREUM_NETWORK.MAINNET,
|
||||||
// $FlowFixMe
|
|
||||||
2: ETHEREUM_NETWORK.MORDEN,
|
2: ETHEREUM_NETWORK.MORDEN,
|
||||||
// $FlowFixMe
|
|
||||||
3: ETHEREUM_NETWORK.ROPSTEN,
|
3: ETHEREUM_NETWORK.ROPSTEN,
|
||||||
// $FlowFixMe
|
|
||||||
4: ETHEREUM_NETWORK.RINKEBY,
|
4: ETHEREUM_NETWORK.RINKEBY,
|
||||||
// $FlowFixMe
|
|
||||||
5: ETHEREUM_NETWORK.GOERLI,
|
5: ETHEREUM_NETWORK.GOERLI,
|
||||||
// $FlowFixMe
|
|
||||||
42: ETHEREUM_NETWORK.KOVAN,
|
42: ETHEREUM_NETWORK.KOVAN,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,15 @@ import { handleActions } from 'redux-actions'
|
||||||
|
|
||||||
import { ADD_PROVIDER } from 'src/logic/wallets/store/actions/addProvider'
|
import { ADD_PROVIDER } from 'src/logic/wallets/store/actions/addProvider'
|
||||||
import { REMOVE_PROVIDER } from 'src/logic/wallets/store/actions/removeProvider'
|
import { REMOVE_PROVIDER } from 'src/logic/wallets/store/actions/removeProvider'
|
||||||
import { makeProvider } from 'src/logic/wallets/store/model/provider'
|
import { makeProvider, ProviderRecord, ProviderProps } from 'src/logic/wallets/store/model/provider'
|
||||||
|
|
||||||
export const PROVIDER_REDUCER_ID = 'providers'
|
export const PROVIDER_REDUCER_ID = 'providers'
|
||||||
|
|
||||||
export default handleActions(
|
export default handleActions(
|
||||||
{
|
{
|
||||||
[ADD_PROVIDER]: (state, { payload }) => makeProvider(payload),
|
[ADD_PROVIDER]: (state: { providers: ProviderProps }, { payload }: { payload: ProviderProps }): ProviderRecord =>
|
||||||
[REMOVE_PROVIDER]: () => makeProvider(),
|
makeProvider(payload),
|
||||||
|
[REMOVE_PROVIDER]: (): ProviderRecord => makeProvider(),
|
||||||
},
|
},
|
||||||
makeProvider(),
|
makeProvider(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,28 +2,30 @@ import { createSelector } from 'reselect'
|
||||||
|
|
||||||
import { ETHEREUM_NETWORK, ETHEREUM_NETWORK_IDS } from 'src/logic/wallets/getWeb3'
|
import { ETHEREUM_NETWORK, ETHEREUM_NETWORK_IDS } from 'src/logic/wallets/getWeb3'
|
||||||
import { PROVIDER_REDUCER_ID } from 'src/logic/wallets/store/reducer/provider'
|
import { PROVIDER_REDUCER_ID } from 'src/logic/wallets/store/reducer/provider'
|
||||||
|
import { GnosisState } from 'src/store'
|
||||||
|
import { ProviderRecord } from '../model/provider'
|
||||||
|
|
||||||
export const providerSelector = (state) => state[PROVIDER_REDUCER_ID]
|
export const providerSelector = (state: GnosisState): ProviderRecord => state[PROVIDER_REDUCER_ID]
|
||||||
|
|
||||||
export const userAccountSelector = createSelector(providerSelector, (provider) => {
|
export const userAccountSelector = createSelector(providerSelector, (provider: ProviderRecord): string => {
|
||||||
const account = provider.get('account')
|
const account = provider.get('account')
|
||||||
|
|
||||||
return account || ''
|
return account || ''
|
||||||
})
|
})
|
||||||
|
|
||||||
export const providerNameSelector = createSelector(providerSelector, (provider) => {
|
export const providerNameSelector = createSelector(providerSelector, (provider: ProviderRecord): string | undefined => {
|
||||||
const name = provider.get('name')
|
const name = provider.get('name')
|
||||||
|
|
||||||
return name ? name.toLowerCase() : undefined
|
return name ? name.toLowerCase() : undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
export const networkSelector = createSelector(providerSelector, (provider) => {
|
export const networkSelector = createSelector(providerSelector, (provider: ProviderRecord): string => {
|
||||||
const networkId = provider.get('network')
|
const networkId = provider.get('network')
|
||||||
const network = ETHEREUM_NETWORK_IDS[networkId] || ETHEREUM_NETWORK.UNKNOWN
|
return ETHEREUM_NETWORK_IDS[networkId] || ETHEREUM_NETWORK.UNKNOWN
|
||||||
|
|
||||||
return network
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const loadedSelector = createSelector(providerSelector, (provider) => provider.get('loaded'))
|
export const loadedSelector = createSelector(providerSelector, (provider: ProviderRecord): boolean =>
|
||||||
|
provider.get('loaded'),
|
||||||
|
)
|
||||||
|
|
||||||
export const availableSelector = createSelector(providerSelector, (provider) => provider.get('available'))
|
export const availableSelector = createSelector(providerSelector, (provider: ProviderRecord): boolean =>
|
||||||
|
provider.get('available'),
|
||||||
|
)
|
||||||
|
|
|
@ -10,30 +10,31 @@ export const getModuleData = (modules: Set<string>): List<{ [MODULES_TABLE_ADDRE
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TableColumn {
|
interface TableColumn {
|
||||||
id: string
|
align?: 'inherit' | 'left' | 'center' | 'right' | 'justify'
|
||||||
order: boolean
|
|
||||||
disablePadding: boolean
|
|
||||||
label: string
|
|
||||||
custom: boolean
|
custom: boolean
|
||||||
align?: string
|
disablePadding: boolean
|
||||||
|
id: string
|
||||||
|
label: string
|
||||||
|
order: boolean
|
||||||
|
width?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generateColumns = (): List<TableColumn> => {
|
export const generateColumns = (): List<TableColumn> => {
|
||||||
const addressColumn: TableColumn = {
|
const addressColumn: TableColumn = {
|
||||||
id: MODULES_TABLE_ADDRESS_ID,
|
|
||||||
order: false,
|
|
||||||
disablePadding: false,
|
|
||||||
label: 'Address',
|
|
||||||
custom: false,
|
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
custom: false,
|
||||||
|
disablePadding: false,
|
||||||
|
id: MODULES_TABLE_ADDRESS_ID,
|
||||||
|
label: 'Address',
|
||||||
|
order: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const actionsColumn: TableColumn = {
|
const actionsColumn: TableColumn = {
|
||||||
id: MODULES_TABLE_ACTIONS_ID,
|
|
||||||
order: false,
|
|
||||||
disablePadding: false,
|
|
||||||
label: '',
|
|
||||||
custom: true,
|
custom: true,
|
||||||
|
disablePadding: false,
|
||||||
|
id: MODULES_TABLE_ACTIONS_ID,
|
||||||
|
label: '',
|
||||||
|
order: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
return List([addressColumn, actionsColumn])
|
return List([addressColumn, actionsColumn])
|
||||||
|
|
|
@ -1,101 +1,86 @@
|
||||||
import { Set } from 'immutable'
|
import { GenericModal, ModalFooterConfirmation } from '@gnosis.pm/safe-react-components'
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
// import { useSnackbar } from 'notistack'
|
import TableContainer from '@material-ui/core/TableContainer'
|
||||||
import React, { useState } from 'react'
|
|
||||||
import { /*useDispatch, */ useSelector } from 'react-redux'
|
|
||||||
import cn from 'classnames'
|
import cn from 'classnames'
|
||||||
|
import { Set } from 'immutable'
|
||||||
|
import { useSnackbar } from 'notistack'
|
||||||
|
import React from 'react'
|
||||||
|
import { useDispatch, useSelector } from 'react-redux'
|
||||||
|
|
||||||
// import ChangeThreshold from './ChangeThreshold'
|
import { generateColumns, MODULES_TABLE_ADDRESS_ID, getModuleData } from './dataFetcher'
|
||||||
import { styles } from './style'
|
import { styles } from './style'
|
||||||
|
import BinIcon from '../assets/icons/bin.svg'
|
||||||
|
|
||||||
import Modal from 'src/components/Modal'
|
import DividerLine from 'src/components/DividerLine'
|
||||||
|
import Identicon from 'src/components/Identicon'
|
||||||
import Block from 'src/components/layout/Block'
|
import Block from 'src/components/layout/Block'
|
||||||
import Bold from 'src/components/layout/Bold'
|
import Bold from 'src/components/layout/Bold'
|
||||||
// import Button from 'src/components/layout/Button'
|
|
||||||
import Heading from 'src/components/layout/Heading'
|
import Heading from 'src/components/layout/Heading'
|
||||||
|
import Img from 'src/components/layout/Img'
|
||||||
import Paragraph from 'src/components/layout/Paragraph'
|
import Paragraph from 'src/components/layout/Paragraph'
|
||||||
// import Row from 'src/components/layout/Row'
|
import Row from 'src/components/layout/Row'
|
||||||
// import { getGnosisSafeInstanceAt } from 'src/logic/contracts/safeContracts'
|
import { TableCell, TableRow } from 'src/components/layout/Table'
|
||||||
// import { TX_NOTIFICATION_TYPES } from 'src/logic/safe/transactions'
|
import Table from 'src/components/Table'
|
||||||
// import { grantedSelector } from 'src/routes/safe/container/selector'
|
|
||||||
// import createTransaction from 'src/routes/safe/store/actions/createTransaction'
|
import { getGnosisSafeInstanceAt } from 'src/logic/contracts/safeContracts'
|
||||||
|
import { TX_NOTIFICATION_TYPES } from 'src/logic/safe/transactions'
|
||||||
|
import { grantedSelector } from 'src/routes/safe/container/selector'
|
||||||
|
import createTransaction from 'src/routes/safe/store/actions/createTransaction'
|
||||||
import {
|
import {
|
||||||
// safeOwnersSelector,
|
safeParamAddressFromStateSelector,
|
||||||
// safeParamAddressFromStateSelector,
|
|
||||||
// safeThresholdSelector,
|
|
||||||
safeNonceSelector,
|
safeNonceSelector,
|
||||||
safeModulesSelector,
|
safeModulesSelector,
|
||||||
} from 'src/routes/safe/store/selectors'
|
} from 'src/routes/safe/store/selectors'
|
||||||
import DividerLine from 'src/components/DividerLine'
|
|
||||||
import TableContainer from '@material-ui/core/TableContainer'
|
|
||||||
import Table from '../../../../../components/Table'
|
|
||||||
import TableRow from '@material-ui/core/TableRow'
|
|
||||||
import TableCell from '@material-ui/core/TableCell'
|
|
||||||
import { cellWidth } from '../../../../../components/Table/TableHead'
|
|
||||||
import OwnerAddressTableCell from '../ManageOwners/OwnerAddressTableCell'
|
|
||||||
import Row from '../../../../../components/layout/Row'
|
|
||||||
import Img from '../../../../../components/layout/Img'
|
|
||||||
// import RenameOwnerIcon from '../ManageOwners/assets/icons/rename-owner.svg'
|
|
||||||
// import ReplaceOwnerIcon from '../ManageOwners/assets/icons/replace-owner.svg'
|
|
||||||
import RemoveOwnerIcon from '../assets/icons/bin.svg'
|
|
||||||
import { generateColumns, MODULES_TABLE_ADDRESS_ID, getModuleData } from './dataFetcher'
|
|
||||||
import { grantedSelector } from '../../../container/selector'
|
|
||||||
// import RemoveOwnerModal from '../ManageOwners/RemoveOwnerModal'
|
|
||||||
// import { getOwnersWithNameFromAddressBook } from '../../../../../logic/addressBook/utils'
|
|
||||||
// import { getOwnerData } from '../ManageOwners/dataFetcher'
|
|
||||||
|
|
||||||
export const REMOVE_MODULE_BTN_TEST_ID = 'remove-module-btn'
|
export const REMOVE_MODULE_BTN_TEST_ID = 'remove-module-btn'
|
||||||
export const MODULES_ROW_TEST_ID = 'owners-row'
|
export const MODULES_ROW_TEST_ID = 'owners-row'
|
||||||
|
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
const useToggle = (initialOn = false) => {
|
|
||||||
const [on, setOn] = useState(initialOn)
|
|
||||||
const toggle = () => setOn(!on)
|
|
||||||
|
|
||||||
return { on, toggle }
|
|
||||||
}
|
|
||||||
|
|
||||||
const Advanced: React.FC = () => {
|
const Advanced: React.FC = () => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
const columns = generateColumns()
|
const columns = generateColumns()
|
||||||
const autoColumns = columns.filter(({ custom }) => !custom)
|
const autoColumns = columns.filter(({ custom }) => !custom)
|
||||||
|
|
||||||
// const { enqueueSnackbar, closeSnackbar } = useSnackbar()
|
const safeAddress = useSelector(safeParamAddressFromStateSelector)
|
||||||
// const dispatch = useDispatch()
|
|
||||||
|
|
||||||
const { on, toggle } = useToggle()
|
|
||||||
|
|
||||||
const nonce = useSelector(safeNonceSelector)
|
const nonce = useSelector(safeNonceSelector)
|
||||||
const granted = useSelector(grantedSelector)
|
const granted = useSelector(grantedSelector)
|
||||||
const modules = useSelector(safeModulesSelector)
|
const modules = useSelector(safeModulesSelector)
|
||||||
console.log(modules)
|
|
||||||
const moduleData = getModuleData(Set(modules))
|
const moduleData = getModuleData(Set(modules))
|
||||||
// const ownersAdbk = getOwnersWithNameFromAddressBook(addressBook, owners)
|
|
||||||
// const ownerData = getOwnerData(ownersAdbk)
|
|
||||||
|
|
||||||
// const safeAddress = useSelector(safeParamAddressFromStateSelector)
|
const [viewRemoveModuleModal, setViewRemoveModuleModal] = React.useState(false)
|
||||||
// const owners = useSelector(safeOwnersSelector)
|
const hideRemoveModuleModal = () => setViewRemoveModuleModal(false)
|
||||||
|
|
||||||
// const onChangeThreshold = async (newThreshold) => {
|
const [selectedModule, setSelectedModule] = React.useState(null)
|
||||||
// const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
|
const triggerRemoveSelectedModule = (moduleAddress: string): void => {
|
||||||
// const txData = safeInstance.contract.methods.changeThreshold(newThreshold).encodeABI()
|
setSelectedModule(moduleAddress)
|
||||||
//
|
setViewRemoveModuleModal(true)
|
||||||
// dispatch(
|
}
|
||||||
// createTransaction({
|
|
||||||
// safeAddress,
|
const { enqueueSnackbar, closeSnackbar } = useSnackbar()
|
||||||
// to: safeAddress,
|
const dispatch = useDispatch()
|
||||||
// valueInWei: 0,
|
|
||||||
// txData,
|
const removeSelectedModule = async (): Promise<void> => {
|
||||||
// notifiedTransaction: TX_NOTIFICATION_TYPES.SETTINGS_CHANGE_TX,
|
const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
|
||||||
// enqueueSnackbar,
|
const txData = safeInstance.contract.methods.disableModule(selectedModule).encodeABI()
|
||||||
// closeSnackbar,
|
|
||||||
// } as any),
|
dispatch(
|
||||||
// )
|
createTransaction({
|
||||||
// }
|
safeAddress,
|
||||||
|
to: safeAddress,
|
||||||
|
valueInWei: '0',
|
||||||
|
txData,
|
||||||
|
notifiedTransaction: TX_NOTIFICATION_TYPES.SETTINGS_CHANGE_TX,
|
||||||
|
enqueueSnackbar,
|
||||||
|
closeSnackbar,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{/* Nonce */}
|
||||||
<Block className={classes.container}>
|
<Block className={classes.container}>
|
||||||
<Heading tag="h2">Safe Nonce</Heading>
|
<Heading tag="h2">Safe Nonce</Heading>
|
||||||
<Paragraph>
|
<Paragraph>
|
||||||
|
@ -107,6 +92,8 @@ const Advanced: React.FC = () => {
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</Block>
|
</Block>
|
||||||
<DividerLine withArrow={false} />
|
<DividerLine withArrow={false} />
|
||||||
|
|
||||||
|
{/* Modules */}
|
||||||
<Block className={classes.container}>
|
<Block className={classes.container}>
|
||||||
<Heading tag="h2">Safe Modules</Heading>
|
<Heading tag="h2">Safe Modules</Heading>
|
||||||
<Paragraph>
|
<Paragraph>
|
||||||
|
@ -145,23 +132,31 @@ const Advanced: React.FC = () => {
|
||||||
key={index}
|
key={index}
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
>
|
>
|
||||||
{autoColumns.map((column: any) => (
|
{autoColumns.map((column) => {
|
||||||
<TableCell align={column.align} component="td" key={column.id} style={cellWidth(column.width)}>
|
const columnId = column.id
|
||||||
{column.id === MODULES_TABLE_ADDRESS_ID ? (
|
const rowElement = row[columnId]
|
||||||
<OwnerAddressTableCell address={row[column.id]} showLinks />
|
|
||||||
) : (
|
return (
|
||||||
row[column.id]
|
<TableCell align={column.align} component="td" key={columnId}>
|
||||||
)}
|
{columnId === MODULES_TABLE_ADDRESS_ID ? (
|
||||||
</TableCell>
|
<Block justify="left">
|
||||||
))}
|
<Identicon address={rowElement} diameter={32} />
|
||||||
|
<Paragraph style={{ marginLeft: 10 }}>{rowElement}</Paragraph>
|
||||||
|
</Block>
|
||||||
|
) : (
|
||||||
|
rowElement
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
)
|
||||||
|
})}
|
||||||
<TableCell component="td">
|
<TableCell component="td">
|
||||||
<Row align="end" className={classes.actions}>
|
<Row align="end" className={classes.actions}>
|
||||||
{granted && (
|
{granted && (
|
||||||
<Img
|
<Img
|
||||||
alt="Remove module"
|
alt="Remove module"
|
||||||
className={classes.removeModuleIcon}
|
className={classes.removeModuleIcon}
|
||||||
onClick={toggle}
|
onClick={triggerRemoveSelectedModule}
|
||||||
src={RemoveOwnerIcon}
|
src={BinIcon}
|
||||||
testId={REMOVE_MODULE_BTN_TEST_ID}
|
testId={REMOVE_MODULE_BTN_TEST_ID}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -174,21 +169,21 @@ const Advanced: React.FC = () => {
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
)}
|
)}
|
||||||
</Block>
|
</Block>
|
||||||
{/*<RemoveModuleModal*/}
|
{viewRemoveModuleModal && (
|
||||||
{/* isOpen={showRemoveModal}*/}
|
<GenericModal
|
||||||
{/* onClose={onHide('RemoveModal')}*/}
|
onClose={hideRemoveModuleModal}
|
||||||
{/* ownerAddress={selectedModalAddress}*/}
|
title="Disable Module"
|
||||||
{/* ownerName={selectedModalName}*/}
|
body={<div>This is the body</div>}
|
||||||
{/*/>*/}
|
footer={
|
||||||
<Modal description="Disable Module" handleClose={toggle} open={on} title="Disable Module">
|
<ModalFooterConfirmation
|
||||||
{/*<ChangeThreshold*/}
|
okText="Remove"
|
||||||
{/* onChangeThreshold={onChangeThreshold}*/}
|
cancelText="Cancel"
|
||||||
{/* onClose={toggle}*/}
|
handleCancel={hideRemoveModuleModal}
|
||||||
{/* owners={owners}*/}
|
handleOk={removeSelectedModule}
|
||||||
{/* safeAddress={safeAddress}*/}
|
/>
|
||||||
{/* threshold={threshold}*/}
|
}
|
||||||
{/*/>*/}
|
/>
|
||||||
</Modal>
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { push } from 'connected-react-router'
|
import { push } from 'connected-react-router'
|
||||||
import { List, Map } from 'immutable'
|
import { List, Map } from 'immutable'
|
||||||
|
import { WithSnackbarProps } from 'notistack'
|
||||||
import { batch } from 'react-redux'
|
import { batch } from 'react-redux'
|
||||||
import semverSatisfies from 'semver/functions/satisfies'
|
import semverSatisfies from 'semver/functions/satisfies'
|
||||||
|
|
||||||
|
@ -35,6 +36,8 @@ import { makeConfirmation } from '../models/confirmation'
|
||||||
import fetchTransactions from './transactions/fetchTransactions'
|
import fetchTransactions from './transactions/fetchTransactions'
|
||||||
import { safeTransactionsSelector } from 'src/routes/safe/store/selectors'
|
import { safeTransactionsSelector } from 'src/routes/safe/store/selectors'
|
||||||
import { TransactionStatus, TxArgs } from 'src/routes/safe/store/models/types/transaction'
|
import { TransactionStatus, TxArgs } from 'src/routes/safe/store/models/types/transaction'
|
||||||
|
import { Dispatch } from 'redux'
|
||||||
|
import { GnosisState } from 'src/store'
|
||||||
|
|
||||||
export const removeTxFromStore = (tx, safeAddress, dispatch, state) => {
|
export const removeTxFromStore = (tx, safeAddress, dispatch, state) => {
|
||||||
if (tx.isCancellationTx) {
|
if (tx.isCancellationTx) {
|
||||||
|
@ -79,6 +82,18 @@ export const storeTx = async (tx, safeAddress, dispatch, state) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CreateTransaction extends WithSnackbarProps {
|
||||||
|
navigateToTransactionsTab?: boolean
|
||||||
|
notifiedTransaction: string
|
||||||
|
operation?: number
|
||||||
|
origin?: string
|
||||||
|
safeAddress: string
|
||||||
|
to: string
|
||||||
|
txData: string
|
||||||
|
txNonce?: number | string
|
||||||
|
valueInWei: string
|
||||||
|
}
|
||||||
|
|
||||||
const createTransaction = ({
|
const createTransaction = ({
|
||||||
safeAddress,
|
safeAddress,
|
||||||
to,
|
to,
|
||||||
|
@ -91,7 +106,7 @@ const createTransaction = ({
|
||||||
operation = CALL,
|
operation = CALL,
|
||||||
navigateToTransactionsTab = true,
|
navigateToTransactionsTab = true,
|
||||||
origin = null,
|
origin = null,
|
||||||
}) => async (dispatch, getState) => {
|
}: CreateTransaction) => async (dispatch: Dispatch, getState: () => GnosisState): Promise<void> => {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
|
|
||||||
if (navigateToTransactionsTab) {
|
if (navigateToTransactionsTab) {
|
||||||
|
|
|
@ -181,7 +181,7 @@ const baseSafe = makeSafe()
|
||||||
|
|
||||||
export const safeFieldSelector = (field: keyof SafeRecordProps) => (
|
export const safeFieldSelector = (field: keyof SafeRecordProps) => (
|
||||||
safe: SafeRecord,
|
safe: SafeRecord,
|
||||||
): SafeRecord[keyof SafeRecordProps] => safe.get(field, baseSafe.get(field))
|
): SafeRecord[keyof SafeRecordProps] | null => (safe ? safe.get(field, baseSafe.get(field)) : null)
|
||||||
|
|
||||||
export const safeNameSelector = createSelector(safeSelector, safeFieldSelector('name'))
|
export const safeNameSelector = createSelector(safeSelector, safeFieldSelector('name'))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connectRouter, routerMiddleware } from 'connected-react-router'
|
import { connectRouter, routerMiddleware } from 'connected-react-router'
|
||||||
import { createHashHistory } from 'history'
|
import { createHashHistory } from 'history'
|
||||||
import { applyMiddleware, combineReducers, compose, createStore } from 'redux'
|
import { applyMiddleware, combineReducers, compose, createStore, CombinedState } from 'redux'
|
||||||
import thunk from 'redux-thunk'
|
import thunk from 'redux-thunk'
|
||||||
|
|
||||||
import addressBookMiddleware from 'src/logic/addressBook/store/middleware/addressBookMiddleware'
|
import addressBookMiddleware from 'src/logic/addressBook/store/middleware/addressBookMiddleware'
|
||||||
|
@ -29,6 +29,8 @@ import incomingTransactions, {
|
||||||
} from 'src/routes/safe/store/reducer/incomingTransactions'
|
} from 'src/routes/safe/store/reducer/incomingTransactions'
|
||||||
import safe, { SAFE_REDUCER_ID } from 'src/routes/safe/store/reducer/safe'
|
import safe, { SAFE_REDUCER_ID } from 'src/routes/safe/store/reducer/safe'
|
||||||
import transactions, { TRANSACTIONS_REDUCER_ID } from 'src/routes/safe/store/reducer/transactions'
|
import transactions, { TRANSACTIONS_REDUCER_ID } from 'src/routes/safe/store/reducer/transactions'
|
||||||
|
import { ProviderRecord } from '../logic/wallets/store/model/provider'
|
||||||
|
import { SafeRecordProps } from '../routes/safe/store/models/safe'
|
||||||
|
|
||||||
export const history = createHashHistory({ hashType: 'slash' })
|
export const history = createHashHistory({ hashType: 'slash' })
|
||||||
|
|
||||||
|
@ -63,6 +65,22 @@ const reducers = combineReducers({
|
||||||
[CURRENT_SESSION_REDUCER_ID]: currentSession,
|
[CURRENT_SESSION_REDUCER_ID]: currentSession,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export type GnosisState = CombinedState<{
|
||||||
|
[PROVIDER_REDUCER_ID]: ProviderRecord
|
||||||
|
[SAFE_REDUCER_ID]: SafeRecordProps
|
||||||
|
// [NFT_ASSETS_REDUCER_ID]: nftAssetReducer,
|
||||||
|
// [NFT_TOKENS_REDUCER_ID]: nftTokensReducer,
|
||||||
|
// [TOKEN_REDUCER_ID]: tokens,
|
||||||
|
// [TRANSACTIONS_REDUCER_ID]: transactions,
|
||||||
|
// [CANCELLATION_TRANSACTIONS_REDUCER_ID]: cancellationTransactions,
|
||||||
|
// [INCOMING_TRANSACTIONS_REDUCER_ID]: incomingTransactions,
|
||||||
|
// [NOTIFICATIONS_REDUCER_ID]: notifications,
|
||||||
|
// [CURRENCY_VALUES_KEY]: currencyValues,
|
||||||
|
// [COOKIES_REDUCER_ID]: cookies,
|
||||||
|
// [ADDRESS_BOOK_REDUCER_ID]: addressBook,
|
||||||
|
// [CURRENT_SESSION_REDUCER_ID]: currentSession,
|
||||||
|
}>
|
||||||
|
|
||||||
export const store: any = createStore(reducers, finalCreateStore)
|
export const store: any = createStore(reducers, finalCreateStore)
|
||||||
|
|
||||||
export const aNewStore = (localState?: any) => createStore(reducers, localState, finalCreateStore)
|
export const aNewStore = (localState?: any) => createStore(reducers, localState, finalCreateStore)
|
||||||
|
|
Loading…
Reference in New Issue