From 5fc9fa64311cdca0faa58a953b12542b03319f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Thu, 12 Sep 2019 17:39:55 +0200 Subject: [PATCH] Format code --- src/components/Footer/index.stories.js | 2 +- .../Header/component/Layout.stories.js | 2 +- src/components/Loader/indes.stories.js | 2 +- src/components/Table/sorting.js | 2 +- src/components/forms/validator.js | 4 ++-- src/logic/safe/transactions/send.js | 4 ++-- src/logic/tokens/utils/tokenHelpers.js | 2 +- src/logic/tokens/utils/tokensStorage.js | 2 +- src/routes/open/components/Layout.stories.js | 2 +- .../SafeOwnersConfirmationsForm/validators.js | 4 +--- src/routes/open/components/fields.js | 2 +- src/routes/open/utils/safeDataExtractor.js | 8 +++---- src/routes/opening/Layout.stories.js | 2 +- .../SendModal/screens/SendFunds/style.js | 4 +--- src/routes/safe/components/Layout.stories.js | 2 +- .../safe/components/NoRights/index.stories.js | 2 +- .../safe/store/actions/processTransaction.js | 2 +- .../safe/store/middleware/safeStorage.js | 8 +++---- src/routes/safe/store/reducer/safe.js | 22 +++++++++---------- .../safeList/components/Layout.stories.js | 2 +- .../welcome/components/Layout.stories.js | 2 +- src/test/safe.dom.funds.threshold>1.test.js | 5 ++++- src/test/utils/logTransactions.js | 5 +---- src/utils/timer.js | 2 +- 24 files changed, 45 insertions(+), 49 deletions(-) diff --git a/src/components/Footer/index.stories.js b/src/components/Footer/index.stories.js index f3220920..e0b29e91 100644 --- a/src/components/Footer/index.stories.js +++ b/src/components/Footer/index.stories.js @@ -4,7 +4,7 @@ import * as React from 'react' import styles from '~/components/layout/PageFrame/index.scss' import Component from './index' -const FrameDecorator = story => ( +const FrameDecorator = (story) => (
{story()} diff --git a/src/components/Header/component/Layout.stories.js b/src/components/Header/component/Layout.stories.js index 7d0ccbe3..e8b235b7 100644 --- a/src/components/Header/component/Layout.stories.js +++ b/src/components/Header/component/Layout.stories.js @@ -8,7 +8,7 @@ import UserDetails from './ProviderDetails/UserDetails' import ProviderDisconnected from './ProviderInfo/ProviderDisconnected' import ConnectDetails from './ProviderDetails/ConnectDetails' -const FrameDecorator = story =>
{story()}
+const FrameDecorator = (story) =>
{story()}
storiesOf('Components /Header', module) .addDecorator(FrameDecorator) diff --git a/src/components/Loader/indes.stories.js b/src/components/Loader/indes.stories.js index f6576f3b..314b33d1 100644 --- a/src/components/Loader/indes.stories.js +++ b/src/components/Loader/indes.stories.js @@ -4,7 +4,7 @@ import * as React from 'react' import styles from '~/components/layout/PageFrame/index.scss' import Component from './index' -const FrameDecorator = story =>
{story()}
+const FrameDecorator = (story) =>
{story()}
storiesOf('Components', module) .addDecorator(FrameDecorator) diff --git a/src/components/Table/sorting.js b/src/components/Table/sorting.js index aad73260..e53480b4 100644 --- a/src/components/Table/sorting.js +++ b/src/components/Table/sorting.js @@ -39,7 +39,7 @@ export const stableSort = (dataArray: List, cmp: any, fixed: boolean): List return a[1] - b[1] }) - const sortedElems: List = stabilizedThis.map(el => el[0]) + const sortedElems: List = stabilizedThis.map((el) => el[0]) return fixedElems.concat(sortedElems) } diff --git a/src/components/forms/validator.js b/src/components/forms/validator.js index 422016f7..f8bfda94 100644 --- a/src/components/forms/validator.js +++ b/src/components/forms/validator.js @@ -69,7 +69,7 @@ export const mustBeEthereumAddress = simpleMemoize((address: Field) => { export const mustBeEthereumContractAddress = simpleMemoize(async (address: string) => { const contractCode: string = await getWeb3().eth.getCode(address) - return (!contractCode || contractCode.replace('0x', '').replace(/0/g, '') === '') + return !contractCode || contractCode.replace('0x', '').replace(/0/g, '') === '' ? 'Address should be a valid Ethereum contract address or ENS name' : undefined }) @@ -83,7 +83,7 @@ export const uniqueAddress = (addresses: string[] | List) => simpleMemoi return addressAlreadyExists ? ADDRESS_REPEATED_ERROR : undefined }) -export const composeValidators = (...validators: Function[]): FieldValidator => (value: Field) => validators.reduce((error, validator) => error || (validator && validator(value)), undefined) +export const composeValidators = (...validators: Function[]): FieldValidator => (value: Field) => validators.reduce((error, validator) => (error || (validator && validator(value)), undefined)) export const inLimit = (limit: number, base: number, baseText: string, symbol: string = 'ETH') => (value: string) => { const amount = Number(value) diff --git a/src/logic/safe/transactions/send.js b/src/logic/safe/transactions/send.js index 6bba674d..0381a7f5 100644 --- a/src/logic/safe/transactions/send.js +++ b/src/logic/safe/transactions/send.js @@ -109,8 +109,8 @@ export const executeTransaction = async ( .encodeABI() const errMsg = await getErrorMessage(safeInstance.address, 0, executeDataUsedSignatures, sender) console.log(`Error executing the TX: ${errMsg}`) - - throw error; + + throw error } } diff --git a/src/logic/tokens/utils/tokenHelpers.js b/src/logic/tokens/utils/tokenHelpers.js index 9d714005..b97b8b6d 100644 --- a/src/logic/tokens/utils/tokenHelpers.js +++ b/src/logic/tokens/utils/tokenHelpers.js @@ -21,7 +21,7 @@ export const getEthAsToken = (balance: string) => { } export const calculateActiveErc20TokensFrom = (tokens: List) => { - const activeTokens = List().withMutations(list => tokens.forEach((token: Token) => { + const activeTokens = List().withMutations((list) => tokens.forEach((token: Token) => { const isDeactivated = isEther(token.symbol) || !token.status if (isDeactivated) { return diff --git a/src/logic/tokens/utils/tokensStorage.js b/src/logic/tokens/utils/tokensStorage.js index b2b4a3b0..7cd06968 100644 --- a/src/logic/tokens/utils/tokensStorage.js +++ b/src/logic/tokens/utils/tokensStorage.js @@ -56,7 +56,7 @@ export const removeTokenFromStorage = async (safeAddress: string, token: Token) export const removeFromActiveTokens = async (safeAddress: string, token: Token) => { const activeTokens = await getActiveTokens() - const index = activeTokens.findIndex(activeToken => activeToken.name === token.name) + const index = activeTokens.findIndex((activeToken) => activeToken.name === token.name) if (index !== -1) { await saveActiveTokens(safeAddress, activeTokens.delete(index)) diff --git a/src/routes/open/components/Layout.stories.js b/src/routes/open/components/Layout.stories.js index 98f4a541..08606dc3 100644 --- a/src/routes/open/components/Layout.stories.js +++ b/src/routes/open/components/Layout.stories.js @@ -8,7 +8,7 @@ import { getProviderInfo } from '~/logic/wallets/getWeb3' import { sleep } from '~/utils/timer' import Component from './Layout' -const FrameDecorator = story =>
{story()}
+const FrameDecorator = (story) =>
{story()}
const store = new Store({ safeAddress: '', diff --git a/src/routes/open/components/SafeOwnersConfirmationsForm/validators.js b/src/routes/open/components/SafeOwnersConfirmationsForm/validators.js index e4697f0e..f32d20c0 100644 --- a/src/routes/open/components/SafeOwnersConfirmationsForm/validators.js +++ b/src/routes/open/components/SafeOwnersConfirmationsForm/validators.js @@ -1,7 +1,5 @@ // @flow -import { - uniqueAddress, -} from '~/components/forms/validator' +import { uniqueAddress } from '~/components/forms/validator' export const getAddressValidator = (addresses: string[], position: number) => { // thanks Rich Harris diff --git a/src/routes/open/components/fields.js b/src/routes/open/components/fields.js index fa280c90..a786ec73 100644 --- a/src/routes/open/components/fields.js +++ b/src/routes/open/components/fields.js @@ -9,7 +9,7 @@ export const getOwnerAddressBy = (index: number) => `owner${index}Address` export const getNumOwnersFrom = (values: Object) => { const accounts = Object.keys(values) .sort() - .filter(key => /^owner\d+Address$/.test(key) && !!values[key]) + .filter((key) => /^owner\d+Address$/.test(key) && !!values[key]) return accounts.length } diff --git a/src/routes/open/utils/safeDataExtractor.js b/src/routes/open/utils/safeDataExtractor.js index 5d198bfc..b20f070f 100644 --- a/src/routes/open/utils/safeDataExtractor.js +++ b/src/routes/open/utils/safeDataExtractor.js @@ -4,17 +4,17 @@ import { makeOwner } from '~/routes/safe/store/models/owner' export const getAccountsFrom = (values: Object): string[] => { const accounts = Object.keys(values) .sort() - .filter(key => /^owner\d+Address$/.test(key)) + .filter((key) => /^owner\d+Address$/.test(key)) - return accounts.map(account => values[account]).slice(0, values.owners) + return accounts.map((account) => values[account]).slice(0, values.owners) } export const getNamesFrom = (values: Object): string[] => { const accounts = Object.keys(values) .sort() - .filter(key => /^owner\d+Name$/.test(key)) + .filter((key) => /^owner\d+Name$/.test(key)) - return accounts.map(account => values[account]).slice(0, values.owners) + return accounts.map((account) => values[account]).slice(0, values.owners) } export const getOwnersFrom = (names: string[], addresses: string[]): Array => { diff --git a/src/routes/opening/Layout.stories.js b/src/routes/opening/Layout.stories.js index 5c208cbb..940a9062 100644 --- a/src/routes/opening/Layout.stories.js +++ b/src/routes/opening/Layout.stories.js @@ -5,7 +5,7 @@ import styles from '~/components/layout/PageFrame/index.scss' import { ETHEREUM_NETWORK } from '~/logic/wallets/getWeb3' import Component from './component' -const FrameDecorator = story =>
{story()}
+const FrameDecorator = (story) =>
{story()}
storiesOf('Routes /opening', module) .addDecorator(FrameDecorator) diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/style.js b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/style.js index b2740346..31d3c991 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/style.js +++ b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/style.js @@ -1,7 +1,5 @@ // @flow -import { - lg, md, secondaryText, -} from '~/theme/variables' +import { lg, md, secondaryText } from '~/theme/variables' export const styles = () => ({ heading: { diff --git a/src/routes/safe/components/Layout.stories.js b/src/routes/safe/components/Layout.stories.js index 689a1bfe..bb6ba32d 100644 --- a/src/routes/safe/components/Layout.stories.js +++ b/src/routes/safe/components/Layout.stories.js @@ -5,7 +5,7 @@ import { List } from 'immutable' import styles from '~/components/layout/PageFrame/index.scss' import Component from './Layout' -const FrameDecorator = story =>
{story()}
+const FrameDecorator = (story) =>
{story()}
storiesOf('Routes /safe:address', module) .addDecorator(FrameDecorator) diff --git a/src/routes/safe/components/NoRights/index.stories.js b/src/routes/safe/components/NoRights/index.stories.js index fbd53f8f..03d95d28 100644 --- a/src/routes/safe/components/NoRights/index.stories.js +++ b/src/routes/safe/components/NoRights/index.stories.js @@ -4,7 +4,7 @@ import * as React from 'react' import styles from '~/components/layout/PageFrame/index.scss' import Component from './index.jsx' -const FrameDecorator = story =>
{story()}
+const FrameDecorator = (story) =>
{story()}
storiesOf('Components', module) .addDecorator(FrameDecorator) diff --git a/src/routes/safe/store/actions/processTransaction.js b/src/routes/safe/store/actions/processTransaction.js index ad5bea46..c30fd27c 100644 --- a/src/routes/safe/store/actions/processTransaction.js +++ b/src/routes/safe/store/actions/processTransaction.js @@ -12,7 +12,7 @@ import { approveTransaction, executeTransaction, CALL } from '~/logic/safe/trans const generateSignaturesFromTxConfirmations = (tx: Transaction, preApprovingOwner?: string) => { // The constant parts need to be sorted so that the recovered signers are sorted ascending // (natural order) by address (not checksummed). - let confirmedAdresses = tx.confirmations.map(conf => conf.owner.address) + let confirmedAdresses = tx.confirmations.map((conf) => conf.owner.address) if (preApprovingOwner) { confirmedAdresses = confirmedAdresses.push(preApprovingOwner) diff --git a/src/routes/safe/store/middleware/safeStorage.js b/src/routes/safe/store/middleware/safeStorage.js index c26a8837..a99708cf 100644 --- a/src/routes/safe/store/middleware/safeStorage.js +++ b/src/routes/safe/store/middleware/safeStorage.js @@ -81,7 +81,7 @@ const safeStorageMware = (store: Store) => (next: Function) => asyn case REMOVE_SAFE_OWNER: { const { safeAddress, ownerAddress } = action.payload const { owners } = safes.get(safeAddress) - setOwners(safeAddress, owners.filter(o => o.address.toLowerCase() !== ownerAddress.toLowerCase())) + setOwners(safeAddress, owners.filter((o) => o.address.toLowerCase() !== ownerAddress.toLowerCase())) break } case REPLACE_SAFE_OWNER: { @@ -92,7 +92,7 @@ const safeStorageMware = (store: Store) => (next: Function) => asyn setOwners( safeAddress, owners - .filter(o => o.address.toLowerCase() !== oldOwnerAddress.toLowerCase()) + .filter((o) => o.address.toLowerCase() !== oldOwnerAddress.toLowerCase()) .push(makeOwner({ address: ownerAddress, name: ownerName })), ) break @@ -100,8 +100,8 @@ const safeStorageMware = (store: Store) => (next: Function) => asyn case EDIT_SAFE_OWNER: { const { safeAddress, ownerAddress, ownerName } = action.payload const { owners } = safes.get(safeAddress) - const ownerToUpdateIndex = owners.findIndex(o => o.address.toLowerCase() === ownerAddress.toLowerCase()) - setOwners(safeAddress, owners.update(ownerToUpdateIndex, owner => owner.set('name', ownerName))) + const ownerToUpdateIndex = owners.findIndex((o) => o.address.toLowerCase() === ownerAddress.toLowerCase()) + setOwners(safeAddress, owners.update(ownerToUpdateIndex, (owner) => owner.set('name', ownerName))) break } default: diff --git a/src/routes/safe/store/reducer/safe.js b/src/routes/safe/store/reducer/safe.js index 088ff9a6..bc942637 100644 --- a/src/routes/safe/store/reducer/safe.js +++ b/src/routes/safe/store/reducer/safe.js @@ -24,7 +24,7 @@ export const buildSafe = (storedSafe: SafeProps) => { const addresses = storedSafe.owners.map((owner: OwnerProps) => owner.address) const owners = buildOwnersFrom(Array.from(names), Array.from(addresses)) const activeTokens = List(storedSafe.activeTokens) - const balances = storedSafe.balances.map(balance => TokenBalance(balance)) + const balances = storedSafe.balances.map((balance) => TokenBalance(balance)) const safe: SafeProps = { ...storedSafe, @@ -67,7 +67,7 @@ export default handleActions( const safe = action.payload const safeAddress = safe.address - return state.update(safeAddress, prevSafe => prevSafe.merge(safe)) + return state.update(safeAddress, (prevSafe) => prevSafe.merge(safe)) }, [ACTIVATE_TOKEN_FOR_ALL_SAFES]: (state: State, action: ActionType): State => { const tokenAddress = action.payload @@ -77,7 +77,7 @@ export default handleActions( const safeActiveTokens = map.getIn([safeAddress, 'activeTokens']) const activeTokens = safeActiveTokens.push(tokenAddress) - map.update(safeAddress, prevSafe => prevSafe.merge({ activeTokens })) + map.update(safeAddress, (prevSafe) => prevSafe.merge({ activeTokens })) }) }) @@ -91,7 +91,7 @@ export default handleActions( // with initial props and it would overwrite existing ones if (state.has(safe.address)) { - return state.update(safe.address, prevSafe => prevSafe.merge(safe)) + return state.update(safe.address, (prevSafe) => prevSafe.merge(safe)) } return state.set(safe.address, SafeRecord(safe)) @@ -104,15 +104,15 @@ export default handleActions( [ADD_SAFE_OWNER]: (state: State, action: ActionType): State => { const { safeAddress, ownerName, ownerAddress } = action.payload - return state.update(safeAddress, prevSafe => prevSafe.merge({ + return state.update(safeAddress, (prevSafe) => prevSafe.merge({ owners: prevSafe.owners.push(makeOwner({ address: ownerAddress, name: ownerName })), })) }, [REMOVE_SAFE_OWNER]: (state: State, action: ActionType): State => { const { safeAddress, ownerAddress } = action.payload - return state.update(safeAddress, prevSafe => prevSafe.merge({ - owners: prevSafe.owners.filter(o => o.address.toLowerCase() !== ownerAddress.toLowerCase()), + return state.update(safeAddress, (prevSafe) => prevSafe.merge({ + owners: prevSafe.owners.filter((o) => o.address.toLowerCase() !== ownerAddress.toLowerCase()), })) }, [REPLACE_SAFE_OWNER]: (state: State, action: ActionType): State => { @@ -120,9 +120,9 @@ export default handleActions( safeAddress, oldOwnerAddress, ownerName, ownerAddress, } = action.payload - return state.update(safeAddress, prevSafe => prevSafe.merge({ + return state.update(safeAddress, (prevSafe) => prevSafe.merge({ owners: prevSafe.owners - .filter(o => o.address.toLowerCase() !== oldOwnerAddress.toLowerCase()) + .filter((o) => o.address.toLowerCase() !== oldOwnerAddress.toLowerCase()) .push(makeOwner({ address: ownerAddress, name: ownerName })), })) }, @@ -131,9 +131,9 @@ export default handleActions( return state.update(safeAddress, (prevSafe) => { const ownerToUpdateIndex = prevSafe.owners.findIndex( - o => o.address.toLowerCase() === ownerAddress.toLowerCase(), + (o) => o.address.toLowerCase() === ownerAddress.toLowerCase(), ) - const updatedOwners = prevSafe.owners.update(ownerToUpdateIndex, owner => owner.set('name', ownerName)) + const updatedOwners = prevSafe.owners.update(ownerToUpdateIndex, (owner) => owner.set('name', ownerName)) return prevSafe.merge({ owners: updatedOwners }) }) }, diff --git a/src/routes/safeList/components/Layout.stories.js b/src/routes/safeList/components/Layout.stories.js index d8189180..391b8de6 100644 --- a/src/routes/safeList/components/Layout.stories.js +++ b/src/routes/safeList/components/Layout.stories.js @@ -5,7 +5,7 @@ import * as React from 'react' import styles from '~/components/layout/PageFrame/index.scss' import Component from './Layout' -const FrameDecorator = story =>
{story()}
+const FrameDecorator = (story) =>
{story()}
storiesOf('Routes /safes', module) .addDecorator(FrameDecorator) diff --git a/src/routes/welcome/components/Layout.stories.js b/src/routes/welcome/components/Layout.stories.js index d5b5c62c..e33a3cbf 100644 --- a/src/routes/welcome/components/Layout.stories.js +++ b/src/routes/welcome/components/Layout.stories.js @@ -5,7 +5,7 @@ import * as React from 'react' import styles from '~/components/layout/PageFrame/index.scss' import Component from './Layout' -const FrameDecorator = story =>
{story()}
+const FrameDecorator = (story) =>
{story()}
storiesOf('Routes /welcome', module) .addDecorator(FrameDecorator) diff --git a/src/test/safe.dom.funds.threshold>1.test.js b/src/test/safe.dom.funds.threshold>1.test.js index 8b355f85..a1ed2088 100644 --- a/src/test/safe.dom.funds.threshold>1.test.js +++ b/src/test/safe.dom.funds.threshold>1.test.js @@ -12,7 +12,10 @@ import { fillAndSubmitSendFundsForm } from './utils/transactions' import { TRANSACTIONS_TAB_BTN_TEST_ID } from '~/routes/safe/components/Layout' import { TRANSACTION_ROW_TEST_ID } from '~/routes/safe/components/Transactions/TxsTable' import { useTestAccountAt, resetTestAccount } from './utils/accounts' -import { CONFIRM_TX_BTN_TEST_ID, EXECUTE_TX_BTN_TEST_ID } from '~/routes/safe/components/Transactions/TxsTable/ExpandedTx/OwnersColumn/ButtonRow' +import { + CONFIRM_TX_BTN_TEST_ID, + EXECUTE_TX_BTN_TEST_ID, +} from '~/routes/safe/components/Transactions/TxsTable/ExpandedTx/OwnersColumn/ButtonRow' import { APPROVE_TX_MODAL_SUBMIT_BTN_TEST_ID } from '~/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal' afterEach(resetTestAccount) diff --git a/src/test/utils/logTransactions.js b/src/test/utils/logTransactions.js index f73c4d2a..2df2e691 100644 --- a/src/test/utils/logTransactions.js +++ b/src/test/utils/logTransactions.js @@ -38,10 +38,7 @@ type FinsihedTx = { finishedTransaction: boolean, } -export const whenExecuted = ( - SafeDom: React.Component, - ParentComponent: React.ElementType, -): Promise => new Promise((resolve, reject) => { +export const whenExecuted = (SafeDom: React.Component, ParentComponent: React.ElementType): Promise => new Promise((resolve, reject) => { let times = 0 const interval = setInterval(() => { if (times >= MAX_TIMES_EXECUTED) { diff --git a/src/utils/timer.js b/src/utils/timer.js index aaa8356b..bd260688 100644 --- a/src/utils/timer.js +++ b/src/utils/timer.js @@ -1,2 +1,2 @@ // @flow -export const sleep: Function = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) +export const sleep: Function = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))