aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/tests.sh4
-rw-r--r--std/StandardToken.sol44
2 files changed, 34 insertions, 14 deletions
diff --git a/scripts/tests.sh b/scripts/tests.sh
index cf18cb26..f2142946 100755
--- a/scripts/tests.sh
+++ b/scripts/tests.sh
@@ -33,6 +33,10 @@ REPO_ROOT="$(dirname "$0")"/..
echo "Running commandline tests..."
"$REPO_ROOT/test/cmdlineTests.sh"
+echo "Checking that StandardToken.sol, owned.sol and mortal.sol produce bytecode..."
+output=$("$REPO_ROOT"/build/solc/solc --bin "$REPO_ROOT"/std/*.sol 2>/dev/null | grep "ffff" | wc -l)
+test "$output" = "3"
+
# This conditional is only needed because we don't have a working Homebrew
# install for `eth` at the time of writing, so we unzip the ZIP file locally
# instead. This will go away soon.
diff --git a/std/StandardToken.sol b/std/StandardToken.sol
index 4ff1b8f9..4dad8541 100644
--- a/std/StandardToken.sol
+++ b/std/StandardToken.sol
@@ -3,31 +3,43 @@ pragma solidity ^0.4.0;
import "./Token.sol";
contract StandardToken is Token {
- uint256 public totalSupply;
- mapping (address => uint256) public balanceOf;
+ uint256 supply;
+ mapping (address => uint256) balance;
mapping (address =>
- mapping (address => uint256)) public allowance;
+ mapping (address => uint256)) m_allowance;
function StandardToken(address _initialOwner, uint256 _supply) {
- totalSupply = _supply;
- balanceOf[_initialOwner] = _supply;
+ supply = _supply;
+ balance[_initialOwner] = _supply;
+ }
+
+ function balanceOf(address _account) constant returns (uint) {
+ return balance[_account];
+ }
+
+ function totalSupply() constant returns (uint) {
+ return supply;
}
function transfer(address _to, uint256 _value) returns (bool success) {
- if (balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]) {
- balanceOf[msg.sender] -= _value;
- balanceOf[_to] += _value;
- Transfer(msg.sender, _to, _value);
+ return doTransfer(msg.sender, _to, _value);
+ }
+
+ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
+ if (m_allowance[_from][msg.sender] >= _value) {
+ if (doTransfer(_from, _to, _value)) {
+ m_allowance[_from][msg.sender] -= _value;
+ }
return true;
} else {
return false;
}
}
- function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
- if (allowance[_from][msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]) {
- allowance[_from][msg.sender] -= _value;
- balanceOf[_to] += _value;
+ function doTransfer(address _from, address _to, uint _value) internal returns (bool success) {
+ if (balance[_from] >= _value && balance[_to] + _value >= balance[_to]) {
+ balance[_from] -= _value;
+ balance[_to] += _value;
Transfer(_from, _to, _value);
return true;
} else {
@@ -36,8 +48,12 @@ contract StandardToken is Token {
}
function approve(address _spender, uint256 _value) returns (bool success) {
- allowance[msg.sender][_spender] = _value;
+ m_allowance[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
+
+ function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
+ return m_allowance[_owner][_spender];
+ }
}