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
e7933fce
Commit
e7933fce
authored
Aug 11, 2016
by
Manuel Araoz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix token style
parent
83acbbbb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
52 deletions
+59
-52
Token.sol
contracts/Token.sol
+59
-52
No files found.
contracts/Token.sol
View file @
e7933fce
...
@@ -4,62 +4,69 @@
...
@@ -4,62 +4,69 @@
// Everything throws instead of returning false on failure.
// Everything throws instead of returning false on failure.
import 'ERC20.sol';
import 'ERC20.sol';
contract Token is ERC20
contract Token is ERC20 {
{
mapping( address => uint ) _balances;
mapping( address => mapping( address => uint ) ) _approvals;
uint _supply;
function Token( uint initial_balance ) {
mapping( address => uint ) _balances;
_balances[msg.sender] = initial_balance;
mapping( address => mapping( address => uint ) ) _approvals;
_supply = initial_balance;
uint _supply;
}
function totalSupply() constant returns (uint supply) {
function Token( uint initial_balance ) {
return _supply;
_balances[msg.sender] = initial_balance;
}
_supply = initial_balance;
function balanceOf( address who ) constant returns (uint value) {
}
return _balances[who];
}
function totalSupply() constant returns (uint supply) {
function transfer( address to, uint value) returns (bool ok) {
return _supply;
if( _balances[msg.sender] < value ) {
}
throw;
}
function balanceOf( address who ) constant returns (uint value) {
if( !safeToAdd(_balances[to], value) ) {
return _balances[who];
throw;
}
}
_balances[msg.sender] -= value;
function transfer( address to, uint value) returns (bool ok) {
_balances[to] += value;
if( _balances[msg.sender] < value ) {
Transfer( msg.sender, to, value );
throw;
return true;
}
}
function transferFrom( address from, address to, uint value) returns (bool ok) {
if( !safeToAdd(_balances[to], value) ) {
// if you don't have enough balance, throw
throw;
if( _balances[from] < value ) {
throw;
}
// if you don't have approval, throw
if( _approvals[from][msg.sender] < value ) {
throw;
}
if( !safeToAdd(_balances[to], value) ) {
throw;
}
// transfer and return true
_approvals[from][msg.sender] -= value;
_balances[from] -= value;
_balances[to] += value;
Transfer( from, to, value );
return true;
}
}
function approve(address spender, uint value) returns (bool ok) {
_balances[msg.sender] -= value;
_approvals[msg.sender][spender] = value;
_balances[to] += value;
Approval( msg.sender, spender, value );
Transfer( msg.sender, to, value );
return true;
return true;
}
function transferFrom( address from, address to, uint value) returns (bool ok) {
// if you don't have enough balance, throw
if( _balances[from] < value ) {
throw;
}
}
function allowance(address owner, address spender) constant returns (uint _allowance) {
// if you don't have approval, throw
return _approvals[owner][spender];
if( _approvals[from][msg.sender] < value ) {
throw;
}
}
function safeToAdd(uint a, uint b) internal returns (bool
) {
if( !safeToAdd(_balances[to], value)
) {
return (a + b >= a)
;
throw
;
}
}
// transfer and return true
_approvals[from][msg.sender] -= value;
_balances[from] -= value;
_balances[to] += value;
Transfer( from, to, value );
return true;
}
function approve(address spender, uint value) returns (bool ok) {
_approvals[msg.sender][spender] = value;
Approval( msg.sender, spender, value );
return true;
}
function allowance(address owner, address spender) constant returns (uint _allowance) {
return _approvals[owner][spender];
}
function safeToAdd(uint a, uint b) internal returns (bool) {
return (a + b >= a);
}
}
}
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