From 16de9184019e4d10af242ea6cfe892dda756579d Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Fri, 8 Jun 2018 17:50:05 +0200 Subject: [PATCH 01/10] Follow transaction after sending it --- packages/light-react/src/App/App.js | 2 - packages/light-react/src/Send/Send.js | 125 +++----------- packages/light-react/src/Send/Sent/Sent.js | 80 +++++++++ .../EthBalance => Send/Sent}/index.js | 4 +- .../light-react/src/Send/Signer/Signer.js | 159 +++++------------- .../src/Send/TokenBalance/TokenBalance.js | 48 ++++++ .../TokenBalance}/index.js | 4 +- .../light-react/src/Send/TxForm/TxForm.js | 115 +++++++++++++ packages/light-react/src/Send/TxForm/index.js | 8 + .../TokensList/BalanceLayout/BalanceLayout.js | 26 --- .../TokensList/EthBalance/EthBalance.js | 33 ---- .../TokensList/TokenBalance/TokenBalance.js | 50 ++++-- .../src/Tokens/TokensList/TokensList.js | 15 +- .../src/assets/img/icons/check.svg | 4 + packages/light-react/src/stores/index.js | 4 +- packages/light-react/src/stores/sendStore.js | 66 ++++++++ .../light-react/src/stores/signerStore.js | 67 -------- 17 files changed, 438 insertions(+), 372 deletions(-) create mode 100644 packages/light-react/src/Send/Sent/Sent.js rename packages/light-react/src/{Tokens/TokensList/EthBalance => Send/Sent}/index.js (64%) create mode 100644 packages/light-react/src/Send/TokenBalance/TokenBalance.js rename packages/light-react/src/{Tokens/TokensList/BalanceLayout => Send/TokenBalance}/index.js (61%) create mode 100644 packages/light-react/src/Send/TxForm/TxForm.js create mode 100644 packages/light-react/src/Send/TxForm/index.js delete mode 100644 packages/light-react/src/Tokens/TokensList/BalanceLayout/BalanceLayout.js delete mode 100644 packages/light-react/src/Tokens/TokensList/EthBalance/EthBalance.js create mode 100644 packages/light-react/src/assets/img/icons/check.svg create mode 100644 packages/light-react/src/stores/sendStore.js delete mode 100644 packages/light-react/src/stores/signerStore.js diff --git a/packages/light-react/src/App/App.js b/packages/light-react/src/App/App.js index d5197696..c1043dcd 100644 --- a/packages/light-react/src/App/App.js +++ b/packages/light-react/src/App/App.js @@ -19,7 +19,6 @@ import Overlay from '../Overlay'; import Receive from '../Receive'; import Send from '../Send'; import Settings from '../Settings'; -import Signer from '../Send/Signer'; import { STATUS } from '../stores/healthStore'; import Tokens from '../Tokens'; import './App.css'; @@ -80,7 +79,6 @@ class App extends Component { - diff --git a/packages/light-react/src/Send/Send.js b/packages/light-react/src/Send/Send.js index e7f3c8ac..7cfc8345 100644 --- a/packages/light-react/src/Send/Send.js +++ b/packages/light-react/src/Send/Send.js @@ -3,49 +3,25 @@ // // SPDX-License-Identifier: MIT -import React, { PureComponent } from 'react'; -import { defaultAccount$, myBalance$ } from '@parity/light.js'; -import { map } from 'rxjs/operators'; -import { fromWei, toWei } from '@parity/api/lib/util/wei'; -import light from 'light-hoc'; -import { Link } from 'react-router-dom'; +import React, { Component } from 'react'; +import { inject, observer } from 'mobx-react'; +import { Link, Route, Redirect, Switch } from 'react-router-dom'; -import ethereumIcon from '../assets/img/tokens/ethereum.png'; - -@light({ - balance: () => myBalance$().pipe(map(value => +fromWei(value))), - me: defaultAccount$ -}) -class Send extends PureComponent { - state = { - amount: 0.01, // In Ether - gas: 21000, - to: '0x00Ae02834e91810B223E54ce3f9B7875258a1747' - }; - - handleChangeAmount = ({ target: { value } }) => - this.setState({ amount: value }); - - handleChangeGas = ({ target: { value } }) => this.setState({ gas: value }); - - handleChangeTo = ({ target: { value } }) => this.setState({ to: value }); - - handleSubmit = e => { - e.preventDefault(); - const { history, me } = this.props; - const { amount, gas, to } = this.state; - const tx = { - from: me, - gas, - to, - value: toWei(amount) - }; - history.push(`/signer`, tx); - }; +import Sent from './Sent'; +import Signer from './Signer'; +import TxForm from './TxForm'; +@inject('sendStore') +@observer +class Send extends Component { render () { - const { balance } = this.props; - const { amount, gas, to } = this.state; + const { + sendStore: { token } + } = this.props; + + if (!token) { + return ; + } return (
@@ -56,74 +32,17 @@ class Send extends PureComponent {
-

Send Ethereum

+

Send {token.name}

-
-
-
-
- ethereum -
-
Ethereum
-
- {balance} - ETH -
-
-
-
-
-
- - - -
-
- -