diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-04-22 07:28:14 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-22 08:31:17 +0800 |
commit | 63abf346643146e7df7d70daa31930e444cb837f (patch) | |
tree | f57ba196b3ce4029bb96d81816adeb80b69bf716 /packages/contracts/src | |
parent | 120ca5b1ec4c0bbda2cbbf684a4d535c9b3c1bab (diff) | |
download | dexon-0x-contracts-63abf346643146e7df7d70daa31930e444cb837f.tar.gz dexon-0x-contracts-63abf346643146e7df7d70daa31930e444cb837f.tar.zst dexon-0x-contracts-63abf346643146e7df7d70daa31930e444cb837f.zip |
Rename Token => IERC20Token
Diffstat (limited to 'packages/contracts/src')
-rw-r--r-- | packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol | 4 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol | 29 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/ERC20Token/IERC20Token.sol (renamed from packages/contracts/src/contracts/current/tokens/Token/Token.sol) | 37 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/Token/IToken.sol | 70 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol | 8 | ||||
-rw-r--r-- | packages/contracts/src/contracts/previous/Token/IToken_v1.sol | 52 | ||||
-rw-r--r-- | packages/contracts/src/utils/artifacts.ts | 2 |
7 files changed, 47 insertions, 155 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol index e785bd26d..eef3a39db 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol @@ -21,7 +21,7 @@ pragma solidity ^0.4.21; import "../IAssetProxy.sol"; import "../../../utils/LibBytes/LibBytes.sol"; import "../../../utils/Authorizable/Authorizable.sol"; -import { Token_v1 as ERC20Token } from "../../../../previous/Token/Token_v1.sol"; +import "../../../tokens/ERC20Token/IERC20Token.sol"; contract ERC20Proxy is LibBytes, @@ -44,7 +44,7 @@ contract ERC20Proxy is { require(assetMetadata.length == 21); address token = readAddress(assetMetadata, 1); - bool success = ERC20Token(token).transferFrom(from, to, amount); + bool success = IERC20Token(token).transferFrom(from, to, amount); require(success == true); } } diff --git a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol index ad6cb28b4..13ceeb2c6 100644 --- a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol +++ b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol @@ -18,22 +18,22 @@ pragma solidity ^0.4.18; -import "../Token/Token.sol"; +import "./IERC20Token.sol"; -contract ERC20Token is Token { +contract ERC20Token is IERC20Token { - function transfer(address _to, uint _value) + function transfer(address _to, uint256 _value) public returns (bool) { require(balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]); balances[msg.sender] -= _value; balances[_to] += _value; - Transfer(msg.sender, _to, _value); + emit Transfer(msg.sender, _to, _value); return true; } - function transferFrom(address _from, address _to, uint _value) + function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { @@ -41,23 +41,22 @@ contract ERC20Token is Token { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; - Transfer(_from, _to, _value); + emit Transfer(_from, _to, _value); return true; } - function approve(address _spender, uint _value) + function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; - Approval(msg.sender, _spender, _value); + emit Approval(msg.sender, _spender, _value); return true; } function balanceOf(address _owner) - public - view - returns (uint) + public view + returns (uint256) { return balances[_owner]; } @@ -65,12 +64,12 @@ contract ERC20Token is Token { function allowance(address _owner, address _spender) public view - returns (uint) + returns (uint256) { return allowed[_owner][_spender]; } - mapping (address => uint) balances; - mapping (address => mapping (address => uint)) allowed; - uint public totalSupply; + mapping (address => uint256) balances; + mapping (address => mapping (address => uint256)) allowed; + uint256 public totalSupply; } diff --git a/packages/contracts/src/contracts/current/tokens/Token/Token.sol b/packages/contracts/src/contracts/current/tokens/ERC20Token/IERC20Token.sol index d683c3113..0159b31e8 100644 --- a/packages/contracts/src/contracts/current/tokens/Token/Token.sol +++ b/packages/contracts/src/contracts/current/tokens/ERC20Token/IERC20Token.sol @@ -18,36 +18,53 @@ pragma solidity ^0.4.18; -contract Token { +contract IERC20Token { /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not - function transfer(address _to, uint _value) public returns (bool) {} + function transfer(address _to, uint256 _value) + public + returns (bool); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not - function transferFrom(address _from, address _to, uint _value) public returns (bool) {} - - /// @notice `msg.sender` approves `_addr` to spend `_value` tokens + function transferFrom(address _from, address _to, uint256 _value) + public + returns (bool); + + /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not - function approve(address _spender, uint _value) public returns (bool) {} + function approve(address _spender, uint256 _value) + public + returns (bool); /// @param _owner The address from which the balance will be retrieved /// @return The balance - function balanceOf(address _owner) public view returns (uint) {} + function balanceOf(address _owner) + public view + returns (uint256); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent - function allowance(address _owner, address _spender) public view returns (uint) {} + function allowance(address _owner, address _spender) + public view + returns (uint256); - event Transfer(address indexed _from, address indexed _to, uint _value); - event Approval(address indexed _owner, address indexed _spender, uint _value); + event Transfer( + address indexed _from, + address indexed _to, + uint256 _value); + + event Approval( + address indexed _owner, + address indexed _spender, + uint256 _value); } diff --git a/packages/contracts/src/contracts/current/tokens/Token/IToken.sol b/packages/contracts/src/contracts/current/tokens/Token/IToken.sol deleted file mode 100644 index cafbd436b..000000000 --- a/packages/contracts/src/contracts/current/tokens/Token/IToken.sol +++ /dev/null @@ -1,70 +0,0 @@ -/* - - 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.18; - -contract IToken { - - /// @notice send `value` token to `to` from `msg.sender` - /// @param to The address of the recipient - /// @param value The amount of token to be transferred - /// @return Whether the transfer was successful or not - function transfer(address to, uint value) - public - returns (bool); - - /// @notice send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param from The address of the sender - /// @param to The address of the recipient - /// @param value The amount of token to be transferred - /// @return Whether the transfer was successful or not - function transferFrom(address from, address to, uint value) - public - returns (bool); - - /// @notice `msg.sender` approves `addr` to spend `value` tokens - /// @param spender The address of the account able to transfer the tokens - /// @param value The amount of wei to be approved for transfer - /// @return Whether the approval was successful or not - function approve(address spender, uint value) - public - returns (bool); - - /// @param owner The address from which the balance will be retrieved - /// @return The balance - function balanceOf(address owner) - public view - returns (uint); - - /// @param owner The address of the account owning tokens - /// @param spender The address of the account able to transfer the tokens - /// @return Amount of remaining tokens allowed to spent - function allowance(address owner, address spender) - public view - returns (uint); - - event Transfer( - address indexed from, - address indexed to, - uint value); - - event Approval( - address indexed owner, - address indexed spender, - uint value); -} diff --git a/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol b/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol index 97c18afb7..be774e374 100644 --- a/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol +++ b/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol @@ -22,25 +22,25 @@ import { ERC20Token } from "../ERC20Token/ERC20Token.sol"; contract UnlimitedAllowanceToken is ERC20Token { - uint constant MAX_UINT = 2**256 - 1; + uint256 constant 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. /// @param _to Address to transfer to. /// @param _value Amount to transfer. /// @return Success of transfer. - function transferFrom(address _from, address _to, uint _value) + function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { - uint allowance = allowed[_from][msg.sender]; + uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value && balances[_to] + _value >= balances[_to]); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT) { allowed[_from][msg.sender] -= _value; } - Transfer(_from, _to, _value); + emit Transfer(_from, _to, _value); return true; } } diff --git a/packages/contracts/src/contracts/previous/Token/IToken_v1.sol b/packages/contracts/src/contracts/previous/Token/IToken_v1.sol deleted file mode 100644 index db4286964..000000000 --- a/packages/contracts/src/contracts/previous/Token/IToken_v1.sol +++ /dev/null @@ -1,52 +0,0 @@ -pragma solidity ^0.4.18; - -contract IToken_v1 { - - /// @notice send `value` token to `to` from `msg.sender` - /// @param to The address of the recipient - /// @param value The amount of token to be transferred - /// @return Whether the transfer was successful or not - function transfer(address to, uint value) - public - returns (bool); - - /// @notice send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param from The address of the sender - /// @param to The address of the recipient - /// @param value The amount of token to be transferred - /// @return Whether the transfer was successful or not - function transferFrom(address from, address to, uint value) - public - returns (bool); - - /// @notice `msg.sender` approves `addr` to spend `value` tokens - /// @param spender The address of the account able to transfer the tokens - /// @param value The amount of wei to be approved for transfer - /// @return Whether the approval was successful or not - function approve(address spender, uint value) - public - returns (bool); - - /// @param owner The address from which the balance will be retrieved - /// @return The balance - function balanceOf(address owner) - public view - returns (uint); - - /// @param owner The address of the account owning tokens - /// @param spender The address of the account able to transfer the tokens - /// @return Amount of remaining tokens allowed to spent - function allowance(address owner, address spender) - public view - returns (uint); - - event Transfer( - address indexed from, - address indexed to, - uint value); - - event Approval( - address indexed owner, - address indexed spender, - uint value); -} diff --git a/packages/contracts/src/utils/artifacts.ts b/packages/contracts/src/utils/artifacts.ts index db52ef0d8..78ba1c142 100644 --- a/packages/contracts/src/utils/artifacts.ts +++ b/packages/contracts/src/utils/artifacts.ts @@ -2,7 +2,6 @@ import * as DummyERC20TokenArtifact from '../artifacts/DummyERC20Token.json'; import * as ExchangeArtifact from '../artifacts/Exchange.json'; import * as MultiSigWalletWithTimeLockArtifact from '../artifacts/MultiSigWalletWithTimeLock.json'; import * as MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact from '../artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json'; -import * as TokenArtifact from '../artifacts/Token.json'; import * as TokenRegistryArtifact from '../artifacts/TokenRegistry.json'; import * as EtherTokenArtifact from '../artifacts/WETH9.json'; import * as ZRXArtifact from '../artifacts/ZRXToken.json'; @@ -12,7 +11,6 @@ import { Artifact } from './types'; export const artifacts = { ZRXArtifact: (ZRXArtifact as any) as Artifact, DummyERC20TokenArtifact: (DummyERC20TokenArtifact as any) as Artifact, - TokenArtifact: (TokenArtifact as any) as Artifact, ExchangeArtifact: (ExchangeArtifact as any) as Artifact, EtherTokenArtifact: (EtherTokenArtifact as any) as Artifact, TokenRegistryArtifact: (TokenRegistryArtifact as any) as Artifact, |