From f7649458113d8db8b679ed36f2366ce4afa85798 Mon Sep 17 00:00:00 2001 From: apanizo Date: Thu, 27 Sep 2018 12:28:28 +0200 Subject: [PATCH] Fixing layout on AddOwner component --- .../safe/component/AddOwner/AddOwnerForm/index.jsx | 7 ++++--- src/routes/safe/component/AddOwner/Review/index.jsx | 7 ++++--- src/routes/safe/component/AddOwner/index.jsx | 9 ++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/routes/safe/component/AddOwner/AddOwnerForm/index.jsx b/src/routes/safe/component/AddOwner/AddOwnerForm/index.jsx index b47890b4..6f9a301f 100644 --- a/src/routes/safe/component/AddOwner/AddOwnerForm/index.jsx +++ b/src/routes/safe/component/AddOwner/AddOwnerForm/index.jsx @@ -1,6 +1,7 @@ // @flow import * as React from 'react' import Field from '~/components/forms/Field' +import OpenPaper from '~/components/Stepper/OpenPaper' import TextField from '~/components/forms/TextField' import Checkbox from '~/components/forms/Checkbox' import { composeValidators, required, mustBeEthereumAddress, uniqueAddress } from '~/components/forms/validator' @@ -29,8 +30,8 @@ type Props = { addresses: string[] } -const AddOwnerForm = ({ addresses, numOwners, threshold }: Props) => () => ( - +const AddOwnerForm = ({ addresses, numOwners, threshold }: Props) => (controls: React$Node) => ( + Add Owner @@ -65,7 +66,7 @@ const AddOwnerForm = ({ addresses, numOwners, threshold }: Props) => () => ( /> Increase threshold? - + ) export default AddOwnerForm diff --git a/src/routes/safe/component/AddOwner/Review/index.jsx b/src/routes/safe/component/AddOwner/Review/index.jsx index 7c2b9ac9..b935c757 100644 --- a/src/routes/safe/component/AddOwner/Review/index.jsx +++ b/src/routes/safe/component/AddOwner/Review/index.jsx @@ -1,6 +1,7 @@ // @flow import * as React from 'react' import CircularProgress from '@material-ui/core/CircularProgress' +import OpenPaper from '~/components/Stepper/OpenPaper' import Block from '~/components/layout/Block' import Bold from '~/components/layout/Bold' import Heading from '~/components/layout/Heading' @@ -16,13 +17,13 @@ const spinnerStyle = { minHeight: '50px', } -const Review = () => ({ values, submitting }: FormProps) => { +const Review = () => (controls: React$Node, { values, submitting }: FormProps) => { const text = values[INCREASE_PARAM] ? 'This operation will increase the threshold of the safe' : 'This operation will not modify the threshold of the safe' return ( - + Review the Add Owner operation Owner Name: {values[NAME_PARAM]} @@ -36,7 +37,7 @@ const Review = () => ({ values, submitting }: FormProps) => { { submitting && } - + ) } diff --git a/src/routes/safe/component/AddOwner/index.jsx b/src/routes/safe/component/AddOwner/index.jsx index f63518e7..69e0381b 100644 --- a/src/routes/safe/component/AddOwner/index.jsx +++ b/src/routes/safe/component/AddOwner/index.jsx @@ -7,6 +7,7 @@ import { type Safe } from '~/routes/safe/store/model/safe' import { type Owner, makeOwner } from '~/routes/safe/store/model/owner' import { setOwners } from '~/utils/localStorage' import { getSafeEthereumInstance, createTransaction } from '~/logic/safe/safeFrontendOperations' +import { signaturesViaMetamask } from '~/config' import AddOwnerForm, { NAME_PARAM, OWNER_ADDRESS_PARAM, INCREASE_PARAM } from './AddOwnerForm' import Review from './Review' import selector, { type SelectorProps } from './selector' @@ -36,12 +37,14 @@ const getOwnerAddressesFrom = (owners: List) => { } export const addOwner = async (values: Object, safe: Safe, threshold: number, executor: string) => { - const nonce = Date.now() + const safeAddress = safe.get('address') + const gnosisSafe = await getSafeEthereumInstance(safeAddress) + const nonce = signaturesViaMetamask() ? await gnosisSafe.nonce() : Date.now() + const newThreshold = values[INCREASE_PARAM] ? threshold + 1 : threshold const newOwnerAddress = values[OWNER_ADDRESS_PARAM] const newOwnerName = values[NAME_PARAM] - const safeAddress = safe.get('address') - const gnosisSafe = await getSafeEthereumInstance(safeAddress) + const data = gnosisSafe.contract.addOwnerWithThreshold.getData(newOwnerAddress, newThreshold) await createTransaction(safe, `Add Owner ${newOwnerName}`, safeAddress, 0, nonce, executor, data) setOwners(safeAddress, safe.get('owners').push(makeOwner({ name: newOwnerName, address: newOwnerAddress })))