import React from 'react'
import { FixedLimitProfit } from './action'
-import {dueBlockHeight, expireBlockHeight, totalAmountBill, totalAmountCapital} from "../../constants";
-import {connect} from "react-redux";
+import {dueBlockHeight, gas, totalAmountBill, totalAmountCapital} from "../../constants";
class Profit extends React.Component {
this.handleSubmit = this.handleSubmit.bind(this);
}
+ componentDidMount() {
+ if (
+ window.bytom
+ && window.bytom.defaultAccount
+ ) {
+ this.setState({ account: window.bytom.defaultAccount })
+ }
+ }
+
handleInputChange(event) {
const target = event.target;
const value = target.value;
event.preventDefault();
const amount = Number(event.target.amount.value)
- const account = this.props.account
+ const account = this.state.account
const address = event.target.address.value
FixedLimitProfit(account, amount, address)
<h2>Profit</h2>
<div className="mt-3 mb-4">
<p className='lead'>Profit should get above the block height {dueBlockHeight}.</p>
- <p className='lead'>Send {this.state.amount} Bill Asset from your chrome extension account <b className="font-weight-bolder text-uppercase">{this.props.account.alias}</b>, and the address {this.state.address} will gain {this.state.amount*totalAmountCapital/totalAmountBill || ''} Deposit Asset.</p>
+ <p className='lead'>Send {this.state.amount} Bill Asset from your chrome extension account <b className="font-weight-bolder text-uppercase">{this.state.account && this.state.account.alias}</b>, and the address {this.state.address} will gain {this.state.amount*totalAmountCapital/totalAmountBill || ''} Deposit Asset.</p>
</div>
<form onSubmit={this.handleSubmit}>
<div className="form-group">
value={this.state.address}
onChange={this.handleInputChange} />
</div>
- <p>Fee: 0.4 BTM</p>
+ <p>Fee: {gas} BTM</p>
<button type="submit" className="btn btn-primary">Profit to address</button>
{this.state.msg && <div className="alert alert-success mt-4" role="alert">
{this.state.msg}
}
}
-
-const mapStateToProps = state => ({
- account: state.account
-})
-
-export default connect(mapStateToProps)(Profit)
+export default Profit
import React from 'react'
import { FixedLimitDeposit} from './action'
import { dueBlockHeight, gas } from '../../constants'
-import {connect} from "react-redux";
class Save extends React.Component {
this.handleSubmit = this.handleSubmit.bind(this);
}
+ componentDidMount() {
+ if (
+ window.bytom
+ && window.bytom.defaultAccount
+ ) {
+ this.setState({ account: window.bytom.defaultAccount })
+ }
+ }
+
handleInputChange(event) {
const target = event.target;
const value = target.value;
event.preventDefault();
const amount = Number(event.target.amount.value)
- const account = this.props.account
+ const account = this.state.account
const address = account.address
FixedLimitDeposit(account, amount, address)
<h2>Deposit</h2>
<div className="mt-3 mb-4">
<p className='lead'>Deposit should happen under the block height {dueBlockHeight}.</p>
- <p className='lead' >Spend {this.state.amount} Deposit Asset from your current chrome extension account <b className="font-weight-bolder text-uppercase">{this.props.account.alias}</b> and you will get the relevant {this.state.amount} Bill Asset.</p>
+ <p className='lead' >Spend {this.state.amount} Deposit Asset from your current chrome extension account <b className="font-weight-bolder text-uppercase">{this.state.account&&this.state.account.alias}</b> and you will get the relevant {this.state.amount} Bill Asset.</p>
<p>Please make sure that your account has enough Deposit Asset.</p>
</div>
<form onSubmit={this.handleSubmit}>
}
}
-const mapStateToProps = state => ({
- account: state.account
-})
-
-export default connect(mapStateToProps)(Save)
+export default Save