aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0/tokens
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/2.0.0/tokens')
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol24
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol4
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol6
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol4
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol20
-rw-r--r--packages/contracts/src/2.0.0/tokens/EtherToken/IEtherToken.sol33
-rw-r--r--packages/contracts/src/2.0.0/tokens/EtherToken/WETH9.sol (renamed from packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol)1
-rw-r--r--packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol11
-rw-r--r--packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol10
9 files changed, 79 insertions, 34 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..d9950145d 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol
+++ b/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol
@@ -16,20 +16,15 @@
*/
-pragma solidity ^0.4.24;
-pragma experimental ABIEncoderV2;
+pragma solidity 0.4.24;
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 +34,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 +52,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 +79,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..5ee5e1011 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol
+++ b/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol
@@ -16,8 +16,7 @@
*/
-pragma solidity ^0.4.24;
-pragma experimental ABIEncoderV2;
+pragma solidity 0.4.24;
contract IERC20Token {
@@ -60,6 +59,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/EtherToken/IEtherToken.sol b/packages/contracts/src/2.0.0/tokens/EtherToken/IEtherToken.sol
new file mode 100644
index 000000000..9e2e68766
--- /dev/null
+++ b/packages/contracts/src/2.0.0/tokens/EtherToken/IEtherToken.sol
@@ -0,0 +1,33 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity 0.4.24;
+
+import "../ERC20Token/IERC20Token.sol";
+
+
+contract IEtherToken is
+ IERC20Token
+{
+ function deposit()
+ public
+ payable;
+
+ function withdraw(uint256 amount)
+ public;
+}
diff --git a/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol b/packages/contracts/src/2.0.0/tokens/EtherToken/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/EtherToken/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/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol b/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol
index 845324e4e..9feb5c914 100644
--- a/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol
+++ b/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol
@@ -16,15 +16,14 @@
*/
-pragma solidity ^0.4.24;
-pragma experimental ABIEncoderV2;
+pragma solidity 0.4.24;
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 +37,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/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;
}
}