migrate to material ui v4, deps bump, show notification before sending the tx

This commit is contained in:
Mikhail Mikheev 2019-05-27 17:06:34 +04:00
parent 5edc8b821a
commit ed2b6139c7
7 changed files with 428 additions and 260 deletions

View File

@ -66,8 +66,8 @@
}, },
"dependencies": { "dependencies": {
"@gnosis.pm/util-contracts": "2.0.1", "@gnosis.pm/util-contracts": "2.0.1",
"@material-ui/core": "^3.9.3", "@material-ui/core": "4.0.0",
"@material-ui/icons": "^3.0.1", "@material-ui/icons": "4.0.0",
"@welldone-software/why-did-you-render": "^3.0.9", "@welldone-software/why-did-you-render": "^3.0.9",
"axios": "^0.18.0", "axios": "^0.18.0",
"bignumber.js": "^8.1.1", "bignumber.js": "^8.1.1",
@ -81,9 +81,9 @@
"qrcode.react": "^0.9.3", "qrcode.react": "^0.9.3",
"react": "^16.8.6", "react": "^16.8.6",
"react-dom": "^16.8.6", "react-dom": "^16.8.6",
"react-final-form": "5.1.0", "react-final-form": "6.0.0",
"react-final-form-listeners": "^1.0.2", "react-final-form-listeners": "^1.0.2",
"react-hot-loader": "4.8.7", "react-hot-loader": "4.8.8",
"react-infinite-scroll-component": "^4.5.2", "react-infinite-scroll-component": "^4.5.2",
"react-redux": "7.0.3", "react-redux": "7.0.3",
"react-router-dom": "^4.3.1", "react-router-dom": "^4.3.1",
@ -96,7 +96,7 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "7.4.4", "@babel/cli": "7.4.4",
"@babel/core": "7.4.4", "@babel/core": "7.4.5",
"@babel/plugin-proposal-class-properties": "7.4.4", "@babel/plugin-proposal-class-properties": "7.4.4",
"@babel/plugin-proposal-decorators": "7.4.4", "@babel/plugin-proposal-decorators": "7.4.4",
"@babel/plugin-proposal-do-expressions": "^7.0.0", "@babel/plugin-proposal-do-expressions": "^7.0.0",
@ -116,7 +116,7 @@
"@babel/plugin-transform-member-expression-literals": "^7.2.0", "@babel/plugin-transform-member-expression-literals": "^7.2.0",
"@babel/plugin-transform-property-literals": "^7.2.0", "@babel/plugin-transform-property-literals": "^7.2.0",
"@babel/polyfill": "7.4.4", "@babel/polyfill": "7.4.4",
"@babel/preset-env": "7.4.4", "@babel/preset-env": "7.4.5",
"@babel/preset-flow": "^7.0.0-beta.40", "@babel/preset-flow": "^7.0.0-beta.40",
"@babel/preset-react": "^7.0.0-beta.40", "@babel/preset-react": "^7.0.0-beta.40",
"@sambego/storybook-state": "^1.0.7", "@sambego/storybook-state": "^1.0.7",
@ -137,9 +137,9 @@
"detect-port": "^1.2.2", "detect-port": "^1.2.2",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0", "eslint-config-airbnb": "^17.1.0",
"eslint-plugin-flowtype": "3.9.0", "eslint-plugin-flowtype": "3.9.1",
"eslint-plugin-import": "2.17.2", "eslint-plugin-import": "2.17.3",
"eslint-plugin-jest": "22.5.1", "eslint-plugin-jest": "22.6.4",
"eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "7.13.0", "eslint-plugin-react": "7.13.0",
"ethereumjs-abi": "^0.6.7", "ethereumjs-abi": "^0.6.7",
@ -161,11 +161,11 @@
"storybook-host": "^5.0.3", "storybook-host": "^5.0.3",
"storybook-router": "^0.3.3", "storybook-router": "^0.3.3",
"style-loader": "^0.23.1", "style-loader": "^0.23.1",
"truffle": "5.0.18", "truffle": "5.0.19",
"truffle-contract": "4.0.16", "truffle-contract": "4.0.17",
"truffle-solidity-loader": "0.1.17", "truffle-solidity-loader": "0.1.18",
"uglifyjs-webpack-plugin": "2.1.3", "uglifyjs-webpack-plugin": "2.1.3",
"webpack": "4.32.0", "webpack": "4.32.2",
"webpack-bundle-analyzer": "3.3.2", "webpack-bundle-analyzer": "3.3.2",
"webpack-cli": "3.3.2", "webpack-cli": "3.3.2",
"webpack-dev-server": "3.4.1", "webpack-dev-server": "3.4.1",

View File

@ -55,16 +55,13 @@ class Provider extends React.Component<Props> {
<React.Fragment> <React.Fragment>
<div ref={this.myRef} className={classes.root}> <div ref={this.myRef} className={classes.root}>
<Col end="sm" middle="xs" className={classes.provider} onClick={toggle}> <Col end="sm" middle="xs" className={classes.provider} onClick={toggle}>
{ info } {info}
<IconButton <IconButton disableRipple className={classes.expand}>
disableRipple {open ? <ExpandLess /> : <ExpandMore />}
className={classes.expand}
>
{ open ? <ExpandLess /> : <ExpandMore />}
</IconButton> </IconButton>
</Col> </Col>
</div> </div>
{ children(this.myRef) } {children(this.myRef)}
</React.Fragment> </React.Fragment>
) )
} }

View File

