From 012f0a969323a94f82bb77f326156f8fccd2ca42 Mon Sep 17 00:00:00 2001 From: fernandomg Date: Tue, 14 Jul 2020 17:02:15 -0300 Subject: [PATCH] Extract [string, string] as ModulePair type --- src/routes/safe/components/Settings/Advanced/dataFetcher.ts | 5 ++--- src/routes/safe/components/Settings/Advanced/index.tsx | 3 ++- src/routes/safe/store/actions/fetchSafe.ts | 4 ++-- src/routes/safe/store/models/safe.ts | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/routes/safe/components/Settings/Advanced/dataFetcher.ts b/src/routes/safe/components/Settings/Advanced/dataFetcher.ts index 1e6965c9..a62f6d6f 100644 --- a/src/routes/safe/components/Settings/Advanced/dataFetcher.ts +++ b/src/routes/safe/components/Settings/Advanced/dataFetcher.ts @@ -1,12 +1,11 @@ import { List } from 'immutable' 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_ACTIONS_ID = 'actions' -export const getModuleData = ( - modulesList: List<[string, string]>, -): List<{ [MODULES_TABLE_ADDRESS_ID]: [string, string] }> => { +export const getModuleData = (modulesList: List): List<{ [MODULES_TABLE_ADDRESS_ID]: ModulePair }> => { return modulesList.map((modules) => ({ [MODULES_TABLE_ADDRESS_ID]: modules, })) diff --git a/src/routes/safe/components/Settings/Advanced/index.tsx b/src/routes/safe/components/Settings/Advanced/index.tsx index 545e95ef..91a2e70a 100644 --- a/src/routes/safe/components/Settings/Advanced/index.tsx +++ b/src/routes/safe/components/Settings/Advanced/index.tsx @@ -35,6 +35,7 @@ import Link from 'src/components/layout/Link' import OpenInNew from '@material-ui/icons/OpenInNew' import { getEtherScanLink } from 'src/logic/wallets/getWeb3' 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 MODULES_ROW_TEST_ID = 'owners-row' @@ -87,7 +88,7 @@ const Advanced = (): JSX.Element => { const hideRemoveModuleModal = () => setViewRemoveModuleModal(false) const [selectedModule, setSelectedModule] = React.useState(null) - const triggerRemoveSelectedModule = (module: [string, string]): void => { + const triggerRemoveSelectedModule = (module: ModulePair): void => { setSelectedModule(module) setViewRemoveModuleModal(true) } diff --git a/src/routes/safe/store/actions/fetchSafe.ts b/src/routes/safe/store/actions/fetchSafe.ts index 11beb9e6..2d65639e 100644 --- a/src/routes/safe/store/actions/fetchSafe.ts +++ b/src/routes/safe/store/actions/fetchSafe.ts @@ -13,7 +13,7 @@ import updateSafe from 'src/routes/safe/store/actions/updateSafe' import { makeOwner } from 'src/routes/safe/store/models/owner' 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 addSafeModules from './addSafeModules' import { SENTINEL_ADDRESS } from 'src/logic/contracts/safeContracts' @@ -39,7 +39,7 @@ const buildOwnersFrom = ( }) }) -const buildModulesLinkedList = (modules: Array, nextModule: string): Array<[string, string]> | null => { +const buildModulesLinkedList = (modules: Array, nextModule: string): Array | null => { if (modules?.length) { return modules.map((moduleAddress, index, modules) => { const prevModule = modules[index + 1] diff --git a/src/routes/safe/store/models/safe.ts b/src/routes/safe/store/models/safe.ts index 9cceb7e1..2abfa566 100644 --- a/src/routes/safe/store/models/safe.ts +++ b/src/routes/safe/store/models/safe.ts @@ -5,13 +5,15 @@ export type SafeOwner = { address: string } +export type ModulePair = [string, string] + export type SafeRecordProps = { name: string address: string threshold: number ethBalance: string owners: List<{ name: string; address: string }> - modules: List<[string, string]> | null + modules: List | null activeTokens: Set activeAssets: Set blacklistedTokens: Set