From 19c8f77d2f005cbf89f18c37c0684edb698c7231 Mon Sep 17 00:00:00 2001 From: apanizo Date: Tue, 25 Sep 2018 13:35:10 +0200 Subject: [PATCH] Creating opening route (no components yet) --- src/routes/open/container/Open.jsx | 27 +++++++++++---------------- src/routes/routes.js | 8 ++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/routes/open/container/Open.jsx b/src/routes/open/container/Open.jsx index a44e0e08..6dc8b149 100644 --- a/src/routes/open/container/Open.jsx +++ b/src/routes/open/container/Open.jsx @@ -7,6 +7,8 @@ import { getAccountsFrom, getThresholdFrom, getNamesFrom, getSafeNameFrom, getDa import { getWeb3 } from '~/logic/wallets/getWeb3' import { getGnosisSafeContract, deploySafeContract, initContracts } from '~/logic/contracts/safeContracts' import { checkReceiptStatus } from '~/logic/wallets/ethTransactions' +import { history } from '~/store' +import { OPENING_ADDRESS, stillInOpeningView, SAFELIST_ADDRESS } from '~/routes/routes' import selector from './selector' import actions, { type Actions, type AddSafe } from './actions' import Layout from '../components/Layout' @@ -18,7 +20,6 @@ type Props = Actions & { export type OpenState = { safeAddress: string, - safeTx: string, } export const createSafe = async (values: Object, userAccount: string, addSafe: AddSafe): Promise => { @@ -40,24 +41,21 @@ export const createSafe = async (values: Object, userAccount: string, addSafe: A addSafe(name, safeContract.address, numConfirmations, dailyLimit, owners, accounts) + if (stillInOpeningView()) { + const url = `${SAFELIST_ADDRESS}/${safeContract.address}` + history.push(url) + } + + // returning info for testing purposes, in app is fully async return { safeAddress: safeContract.address, safeTx: safe } } -class Open extends React.Component { - constructor() { - super() - - this.state = { - safeAddress: '', - safeTx: '', - } - } - +class Open extends React.Component { onCallSafeContractSubmit = async (values) => { try { const { userAccount, addSafe } = this.props - const safeInstance = await createSafe(values, userAccount, addSafe) - this.setState(safeInstance) + createSafe(values, userAccount, addSafe) + history.push(OPENING_ADDRESS) } catch (error) { // eslint-disable-next-line console.log('Error while creating the Safe' + error) @@ -65,7 +63,6 @@ class Open extends React.Component { } render() { - const { safeAddress, safeTx } = this.state const { provider, userAccount } = this.props return ( @@ -73,8 +70,6 @@ class Open extends React.Component { diff --git a/src/routes/routes.js b/src/routes/routes.js index 4ab227a3..ca326218 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -1,6 +1,14 @@ // @flow +import { history } from '~/store' + export const SAFE_PARAM_ADDRESS = 'address' export const SAFELIST_ADDRESS = '/safes' export const OPEN_ADDRESS = '/open' export const WELCOME_ADDRESS = '/welcome' export const SETTINS_ADDRESS = '/settings' +export const OPENING_ADDRESS = '/opening' + +export const stillInOpeningView = () => { + const path = history.location.pathname + return path === OPENING_ADDRESS +}