1 import React from 'react'
2 import { FixedLimitProfit } from './action'
3 import GetContractArgs from "../../constants";
4 import BigNumber from 'bignumber.js'
6 class Profit extends React.Component {
17 this.handleInputChange = this.handleInputChange.bind(this);
18 this.handleSubmit = this.handleSubmit.bind(this);
24 && window.bytom.defaultAccount
26 this.setState({ account: window.bytom.defaultAccount })
30 handleInputChange(event) {
31 const target = event.target;
32 const value = target.value;
33 const name = target.name;
41 event.preventDefault();
43 const amount = Number(event.target.amount.value)
44 const account = this.state.account
45 const address = event.target.address.value
47 FixedLimitProfit(account, amount, address)
51 msg:`Submit success!!! you spent ${amount} bill asset, and gain ${BigNumber(amount).multipliedBy(GetContractArgs().radio).toNumber()} deposit asset.`
65 <div className="mt-3 mb-4">
66 <p className='lead'>Profit should get above the block height {GetContractArgs().dueBlockHeight}.</p>
67 <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 {BigNumber(this.state.amount).multipliedBy(GetContractArgs().radio).toNumber() || ''} Deposit Asset.</p>
69 <form onSubmit={this.handleSubmit}>
70 <div className="form-group">
71 <label>Bill Asset Amount</label>
74 className="form-control"
75 placeholder="Amount Profit"
77 value={this.state.amount}
78 onChange={this.handleInputChange} />
80 <div className="form-group">
81 <label >Address</label>
84 className="form-control"
87 value={this.state.address}
88 onChange={this.handleInputChange} />
90 <p>Fee: {GetContractArgs().gas} BTM</p>
91 <button type="submit" className="btn btn-primary">Profit to address</button>
92 {this.state.msg && <div className="alert alert-success mt-4" role="alert">
95 {this.state.error && <div className="alert alert-danger mt-4" role="alert">
104 export default Profit