Skip to content

Commit

Permalink
Merge branch 'bounty'
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Aug 21, 2016
2 parents 61fad09 + eaee4d7 commit 8623ac4
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 3 deletions.
74 changes: 74 additions & 0 deletions app/javascripts/BountyInstruction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';

export default class BountyInstruction extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false
};
}

handleOpen(){
this.setState({open: true});
}

handleClose(){
this.setState({open: false});
}

render() {
const actions = [
<FlatButton
label="Ok"
primary={true}
onTouchTap={this.handleClose.bind(this)}
/>
];

return(
<span>
<FlatButton style={{color:'white'}} label="Bounty" onClick={ () => {this.handleOpen()}} />
<Dialog
title="Bounty program"
actions={actions}
open={this.state.open}
onRequestClose={this.handleClose.bind(this)}
modal={false}
autoScrollBodyContent={true}
contentStyle={{width:'90%', maxWidth:'none'}}
>
<div>
<p>Please help our site secure by participating our automatic bug bounty program.</p>
<ul>
<li>
DemoBounty Address:
<a
target='_blank'
href={ `https://testnet.etherscan.io/address/${this.props.demoBounty.address}` }>
{this.props.demoBounty.address}
</a>
</li>
<li>
Bounty Address:
<a
target='_blank'
href={ `https://testnet.etherscan.io/address/${this.props.bounty.address}` }>
{this.props.bounty.address}
</a>
</li>
</ul>
<p>
Read "Fault tolerance and Automatic bug bounties" section of
&nbsp;<a target="_blank" href="https://medium.com/bitcorps-blog/onward-with-ethereum-smart-contract-security-97a827e47702#.67zm0vrin"> Onward with Ethereum Smart Contract Security </a>&nbsp;
blog post for more detail.for more detail.
</p>
</div>
</Dialog>
</span>
)
}
}

export default BountyInstruction;
17 changes: 15 additions & 2 deletions app/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import FlatButton from 'material-ui/FlatButton';
import ConferenceDetail from './ConferenceDetail';
import FormInput from './FormInput';
import Bounty from '../../build/contracts/Bounty.sol.js';
import DemoBounty from '../../build/contracts/DemoBounty.sol.js';
import BountyInstruction from './BountyInstruction';
import Notification from './Notification';
import Instruction from './Instruction';
import Participants from './Participants';
Expand Down Expand Up @@ -39,6 +42,11 @@ if(typeof web3 !== 'undefined'){ // eg: If accessed via mist
}
web3.setProvider(provider);
Conference.setProvider(provider);
Bounty.setProvider(provider);
DemoBounty.setProvider(provider);
const bounty = Bounty.deployed();
const demoBounty = DemoBounty.deployed();

const contract = Conference.deployed();
const eventEmitter = EventEmitter()

Expand Down Expand Up @@ -159,7 +167,6 @@ function getAccounts(callback){
callback(accs);
})
}

const App = (props) => (
<div>
<MuiThemeProvider muiTheme={getMuiTheme()}>
Expand All @@ -169,8 +176,14 @@ const App = (props) => (
<span>Block Party<span style={{fontSize:'small', fontFamily:'sans-serif'}}> - NO BLOCK NO PARTY -</span></span>
}
iconElementLeft={<Avatar src="/images/nightclub-white.png" size={50} backgroundColor="rgb(96, 125, 139)" />}
iconElementRight={<FlatButton label="About" onClick={ () => {eventEmitter.emit('instruction')}} />}
iconElementRight={
<span>
<FlatButton style={{color:'white'}} label="About" onClick={ () => {eventEmitter.emit('instruction')}} />
<BountyInstruction demoBounty={demoBounty} bounty={bounty}/>
</span>
}
/>

<Instruction eventEmitter={eventEmitter} />
<Notification eventEmitter={eventEmitter} />
<div style={styles.div}>
Expand Down
2 changes: 1 addition & 1 deletion contracts/Bounty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './zeppelin/Rejector.sol';
/*
* Bounty
* This bounty will pay out if you can cause a Conference's balance
* to be different from its totalBalance, which would mean that it doesn't
* to be lower from its totalBalance, which would mean that it doesn't
* have sufficient ether for everyone to withdraw.
*/
contract Bounty is PullPaymentCapable, Rejector{
Expand Down
4 changes: 4 additions & 0 deletions contracts/Conference.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ contract Conference is Rejector, Ownable {
Payback(participantsIndex[i], payout(), participantsIndex[i].balance, false);
}
}
/*
* Actual balance may have some left over if 4 payout is divided among 3 attendees
* eg: 4 / 3 = 1.333
*/
totalBalance = 0;
ended = true;
}
Expand Down
52 changes: 52 additions & 0 deletions contracts/DemoBounty.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import './Conference.sol';
import './zeppelin/PullPaymentCapable.sol';

/*
* DemoBounty
* This bounty will pay out if you can cause a Conference's balance
* to not to be same as its totalBalance, which can be done by
* dividing payout with undividable number (eg: 4/3 = 1.3333...)
*/
contract DemoBounty is PullPaymentCapable, Rejector{
uint public totalBounty;
bool public claimed;
mapping(address => address) public researchers;
event TargetCreation(address createdAddress);
event Error(string message);

function contribute() {
totalBounty = msg.value;
if (claimed) throw;
}

function createTarget() returns(Conference) {
Conference target = new Conference();
researchers[target] = msg.sender;
TargetCreation(target);
return target;
}

modifier hasResearcher(Conference target) {
address researcher = researchers[target];
if (researcher != 0){
_
}else{
Error('there are no researcher');
}
}

modifier hasBug(Conference target) {
if (target.totalBalance() != target.balance){
_
}else{
Error('No security breach');
}
}

function claim(Conference target) hasResearcher(target) hasBug(target){
address researcher = researchers[target];
asyncSend(researcher, this.balance);
totalBounty = 0;
claimed = true;
}
}
1 change: 1 addition & 0 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = function(deployer) {
deployer.deploy(Conference);
deployer.deploy(Bounty);
deployer.deploy(DemoBounty);
deployer.autolink();
};
4 changes: 4 additions & 0 deletions releases.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.4

- Add Bounty program
- Support metamask

## v0.3

Expand Down

0 comments on commit 8623ac4

Please sign in to comment.