From d97e61993cd51fc6e13b9472969490bc2a3a89eb Mon Sep 17 00:00:00 2001 From: apanizo Date: Mon, 15 Oct 2018 13:33:44 +0200 Subject: [PATCH] Removing daily limit from addSafe action --- src/routes/open/components/fields.js | 1 - src/routes/open/container/Open.jsx | 2 +- src/routes/safe/store/actions/addSafe.js | 3 +- .../test/builder/deployedSafe.builder.js | 109 ------------------ src/routes/safe/store/test/safe.reducer.js | 2 - src/test/builder/safe.dom.builder.js | 3 +- src/test/builder/safe.redux.builder.js | 4 +- src/test/safe.redux.owners.test.js | 10 +- 8 files changed, 9 insertions(+), 125 deletions(-) delete mode 100644 src/routes/safe/store/test/builder/deployedSafe.builder.js diff --git a/src/routes/open/components/fields.js b/src/routes/open/components/fields.js index 9b57c8f5..bd2c1ba7 100644 --- a/src/routes/open/components/fields.js +++ b/src/routes/open/components/fields.js @@ -2,7 +2,6 @@ export const FIELD_NAME: string = 'name' export const FIELD_CONFIRMATIONS: string = 'confirmations' export const FIELD_OWNERS: string = 'owners' -export const FIELD_DAILY_LIMIT: string = 'limit' export const getOwnerNameBy = (index: number) => `owner${index}Name` export const getOwnerAddressBy = (index: number) => `owner${index}Address` diff --git a/src/routes/open/container/Open.jsx b/src/routes/open/container/Open.jsx index 47d2c31b..e568ce52 100644 --- a/src/routes/open/container/Open.jsx +++ b/src/routes/open/container/Open.jsx @@ -37,7 +37,7 @@ export const createSafe = async (values: Object, userAccount: string, addSafe: A const param = safe.logs[0].args.proxy const safeContract = GnosisSafe.at(param) - addSafe(name, safeContract.address, numConfirmations, 0, owners, accounts) + addSafe(name, safeContract.address, numConfirmations, owners, accounts) if (stillInOpeningView()) { const url = { diff --git a/src/routes/safe/store/actions/addSafe.js b/src/routes/safe/store/actions/addSafe.js index 53e90f8c..286bd9d3 100644 --- a/src/routes/safe/store/actions/addSafe.js +++ b/src/routes/safe/store/actions/addSafe.js @@ -15,8 +15,7 @@ export const buildOwnersFrom = (names: string[], addresses: string[]) => { const addSafe = createAction( ADD_SAFE, ( - name: string, address: string, - threshold: number, limit: number, + name: string, address: string, threshold: number, ownersName: string[], ownersAddress: string[], ): SafeProps => { const owners: List = buildOwnersFrom(ownersName, ownersAddress) diff --git a/src/routes/safe/store/test/builder/deployedSafe.builder.js b/src/routes/safe/store/test/builder/deployedSafe.builder.js deleted file mode 100644 index 3ad683ac..00000000 --- a/src/routes/safe/store/test/builder/deployedSafe.builder.js +++ /dev/null @@ -1,109 +0,0 @@ -// @flow -import * as React from 'react' -import { type Store } from 'redux' -import TestUtils from 'react-dom/test-utils' -import { Provider } from 'react-redux' -import { ConnectedRouter } from 'react-router-redux' -import { DEPLOYED_COMPONENT_ID } from '~/routes/open/components/FormConfirmation' -import Open from '~/routes/open/container/Open' -import { history, type GlobalState } from '~/store' -import { sleep } from '~/utils/timer' -import { getProviderInfo, getWeb3 } from '~/logic/wallets/getWeb3' -import addProvider from '~/logic/wallets/store/actions/addProvider' -import { makeProvider } from '~/logic/wallets/store/model/provider' -import { promisify } from '~/utils/promisify' -import { type Safe } from '~/routes/safe/store/model/safe' -import { DESTINATION_PARAM, VALUE_PARAM } from '~/routes/safe/component/Withdraw/WithdrawForm' -import { withdraw } from '~/logic/safe/safeFrontendOperations' - -export const renderSafe = async (localStore: Store) => { - const provider = await getProviderInfo() - const walletRecord = makeProvider(provider) - localStore.dispatch(addProvider(walletRecord)) - - return ( - TestUtils.renderIntoDocument(( - - - - - - )) - ) -} - -const deploySafe = async (safe: React$Component<{}>, dailyLimit: string, threshold: number, numOwners: number) => { - expect(threshold).toBeLessThanOrEqual(numOwners) - const inputs = TestUtils.scryRenderedDOMComponentsWithTag(safe, 'input') - const fieldName = inputs[0] - const fieldOwners = inputs[1] - const fieldConfirmations = inputs[2] - const fieldDailyLimit = inputs[3] - - const web3 = getWeb3() - const accounts = await promisify(cb => web3.eth.getAccounts(cb)) - TestUtils.Simulate.change(fieldOwners, { target: { value: `${numOwners}` } }) - await sleep(800) - const inputsExpanded = TestUtils.scryRenderedDOMComponentsWithTag(safe, 'input') - expect(inputsExpanded.length).toBe((numOwners * 2) + 4) // 2 per owner + name, dailyLimit, confirmations, numOwners - - for (let i = 0; i < numOwners; i += 1) { - const nameIndex = (i * 2) + 2 - const addressIndex = (i * 2) + 3 - const ownerName = inputsExpanded[nameIndex] - const account = inputsExpanded[addressIndex] - - TestUtils.Simulate.change(ownerName, { target: { value: `Adolfo ${i + 1} Eth Account` } }) - TestUtils.Simulate.change(account, { target: { value: accounts[i] } }) - } - - TestUtils.Simulate.change(fieldName, { target: { value: 'Adolfo Safe' } }) - TestUtils.Simulate.change(fieldConfirmations, { target: { value: `${threshold}` } }) - - TestUtils.Simulate.change(fieldDailyLimit, { target: { value: dailyLimit } }) - - const form = TestUtils.findRenderedDOMComponentWithTag(safe, 'form') - - TestUtils.Simulate.submit(form) // fill the form - TestUtils.Simulate.submit(form) // confirming data - TestUtils.Simulate.submit(form) // Executing transaction - - // giving some time to the component for updating its state with safe - // before destroying its context - await sleep(12000) - - // THEN - const deployed = TestUtils.findRenderedDOMComponentWithClass(safe, DEPLOYED_COMPONENT_ID) - if (!deployed) { - throw new Error() - } - - const transactionHash = JSON.parse(deployed.getElementsByTagName('pre')[0].innerHTML) - delete transactionHash.receipt.logsBloom - - return transactionHash -} - -export const aDeployedSafe = async ( - specificStore: Store, - dailyLimit?: number = 0.5, - threshold?: number = 1, - numOwners?: number = 1, -) => { - const safe: React$Component<{}> = await renderSafe(specificStore) - const deployedSafe = await deploySafe(safe, `${dailyLimit}`, threshold, numOwners) - - return deployedSafe.logs[1].args.proxy -} - -export const executeWithdrawOn = async (safe: Safe, value: number) => { - const providerInfo = await getProviderInfo() - const userAddress = providerInfo.account - - const values = { - [DESTINATION_PARAM]: userAddress, - [VALUE_PARAM]: `${value}`, - } - - return withdraw(values, safe, userAddress) -} diff --git a/src/routes/safe/store/test/safe.reducer.js b/src/routes/safe/store/test/safe.reducer.js index e3e8af81..bdb48f09 100644 --- a/src/routes/safe/store/test/safe.reducer.js +++ b/src/routes/safe/store/test/safe.reducer.js @@ -32,7 +32,6 @@ const providerReducerTests = () => { [SafeFields.FIELD_NAME]: 'Adol ICO Safe', [SafeFields.FIELD_CONFIRMATIONS]: 1, [SafeFields.FIELD_OWNERS]: 1, - [SafeFields.FIELD_DAILY_LIMIT]: 10, [SafeFields.getOwnerAddressBy(0)]: '0x03db1a8b26d08df23337e9276a36b474510f0023', [SafeFields.getOwnerNameBy(0)]: 'Adol Metamask', address, @@ -47,7 +46,6 @@ const providerReducerTests = () => { formValues[SafeFields.FIELD_NAME], formValues.address, formValues[SafeFields.FIELD_CONFIRMATIONS], - formValues[SafeFields.FIELD_DAILY_LIMIT], getNamesFrom(formValues), getAccountsFrom(formValues), )) diff --git a/src/test/builder/safe.dom.builder.js b/src/test/builder/safe.dom.builder.js index 70674d7b..30248b24 100644 --- a/src/test/builder/safe.dom.builder.js +++ b/src/test/builder/safe.dom.builder.js @@ -25,12 +25,11 @@ export const filterMoveButtonsFrom = (buttons: Element[]) => export const renderSafeInDom = async ( owners: number = 1, threshold: number = 1, - dailyLimit: number = 0.5, ): Promise => { // create store const store = aNewStore() // deploy safe updating store - const address = await aMinedSafe(store, owners, threshold, dailyLimit) + const address = await aMinedSafe(store, owners, threshold) // have available accounts const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb)) // navigate to SAFE route diff --git a/src/test/builder/safe.redux.builder.js b/src/test/builder/safe.redux.builder.js index 32d8d954..47498c4b 100644 --- a/src/test/builder/safe.redux.builder.js +++ b/src/test/builder/safe.redux.builder.js @@ -1,7 +1,7 @@ // @flow import { makeSafe, type Safe } from '~/routes/safe/store/model/safe' import { buildOwnersFrom } from '~/routes/safe/store/actions' -import { FIELD_NAME, FIELD_CONFIRMATIONS, FIELD_OWNERS, getOwnerNameBy, getOwnerAddressBy, FIELD_DAILY_LIMIT } from '~/routes/open/components/fields' +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' @@ -68,7 +68,6 @@ export const aMinedSafe = async ( store: Store, owners: number = 1, threshold: number = 1, - dailyLimit: number = 0.5, ): Promise => { const provider = await getProviderInfo() const walletRecord = makeProvider(provider) @@ -79,7 +78,6 @@ export const aMinedSafe = async ( [FIELD_NAME]: 'Safe Name', [FIELD_CONFIRMATIONS]: `${threshold}`, [FIELD_OWNERS]: `${owners}`, - [FIELD_DAILY_LIMIT]: `${dailyLimit}`, } for (let i = 0; i < owners; i += 1) { diff --git a/src/test/safe.redux.owners.test.js b/src/test/safe.redux.owners.test.js index 28802e54..2fec5044 100644 --- a/src/test/safe.redux.owners.test.js +++ b/src/test/safe.redux.owners.test.js @@ -102,7 +102,7 @@ describe('React DOM TESTS > Add and remove owners', () => { const numOwners = 2 const threshold = 1 const store = aNewStore() - const address = await aMinedSafe(store, numOwners, threshold, 10) + const address = await aMinedSafe(store, numOwners, threshold) const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb)) const gnosisSafe = await getGnosisSafeInstanceAt(address) @@ -131,7 +131,7 @@ describe('React DOM TESTS > Add and remove owners', () => { const numOwners = 2 const threshold = 1 const store = aNewStore() - const address = await aMinedSafe(store, numOwners, threshold, 10) + const address = await aMinedSafe(store, numOwners, threshold) const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb)) const gnosisSafe = await getGnosisSafeInstanceAt(address) @@ -163,7 +163,7 @@ describe('React DOM TESTS > Add and remove owners', () => { const numOwners = 2 const threshold = 2 const store = aNewStore() - const address = await aMinedSafe(store, numOwners, threshold, 10) + const address = await aMinedSafe(store, numOwners, threshold) const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb)) const gnosisSafe = await getGnosisSafeInstanceAt(address) @@ -189,7 +189,7 @@ describe('React DOM TESTS > Add and remove owners', () => { const numOwners = 3 const threshold = 2 const store = aNewStore() - const address = await aMinedSafe(store, numOwners, threshold, 10) + const address = await aMinedSafe(store, numOwners, threshold) const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb)) const gnosisSafe = await getGnosisSafeInstanceAt(address) @@ -214,7 +214,7 @@ describe('React DOM TESTS > Add and remove owners', () => { const numOwners = 3 const threshold = 2 const store = aNewStore() - const address = await aMinedSafe(store, numOwners, threshold, 10) + const address = await aMinedSafe(store, numOwners, threshold) const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb)) const gnosisSafe = await getGnosisSafeInstanceAt(address)