diff --git a/src/routes/open/components/FormConfirmation/index.jsx b/src/routes/open/components/FormConfirmation/index.jsx deleted file mode 100644 index e90e6ed3..00000000 --- a/src/routes/open/components/FormConfirmation/index.jsx +++ /dev/null @@ -1,57 +0,0 @@ -// @flow -import * as React from 'react' -import CircularProgress from '@material-ui/core/CircularProgress' -import Block from '~/components/layout/Block' -import Bold from '~/components/layout/Bold' -import Col from '~/components/layout/Col' -import OpenPaper from '~/components/Stepper/OpenPaper' -import Paragraph from '~/components/layout/Paragraph' -import Pre from '~/components/layout/Pre' -import Row from '~/components/layout/Row' - -type FormProps = { - submitting: boolean, -} - -type Props = { - address: string, - tx: Object, -} - -export const DEPLOYED_COMPONENT_ID = 'deployedSafeComponent' - -const Deployment = ({ address, tx }: Props) => ( - - Deployed safe to: {address} -
-      {JSON.stringify(tx, null, 2) }
-    
-
-) - -export default ({ address, tx }: Props) => (controls: React$Node, { submitting }: FormProps) => { - const txFinished = !!address - - return ( - - { !txFinished && - - - You are about to create a Safe for keeping your funds more secure. - - - Remember to check you have enough funds in your wallet. - - - } - - - { submitting - ? - : txFinished && - } - - - - ) -} diff --git a/src/routes/open/components/SafeForm/Confirmations/index.jsx b/src/routes/open/components/SafeForm/Confirmations/index.jsx deleted file mode 100644 index 01115791..00000000 --- a/src/routes/open/components/SafeForm/Confirmations/index.jsx +++ /dev/null @@ -1,26 +0,0 @@ -// @flow -import * as React from 'react' -import Field from '~/components/forms/Field' -import TextField from '~/components/forms/TextField' -import { composeValidators, minValue, mustBeInteger, required } from '~/components/forms/validator' -import Block from '~/components/layout/Block' -import { FIELD_CONFIRMATIONS } from '~/routes/open/components/fields' - -const Confirmations = () => ( - - - -) - -export default Confirmations diff --git a/src/routes/open/components/SafeForm/Confirmations/index.test.js b/src/routes/open/components/SafeForm/Confirmations/index.test.js deleted file mode 100644 index 83adc3ad..00000000 --- a/src/routes/open/components/SafeForm/Confirmations/index.test.js +++ /dev/null @@ -1,74 +0,0 @@ -// @flow -import TextField from '~/components/forms/TextField' -import * as React from 'react' -import * as TestUtils from 'react-dom/test-utils' -import Layout from '~/routes/open/components/Layout' -import { FIELD_CONFIRMATIONS, FIELD_OWNERS } from '~/routes/open/components/fields' -import { getProviderInfo } from '~/logic/wallets/getWeb3' -import Wrapper from '~/test/utils/Wrapper' -import { CONFIRMATIONS_ERROR } from '~/routes/open/components/SafeForm' - -const onSubmitMock = async (): Promise => {} - -describe('React DOM TESTS > Create Safe form', () => { - let open - let fieldOwners - let fieldConfirmations - beforeEach(async () => { - // init app web3 instance - await getProviderInfo() - - open = TestUtils.renderIntoDocument(( - - - - )) - - const inputs = TestUtils.scryRenderedDOMComponentsWithTag(open, 'input') - const indexOwners = 1 - const indexConfirmations = 2 - fieldOwners = inputs[indexOwners] - fieldConfirmations = inputs[indexConfirmations] - - expect(fieldOwners.name).toEqual(FIELD_OWNERS) - expect(fieldConfirmations.name).toEqual(FIELD_CONFIRMATIONS) - }) - - it('should not allow to continue if confirmations are higher than owners', async () => { - // GIVEN - TestUtils.Simulate.change(fieldOwners, { target: { value: '1' } }) - - // WHEN - TestUtils.Simulate.change(fieldConfirmations, { target: { value: '2' } }) - - // THEN - const muiFields = TestUtils.scryRenderedComponentsWithType(open, TextField) - expect(6).toEqual(muiFields.length) - const confirmationsField = muiFields[4] - - expect(confirmationsField.props.meta.valid).toBe(false) - expect(confirmationsField.props.meta.error).toBe(CONFIRMATIONS_ERROR) - }) - - it('should raise error when confirmations are 012 and number of owners are 2', async () => { - // GIVEN - TestUtils.Simulate.change(fieldOwners, { target: { value: '2' } }) - // WHEN - TestUtils.Simulate.change(fieldConfirmations, { target: { value: '014' } }) - - // THEN - const muiFields = TestUtils.scryRenderedComponentsWithType(open, TextField) - expect(8).toEqual(muiFields.length) - const confirmationsField = muiFields[6] - - expect(confirmationsField.props.meta.valid).toBe(false) - expect(confirmationsField.props.meta.error).toBe(CONFIRMATIONS_ERROR) - }) -}) diff --git a/src/routes/open/components/SafeForm/DailyLimit/index.jsx b/src/routes/open/components/SafeForm/DailyLimit/index.jsx deleted file mode 100644 index 6c26b035..00000000 --- a/src/routes/open/components/SafeForm/DailyLimit/index.jsx +++ /dev/null @@ -1,22 +0,0 @@ -// @flow -import * as React from 'react' -import Field from '~/components/forms/Field' -import TextField from '~/components/forms/TextField' -import { composeValidators, mustBeFloat, required, minValue } from '~/components/forms/validator' -import Block from '~/components/layout/Block' -import { FIELD_DAILY_LIMIT } from '~/routes/open/components/fields' - -const DailyLimit = () => ( - - - -) - -export default DailyLimit diff --git a/src/routes/open/components/SafeForm/Owners/index.jsx b/src/routes/open/components/SafeForm/Owners/index.jsx deleted file mode 100644 index 18295edd..00000000 --- a/src/routes/open/components/SafeForm/Owners/index.jsx +++ /dev/null @@ -1,84 +0,0 @@ -// @flow -import * as React from 'react' -import Field from '~/components/forms/Field' -import TextField from '~/components/forms/TextField' -import { - composeValidators, - minValue, - maxValue, - mustBeInteger, - mustBeEthereumAddress, - required, - uniqueAddress, -} from '~/components/forms/validator' -import Block from '~/components/layout/Block' -import Col from '~/components/layout/Col' -import Heading from '~/components/layout/Heading' -import Row from '~/components/layout/Row' -import Paragraph from '~/components/layout/Paragraph' -import { FIELD_OWNERS, getOwnerNameBy, getOwnerAddressBy } from '~/routes/open/components/fields' - -type Props = { - numOwners: number, - otherAccounts: string[], -} - -const MAX_NUMBER_OWNERS = 50 - -const getAddressValidators = (addresses: string[], position: number) => { - const copy = addresses.slice() - copy.splice(position, 1) - - return composeValidators(required, mustBeEthereumAddress, uniqueAddress(copy)) -} - -const Owners = (props: Props) => { - const { numOwners, otherAccounts } = props - const validNumber = numOwners && Number.isInteger(Number(numOwners)) - const renderOwners = validNumber && Number(numOwners) <= MAX_NUMBER_OWNERS - - return ( - - Owners - - - - { renderOwners && [...Array(Number(numOwners))].map((x, index) => ( - - - Owner NÂș {index + 1} - - - - - - - - - )) } - - ) -} - -export default Owners diff --git a/src/routes/open/components/SafeForm/Owners/index.test.js b/src/routes/open/components/SafeForm/Owners/index.test.js deleted file mode 100644 index d42acdf1..00000000 --- a/src/routes/open/components/SafeForm/Owners/index.test.js +++ /dev/null @@ -1,61 +0,0 @@ -// @flow -import TextField from '~/components/forms/TextField' -import * as React from 'react' -import * as TestUtils from 'react-dom/test-utils' -import GnoForm from '~/components/forms/GnoForm' -import { FIELD_OWNERS } from '~/routes/open/components/fields' -import { getAccountsFrom } from '~/routes/open/utils/safeDataExtractor' -import { getProviderInfo } from '~/logic/wallets/getWeb3' -import Wrapper from '~/test/utils/Wrapper' -import { ADDRESS_REPEATED_ERROR } from '~/components/forms/validator' -import Owners from './index' - -const onSubmitMock = () => {} -const childrenMock = () => {} - -describe('React DOM TESTS > Create Safe form', () => { - beforeEach(async () => { - // init app web3 instance - await getProviderInfo() - }) - - it('should not allow to continue if owners addresses are duplicated', async () => { - // GIVEN - const open = TestUtils.renderIntoDocument(( - - ( - - )} - > - {childrenMock} - - - )) - - let inputs = TestUtils.scryRenderedDOMComponentsWithTag(open, 'input') - const fieldOwners = inputs[0] - expect(fieldOwners.name).toEqual(FIELD_OWNERS) - TestUtils.Simulate.change(fieldOwners, { target: { value: '2' } }) - - // WHEN - inputs = TestUtils.scryRenderedDOMComponentsWithTag(open, 'input') - const firstOwnerAddress = inputs[2] - TestUtils.Simulate.change(firstOwnerAddress, { target: { value: '0xC21aC257Db500a87c65Daa980432F216A719bA30' } }) - const secondOwnerAddress = inputs[4] - TestUtils.Simulate.change(secondOwnerAddress, { target: { value: '0xC21aC257Db500a87c65Daa980432F216A719bA30' } }) - - // THEN - const muiFields = TestUtils.scryRenderedComponentsWithType(open, TextField) - expect(5).toEqual(muiFields.length) - const secondAddressField = muiFields[4] - - expect(secondAddressField.props.meta.valid).toBe(false) - expect(secondAddressField.props.meta.error).toBe(ADDRESS_REPEATED_ERROR) - }) -}) diff --git a/src/routes/open/components/SafeForm/index.jsx b/src/routes/open/components/SafeForm/index.jsx deleted file mode 100644 index d4095064..00000000 --- a/src/routes/open/components/SafeForm/index.jsx +++ /dev/null @@ -1,29 +0,0 @@ -// @flow -import * as React from 'react' -import OpenPaper from '~/components/Stepper/OpenPaper' -import { getAccountsFrom } from '~/routes/open/utils/safeDataExtractor' -import Owners from './Owners' -import Confirmations from './Confirmations' -import DailyLimit from './DailyLimit' - -export const CONFIRMATIONS_ERROR = 'Number of confirmations can not be higher than the number of owners' - -export const safeFieldsValidation = (values: Object) => { - const errors = {} - - if (Number.parseInt(values.owners, 10) < Number.parseInt(values.confirmations, 10)) { - errors.confirmations = CONFIRMATIONS_ERROR - } - - return errors -} - -const SafeRestPage = () => (controls: React$Node, { values }: Object) => ( - - - - - -) - -export default SafeRestPage diff --git a/src/routes/open/utils/safeDataExtractor.js b/src/routes/open/utils/safeDataExtractor.js index 25a91fc5..e0d84130 100644 --- a/src/routes/open/utils/safeDataExtractor.js +++ b/src/routes/open/utils/safeDataExtractor.js @@ -1,6 +1,4 @@ // @flow -export const getDailyLimitFrom = (values: Object): number => Number(values.limit) - export const getAccountsFrom = (values: Object): string[] => { const accounts = Object.keys(values).sort().filter(key => /^owner\d+Address$/.test(key))