Adding etherscan network details for user addresses

This commit is contained in:
apanizo 2018-10-04 15:08:56 +02:00
parent 8f3fd161d0
commit 5a1df5e363
7 changed files with 42 additions and 11 deletions

View File

@ -27,6 +27,7 @@ const initialValuesFrom = (userAccount: string) => ({
type Props = { type Props = {
provider: string, provider: string,
userAccount: string, userAccount: string,
network: string,
onCallSafeContractSubmit: (values: Object) => Promise<void>, onCallSafeContractSubmit: (values: Object) => Promise<void>,
} }
@ -41,7 +42,7 @@ const back = () => {
} }
const Layout = ({ const Layout = ({
provider, userAccount, onCallSafeContractSubmit, provider, userAccount, onCallSafeContractSubmit, network,
}: Props) => { }: Props) => {
const steps = getSteps() const steps = getSteps()
const initialValues = initialValuesFrom(userAccount) const initialValues = initialValuesFrom(userAccount)
@ -71,7 +72,7 @@ const Layout = ({
<Stepper.Page validate={safeFieldsValidation}> <Stepper.Page validate={safeFieldsValidation}>
{ SafeThresholdField } { SafeThresholdField }
</Stepper.Page> </Stepper.Page>
<Stepper.Page> <Stepper.Page network={network}>
{ Review } { Review }
</Stepper.Page> </Stepper.Page>
</Stepper> </Stepper>

View File

@ -49,6 +49,7 @@ storiesOf('Routes /open', module)
return ( return (
<State store={store}> <State store={store}>
<Component <Component
network="rinkeby"
provider={provider} provider={provider}
userAccount={userAccount} userAccount={userAccount}
safeAddress={store.get('safeAddress')} safeAddress={store.get('safeAddress')}

View File

@ -3,15 +3,22 @@ import * as React from 'react'
import { getNamesFrom, getAccountsFrom } from '~/routes/open/utils/safeDataExtractor' import { getNamesFrom, getAccountsFrom } from '~/routes/open/utils/safeDataExtractor'
import Block from '~/components/layout/Block' import Block from '~/components/layout/Block'
import { withStyles } from '@material-ui/core/styles' import { withStyles } from '@material-ui/core/styles'
import OpenInNew from '@material-ui/icons/OpenInNew'
import Identicon from '~/components/Identicon' import Identicon from '~/components/Identicon'
import OpenPaper from '~/components/Stepper/OpenPaper' import OpenPaper from '~/components/Stepper/OpenPaper'
import Col from '~/components/layout/Col' import Col from '~/components/layout/Col'
import Row from '~/components/layout/Row' import Row from '~/components/layout/Row'
import Paragraph from '~/components/layout/Paragraph' import Paragraph from '~/components/layout/Paragraph'
import { md, lg, border, background } from '~/theme/variables' import { sm, md, lg, border, secondary, background } from '~/theme/variables'
import Hairline from '~/components/layout/Hairline' import Hairline from '~/components/layout/Hairline'
import { openAddressInEtherScan } from '~/logic/wallets/getWeb3'
import { FIELD_NAME, FIELD_CONFIRMATIONS, getNumOwnersFrom } from '../fields' import { FIELD_NAME, FIELD_CONFIRMATIONS, getNumOwnersFrom } from '../fields'
const openIconStyle = {
height: '16px',
color: secondary,
}
const styles = () => ({ const styles = () => ({
root: { root: {
minHeight: '300px', minHeight: '300px',
@ -33,14 +40,25 @@ const styles = () => ({
padding: md, padding: md,
alignItems: 'center', alignItems: 'center',
}, },
open: {
paddingLeft: sm,
width: 'auto',
'&:hover': {
cursor: 'pointer',
},
},
}) })
type Props = { type LayoutProps = {
network: string,
}
type Props = LayoutProps & {
values: Object, values: Object,
classes: Object, classes: Object,
} }
const ReviewComponent = ({ values, classes }: Props) => { const ReviewComponent = ({ values, classes, network }: Props) => {
const names = getNamesFrom(values) const names = getNamesFrom(values)
const addresses = getAccountsFrom(values) const addresses = getAccountsFrom(values)
const numOwners = getNumOwnersFrom(values) const numOwners = getNumOwnersFrom(values)
@ -89,7 +107,14 @@ const ReviewComponent = ({ values, classes }: Props) => {
<Col xs={11}> <Col xs={11}>
<Block> <Block>
<Paragraph size="lg" noMargin>{name}</Paragraph> <Paragraph size="lg" noMargin>{name}</Paragraph>
<Paragraph size="md" color="disabled" noMargin>{addresses[index]}</Paragraph> <Block align="center">
<Paragraph size="md" color="disabled" noMargin>{addresses[index]}</Paragraph>
<OpenInNew
className={classes.open}
style={openIconStyle}
onClick={openAddressInEtherScan(addresses[index], network)}
/>
</Block>
</Block> </Block>
</Col> </Col>
</Row> </Row>
@ -112,10 +137,10 @@ const ReviewComponent = ({ values, classes }: Props) => {
const ReviewPage = withStyles(styles)(ReviewComponent) const ReviewPage = withStyles(styles)(ReviewComponent)
const Review = () => (controls: React$Node, { values }: Object) => ( const Review = ({ network }: LayoutProps) => (controls: React$Node, { values }: Object) => (
<React.Fragment> <React.Fragment>
<OpenPaper controls={controls} padding={false}> <OpenPaper controls={controls} padding={false}>
<ReviewPage values={values} /> <ReviewPage network={network} values={values} />
</OpenPaper> </OpenPaper>
</React.Fragment> </React.Fragment>
) )

View File

@ -21,6 +21,7 @@ describe('React DOM TESTS > Create Safe form', () => {
open = TestUtils.renderIntoDocument(( open = TestUtils.renderIntoDocument((
<Wrapper> <Wrapper>
<Layout <Layout
network="rinkeby"
provider="METAMASK" provider="METAMASK"
userAccount="foo" userAccount="foo"
safeAddress="" safeAddress=""

View File

@ -93,7 +93,7 @@ const SafeThresholdForm = withStyles(styles)(SafeThreshold)
const SafeOwnersPage = () => (controls: React$Node, { values }: Object) => ( const SafeOwnersPage = () => (controls: React$Node, { values }: Object) => (
<React.Fragment> <React.Fragment>
<OpenPaper controls={controls} values={values}> <OpenPaper controls={controls}>
<SafeThresholdForm values={values} /> <SafeThresholdForm values={values} />
</OpenPaper> </OpenPaper>
</React.Fragment> </React.Fragment>

View File

@ -15,6 +15,7 @@ import Layout from '../components/Layout'
type Props = Actions & { type Props = Actions & {
provider: string, provider: string,
userAccount: string, userAccount: string,
network: string,
} }
export type OpenState = { export type OpenState = {
@ -69,11 +70,12 @@ class Open extends React.Component<Props> {
} }
render() { render() {
const { provider, userAccount } = this.props const { provider, userAccount, network } = this.props
return ( return (
<Page> <Page>
<Layout <Layout
network={network}
provider={provider} provider={provider}
userAccount={userAccount} userAccount={userAccount}
onCallSafeContractSubmit={this.onCallSafeContractSubmit} onCallSafeContractSubmit={this.onCallSafeContractSubmit}

View File

@ -1,8 +1,9 @@
// @flow // @flow
import { createStructuredSelector } from 'reselect' import { createStructuredSelector } from 'reselect'
import { providerNameSelector, userAccountSelector } from '~/logic/wallets/store/selectors' import { providerNameSelector, userAccountSelector, networkSelector } from '~/logic/wallets/store/selectors'
export default createStructuredSelector({ export default createStructuredSelector({
provider: providerNameSelector, provider: providerNameSelector,
network: networkSelector,
userAccount: userAccountSelector, userAccount: userAccountSelector,
}) })