@ -15,7 +15,7 @@ type Props = {
padding?: number, padding?: number,
validation?: (values: Object) => Object | Promise<Object>, validation?: (values: Object) => Object | Promise<Object>,
initialValues?: Object, initialValues?: Object,
formMutators: Object, formMutators?: Object,
} }
const stylesBasedOn = (padding: number): $Shape<CSSStyleDeclaration> => ({ const stylesBasedOn = (padding: number): $Shape<CSSStyleDeclaration> => ({

View File

@ -1,6 +1,6 @@
// @flow // @flow
import * as React from 'react'
import classNames from 'classnames/bind' import classNames from 'classnames/bind'
import React from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { capitalize } from '~/utils/css' import { capitalize } from '~/utils/css'
import styles from './index.scss' import styles from './index.scss'
@ -13,20 +13,35 @@ type Props = {
children: React$Node, children: React$Node,
color?: 'regular' | 'white', color?: 'regular' | 'white',
className?: string, className?: string,
innerRef: React.ElementRef<any>,
} }
const GnosisLink = ({ const GnosisLink = ({
to, children, color, className, padding, ...props to, children, color, className, padding, innerRef, ...props
}: Props) => { }: Props) => {
const internal = /^\/(?!\/)/.test(to) const internal = /^\/(?!\/)/.test(to)
const classes = cx(styles.link, color || 'regular', padding ? capitalize(padding, 'padding') : undefined, className) const classes = cx(styles.link, color || 'regular', padding ? capitalize(padding, 'padding') : undefined, className)
const LinkElement = internal ? Link : 'a' const LinkElement = internal ? Link : 'a'
const refs = {}
if (internal) {
// To avoid warning about React not recognizing the prop innerRef on native element (a) if the link is external
refs.innerRef = innerRef
}
return ( return (
<LinkElement className={classes} href={internal ? null : to} to={internal ? to : null} {...props}> <LinkElement
className={classes}
href={internal ? null : to}
to={internal ? to : null}
{...refs}
{...props}
>
{children} {children}
</LinkElement> </LinkElement>
) )
} }
export default GnosisLink // https://material-ui.com/guides/composition/#caveat-with-refs
const LinkWithRef = React.forwardRef<Props, typeof GnosisLink>((props, ref) => <GnosisLink {...props} innerRef={ref} />)
export default LinkWithRef

View File

@ -43,10 +43,7 @@ const styles = {
} }
const Opening = ({ const Opening = ({
classes, classes, name = 'Safe creation process', tx, network,
name = 'Safe creation process',
tx,
network,
}: Props) => ( }: Props) => (
<Page align="center"> <Page align="center">
<Paragraph className={classes.page} color="secondary" size="xxl" weight="bolder" align="center"> <Paragraph className={classes.page} color="secondary" size="xxl" weight="bolder" align="center">
@ -68,13 +65,25 @@ const Opening = ({
</Block> </Block>
<Block margin="md"> <Block margin="md">
<Paragraph size="md" align="center" weight="light" noMargin> <Paragraph size="md" align="center" weight="light" noMargin>
This process should take a couple of minutes. <br /> This process should take a couple of minutes.
{' '}
<br />
</Paragraph> </Paragraph>
{ tx && {tx && (
<Paragraph className={classes.follow} size="md" align="center" weight="light" noMargin> <Paragraph className={classes.follow} size="md" align="center" weight="light" noMargin>
Follow progress on <a href={openTxInEtherScan(tx, network)} target="_blank" rel="noopener noreferrer" className={classes.etherscan}>Etherscan.io<OpenInNew className={classes.icon} /></a> Follow progress on
{' '}
<a
href={openTxInEtherScan(tx, network)}
target="_blank"
rel="noopener noreferrer"
className={classes.etherscan}
>
Etherscan.io
<OpenInNew className={classes.icon} />
</a>
</Paragraph> </Paragraph>
} )}
</Block> </Block>
</Page> </Page>
) )

View File

@ -28,7 +28,8 @@ const createTransaction = (
const threshold = await safeInstance.getThreshold() const threshold = await safeInstance.getThreshold()
const nonce = await safeInstance.nonce() const nonce = await safeInstance.nonce()
const txRecipient = isSendingETH ? to : token.address const txRecipient = isSendingETH ? to : token.address
let valueInWei = web3.utils.toWei(valueInEth, 'ether') const valueInWei = web3.utils.toWei(valueInEth, 'ether')
let txAmount = valueInWei
const isExecution = threshold.toNumber() === 1 const isExecution = threshold.toNumber() === 1
let txData = EMPTY_DATA let txData = EMPTY_DATA
@ -37,16 +38,17 @@ const createTransaction = (
const sendToken = await StandardToken.at(token.address) const sendToken = await StandardToken.at(token.address)
txData = sendToken.contract.methods.transfer(to, valueInWei).encodeABI() txData = sendToken.contract.methods.transfer(to, valueInWei).encodeABI()
// valueInWei should be 0 if we send tokens // txAmount should be 0 if we send tokens
// the real value is encoded in txData and will be used by the contract // the real value is encoded in txData and will be used by the contract
// if valueInWei > 0 it would send ETH from the safe // if txAmount > 0 it would send ETH from the safe
valueInWei = 0 txAmount = 0
} }
let txHash let txHash
if (isExecution) { if (isExecution) {
txHash = await executeTransaction(safeInstance, txRecipient, valueInWei, txData, CALL, nonce, from)
openSnackbar('Transaction has been submitted', 'success') openSnackbar('Transaction has been submitted', 'success')
txHash = await executeTransaction(safeInstance, txRecipient, txAmount, txData, CALL, nonce, from)
openSnackbar('Transaction has been confirmed', 'success')
} else { } else {
// txHash = await approveTransaction(safeAddress, to, valueInWei, txData, CALL, nonce) // txHash = await approveTransaction(safeAddress, to, valueInWei, txData, CALL, nonce)
} }

589
yarn.lock

File diff suppressed because it is too large Load Diff