diff options
Diffstat (limited to 'packages/contracts/src/2.0.0/tokens')
8 files changed, 46 insertions, 31 deletions
diff --git a/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol index 59dc7d7bf..58ffdfcb6 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./IERC20Token.sol"; @@ -24,12 +24,8 @@ import "./IERC20Token.sol"; contract ERC20Token is IERC20Token { - string constant INSUFFICIENT_BALANCE = "ERC20_INSUFFICIENT_BALANCE"; - string constant INSUFFICIENT_ALLOWANCE = "ERC20_INSUFFICIENT_ALLOWANCE"; - string constant OVERFLOW = "Transfer would result in an overflow."; - - mapping (address => uint256) balances; - mapping (address => mapping (address => uint256)) allowed; + mapping (address => uint256) internal balances; + mapping (address => mapping (address => uint256)) internal allowed; uint256 public totalSupply; @@ -39,11 +35,11 @@ contract ERC20Token is IERC20Token { { require( balances[msg.sender] >= _value, - INSUFFICIENT_BALANCE + "ERC20_INSUFFICIENT_BALANCE" ); require( balances[_to] + _value >= balances[_to], - OVERFLOW + "OVERFLOW" ); balances[msg.sender] -= _value; balances[_to] += _value; @@ -57,15 +53,15 @@ contract ERC20Token is IERC20Token { { require( balances[_from] >= _value, - INSUFFICIENT_BALANCE + "ERC20_INSUFFICIENT_BALANCE" ); require( allowed[_from][msg.sender] >= _value, - INSUFFICIENT_ALLOWANCE + "ERC20_INSUFFICIENT_ALLOWANCE" ); require( balances[_to] + _value >= balances[_to], - OVERFLOW + "OVERFLOW" ); balances[_to] += _value; balances[_from] -= _value; @@ -84,7 +80,8 @@ contract ERC20Token is IERC20Token { } function balanceOf(address _owner) - public view + public + view returns (uint256) { return balances[_owner]; diff --git a/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol b/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol index de4ed2af9..e3e193666 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; @@ -60,6 +60,7 @@ contract IERC20Token { public view returns (uint256); + // solhint-disable-next-line no-simple-event-func-name event Transfer( address indexed _from, address indexed _to, diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol index defb506a8..60603aa19 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol @@ -23,7 +23,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "./IERC721Token.sol"; import "./IERC721Receiver.sol"; @@ -41,7 +41,7 @@ contract ERC721Token is { // Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` - bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba; + bytes4 constant internal ERC721_RECEIVED = 0xf0b9e5ba; // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; @@ -73,7 +73,7 @@ contract ERC721Token is _; } - function ERC721Token( + constructor ( string _name, string _symbol) public diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol index f72c75638..f2e8f3c88 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol @@ -23,7 +23,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; /** @@ -38,7 +38,7 @@ contract IERC721Receiver { * Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`, * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` */ - bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba; + bytes4 constant internal ERC721_RECEIVED = 0xf0b9e5ba; /** * @notice Handle the receipt of an NFT diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol index 0d64ee861..4d57ece38 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol @@ -23,7 +23,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; /** @@ -40,11 +40,13 @@ contract IERC721Token { address indexed _to, uint256 _tokenId ); + event Approval( address indexed _owner, address indexed _approved, uint256 _tokenId ); + event ApprovalForAll( address indexed _owner, address indexed _operator, @@ -55,6 +57,7 @@ contract IERC721Token { public view returns (string); + function symbol() public view @@ -64,10 +67,12 @@ contract IERC721Token { public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view @@ -75,6 +80,7 @@ contract IERC721Token { function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) public view @@ -82,6 +88,7 @@ contract IERC721Token { function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) public view @@ -90,17 +97,22 @@ contract IERC721Token { function transferFrom( address _from, address _to, - uint256 _tokenId) + uint256 _tokenId + ) public; + function safeTransferFrom( address _from, address _to, - uint256 _tokenId) + uint256 _tokenId + ) public; + function safeTransferFrom( address _from, address _to, uint256 _tokenId, - bytes _data) + bytes _data + ) public; } diff --git a/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol b/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol index 845324e4e..a974503ca 100644 --- a/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol +++ b/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../ERC20Token/ERC20Token.sol"; @@ -24,7 +24,7 @@ import "../ERC20Token/ERC20Token.sol"; contract UnlimitedAllowanceToken is ERC20Token { - uint256 constant MAX_UINT = 2**256 - 1; + uint256 constant internal MAX_UINT = 2**256 - 1; /// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717 /// @param _from Address to transfer from. @@ -38,15 +38,15 @@ contract UnlimitedAllowanceToken is ERC20Token { uint256 allowance = allowed[_from][msg.sender]; require( balances[_from] >= _value, - INSUFFICIENT_BALANCE + "ERC20_INSUFFICIENT_BALANCE" ); require( allowance >= _value, - INSUFFICIENT_ALLOWANCE + "ERC20_INSUFFICIENT_ALLOWANCE" ); require( balances[_to] + _value >= balances[_to], - OVERFLOW + "OVERFLOW" ); balances[_to] += _value; balances[_from] -= _value; diff --git a/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol b/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol index 378a507b9..1fdb04de5 100644 --- a/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol +++ b/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol @@ -13,6 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. +// solhint-disable pragma solidity ^0.4.18; diff --git a/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol b/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol index ed0670072..28c0b2fb3 100644 --- a/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol +++ b/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol @@ -16,20 +16,24 @@ */ -pragma solidity ^0.4.11; +pragma solidity 0.4.11; +// solhint-disable-next-line max-line-length import { UnlimitedAllowanceToken_v1 as UnlimitedAllowanceToken } from "../../../1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol"; - contract ZRXToken is UnlimitedAllowanceToken { + // solhint-disable const-name-snakecase uint8 constant public decimals = 18; uint public totalSupply = 10**27; // 1 billion tokens, 18 decimal places string constant public name = "0x Protocol Token"; string constant public symbol = "ZRX"; + // solhint-enableconst-name-snakecase - function ZRXToken() { + function ZRXToken() + public + { balances[msg.sender] = totalSupply; } } |