diff --git a/src/components/forms/GnoForm/index.jsx b/src/components/forms/GnoForm/index.jsx index d51637f1..7dc29a35 100644 --- a/src/components/forms/GnoForm/index.jsx +++ b/src/components/forms/GnoForm/index.jsx @@ -29,7 +29,7 @@ const GnoForm = ({ render={({ handleSubmit, ...rest }) => (
{render(rest)} - {children(rest.submitting)} + {children(rest.submitting, rest.submitSucceeded)}
)} /> diff --git a/src/routes/safe/component/AddTransaction/createTransactions.js b/src/routes/safe/component/AddTransaction/createTransactions.js index d0d83569..2bc545cc 100644 --- a/src/routes/safe/component/AddTransaction/createTransactions.js +++ b/src/routes/safe/component/AddTransaction/createTransactions.js @@ -80,6 +80,12 @@ const hasOneOwner = (safe: Safe) => { return owners.count() === 1 } +export const getSafeEthereumInstance = async (safeAddress) => { + const web3 = getWeb3() + const GnosisSafe = await getGnosisSafeContract(web3) + return GnosisSafe.at(safeAddress) +} + export const createTransaction = async ( safe: Safe, txName: string, @@ -90,10 +96,8 @@ export const createTransaction = async ( data: string = '0x', ) => { const web3 = getWeb3() - const GnosisSafe = await getGnosisSafeContract(web3) const safeAddress = safe.get('address') - const gnosisSafe = GnosisSafe.at(safeAddress) - + const gnosisSafe = await getSafeEthereumInstance(safeAddress) const valueInWei = web3.toWei(txValue, 'ether') const CALL = 0 diff --git a/src/routes/safe/component/Safe/index.jsx b/src/routes/safe/component/Safe/index.jsx index 4cb26bd7..cbb9f894 100644 --- a/src/routes/safe/component/Safe/index.jsx +++ b/src/routes/safe/component/Safe/index.jsx @@ -12,6 +12,7 @@ import List from 'material-ui/List' import Withdrawn from '~/routes/safe/component/Withdrawn' import Transactions from '~/routes/safe/component/Transactions' import AddTransaction from '~/routes/safe/component/AddTransaction' +import Threshold from '~/routes/safe/component/Threshold' import Address from './Address' import Balance from './Balance' @@ -59,6 +60,12 @@ class GnoSafe extends React.PureComponent { this.setState({ component: }) } + onEditThreshold = () => { + const { safe } = this.props + + this.setState({ component: }) + } + render() { const { safe, balance } = this.props const { component } = this.state @@ -69,7 +76,7 @@ class GnoSafe extends React.PureComponent { - {}} /> +
diff --git a/src/routes/safe/component/Threshold/index.jsx b/src/routes/safe/component/Threshold/index.jsx new file mode 100644 index 00000000..86cca73c --- /dev/null +++ b/src/routes/safe/component/Threshold/index.jsx @@ -0,0 +1,98 @@ +// @flow +import * as React from 'react' +import Block from '~/components/layout/Block' +import Heading from '~/components/layout/Heading' +import Field from '~/components/forms/Field' +import TextField from '~/components/forms/TextField' +import GnoForm from '~/components/forms/GnoForm' +import { connect } from 'react-redux' +import Button from '~/components/layout/Button' +import Col from '~/components/layout/Col' +import Row from '~/components/layout/Row' +import { composeValidators, minValue, maxValue, mustBeInteger, required } from '~/components/forms/validator' +import { getSafeEthereumInstance, createTransaction } from '~/routes/safe/component/AddTransaction/createTransactions' +import { sleep } from '~/utils/timer' +import selector, { type SelectorProps } from './selector' + +type Props = SelectorProps & { + numOwners: number, + safe: Safe, +} + +const THRESHOLD_PARAM = 'threshold' + +const ThresholdComponent = ({ numOwners }: Props) => () => ( + + + {'Change safe\'s threshold'} + + + {`Actual number of owners: ${numOwners}`} + + + + + +) + +type State = { + initialValues: Object, +} + +class Threshold extends React.PureComponent { + state = { + initialValues: {}, + } + + onThreshold = async (values: Object) => { + const { safe, userAddress } = this.props // , fetchThreshold } = this.props + const newThreshold = values[THRESHOLD_PARAM] + const gnosisSafe = await getSafeEthereumInstance(safe.get('address')) + const nonce = Date.now() + const data = gnosisSafe.contract.changeThreshold.getData(newThreshold) + await createTransaction(safe, "Change Safe's threshold", safe.get('address'), 0, nonce, userAddress, data) + await sleep(1500) + // this.props.fetchThreshold(safe.get('address')) + } + + render() { + const { numOwners } = this.props + + return ( + + {(submitting: boolean, submitSucceeded: boolean) => ( + + + + + + )} + + ) + } +} + +export default connect(selector)(Threshold) diff --git a/src/routes/safe/component/Threshold/selector.js b/src/routes/safe/component/Threshold/selector.js new file mode 100644 index 00000000..9e7bfef1 --- /dev/null +++ b/src/routes/safe/component/Threshold/selector.js @@ -0,0 +1,11 @@ +// @flow +import { createStructuredSelector } from 'reselect' +import { userAccountSelector } from '~/wallets/store/selectors/index' + +export type SelectorProps = { + userAddress: userAccountSelector, +} + +export default createStructuredSelector({ + userAddress: userAccountSelector, +})