Skip to content

Commit

Permalink
Merge pull request PortalNetwork#41 from ahlumin/develop
Browse files Browse the repository at this point in the history
fix something error in Arena page
  • Loading branch information
ahlumin authored Jul 25, 2018
2 parents aef95e7 + 27aa0e5 commit 0688d00
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
8 changes: 5 additions & 3 deletions dapp/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ class App extends Component {

// 開局, 前往鬥技場
handleGoArena = async e => {
this.setState({
isLoadingCoinLoading: true,
});

const { network, account, } = this.props.metaMask;
console.log('network', network)
console.log('account', account)

const result = await doGetOwnedTokens(network, account);
const cardsPromises = result.map(cur => doGetTokenProperty(network, cur.c));
const detailResult = await Promise.all(cardsPromises);
Expand All @@ -117,6 +118,7 @@ class App extends Component {
});

this.setState({
isLoadingCoinLoading: false,
isShowArena: true,
userOwnCards,
});
Expand Down
25 changes: 15 additions & 10 deletions dapp/src/components/Arena/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import style from './Arena.css';
import { TweenMax, } from "gsap/TweenMax";
import BattleCard from '../BattleCard';
import Loading from '../Loading';
import LoadingCoin from '../LoadingCoin';
import gameplaytitleImg from '../../images/gameplaytitle.png';
import playgameImg from '../../images/playgame.png';
import historyImg from '../../images/history.png';
Expand Down Expand Up @@ -71,7 +72,6 @@ export default class extends React.Component {
const { betEth, selectedCardIdx, } = this.state;
const { account, network } = metaMask;


if (betEth > 1 || betEth < 0.01) {
alert('bet eth should not be bigger than 1 and less than 0.01');
return;
Expand All @@ -91,6 +91,14 @@ export default class extends React.Component {
};

web3.eth.sendTransaction(tx, (err, response) => {
if(err) {
alert('Sorry, transaction failed');
this.setState({
isLoading: false,
});
return;
}

let t = setInterval(async () => {
const result = await axios.get(`https://api-ropsten.etherscan.io/api?module=transaction&action=gettxreceiptstatus&txhash=${response}&apikey=RAADZVN65BQA7G839DFN3VHWCZBQMRBR11`)
if (result.data.status === "1") {
Expand Down Expand Up @@ -209,7 +217,7 @@ export default class extends React.Component {
'QmWzdBNu1ikXvcXo7C1WyUk3FxWRnDo5gt2WKm14Rcs1Pc',
'Qmf8MPrUF41e5N5rtXVEGZg5AC7m8NLsjqf9ad9fvwVSrw',
]
console.log('battleResult', battleResult)

if (!selectedCard) {
return null;
}
Expand All @@ -224,13 +232,6 @@ export default class extends React.Component {
<img src={gameplaytitleImg} />
</div>

{
isLoading &&
<div className={cx('loading-spinner')}>
<div style={{ display: 'inline-block', width: '100px' }}><Loading /></div>
</div>
}

{ /* 開局 */}
{
!isLoading && !isShowHistory && !isShowResult &&
Expand All @@ -250,7 +251,7 @@ export default class extends React.Component {

<div className={cx('left-item')}>
<span className={cx('bet_eth_field')}>
<input type="number" name="betEth" value={betEth} onChange={this.handleBetETHChange} />
<input type="number" name="betEth" value={betEth} max="1" step="0.01" min="0.01" onChange={this.handleBetETHChange} />
</span>
<a onClick={this.handlePlaceBet}>
<img className={cx('place_bet_button')} src={playgameImg} />
Expand Down Expand Up @@ -376,6 +377,10 @@ export default class extends React.Component {

</div>
}

{
isLoading && <LoadingCoin />
}
</div>
)

Expand Down

0 comments on commit 0688d00

Please sign in to comment.