Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
Support testnet.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork committed Jul 17, 2016
1 parent bb11d2f commit ec4c1fe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
13 changes: 6 additions & 7 deletions src/client/scripts/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ import {HexDump, Balance, InputBalance, TokenContractBalance, Account, AccountBa
import {TotalDAOTokenBalance, DAOTokenBalance, InteractionConsole} from './react-dao.jsx';
import {Log} from './react-events.jsx';

/*dao.approve(withdrawable.address, dao.balanceOf(eth.accounts[0]), {from: eth.accounts[0]})
withdrawable.withdraw({from: eth.accounts[0], gas: 500000})*/

export var DAO = web3.eth.contract([{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"},{"constant":true,"inputs":[],"name":"standard","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Approval","type":"event"}]);
export var Withdrawable = web3.eth.contract([{"constant":false,"inputs":[],"name":"trusteeWithdraw","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"mainDAO","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"trustee","outputs":[{"name":"","type":"address"}],"type":"function"}]);

// Approval(_owner, _spender, _value)

export class App extends React.Component {
constructor() {
super();
Expand All @@ -32,13 +27,17 @@ export class App extends React.Component {
});
}
}

render() {
var theDAO = DAO.at(this.props.dao);
var theWithdraw = Withdrawable.at(this.props.withdraw);

window.theDAO = theDAO;
window.theWithdraw = theWithdraw;

var allUserAccounts = this.state.allUserAccounts;
return <div id="app">
<div id="youhave">You have <DAOTokenBalance address={allUserAccounts} contract={theDAO} /> to be claimed!</div>
<div id="youhave">You have <DAOTokenBalance address={allUserAccounts} contract={theDAO} /> to be claimed</div>
<InteractionConsole user={allUserAccounts} dao={theDAO} withdraw={theWithdraw}/>
<div id="extrainfo"><span>DAO contract address: <Account addr={this.props.dao} /> | Withdraw contract address: <Account addr={this.props.withdraw} /></span></div>
</div>;
Expand Down
7 changes: 6 additions & 1 deletion src/client/scripts/entry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ import 'jquery';
import React from 'react';
import {render} from 'react-dom';
import {App} from './app.jsx'
import {web3} from './web3plus.jsx';

render(<App dao="0xbb9bc244d798123fde783fcc1c72d3bb8c189413" withdraw="0xbf4ed7b27f1d666546e30d74d50d173d20bca754"/>, document.getElementById('app'));
if (+web3.eth.getBalance('0x7deBEFD57d9BF7aA8af74AB62Ac629f5a8a09694') > 0) {
render(<App dao="0x7deBEFD57d9BF7aA8af74AB62Ac629f5a8a09694" withdraw="0xd89bfE6C0F3747163db598A1C316C997fC91D113"/>, document.getElementById('app'));
} else {
render(<App dao="0xbb9bc244d798123fde783fcc1c72d3bb8c189413" withdraw="0xbf4ed7b27f1d666546e30d74d50d173d20bca754"/>, document.getElementById('app'));
}
18 changes: 16 additions & 2 deletions src/client/scripts/react-dao.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@ export class InteractionConsole extends React.Component {
var b = this.props.dao.balanceOf(addr);
if (+b > new BigNumber(0)) {
if (+web3.eth.getBalance(addr) > 0) {
this.props.dao.approve(this.props.withdraw.address, b, {from: addr});
this.props.withdraw.withdraw({from: addr, gas: 500000});
this.props.dao.approve(this.props.withdraw.address, b, {from: addr}, (e, r) => {
console.log("e=" + JSON.stringify(e) + "; r=" + JSON.stringify(r));
if (e) {
alert("Error authorising DAO token transfer!" + e);
} else {
this.props.withdraw.withdraw({from: addr, gas: 500000}, (e, r) => {
if (e) {
alert("Error withdrawing!" + e);
} else {
// all good!
alert("All good!");
}
});
}
});

} else {
alert("Cannot afford to get refund for address " + addr + ". Ensure there is at least 0.001 ETH in the account.");
}
Expand Down

0 comments on commit ec4c1fe

Please sign in to comment.