|
@@ -7,83 +7,79 @@ Based on standardised APIs: https://github.com/ethereum/wiki/wiki/Standardized_C
|
|
|
import "Token";
|
|
|
|
|
|
contract Standard_Token is Token {
|
|
|
- uint total;
|
|
|
- bytes32 defaultIdentifier = bytes32(address(this));
|
|
|
|
|
|
- function Standard_Token(uint _initialAmount) {
|
|
|
- balances[msg.sender][bytes32(address(this))] = _initialAmount;
|
|
|
- totals[defaultIdentifier] = _initialAmount;
|
|
|
+ function Standard_Token(uint256 _initial_amount) {
|
|
|
+ balances[msg.sender] = _initial_amount;
|
|
|
+ total_supply = _initial_amount;
|
|
|
}
|
|
|
|
|
|
- function transfer(uint _value, bytes32 _identifier, address _to) returns (bool _success) {
|
|
|
- if (balances[msg.sender][_identifier] >= _value) {
|
|
|
- balances[msg.sender][_identifier] -= _value;
|
|
|
- balances[_to][_identifier] += _value;
|
|
|
- Transfer(msg.sender, _identifier, _to, _value);
|
|
|
+ function transfer(address _to, uint256 _value) returns (bool success) {
|
|
|
+ if (balances[msg.sender] >= _value) {
|
|
|
+ balances[msg.sender] -= _value;
|
|
|
+ balances[_to] += _value;
|
|
|
+ Transfer(msg.sender, _to, _value);
|
|
|
return true;
|
|
|
} else { return false; }
|
|
|
}
|
|
|
|
|
|
- function transferFrom(address _from, bytes32 _identifier, uint _value, address _to) returns (bool _success) {
|
|
|
- if (balances[_from][_identifier] >= _value) {
|
|
|
+ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
|
|
|
+ if (balances[_from] >= _value) {
|
|
|
bool transfer = false;
|
|
|
- if(approved[_from][_identifier][msg.sender]) {
|
|
|
+ if(approved[_from][msg.sender]) {
|
|
|
transfer = true;
|
|
|
} else {
|
|
|
- if(_value <= approved_once[_from][_identifier][msg.sender]) {
|
|
|
+ if(_value <= approved_once[_from][msg.sender]) {
|
|
|
transfer = true;
|
|
|
- approved_once[_from][_identifier][msg.sender] = 0; //reset
|
|
|
+ approved_once[_from][msg.sender] = 0; //reset
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(transfer == true) {
|
|
|
- balances[_from][_identifier] -= _value;
|
|
|
- balances[_to][_identifier] += _value;
|
|
|
- Transfer(_from, _identifier, _to, _value);
|
|
|
+ balances[_from] -= _value;
|
|
|
+ balances[_to] += _value;
|
|
|
+ Transfer(_from, _to, _value);
|
|
|
return true;
|
|
|
} else { return false; }
|
|
|
} else { return false; }
|
|
|
}
|
|
|
|
|
|
- function balanceOf(address _addr, bytes32 _identifier) constant returns (uint _r) {
|
|
|
- return balances[_addr][_identifier];
|
|
|
+ function balanceOf(address _address) constant returns (uint256 balance) {
|
|
|
+ return balances[_address];
|
|
|
}
|
|
|
|
|
|
- function approve(address _addr, bytes32 _identifier) returns (bool _success) {
|
|
|
- approved[msg.sender][_identifier][_addr] = true;
|
|
|
- AddressApproval(msg.sender, _identifier, _addr, true);
|
|
|
+ function approve(address _address) returns (bool success) {
|
|
|
+ approved[msg.sender][_address] = true;
|
|
|
+ AddressApproval(msg.sender, _address, true);
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
- function unapprove(address _addr, bytes32 _identifier) returns (bool _success) {
|
|
|
- approved[msg.sender][_identifier][_addr] = false;
|
|
|
- approved_once[msg.sender][_identifier][_addr] = 0;
|
|
|
- //debatable whether to include...
|
|
|
- AddressApproval(msg.sender, _identifier, _addr, false);
|
|
|
- AddressApprovalOnce(msg.sender, _identifier, _addr, 0);
|
|
|
+
|
|
|
+ function unapprove(address _address) returns (bool success) {
|
|
|
+ approved[msg.sender][_address] = false;
|
|
|
+ approved_once[msg.sender][_address] = 0;
|
|
|
+ AddressApproval(msg.sender, _address, false);
|
|
|
+ AddressApprovalOnce(msg.sender, _address, 0);
|
|
|
}
|
|
|
-
|
|
|
- function isApprovedFor(address _target, bytes32 _identifier, address _proxy) constant returns (bool _r) {
|
|
|
- return approved[_target][_identifier][_proxy];
|
|
|
+
|
|
|
+ function isApprovedFor(address _target, address _proxy) constant returns (bool success) {
|
|
|
+ return approved[_target][_proxy];
|
|
|
}
|
|
|
|
|
|
- function approveOnce(address _addr, bytes32 _identifier, uint256 _maxValue) returns (bool _success) {
|
|
|
- approved_once[msg.sender][_identifier][_addr] = _maxValue;
|
|
|
- AddressApprovalOnce(msg.sender, _identifier, _addr, _maxValue);
|
|
|
+ function approveOnce(address _address, uint256 _maxValue) returns (bool success) {
|
|
|
+ approved_once[msg.sender][_address] = _maxValue;
|
|
|
+ AddressApprovalOnce(msg.sender, _address, _maxValue);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- function isApprovedOnceFor(address _target, bytes32 _identifier, address _proxy) constant returns (uint _maxValue) {
|
|
|
- return approved_once[_target][_identifier][_proxy];
|
|
|
+ function isApprovedOnceFor(address _target, address _proxy) constant returns (uint256 _maxValue) {
|
|
|
+ return approved_once[_target][_proxy];
|
|
|
}
|
|
|
|
|
|
- function totalAmount(bytes32 _identifier) constant returns (uint _totalAmount) {
|
|
|
- return totals[_identifier];
|
|
|
+ function totalSupply() constant returns (uint256 _total) {
|
|
|
+ return total_supply;
|
|
|
}
|
|
|
|
|
|
- //explicitly not publicly accessible. Should rely on methods for purpose of standardization.
|
|
|
- mapping (bytes32 => uint) totals;
|
|
|
- mapping (address => mapping (bytes32 => uint)) balances;
|
|
|
- mapping (address => mapping (bytes32 => mapping (address => bool))) approved;
|
|
|
- mapping (address => mapping (bytes32 => mapping (address => uint256))) approved_once;
|
|
|
+ mapping (address => uint) balances;
|
|
|
+ mapping (address => mapping (address => bool)) approved;
|
|
|
+ mapping (address => mapping (address => uint256)) approved_once;
|
|
|
+ uint256 total_supply;
|
|
|
}
|