aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-01-19 23:13:31 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-02-03 01:39:08 +0800
commit2721252d6a82e83801c650ebad6a2cb4d7195bc1 (patch)
treec22be8b830f57e8984be92d6936f5fefc9c44c2d /packages
parent47d74aa24ac06de33ae331f3589e9c8013c655ec (diff)
downloaddexon-0x-contracts-2721252d6a82e83801c650ebad6a2cb4d7195bc1.tar.gz
dexon-0x-contracts-2721252d6a82e83801c650ebad6a2cb4d7195bc1.tar.zst
dexon-0x-contracts-2721252d6a82e83801c650ebad6a2cb4d7195bc1.zip
Get rid of suffixed contract versioning and replace it with a poor-mans package manager. Versions are stored locally, and are generated in a copy-on-write basis as required
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/contracts/DummyToken/DummyToken.sol (renamed from packages/contracts/contracts/test/DummyToken.sol)11
-rw-r--r--packages/contracts/contracts/ERC20Token/ERC20Token.sol (renamed from packages/contracts/contracts/tokens/ERC20Token.sol)19
-rw-r--r--packages/contracts/contracts/Exchange/Exchange.sol (renamed from packages/contracts/contracts/Exchange.sol)6
-rw-r--r--packages/contracts/contracts/MaliciousToken/MaliciousToken.sol (renamed from packages/contracts/contracts/test/MaliciousToken.sol)7
-rw-r--r--packages/contracts/contracts/Mintable/Mintable.sol (renamed from packages/contracts/contracts/test/Mintable.sol)9
-rw-r--r--packages/contracts/contracts/MultiSigWallet/MultiSigWallet.sol (renamed from packages/contracts/contracts/multisig/MultiSigWallet.sol)0
-rw-r--r--packages/contracts/contracts/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol (renamed from packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol)3
-rw-r--r--packages/contracts/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol (renamed from packages/contracts/contracts/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol)3
-rw-r--r--packages/contracts/contracts/Ownable/Ownable.sol (renamed from packages/contracts/contracts/utils/Ownable_v2.sol)7
-rw-r--r--packages/contracts/contracts/SafeMath/SafeMath.sol (renamed from packages/contracts/contracts/utils/SafeMath_v2.sol)3
-rw-r--r--packages/contracts/contracts/StandardToken/StandardToken.sol (renamed from packages/contracts/contracts/tokens/StandardToken.sol)3
-rw-r--r--packages/contracts/contracts/Token/Token.sol (renamed from packages/contracts/contracts/tokens/Token_v2.sol)3
-rw-r--r--packages/contracts/contracts/TokenRegistry/TokenRegistry.sol (renamed from packages/contracts/contracts/TokenRegistry.sol)3
-rw-r--r--packages/contracts/contracts/TokenTransferProxy/TokenTransferProxy.sol (renamed from packages/contracts/contracts/TokenTransferProxy.sol)5
-rw-r--r--packages/contracts/contracts/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol (renamed from packages/contracts/contracts/tokens/UnlimitedAllowanceToken_v2.sol)11
-rw-r--r--packages/contracts/contracts/WETH9/WETH9.sol (renamed from packages/contracts/contracts/tokens/WETH9.sol)0
-rw-r--r--packages/contracts/contracts/ZRXToken/ZRXToken.sol (renamed from packages/contracts/contracts/tokens/ZRXToken.sol)3
-rw-r--r--packages/contracts/contracts/test/DummyToken_v2.sol38
-rw-r--r--packages/contracts/contracts/test/Mintable_v2.sol19
-rw-r--r--packages/contracts/contracts/utils/SafeMath.sol74
-rw-r--r--packages/contracts/contracts_old/Ownable/v1.sol (renamed from packages/contracts/contracts/utils/Ownable.sol)1
-rw-r--r--packages/contracts/contracts_old/SafeMath/v1.sol73
-rw-r--r--packages/contracts/contracts_old/Token/v1.sol (renamed from packages/contracts/contracts/tokens/Token.sol)0
-rw-r--r--packages/contracts/contracts_old/UnlimitedAllowanceToken/v1.sol (renamed from packages/contracts/contracts/tokens/UnlimitedAllowanceToken.sol)3
-rw-r--r--packages/contracts/test/unlimited_allowance_token.ts26
-rw-r--r--packages/contracts/test/unlimited_allowance_token_v2.ts152
26 files changed, 136 insertions, 346 deletions
diff --git a/packages/contracts/contracts/test/DummyToken.sol b/packages/contracts/contracts/DummyToken/DummyToken.sol
index 046af3059..7a7ac8e48 100644
--- a/packages/contracts/contracts/test/DummyToken.sol
+++ b/packages/contracts/contracts/DummyToken/DummyToken.sol
@@ -1,7 +1,7 @@
-pragma solidity ^0.4.11;
+pragma solidity 0.4.18;
-import "./Mintable.sol";
-import "./../utils/Ownable.sol";
+import "../Mintable/Mintable.sol";
+import "../../contracts_old/Ownable/v1.sol";
contract DummyToken is Mintable, Ownable {
string public name;
@@ -13,6 +13,7 @@ contract DummyToken is Mintable, Ownable {
string _symbol,
uint _decimals,
uint _totalSupply)
+ public
{
name = _name;
symbol = _symbol;
@@ -22,7 +23,8 @@ contract DummyToken is Mintable, Ownable {
}
function setBalance(address _target, uint _value)
- onlyOwner
+ public
+ onlyOwner
{
uint currBalance = balanceOf(_target);
if (_value < currBalance) {
@@ -33,4 +35,3 @@ contract DummyToken is Mintable, Ownable {
balances[_target] = _value;
}
}
-
diff --git a/packages/contracts/contracts/tokens/ERC20Token.sol b/packages/contracts/contracts/ERC20Token/ERC20Token.sol
index 318da8c01..976b5564e 100644
--- a/packages/contracts/contracts/tokens/ERC20Token.sol
+++ b/packages/contracts/contracts/ERC20Token/ERC20Token.sol
@@ -1,14 +1,14 @@
pragma solidity 0.4.18;
-import "./Token_v2.sol";
+import "../Token/Token.sol";
-contract ERC20Token is Token_v2 {
+contract ERC20Token is Token {
function transfer(address _to, uint _value)
public
- returns (bool)
+ returns (bool)
{
- require(balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]);
+ require(balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]);
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
@@ -16,10 +16,10 @@ contract ERC20Token is Token_v2 {
}
function transferFrom(address _from, address _to, uint _value)
- public
- returns (bool)
+ public
+ returns (bool)
{
- require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value >= balances[_to]);
+ require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value >= balances[_to]);
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
@@ -27,7 +27,7 @@ contract ERC20Token is Token_v2 {
return true;
}
- function approve(address _spender, uint _value)
+ function approve(address _spender, uint _value)
public
returns (bool)
{
@@ -44,7 +44,7 @@ contract ERC20Token is Token_v2 {
return balances[_owner];
}
- function allowance(address _owner, address _spender)
+ function allowance(address _owner, address _spender)
public
view
returns (uint)
@@ -56,4 +56,3 @@ contract ERC20Token is Token_v2 {
mapping (address => mapping (address => uint)) allowed;
uint public totalSupply;
}
-
diff --git a/packages/contracts/contracts/Exchange.sol b/packages/contracts/contracts/Exchange/Exchange.sol
index 1da74deef..db2ce6584 100644
--- a/packages/contracts/contracts/Exchange.sol
+++ b/packages/contracts/contracts/Exchange/Exchange.sol
@@ -18,9 +18,9 @@
pragma solidity ^0.4.11;
-import "./TokenTransferProxy.sol";
-import "./tokens/Token.sol";
-import "./utils/SafeMath.sol";
+import "../TokenTransferProxy/TokenTransferProxy.sol";
+import "../../contracts_old/Token/v1.sol";
+import "../../contracts_old/SafeMath/v1.sol";
/// @title Exchange - Facilitates exchange of ERC20 tokens.
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
diff --git a/packages/contracts/contracts/test/MaliciousToken.sol b/packages/contracts/contracts/MaliciousToken/MaliciousToken.sol
index 3e7d5d1a5..c3cace9af 100644
--- a/packages/contracts/contracts/test/MaliciousToken.sol
+++ b/packages/contracts/contracts/MaliciousToken/MaliciousToken.sol
@@ -1,12 +1,12 @@
pragma solidity ^0.4.11;
-import "./../tokens/StandardToken.sol";
+import "../StandardToken/StandardToken.sol";
contract MaliciousToken is StandardToken {
uint8 stateToUpdate = 1; // Not null so that change only requires 5000 gas
- function updateState()
- internal
+ function updateState()
+ internal
{
stateToUpdate++;
}
@@ -29,4 +29,3 @@ contract MaliciousToken is StandardToken {
return allowed[_owner][_spender];
}
}
-
diff --git a/packages/contracts/contracts/test/Mintable.sol b/packages/contracts/contracts/Mintable/Mintable.sol
index 3b91415ef..2dbc0f349 100644
--- a/packages/contracts/contracts/test/Mintable.sol
+++ b/packages/contracts/contracts/Mintable/Mintable.sol
@@ -1,14 +1,14 @@
-pragma solidity ^0.4.11;
+pragma solidity 0.4.18;
-import "./../tokens/UnlimitedAllowanceToken.sol";
-import "./../utils/SafeMath.sol";
+import "../UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol";
+import "../SafeMath/SafeMath.sol";
/*
* Mintable
* Base contract that creates a mintable UnlimitedAllowanceToken
*/
contract Mintable is UnlimitedAllowanceToken, SafeMath {
- function mint(uint _value)
+ function mint(uint _value)
public
{
require(_value <= 100000000000000000000);
@@ -16,4 +16,3 @@ contract Mintable is UnlimitedAllowanceToken, SafeMath {
totalSupply = safeAdd(totalSupply, _value);
}
}
-
diff --git a/packages/contracts/contracts/multisig/MultiSigWallet.sol b/packages/contracts/contracts/MultiSigWallet/MultiSigWallet.sol
index ae7ef06fd..ae7ef06fd 100644
--- a/packages/contracts/contracts/multisig/MultiSigWallet.sol
+++ b/packages/contracts/contracts/MultiSigWallet/MultiSigWallet.sol
diff --git a/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol b/packages/contracts/contracts/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol
index 62273eba3..f8606762e 100644
--- a/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol
+++ b/packages/contracts/contracts/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.11;
-import "./MultiSigWallet.sol";
+import "../MultiSigWallet/MultiSigWallet.sol";
/// @title Multisignature wallet with time lock- Allows multiple parties to execute a transaction after a time lock has passed.
/// @author Amir Bandeali - <amir@0xProject.com>
@@ -130,4 +130,3 @@ contract MultiSigWalletWithTimeLock is MultiSigWallet {
ConfirmationTimeSet(transactionId, confirmationTime);
}
}
-
diff --git a/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol b/packages/contracts/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
index 07beb9f5b..81a3d4637 100644
--- a/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
+++ b/packages/contracts/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.11;
-import "./MultiSigWalletWithTimeLock.sol";
+import "../MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol";
contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWalletWithTimeLock {
@@ -80,4 +80,3 @@ contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWall
return true;
}
}
-
diff --git a/packages/contracts/contracts/utils/Ownable_v2.sol b/packages/contracts/contracts/Ownable/Ownable.sol
index 77e1fed08..199c3c1c1 100644
--- a/packages/contracts/contracts/utils/Ownable_v2.sol
+++ b/packages/contracts/contracts/Ownable/Ownable.sol
@@ -7,10 +7,10 @@ pragma solidity 0.4.18;
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
*/
-contract Ownable_v2 {
+contract Ownable {
address public owner;
- function Ownable_v2()
+ function Ownable()
public
{
owner = msg.sender;
@@ -23,11 +23,10 @@ contract Ownable_v2 {
function transferOwnership(address newOwner)
public
- onlyOwner
+ onlyOwner
{
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
-
diff --git a/packages/contracts/contracts/utils/SafeMath_v2.sol b/packages/contracts/contracts/SafeMath/SafeMath.sol
index 6eda03999..325bddc82 100644
--- a/packages/contracts/contracts/utils/SafeMath_v2.sol
+++ b/packages/contracts/contracts/SafeMath/SafeMath.sol
@@ -1,6 +1,6 @@
pragma solidity 0.4.18;
-contract SafeMath_v2 {
+contract SafeMath {
function safeMul(uint a, uint b)
internal
pure
@@ -71,4 +71,3 @@ contract SafeMath_v2 {
return a < b ? a : b;
}
}
-
diff --git a/packages/contracts/contracts/tokens/StandardToken.sol b/packages/contracts/contracts/StandardToken/StandardToken.sol
index 9cd53d94a..fbb886c7b 100644
--- a/packages/contracts/contracts/tokens/StandardToken.sol
+++ b/packages/contracts/contracts/StandardToken/StandardToken.sol
@@ -1,6 +1,6 @@
pragma solidity ^0.4.11;
-import "./Token.sol";
+import "../../contracts_old/Token/v1.sol";
contract StandardToken is Token {
@@ -42,4 +42,3 @@ contract StandardToken is Token {
mapping (address => mapping (address => uint)) allowed;
uint public totalSupply;
}
-
diff --git a/packages/contracts/contracts/tokens/Token_v2.sol b/packages/contracts/contracts/Token/Token.sol
index e1088c560..8688bcae8 100644
--- a/packages/contracts/contracts/tokens/Token_v2.sol
+++ b/packages/contracts/contracts/Token/Token.sol
@@ -1,6 +1,6 @@
pragma solidity 0.4.18;
-contract Token_v2 {
+contract Token {
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
@@ -33,4 +33,3 @@ contract Token_v2 {
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/contracts/TokenRegistry.sol b/packages/contracts/contracts/TokenRegistry/TokenRegistry.sol
index d2570e71d..2a0cab36d 100644
--- a/packages/contracts/contracts/TokenRegistry.sol
+++ b/packages/contracts/contracts/TokenRegistry/TokenRegistry.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.11;
-import "./utils/Ownable.sol";
+import "../../contracts_old/Ownable/v1.sol";
/// @title Token Registry - Stores metadata associated with ERC20 tokens. See ERC22 https://github.com/ethereum/EIPs/issues/22
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
@@ -306,4 +306,3 @@ contract TokenRegistry is Ownable {
return tokenAddresses;
}
}
-
diff --git a/packages/contracts/contracts/TokenTransferProxy.sol b/packages/contracts/contracts/TokenTransferProxy/TokenTransferProxy.sol
index fd2358496..f3fdbbee8 100644
--- a/packages/contracts/contracts/TokenTransferProxy.sol
+++ b/packages/contracts/contracts/TokenTransferProxy/TokenTransferProxy.sol
@@ -18,8 +18,8 @@
pragma solidity ^0.4.11;
-import "./tokens/Token.sol";
-import "./utils/Ownable.sol";
+import "../../contracts_old/Token/v1.sol";
+import "../../contracts_old/Ownable/v1.sol";
/// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance.
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
@@ -113,4 +113,3 @@ contract TokenTransferProxy is Ownable {
return authorities;
}
}
-
diff --git a/packages/contracts/contracts/tokens/UnlimitedAllowanceToken_v2.sol b/packages/contracts/contracts/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol
index b2caab8af..52b80f8c8 100644
--- a/packages/contracts/contracts/tokens/UnlimitedAllowanceToken_v2.sol
+++ b/packages/contracts/contracts/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol
@@ -18,9 +18,9 @@
pragma solidity 0.4.18;
-import "./ERC20Token.sol";
+import "../ERC20Token/ERC20Token.sol";
-contract UnlimitedAllowanceToken_v2 is ERC20Token {
+contract UnlimitedAllowanceToken is ERC20Token {
uint constant MAX_UINT = 2**256 - 1;
@@ -30,11 +30,11 @@ contract UnlimitedAllowanceToken_v2 is ERC20Token {
/// @param _value Amount to transfer.
/// @return Success of transfer.
function transferFrom(address _from, address _to, uint _value)
- public
- returns (bool)
+ public
+ returns (bool)
{
uint allowance = allowed[_from][msg.sender];
- require(balances[_from] >= _value && allowance >= _value && balances[_to] + _value >= balances[_to]);
+ require(balances[_from] >= _value && allowance >= _value && balances[_to] + _value >= balances[_to]);
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT) {
@@ -44,4 +44,3 @@ contract UnlimitedAllowanceToken_v2 is ERC20Token {
return true;
}
}
-
diff --git a/packages/contracts/contracts/tokens/WETH9.sol b/packages/contracts/contracts/WETH9/WETH9.sol
index 733ca414b..733ca414b 100644
--- a/packages/contracts/contracts/tokens/WETH9.sol
+++ b/packages/contracts/contracts/WETH9/WETH9.sol
diff --git a/packages/contracts/contracts/tokens/ZRXToken.sol b/packages/contracts/contracts/ZRXToken/ZRXToken.sol
index af1dfac99..876e58d05 100644
--- a/packages/contracts/contracts/tokens/ZRXToken.sol
+++ b/packages/contracts/contracts/ZRXToken/ZRXToken.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.11;
-import "./UnlimitedAllowanceToken.sol";
+import "../../contracts_old/UnlimitedAllowanceToken/v1.sol";
contract ZRXToken is UnlimitedAllowanceToken {
@@ -31,4 +31,3 @@ contract ZRXToken is UnlimitedAllowanceToken {
balances[msg.sender] = totalSupply;
}
}
-
diff --git a/packages/contracts/contracts/test/DummyToken_v2.sol b/packages/contracts/contracts/test/DummyToken_v2.sol
deleted file mode 100644
index bd4d06be9..000000000
--- a/packages/contracts/contracts/test/DummyToken_v2.sol
+++ /dev/null
@@ -1,38 +0,0 @@
-pragma solidity 0.4.18;
-
-import "./Mintable_v2.sol";
-import "./../utils/Ownable_v2.sol";
-
-contract DummyToken_v2 is Mintable_v2, Ownable_v2 {
- string public name;
- string public symbol;
- uint public decimals;
-
- function DummyToken_v2(
- string _name,
- string _symbol,
- uint _decimals,
- uint _totalSupply)
- public
- {
- name = _name;
- symbol = _symbol;
- decimals = _decimals;
- totalSupply = _totalSupply;
- balances[msg.sender] = _totalSupply;
- }
-
- function setBalance(address _target, uint _value)
- public
- onlyOwner
- {
- uint currBalance = balanceOf(_target);
- if (_value < currBalance) {
- totalSupply = safeSub(totalSupply, safeSub(currBalance, _value));
- } else {
- totalSupply = safeAdd(totalSupply, safeSub(_value, currBalance));
- }
- balances[_target] = _value;
- }
-}
-
diff --git a/packages/contracts/contracts/test/Mintable_v2.sol b/packages/contracts/contracts/test/Mintable_v2.sol
deleted file mode 100644
index 829145cfb..000000000
--- a/packages/contracts/contracts/test/Mintable_v2.sol
+++ /dev/null
@@ -1,19 +0,0 @@
-pragma solidity 0.4.18;
-
-import "./../tokens/UnlimitedAllowanceToken_v2.sol";
-import "./../utils/SafeMath_v2.sol";
-
-/*
- * Mintable
- * Base contract that creates a mintable UnlimitedAllowanceToken
- */
-contract Mintable_v2 is UnlimitedAllowanceToken_v2, SafeMath_v2 {
- function mint(uint _value)
- public
- {
- require(_value <= 100000000000000000000);
- balances[msg.sender] = safeAdd(_value, balances[msg.sender]);
- totalSupply = safeAdd(totalSupply, _value);
- }
-}
-
diff --git a/packages/contracts/contracts/utils/SafeMath.sol b/packages/contracts/contracts/utils/SafeMath.sol
deleted file mode 100644
index a7891a7af..000000000
--- a/packages/contracts/contracts/utils/SafeMath.sol
+++ /dev/null
@@ -1,74 +0,0 @@
-pragma solidity ^0.4.11;
-
-contract SafeMath {
- function safeMul(uint a, uint b)
- internal
- constant
- returns (uint256)
- {
- uint c = a * b;
- assert(a == 0 || c / a == b);
- return c;
- }
-
- function safeDiv(uint a, uint b)
- internal
- constant
- returns (uint256)
- {
- uint c = a / b;
- return c;
- }
-
- function safeSub(uint a, uint b)
- internal
- constant
- returns (uint256)
- {
- assert(b <= a);
- return a - b;
- }
-
- function safeAdd(uint a, uint b)
- internal
- constant
- returns (uint256)
- {
- uint c = a + b;
- assert(c >= a);
- return c;
- }
-
- function max64(uint64 a, uint64 b)
- internal
- constant
- returns (uint64)
- {
- return a >= b ? a : b;
- }
-
- function min64(uint64 a, uint64 b)
- internal
- constant
- returns (uint64)
- {
- return a < b ? a : b;
- }
-
- function max256(uint256 a, uint256 b)
- internal
- constant
- returns (uint256)
- {
- return a >= b ? a : b;
- }
-
- function min256(uint256 a, uint256 b)
- internal
- constant
- returns (uint256)
- {
- return a < b ? a : b;
- }
-}
-
diff --git a/packages/contracts/contracts/utils/Ownable.sol b/packages/contracts/contracts_old/Ownable/v1.sol
index 77fdaf085..5488896d7 100644
--- a/packages/contracts/contracts/utils/Ownable.sol
+++ b/packages/contracts/contracts_old/Ownable/v1.sol
@@ -25,4 +25,3 @@ contract Ownable {
}
}
}
-
diff --git a/packages/contracts/contracts_old/SafeMath/v1.sol b/packages/contracts/contracts_old/SafeMath/v1.sol
new file mode 100644
index 000000000..e35c0dc81
--- /dev/null
+++ b/packages/contracts/contracts_old/SafeMath/v1.sol
@@ -0,0 +1,73 @@
+pragma solidity ^0.4.11;
+
+contract SafeMath {
+ function safeMul(uint a, uint b)
+ internal
+ constant
+ returns (uint256)
+ {
+ uint c = a * b;
+ assert(a == 0 || c / a == b);
+ return c;
+ }
+
+ function safeDiv(uint a, uint b)
+ internal
+ constant
+ returns (uint256)
+ {
+ uint c = a / b;
+ return c;
+ }
+
+ function safeSub(uint a, uint b)
+ internal
+ constant
+ returns (uint256)
+ {
+ assert(b <= a);
+ return a - b;
+ }
+
+ function safeAdd(uint a, uint b)
+ internal
+ constant
+ returns (uint256)
+ {
+ uint c = a + b;
+ assert(c >= a);
+ return c;
+ }
+
+ function max64(uint64 a, uint64 b)
+ internal
+ constant
+ returns (uint64)
+ {
+ return a >= b ? a : b;
+ }
+
+ function min64(uint64 a, uint64 b)
+ internal
+ constant
+ returns (uint64)
+ {
+ return a < b ? a : b;
+ }
+
+ function max256(uint256 a, uint256 b)
+ internal
+ constant
+ returns (uint256)
+ {
+ return a >= b ? a : b;
+ }
+
+ function min256(uint256 a, uint256 b)
+ internal
+ constant
+ returns (uint256)
+ {
+ return a < b ? a : b;
+ }
+}
diff --git a/packages/contracts/contracts/tokens/Token.sol b/packages/contracts/contracts_old/Token/v1.sol
index 507de9b12..507de9b12 100644
--- a/packages/contracts/contracts/tokens/Token.sol
+++ b/packages/contracts/contracts_old/Token/v1.sol
diff --git a/packages/contracts/contracts/tokens/UnlimitedAllowanceToken.sol b/packages/contracts/contracts_old/UnlimitedAllowanceToken/v1.sol
index 0994cfae4..b7c285f06 100644
--- a/packages/contracts/contracts/tokens/UnlimitedAllowanceToken.sol
+++ b/packages/contracts/contracts_old/UnlimitedAllowanceToken/v1.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.11;
-import "./StandardToken.sol";
+import "../../packages/StandardToken/StandardToken.sol";
contract UnlimitedAllowanceToken is StandardToken {
@@ -50,4 +50,3 @@ contract UnlimitedAllowanceToken is StandardToken {
}
}
}
-
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts
index 7f4fef987..34d2ba33b 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/unlimited_allowance_token.ts
@@ -44,6 +44,14 @@ describe('UnlimitedAllowanceToken', () => {
await blockchainLifecycle.revertAsync();
});
describe('transfer', () => {
+ it('should throw if owner has insufficient balance', async () => {
+ const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = ownerBalance.plus(1);
+ return expect(token.transfer.call(spender, amountToTransfer, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
+ });
+
it('should transfer balance from sender to receiver', async () => {
const receiver = spender;
const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
@@ -67,15 +75,18 @@ describe('UnlimitedAllowanceToken', () => {
});
describe('transferFrom', () => {
- it('should return false if owner has insufficient balance', async () => {
+ it('should throw if owner has insufficient balance', async () => {
const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
- expect(didReturnTrue).to.be.false();
+ return expect(
+ token.transferFrom.call(owner, spender, amountToTransfer, {
+ from: spender,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
- it('should return false if spender has insufficient allowance', async () => {
+ it('should throw if spender has insufficient allowance', async () => {
const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance;
@@ -83,8 +94,11 @@ describe('UnlimitedAllowanceToken', () => {
const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(spenderAllowanceIsInsufficient).to.be.true();
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
- expect(didReturnTrue).to.be.false();
+ return expect(
+ token.transferFrom.call(owner, spender, amountToTransfer, {
+ from: spender,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should return true on a 0 value transfer', async () => {
diff --git a/packages/contracts/test/unlimited_allowance_token_v2.ts b/packages/contracts/test/unlimited_allowance_token_v2.ts
deleted file mode 100644
index 440cc11ac..000000000
--- a/packages/contracts/test/unlimited_allowance_token_v2.ts
+++ /dev/null
@@ -1,152 +0,0 @@
-import { ZeroEx } from '0x.js';
-import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import * as chai from 'chai';
-import * as Web3 from 'web3';
-
-import { constants } from '../util/constants';
-import { ContractName } from '../util/types';
-
-import { chaiSetup } from './utils/chai_setup';
-import { deployer } from './utils/deployer';
-
-chaiSetup.configure();
-const expect = chai.expect;
-const web3 = web3Factory.create();
-const web3Wrapper = new Web3Wrapper(web3.currentProvider);
-const blockchainLifecycle = new BlockchainLifecycle();
-
-describe('UnlimitedAllowanceTokenV2', () => {
- const config = {
- networkId: constants.TESTRPC_NETWORK_ID,
- };
- const zeroEx = new ZeroEx(web3.currentProvider, config);
- let owner: string;
- let spender: string;
-
- const MAX_MINT_VALUE = new BigNumber(100000000000000000000);
- let tokenAddress: string;
- let token: Web3.ContractInstance;
-
- before(async () => {
- const accounts = await web3Wrapper.getAvailableAddressesAsync();
- owner = accounts[0];
- spender = accounts[1];
- token = await deployer.deployAsync(ContractName.DummyToken_v2);
- await token.mint(MAX_MINT_VALUE, { from: owner });
- tokenAddress = token.address;
- });
- beforeEach(async () => {
- await blockchainLifecycle.startAsync();
- });
- afterEach(async () => {
- await blockchainLifecycle.revertAsync();
- });
- describe('transfer', () => {
- it('should throw if owner has insufficient balance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = ownerBalance.plus(1);
- return expect(token.transfer.call(spender, amountToTransfer, { from: owner })).to.be.rejectedWith(
- constants.REVERT,
- );
- });
-
- it('should transfer balance from sender to receiver', async () => {
- const receiver = spender;
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = new BigNumber(1);
- await zeroEx.token.transferAsync(tokenAddress, owner, receiver, amountToTransfer);
- const finalOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const finalReceiverBalance = await zeroEx.token.getBalanceAsync(tokenAddress, receiver);
-
- const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
- const expectedFinalReceiverBalance = amountToTransfer;
- expect(finalOwnerBalance).to.be.bignumber.equal(expectedFinalOwnerBalance);
- expect(finalReceiverBalance).to.be.bignumber.equal(expectedFinalReceiverBalance);
- });
-
- it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await token.transfer.call(spender, 0, {
- from: owner,
- });
- expect(didReturnTrue).to.be.true();
- });
- });
-
- describe('transferFrom', () => {
- it('should throw if owner has insufficient balance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = ownerBalance.plus(1);
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
- return expect(
- token.transferFrom.call(owner, spender, amountToTransfer, {
- from: spender,
- }),
- ).to.be.rejectedWith(constants.REVERT);
- });
-
- it('should throw if spender has insufficient allowance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = ownerBalance;
-
- const spenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
- const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
- expect(spenderAllowanceIsInsufficient).to.be.true();
-
- return expect(
- token.transferFrom.call(owner, spender, amountToTransfer, {
- from: spender,
- }),
- ).to.be.rejectedWith(constants.REVERT);
- });
-
- it('should return true on a 0 value transfer', async () => {
- const amountToTransfer = 0;
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
- expect(didReturnTrue).to.be.true();
- });
-
- it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- });
-
- const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
- expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
- });
-
- it('should transfer the correct balances if spender has sufficient allowance', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = initOwnerBalance;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- });
-
- const newOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const newSpenderBalance = await zeroEx.token.getBalanceAsync(tokenAddress, spender);
-
- expect(newOwnerBalance).to.be.bignumber.equal(0);
- expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance);
- });
-
- it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = initOwnerBalance;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- });
-
- const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
- expect(newSpenderAllowance).to.be.bignumber.equal(0);
- });
- });
-});