Skip to content

Commit

Permalink
更新代码以适配新版编译器。
Browse files Browse the repository at this point in the history
  • Loading branch information
xilibi2003 committed Jul 26, 2018
1 parent d6a72b8 commit db6e3cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions MyAdvancedToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.16;
pragma solidity ^0.4.20;


import "./owned.sol";
Expand All @@ -19,7 +19,7 @@ contract MyAdvancedToken is owned, TokenERC20 {
event FrozenFunds(address target, bool frozen);

/* Initializes contract with initial supply tokens to the creator of the contract */
function MyAdvancedToken(
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
Expand All @@ -34,7 +34,7 @@ contract MyAdvancedToken is owned, TokenERC20 {
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
Transfer(_from, _to, _value);
emit Transfer(_from, _to, _value);
}

/// @notice Create `mintedAmount` tokens and send it to `target`
Expand All @@ -43,16 +43,16 @@ contract MyAdvancedToken is owned, TokenERC20 {
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, this, mintedAmount);
Transfer(this, target, mintedAmount);
emit Transfer(0, this, mintedAmount);
emit Transfer(this, target, mintedAmount);
}

/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
/// @param target Address to be frozen
/// @param freeze either to freeze it or not
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
emit FrozenFunds(target, freeze);
}

/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
Expand Down
12 changes: 6 additions & 6 deletions TokenERC20.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.16;
pragma solidity ^0.4.20;

interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; }
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }

contract TokenERC20 {
string public name;
Expand All @@ -22,7 +22,7 @@ contract TokenERC20 {
/**
* 初始化构造
*/
function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public {
constructor(uint256 initialSupply, string tokenName, string tokenSymbol) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // 供应的份额,份额跟最小的代币单位有关,份额 = 币数 * 10 ** decimals。
balanceOf[msg.sender] = totalSupply; // 创建者拥有所有的代币
name = tokenName; // 代币名称
Expand All @@ -46,7 +46,7 @@ contract TokenERC20 {
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
emit Transfer(_from, _to, _value);

// 用assert来检查代码逻辑。
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
Expand Down Expand Up @@ -114,7 +114,7 @@ contract TokenERC20 {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
emit Burn(msg.sender, _value);
return true;
}

Expand All @@ -132,7 +132,7 @@ contract TokenERC20 {
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
emit Burn(_from, _value);
return true;
}
}
2 changes: 1 addition & 1 deletion owned.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.4.16;
contract owned {
address public owner;

function owned() public {
constructor() public {
owner = msg.sender;
}

Expand Down

0 comments on commit db6e3cb

Please sign in to comment.