import React from 'react' import { FixedLimitDeposit} from './action' import GetContractArgs from '../../constants' import {connect} from "react-redux"; class Save extends React.Component { constructor(props) { super(props); this.state = { amount: '', address: '', msg:'', error:'' }; this.handleInputChange = this.handleInputChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); } componentDidMount() { const bytom = this.props.bytom if ( bytom && bytom.default_account ) { this.setState({ account: bytom.default_account }) } } handleInputChange(event) { const target = event.target; const value = target.value; const name = target.name; this.setState({ [name]: value }); } handleSubmit(event) { event.preventDefault(); const amount = Number(event.target.amount.value) const account = this.state.account const address = account.address this.refs.btn.setAttribute("disabled", "disabled") this.setState({ error:'', msg: '' }) FixedLimitDeposit(amount, address) .then(()=> { this.refs.btn.removeAttribute("disabled"); this.setState({ error:'', msg:`Submit success!!! you spent ${amount} deposite asset,and gain ${amount} bill asset.` }) }).catch(err => { this.refs.btn.removeAttribute("disabled"); this.setState({ error:err, msg: '' }) }) } render() { return (

Deposit

Deposit should happen under the block height {GetContractArgs().dueBlockHeight}.

Spend {this.state.amount} Deposit Asset from your current chrome extension account {this.state.account&&this.state.account.alias} and you will get the relevant {this.state.amount} Bill Asset.

Please make sure that your account has enough Deposit Asset.

Fee: {GetContractArgs().gas} BTM

{this.state.msg &&
{this.state.msg}
} {this.state.error &&
{this.state.error}
}
) } } const mapStateToProps = state => ({ bytom: state.bytom, }) export default connect(mapStateToProps)(Save)