Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
99f288bf
Commit
99f288bf
authored
Oct 27, 2016
by
Makoto Inoue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate TokenBounties into Bounty
parent
caca41f8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
53 deletions
+15
-53
Bounty.sol
contracts/Bounty.sol
+7
-7
CrowdsaleTokenBounty.sol
contracts/bounties/CrowdsaleTokenBounty.sol
+0
-38
2_deploy_contracts.js
migrations/2_deploy_contracts.js
+1
-1
Bounty.js
test/Bounty.js
+7
-7
No files found.
contracts/
bounties/SimpleToken
Bounty.sol
→
contracts/Bounty.sol
View file @
99f288bf
pragma solidity ^0.4.0;
pragma solidity ^0.4.0;
import '../PullPayment.sol';
import './PullPayment.sol';
import '../Killable.sol';
import './Killable.sol';
/*
/*
* Bounty
* Bounty
* This bounty will pay out if you can cause a SimpleToken's balance
* This bounty will pay out to a researcher if he/she breaks invariant logic of
* to be lower than its totalSupply, which would mean that it doesn't
* the contract you bet reward against.
* have sufficient ether for everyone to withdraw.
*/
*/
contract Factory {
contract Factory {
...
@@ -16,7 +16,7 @@ contract Target {
...
@@ -16,7 +16,7 @@ contract Target {
function checkInvariant() returns(bool);
function checkInvariant() returns(bool);
}
}
contract
SimpleToken
Bounty is PullPayment, Killable {
contract Bounty is PullPayment, Killable {
Target target;
Target target;
bool public claimed;
bool public claimed;
address public factoryAddress;
address public factoryAddress;
...
@@ -28,7 +28,7 @@ contract SimpleTokenBounty is PullPayment, Killable {
...
@@ -28,7 +28,7 @@ contract SimpleTokenBounty is PullPayment, Killable {
if (claimed) throw;
if (claimed) throw;
}
}
function
SimpleToken
Bounty(address _factoryAddress){
function Bounty(address _factoryAddress){
factoryAddress = _factoryAddress;
factoryAddress = _factoryAddress;
}
}
...
...
contracts/bounties/CrowdsaleTokenBounty.sol
deleted
100644 → 0
View file @
caca41f8
pragma solidity ^0.4.0;
import '../PullPayment.sol';
import '../token/CrowdsaleToken.sol';
/*
* Bounty
* This bounty will pay out if you can cause a CrowdsaleToken's balance
* to be lower than its totalSupply, which would mean that it doesn't
* have sufficient ether for everyone to withdraw.
*/
contract CrowdsaleTokenBounty is PullPayment {
bool public claimed;
mapping(address => address) public researchers;
function() {
if (claimed) throw;
}
function createTarget() returns(CrowdsaleToken) {
CrowdsaleToken target = new CrowdsaleToken();
researchers[target] = msg.sender;
return target;
}
function claim(CrowdsaleToken target) {
address researcher = researchers[target];
if (researcher == 0) throw;
// Check CrowdsaleToken contract invariants
// Customize this to the specifics of your contract
if (target.totalSupply() == target.balance) {
throw;
}
asyncSend(researcher, this.balance);
claimed = true;
}
}
migrations/2_deploy_contracts.js
View file @
99f288bf
...
@@ -2,7 +2,7 @@ module.exports = function(deployer) {
...
@@ -2,7 +2,7 @@ module.exports = function(deployer) {
deployer
.
deploy
(
PullPaymentBid
);
deployer
.
deploy
(
PullPaymentBid
);
deployer
.
deploy
(
BadArrayUse
);
deployer
.
deploy
(
BadArrayUse
);
deployer
.
deploy
(
ProofOfExistence
);
deployer
.
deploy
(
ProofOfExistence
);
deployer
.
deploy
(
SimpleToken
Bounty
);
deployer
.
deploy
(
Bounty
);
deployer
.
deploy
(
CrowdsaleTokenBounty
);
deployer
.
deploy
(
CrowdsaleTokenBounty
);
deployer
.
deploy
(
Ownable
);
deployer
.
deploy
(
Ownable
);
deployer
.
deploy
(
LimitFunds
);
deployer
.
deploy
(
LimitFunds
);
...
...
test/Bounty.js
View file @
99f288bf
...
@@ -10,7 +10,7 @@ contract('Bounty', function(accounts) {
...
@@ -10,7 +10,7 @@ contract('Bounty', function(accounts) {
it
(
"creates bounty contract with factory address"
,
function
(
done
){
it
(
"creates bounty contract with factory address"
,
function
(
done
){
var
target
=
SecureTargetMock
.
deployed
();
var
target
=
SecureTargetMock
.
deployed
();
SimpleToken
Bounty
.
new
(
target
.
address
).
Bounty
.
new
(
target
.
address
).
then
(
function
(
bounty
){
then
(
function
(
bounty
){
return
bounty
.
factoryAddress
.
call
()
return
bounty
.
factoryAddress
.
call
()
}).
}).
...
@@ -25,7 +25,7 @@ contract('Bounty', function(accounts) {
...
@@ -25,7 +25,7 @@ contract('Bounty', function(accounts) {
var
owner
=
accounts
[
0
];
var
owner
=
accounts
[
0
];
var
reward
=
web3
.
toWei
(
1
,
"ether"
);
var
reward
=
web3
.
toWei
(
1
,
"ether"
);
SimpleToken
Bounty
.
new
(
target
.
address
).
Bounty
.
new
(
target
.
address
).
then
(
function
(
bounty
){
then
(
function
(
bounty
){
sendReward
(
owner
,
bounty
.
address
,
reward
);
sendReward
(
owner
,
bounty
.
address
,
reward
);
assert
.
equal
(
reward
,
web3
.
eth
.
getBalance
(
bounty
.
address
).
toNumber
())
assert
.
equal
(
reward
,
web3
.
eth
.
getBalance
(
bounty
.
address
).
toNumber
())
...
@@ -38,7 +38,7 @@ contract('Bounty', function(accounts) {
...
@@ -38,7 +38,7 @@ contract('Bounty', function(accounts) {
var
owner
=
accounts
[
0
];
var
owner
=
accounts
[
0
];
var
reward
=
web3
.
toWei
(
1
,
"ether"
);
var
reward
=
web3
.
toWei
(
1
,
"ether"
);
var
bounty
;
var
bounty
;
SimpleToken
Bounty
.
new
(
target
.
address
).
Bounty
.
new
(
target
.
address
).
then
(
function
(
_bounty
){
then
(
function
(
_bounty
){
bounty
=
_bounty
;
bounty
=
_bounty
;
sendReward
(
owner
,
bounty
.
address
,
reward
);
sendReward
(
owner
,
bounty
.
address
,
reward
);
...
@@ -55,7 +55,7 @@ contract('Bounty', function(accounts) {
...
@@ -55,7 +55,7 @@ contract('Bounty', function(accounts) {
it
(
"checkInvariant returns true"
,
function
(
done
){
it
(
"checkInvariant returns true"
,
function
(
done
){
var
targetFactory
=
SecureTargetFactory
.
deployed
();
var
targetFactory
=
SecureTargetFactory
.
deployed
();
var
bounty
;
var
bounty
;
SimpleToken
Bounty
.
new
(
targetFactory
.
address
).
Bounty
.
new
(
targetFactory
.
address
).
then
(
function
(
_bounty
)
{
then
(
function
(
_bounty
)
{
bounty
=
_bounty
;
bounty
=
_bounty
;
return
bounty
.
createTarget
();
return
bounty
.
createTarget
();
...
@@ -75,7 +75,7 @@ contract('Bounty', function(accounts) {
...
@@ -75,7 +75,7 @@ contract('Bounty', function(accounts) {
var
researcher
=
accounts
[
1
];
var
researcher
=
accounts
[
1
];
var
reward
=
web3
.
toWei
(
1
,
"ether"
);
var
reward
=
web3
.
toWei
(
1
,
"ether"
);
SimpleToken
Bounty
.
new
(
targetFactory
.
address
).
Bounty
.
new
(
targetFactory
.
address
).
then
(
function
(
bounty
)
{
then
(
function
(
bounty
)
{
var
event
=
bounty
.
TargetCreated
({});
var
event
=
bounty
.
TargetCreated
({});
event
.
watch
(
function
(
err
,
result
)
{
event
.
watch
(
function
(
err
,
result
)
{
...
@@ -108,7 +108,7 @@ contract('Bounty', function(accounts) {
...
@@ -108,7 +108,7 @@ contract('Bounty', function(accounts) {
it
(
"checkInvariant returns false"
,
function
(
done
){
it
(
"checkInvariant returns false"
,
function
(
done
){
var
targetFactory
=
InsecureTargetFactory
.
deployed
();
var
targetFactory
=
InsecureTargetFactory
.
deployed
();
var
bounty
;
var
bounty
;
SimpleToken
Bounty
.
new
(
targetFactory
.
address
).
Bounty
.
new
(
targetFactory
.
address
).
then
(
function
(
_bounty
)
{
then
(
function
(
_bounty
)
{
bounty
=
_bounty
;
bounty
=
_bounty
;
return
bounty
.
createTarget
();
return
bounty
.
createTarget
();
...
@@ -128,7 +128,7 @@ contract('Bounty', function(accounts) {
...
@@ -128,7 +128,7 @@ contract('Bounty', function(accounts) {
var
researcher
=
accounts
[
1
];
var
researcher
=
accounts
[
1
];
var
reward
=
web3
.
toWei
(
1
,
"ether"
);
var
reward
=
web3
.
toWei
(
1
,
"ether"
);
SimpleToken
Bounty
.
new
(
targetFactory
.
address
).
Bounty
.
new
(
targetFactory
.
address
).
then
(
function
(
bounty
)
{
then
(
function
(
bounty
)
{
var
event
=
bounty
.
TargetCreated
({});
var
event
=
bounty
.
TargetCreated
({});
event
.
watch
(
function
(
err
,
result
)
{
event
.
watch
(
function
(
err
,
result
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment