Skip to content

Commit

Permalink
retrieve money button
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Waas committed Mar 12, 2018
1 parent a38ba4f commit aca4008
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import getWeb3 from './utils/getWeb3';
import { connect } from 'react-redux';

import BankAndUserFunds from './BankAndUserFunds';
import RetrieveMoney from './RetrieveMoney';
import RouletteGame from './RouletteGame';

import './css/oswald.css';
Expand Down Expand Up @@ -39,6 +40,7 @@ class App extends React.Component {
<div className="pure-u-1-1">
<h2>Roulette Contract</h2>
{ this._showRouletteUI() && <BankAndUserFunds /> }
{ this._showRouletteUI() && <RetrieveMoney /> }
{ this._showRouletteUI() && <RouletteGame /> }
{ !this.props.web3 && <NoMetaMask /> }
{ this.state.incorrectNetwork && <IncorrectNetwork /> }
Expand Down
39 changes: 39 additions & 0 deletions src/RetrieveMoney.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { connect } from 'react-redux';

class RetrieveMoney extends React.Component {
constructor(props) {
super(props);
this._onButtonClick = this._onButtonClick.bind(this);
}

render() {
return (
<div
className="retrieve-money redbg"
onClick={ this._onButtonClick }
>
Retrieve Money
</div>
);
}

_onButtonClick() {
if (this.props.gameState === 'loading') { return; }

this.props.web3.eth.getAccounts(async (error, accounts) => {
const rouletteInstance = await this.props.roulette.deployed();
await rouletteInstance.retrieveMoney({ from: accounts[0] });
});
}
}

const mapStateToProps = state => {
return {
gameState: state.gameState,
roulette: state.roulette,
web3: state.web3,
};
}

export default connect(mapStateToProps)(RetrieveMoney);
19 changes: 19 additions & 0 deletions src/css/roulette-wheel.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@

}

.retrieve-money {
font-size: 15pt;
position: absolute;
right: 0;
width: 8em;
height: 3em;
color: #FFF;
text-align: center;
cursor: pointer;
line-height: 3em;
border-radius: 1em;
margin: .2em;
float: left;
box-shadow: 0 0 1em #333;
border-bottom: solid .1em rgba(0, 0, 0, 1);
margin-right: 20px;
margin-top: -55px;
}

div.container4 {
height: 500px;
position: relative }
Expand Down

0 comments on commit aca4008

Please sign in to comment.