diff --git a/src/components/Table/index.jsx b/src/components/Table/index.jsx index 6c85880d..66785a9d 100644 --- a/src/components/Table/index.jsx +++ b/src/components/Table/index.jsx @@ -28,6 +28,7 @@ type State = { orderBy: string, orderProp: boolean, rowsPerPage: number, + fixed: boolean, } const styles = { diff --git a/src/components/Table/sorting.js b/src/components/Table/sorting.js index dbb5152a..e41f8f13 100644 --- a/src/components/Table/sorting.js +++ b/src/components/Table/sorting.js @@ -1,10 +1,12 @@ // @flow export const FIXED = 'fixed' -export type SortRow = { - [FIXED]: boolean, +type Fixed = { + fixed?: boolean, } +export type SortRow = T & Fixed + export const buildOrderFieldFrom = (attr: string) => `${attr}Order` @@ -21,9 +23,10 @@ const desc = (a: Object, b: Object, orderBy: string, orderProp: boolean) => { return 0 } -export const stableSort = (array: any, cmp: any, fixed: boolean) => { - const fixedElems = fixed ? array.filter(elem => elem[FIXED]) : [] - const data = fixed ? array.filter(elem => !elem[FIXED]) : array +// eslint-disable-next-line +export const stableSort = (array: Array, cmp: any, fixed: boolean): Array => { + const fixedElems: Array = fixed ? array.filter((elem: any) => elem.fixed) : [] + const data: Array = fixed ? array.filter((elem: any) => !elem[FIXED]) : array const stabilizedThis = data.map((el, index) => [el, index]) stabilizedThis.sort((a, b) => { @@ -35,7 +38,7 @@ export const stableSort = (array: any, cmp: any, fixed: boolean) => { return a[1] - b[1] }) - const sortedElems = stabilizedThis.map(el => el[0]) + const sortedElems: Array = stabilizedThis.map(el => el[0]) return fixedElems.concat(sortedElems) } diff --git a/src/routes/safe/component/Balances/dataFetcher.js b/src/routes/safe/component/Balances/dataFetcher.js index 13a00bde..0ad3f405 100644 --- a/src/routes/safe/component/Balances/dataFetcher.js +++ b/src/routes/safe/component/Balances/dataFetcher.js @@ -7,12 +7,13 @@ export const BALANCE_TABLE_ASSET_ID = 'asset' export const BALANCE_TABLE_BALANCE_ID = 'balance' export const BALANCE_TABLE_VALUE_ID = 'value' -export type BalanceRow = SortRow & { +type BalanceData = { asset: string, balance: string, - value: string, } +export type BalanceRow = SortRow + export const getBalanceData = (): Array => [ { [BALANCE_TABLE_ASSET_ID]: 'CVL Journalism', diff --git a/src/routes/safe/component/Balances/index.jsx b/src/routes/safe/component/Balances/index.jsx index 25c0249e..c9b9dee1 100644 --- a/src/routes/safe/component/Balances/index.jsx +++ b/src/routes/safe/component/Balances/index.jsx @@ -23,6 +23,8 @@ import Receive from './Receive' type State = { hideZero: boolean, showToken: boolean, + showReceive: boolean, + showSend: boolean, } const styles = theme => ({ diff --git a/src/routes/safe/store/actions/addSafe.js b/src/routes/safe/store/actions/addSafe.js index 286bd9d3..5a1beef6 100644 --- a/src/routes/safe/store/actions/addSafe.js +++ b/src/routes/safe/store/actions/addSafe.js @@ -6,7 +6,7 @@ import { makeOwner, type Owner } from '~/routes/safe/store/model/owner' export const ADD_SAFE = 'ADD_SAFE' -export const buildOwnersFrom = (names: string[], addresses: string[]) => { +export const buildOwnersFrom = (names: Array, addresses: Array) => { const owners = names.map((name: string, index: number) => makeOwner({ name, address: addresses[index] })) return List(owners) diff --git a/src/routes/safe/store/reducer/safe.js b/src/routes/safe/store/reducer/safe.js index 4750c6b9..65952b6f 100644 --- a/src/routes/safe/store/reducer/safe.js +++ b/src/routes/safe/store/reducer/safe.js @@ -2,7 +2,8 @@ import { Map } from 'immutable' import { handleActions, type ActionType } from 'redux-actions' import addSafe, { ADD_SAFE, buildOwnersFrom } from '~/routes/safe/store/actions/addSafe' -import { type Safe, makeSafe } from '~/routes/safe/store/model/safe' +import { type Safe, type SafeProps, makeSafe } from '~/routes/safe/store/model/safe' +import { type OwnerProps } from '~/routes/safe/store/model/owner' import { saveSafes, setOwners, load, SAFES_KEY } from '~/utils/localStorage' import updateSafe, { UPDATE_SAFE } from '~/routes/safe/store/actions/updateSafe' @@ -11,10 +12,9 @@ export const SAFE_REDUCER_ID = 'safes' export type State = Map export const buildSafe = (storedSafe: SafeProps) => { - const owners = buildOwnersFrom( - storedSafe.owners.map((owner: OwnerProps) => owner.name), - storedSafe.owners.map((owner: OwnerProps) => owner.address), - ) + const names = storedSafe.owners.map((owner: OwnerProps) => owner.name) + const addresses = storedSafe.owners.map((owner: OwnerProps) => owner.address) + const owners = buildOwnersFrom(names.toIndexedSeq().toArray(), addresses.toIndexedSeq().toArray()) const safe: SafeProps = { address: storedSafe.address, @@ -26,8 +26,8 @@ export const buildSafe = (storedSafe: SafeProps) => { return makeSafe(safe) } -const buildSafesFrom = (loadedSafes: Object): Promise> => { - const safes = Map() +const buildSafesFrom = (loadedSafes: Object): Map => { + const safes: Map = Map() const keys = Object.keys(loadedSafes) try { diff --git a/src/routes/safe/store/test/builder/safe.builder.js b/src/routes/safe/store/test/builder/safe.builder.js index 9e659bcb..cb0f16c5 100644 --- a/src/routes/safe/store/test/builder/safe.builder.js +++ b/src/routes/safe/store/test/builder/safe.builder.js @@ -1,6 +1,6 @@ // @flow import { makeSafe, type Safe } from '~/routes/safe/store/model/safe' -import { buildOwnersFrom } from '~/routes/safe/store/actions' +import { buildOwnersFrom } from '~/routes/safe/store/actions/addSafe' class SafeBuilder { safe: Safe diff --git a/src/test/builder/safe.redux.builder.js b/src/test/builder/safe.redux.builder.js index 47498c4b..60968248 100644 --- a/src/test/builder/safe.redux.builder.js +++ b/src/test/builder/safe.redux.builder.js @@ -1,10 +1,9 @@ // @flow import { makeSafe, type Safe } from '~/routes/safe/store/model/safe' -import { buildOwnersFrom } from '~/routes/safe/store/actions' +import addSafe, { buildOwnersFrom } from '~/routes/safe/store/actions/addSafe' import { FIELD_NAME, FIELD_CONFIRMATIONS, FIELD_OWNERS, getOwnerNameBy, getOwnerAddressBy } from '~/routes/open/components/fields' import { getWeb3, getProviderInfo } from '~/logic/wallets/getWeb3' import { promisify } from '~/utils/promisify' -import addSafe from '~/routes/safe/store/actions/addSafe' import { createSafe, type OpenState } from '~/routes/open/container/Open' import { type GlobalState } from '~/store/index' import { makeProvider } from '~/logic/wallets/store/model/provider' diff --git a/src/test/safe.redux.owners.test.js b/src/test/safe.redux.owners.test.js index 2fec5044..c185a4fb 100644 --- a/src/test/safe.redux.owners.test.js +++ b/src/test/safe.redux.owners.test.js @@ -120,7 +120,7 @@ describe('React DOM TESTS > Add and remove owners', () => { await assureThresholdIs(gnosisSafe, 1) await assureOwnersAre(gnosisSafe, accounts[2], accounts[0], accounts[1]) - await store.dispatch(fetchSafe(safe)) + await store.dispatch(fetchSafe(safe.get('address'))) safe = getSafeFrom(store.getState(), address) expect(safe.get('owners').count()).toBe(3) await assureOwnersAre(gnosisSafe, ...getAddressesFrom(safe)) @@ -149,7 +149,7 @@ describe('React DOM TESTS > Add and remove owners', () => { await assureThresholdIs(gnosisSafe, 2) await assureOwnersAre(gnosisSafe, accounts[2], accounts[0], accounts[1]) - await store.dispatch(fetchSafe(safe)) + await store.dispatch(fetchSafe(safe.get('address'))) safe = getSafeFrom(store.getState(), address) expect(safe.get('owners').count()).toBe(3) await assureOwnersAre(gnosisSafe, ...getAddressesFrom(safe)) @@ -179,7 +179,7 @@ describe('React DOM TESTS > Add and remove owners', () => { await assureThresholdIs(gnosisSafe, 1) await assureOwnersAre(gnosisSafe, accounts[0]) - await store.dispatch(fetchSafe(safe)) + await store.dispatch(fetchSafe(safe.get('address'))) safe = getSafeFrom(store.getState(), address) expect(safe.get('owners').count()).toBe(1) await assureOwnersAre(gnosisSafe, ...getAddressesFrom(safe)) @@ -204,7 +204,7 @@ describe('React DOM TESTS > Add and remove owners', () => { await assureThresholdIs(gnosisSafe, 1) await assureOwnersAre(gnosisSafe, accounts[0], accounts[1]) - await store.dispatch(fetchSafe(safe)) + await store.dispatch(fetchSafe(safe.get('address'))) safe = getSafeFrom(store.getState(), address) expect(safe.get('owners').count()).toBe(2) await assureOwnersAre(gnosisSafe, ...getAddressesFrom(safe)) @@ -230,7 +230,7 @@ describe('React DOM TESTS > Add and remove owners', () => { await assureThresholdIs(gnosisSafe, 2) await assureOwnersAre(gnosisSafe, accounts[0], accounts[1]) - await store.dispatch(fetchSafe(safe)) + await store.dispatch(fetchSafe(safe.get('address'))) safe = getSafeFrom(store.getState(), address) expect(safe.get('owners').count()).toBe(2) await assureOwnersAre(gnosisSafe, ...getAddressesFrom(safe)) diff --git a/src/test/safe.redux.transactions.test.js b/src/test/safe.redux.transactions.test.js index d812fdee..cffffd8c 100644 --- a/src/test/safe.redux.transactions.test.js +++ b/src/test/safe.redux.transactions.test.js @@ -36,12 +36,12 @@ describe('Transactions Suite', () => { const executor = accounts[0] const nonce = await gnosisSafe.nonce() const firstTxHash = await createTransaction(safe, 'Add Owner Second account', safeAddress, 0, nonce, executor, firstTxData) - await store.dispatch(fetchSafe(safe)) + await store.dispatch(fetchSafe(safe.get('address'))) safe = getSafeFrom(store.getState(), safeAddress) const secondTxData = gnosisSafe.contract.addOwnerWithThreshold.getData(accounts[2], 2) const secondTxHash = await createTransaction(safe, 'Add Owner Third account', safeAddress, 0, nonce + 100, executor, secondTxData) - await store.dispatch(fetchSafe(safe)) + await store.dispatch(fetchSafe(safe.get('address'))) safe = getSafeFrom(store.getState(), safeAddress) // WHEN