Extract [string, string] as ModulePair type

This commit is contained in:
fernandomg 2020-07-14 17:02:15 -03:00
parent 79e80ea5e4
commit 012f0a9693
4 changed files with 9 additions and 7 deletions

View File

@ -1,12 +1,11 @@
import { List } from 'immutable' import { List } from 'immutable'
import { TableColumn } from 'src/routes/safe/components/tableTypes' import { TableColumn } from 'src/routes/safe/components/tableTypes'
import { ModulePair } from 'src/routes/safe/store/models/safe'
export const MODULES_TABLE_ADDRESS_ID = 'address' export const MODULES_TABLE_ADDRESS_ID = 'address'
export const MODULES_TABLE_ACTIONS_ID = 'actions' export const MODULES_TABLE_ACTIONS_ID = 'actions'
export const getModuleData = ( export const getModuleData = (modulesList: List<ModulePair>): List<{ [MODULES_TABLE_ADDRESS_ID]: ModulePair }> => {
modulesList: List<[string, string]>,
): List<{ [MODULES_TABLE_ADDRESS_ID]: [string, string] }> => {
return modulesList.map((modules) => ({ return modulesList.map((modules) => ({
[MODULES_TABLE_ADDRESS_ID]: modules, [MODULES_TABLE_ADDRESS_ID]: modules,
})) }))

View File

@ -35,6 +35,7 @@ import Link from 'src/components/layout/Link'
import OpenInNew from '@material-ui/icons/OpenInNew' import OpenInNew from '@material-ui/icons/OpenInNew'
import { getEtherScanLink } from 'src/logic/wallets/getWeb3' import { getEtherScanLink } from 'src/logic/wallets/getWeb3'
import { md, secondary } from 'src/theme/variables' import { md, secondary } from 'src/theme/variables'
import { ModulePair } from 'src/routes/safe/store/models/safe'
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'
@ -87,7 +88,7 @@ const Advanced = (): JSX.Element => {
const hideRemoveModuleModal = () => setViewRemoveModuleModal(false) const hideRemoveModuleModal = () => setViewRemoveModuleModal(false)
const [selectedModule, setSelectedModule] = React.useState(null) const [selectedModule, setSelectedModule] = React.useState(null)
const triggerRemoveSelectedModule = (module: [string, string]): void => { const triggerRemoveSelectedModule = (module: ModulePair): void => {
setSelectedModule(module) setSelectedModule(module)
setViewRemoveModuleModal(true) setViewRemoveModuleModal(true)
} }

View File

@ -13,7 +13,7 @@ import updateSafe from 'src/routes/safe/store/actions/updateSafe'
import { makeOwner } from 'src/routes/safe/store/models/owner' import { makeOwner } from 'src/routes/safe/store/models/owner'
import { checksumAddress } from 'src/utils/checksumAddress' import { checksumAddress } from 'src/utils/checksumAddress'
import { SafeOwner } from 'src/routes/safe/store/models/safe' import { ModulePair, SafeOwner } from 'src/routes/safe/store/models/safe'
import { Dispatch } from 'redux' import { Dispatch } from 'redux'
import addSafeModules from './addSafeModules' import addSafeModules from './addSafeModules'
import { SENTINEL_ADDRESS } from 'src/logic/contracts/safeContracts' import { SENTINEL_ADDRESS } from 'src/logic/contracts/safeContracts'
@ -39,7 +39,7 @@ const buildOwnersFrom = (
}) })
}) })
const buildModulesLinkedList = (modules: Array<string>, nextModule: string): Array<[string, string]> | null => { const buildModulesLinkedList = (modules: Array<string>, nextModule: string): Array<ModulePair> | null => {
if (modules?.length) { if (modules?.length) {
return modules.map((moduleAddress, index, modules) => { return modules.map((moduleAddress, index, modules) => {
const prevModule = modules[index + 1] const prevModule = modules[index + 1]

View File

@ -5,13 +5,15 @@ export type SafeOwner = {
address: string address: string
} }
export type ModulePair = [string, string]
export type SafeRecordProps = { export type SafeRecordProps = {
name: string name: string
address: string address: string
threshold: number threshold: number
ethBalance: string ethBalance: string
owners: List<{ name: string; address: string }> owners: List<{ name: string; address: string }>
modules: List<[string, string]> | null modules: List<ModulePair> | null
activeTokens: Set<string> activeTokens: Set<string>
activeAssets: Set<string> activeAssets: Set<string>
blacklistedTokens: Set<string> blacklistedTokens: Set<string>