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
dbc28533
Commit
dbc28533
authored
Oct 14, 2016
by
Manuel Araoz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes for StandardToken
parent
a1f7de0c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
23 deletions
+54
-23
Bounty.sol
contracts/Bounty.sol
+6
-5
ERC20.sol
contracts/ERC20.sol
+8
-9
StandardToken.sol
contracts/StandardToken.sol
+7
-8
ExampleToken.sol
contracts/examples/ExampleToken.sol
+32
-0
package.json
package.json
+1
-1
No files found.
contracts/Bounty.sol
View file @
dbc28533
pragma solidity ^0.4.0;
import './PullPayment.sol';
import './examples/ExampleToken.sol';
/*
* Bounty
* This bounty will pay out if you can cause a Token's balance
* This bounty will pay out if you can cause a
Example
Token's balance
* to be lower than its totalSupply, which would mean that it doesn't
* have sufficient ether for everyone to withdraw.
*/
...
...
@@ -16,16 +17,16 @@ contract Bounty is PullPayment {
if (claimed) throw;
}
function createTarget() returns(Token) {
Token target = new Token(0
);
function createTarget() returns(
Example
Token) {
ExampleToken target = new ExampleToken(
);
researchers[target] = msg.sender;
return target;
}
function claim(Token target) {
function claim(
Example
Token target) {
address researcher = researchers[target];
if (researcher == 0) throw;
// check Token contract invariants
// check
Example
Token contract invariants
if (target.totalSupply() == target.balance) {
throw;
}
...
...
contracts/ERC20.sol
View file @
dbc28533
...
...
@@ -4,14 +4,13 @@ pragma solidity ^0.4.0;
// see https://github.com/ethereum/EIPs/issues/20
contract ERC20 {
function totalSupply() constant returns (uint)
;
function balanceOf(address who) constant returns (uint);
function allowance(address owner, address spender) constant returns (uint);
uint public totalSupply
;
function balanceOf(address who) constant returns (uint);
function allowance(address owner, address spender) constant returns (uint);
function transfer(address to, uint value) returns (bool ok);
function transferFrom(address from, address to, uint value) returns (bool ok);
function approve(address spender, uint value) returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
function transfer(address to, uint value) returns (bool ok);
function transferFrom(address from, address to, uint value) returns (bool ok);
function approve(address spender, uint value) returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
contracts/StandardToken.sol
View file @
dbc28533
...
...
@@ -12,11 +12,10 @@ import './SafeMath.sol';
*/
contract StandardToken is ERC20, SafeMath {
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply;
mapping(address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
function transfer(address _to, uint
256
_value) returns (bool success) {
function transfer(address _to, uint _value) returns (bool success) {
if (balances[msg.sender] < _value) {
throw;
}
...
...
@@ -26,7 +25,7 @@ contract StandardToken is ERC20, SafeMath {
return true;
}
function transferFrom(address _from, address _to, uint
256
_value) returns (bool success) {
function transferFrom(address _from, address _to, uint _value) returns (bool success) {
var _allowance = allowed[_from][msg.sender];
if (balances[_from] < _value ||
_allowance < _value) {
...
...
@@ -40,17 +39,17 @@ contract StandardToken is ERC20, SafeMath {
return true;
}
function balanceOf(address _owner) constant returns (uint
256
balance) {
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
function approve(address _spender, uint
256
_value) returns (bool success) {
function approve(address _spender, uint _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint
256
remaining) {
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
...
...
contracts/examples/ExampleToken.sol
0 → 100644
View file @
dbc28533
pragma solidity ^0.4.0;
import "../StandardToken.sol";
contract ExampleToken is StandardToken {
string public name = "ExampleToken";
string public symbol = "TOK";
uint public decimals = 18;
// 1 ether = 500 example tokens
uint PRICE = 500;
function () payable {
createTokens(msg.sender);
}
function createTokens(address recipient) payable {
if (msg.value == 0) throw;
uint tokens = safeMul(msg.value, getPrice());
totalSupply = safeAdd(totalSupply, tokens);
balances[recipient] = safeAdd(balances[recipient], tokens);
}
// replace this with any other price function
function getPrice() constant returns (uint result){
return PRICE;
}
}
package.json
View file @
dbc28533
...
...
@@ -5,7 +5,7 @@
"main"
:
"truffle.js"
,
"devDependencies"
:
{},
"scripts"
:
{
"test"
:
"
echo
\"
Error: no test specified
\"
&& exit 1
"
,
"test"
:
"
truffle test
"
,
"install"
:
"scripts/install.sh"
},
"repository"
:
{
...
...
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