aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2017-12-12 05:29:59 +0800
committerAmir Bandeali <abandeali1@gmail.com>2017-12-13 07:05:29 +0800
commit1dda4d5f78705d96934a08f00000e9a98a3bbc3d (patch)
tree4c9354b40383c07d634f858c598dae2d212cbb0f /packages/contracts
parent6f2cb661638f86bae7a000f69cca1a6ba32a7087 (diff)
downloaddexon-sol-tools-1dda4d5f78705d96934a08f00000e9a98a3bbc3d.tar
dexon-sol-tools-1dda4d5f78705d96934a08f00000e9a98a3bbc3d.tar.gz
dexon-sol-tools-1dda4d5f78705d96934a08f00000e9a98a3bbc3d.tar.bz2
dexon-sol-tools-1dda4d5f78705d96934a08f00000e9a98a3bbc3d.tar.lz
dexon-sol-tools-1dda4d5f78705d96934a08f00000e9a98a3bbc3d.tar.xz
dexon-sol-tools-1dda4d5f78705d96934a08f00000e9a98a3bbc3d.tar.zst
dexon-sol-tools-1dda4d5f78705d96934a08f00000e9a98a3bbc3d.zip
Rename contracts lib to utils
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/contracts/Exchange.sol2
-rw-r--r--packages/contracts/contracts/TokenRegistry.sol2
-rw-r--r--packages/contracts/contracts/TokenTransferProxy.sol2
-rw-r--r--packages/contracts/contracts/test/DummyToken.sol2
-rw-r--r--packages/contracts/contracts/test/DummyToken_v2.sol2
-rw-r--r--packages/contracts/contracts/test/Mintable.sol2
-rw-r--r--packages/contracts/contracts/test/Mintable_v2.sol2
-rw-r--r--packages/contracts/contracts/tokens/EtherToken.sol2
-rw-r--r--packages/contracts/contracts/tokens/EtherToken_v2.sol2
-rw-r--r--packages/contracts/contracts/utils/Ownable.sol27
-rw-r--r--packages/contracts/contracts/utils/Ownable_v2.sol32
-rw-r--r--packages/contracts/contracts/utils/SafeMath.sol73
-rw-r--r--packages/contracts/contracts/utils/SafeMath_v2.sol73
13 files changed, 214 insertions, 9 deletions
diff --git a/packages/contracts/contracts/Exchange.sol b/packages/contracts/contracts/Exchange.sol
index 2f734fb20..1da74deef 100644
--- a/packages/contracts/contracts/Exchange.sol
+++ b/packages/contracts/contracts/Exchange.sol
@@ -20,7 +20,7 @@ pragma solidity ^0.4.11;
import "./TokenTransferProxy.sol";
import "./tokens/Token.sol";
-import "./lib/SafeMath.sol";
+import "./utils/SafeMath.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/TokenRegistry.sol b/packages/contracts/contracts/TokenRegistry.sol
index c76eaea9d..891d923ee 100644
--- a/packages/contracts/contracts/TokenRegistry.sol
+++ b/packages/contracts/contracts/TokenRegistry.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.11;
-import "./lib/Ownable.sol";
+import "./utils/Ownable.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>
diff --git a/packages/contracts/contracts/TokenTransferProxy.sol b/packages/contracts/contracts/TokenTransferProxy.sol
index 81ada804d..e92c37243 100644
--- a/packages/contracts/contracts/TokenTransferProxy.sol
+++ b/packages/contracts/contracts/TokenTransferProxy.sol
@@ -19,7 +19,7 @@
pragma solidity ^0.4.11;
import "./tokens/Token.sol";
-import "./lib/Ownable.sol";
+import "./utils/Ownable.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>
diff --git a/packages/contracts/contracts/test/DummyToken.sol b/packages/contracts/contracts/test/DummyToken.sol
index cf8c27201..d71edf260 100644
--- a/packages/contracts/contracts/test/DummyToken.sol
+++ b/packages/contracts/contracts/test/DummyToken.sol
@@ -1,7 +1,7 @@
pragma solidity ^0.4.11;
import "./Mintable.sol";
-import "./../lib/Ownable.sol";
+import "./../utils/Ownable.sol";
contract DummyToken is Mintable, Ownable {
string public name;
diff --git a/packages/contracts/contracts/test/DummyToken_v2.sol b/packages/contracts/contracts/test/DummyToken_v2.sol
index e3392bf64..9b4808703 100644
--- a/packages/contracts/contracts/test/DummyToken_v2.sol
+++ b/packages/contracts/contracts/test/DummyToken_v2.sol
@@ -1,7 +1,7 @@
pragma solidity 0.4.18;
import "./Mintable_v2.sol";
-import "./../lib/Ownable_v2.sol";
+import "./../utils/Ownable_v2.sol";
contract DummyToken_v2 is Mintable_v2, Ownable_v2 {
string public name;
diff --git a/packages/contracts/contracts/test/Mintable.sol b/packages/contracts/contracts/test/Mintable.sol
index 34c9eb858..3c790534f 100644
--- a/packages/contracts/contracts/test/Mintable.sol
+++ b/packages/contracts/contracts/test/Mintable.sol
@@ -1,7 +1,7 @@
pragma solidity ^0.4.11;
import "./../tokens/UnlimitedAllowanceToken.sol";
-import "./../lib/SafeMath.sol";
+import "./../utils/SafeMath.sol";
/*
* Mintable
diff --git a/packages/contracts/contracts/test/Mintable_v2.sol b/packages/contracts/contracts/test/Mintable_v2.sol
index a2605791f..54085e029 100644
--- a/packages/contracts/contracts/test/Mintable_v2.sol
+++ b/packages/contracts/contracts/test/Mintable_v2.sol
@@ -1,7 +1,7 @@
pragma solidity 0.4.18;
import "./../tokens/UnlimitedAllowanceToken_v2.sol";
-import "./../lib/SafeMath_v2.sol";
+import "./../utils/SafeMath_v2.sol";
/*
* Mintable
diff --git a/packages/contracts/contracts/tokens/EtherToken.sol b/packages/contracts/contracts/tokens/EtherToken.sol
index daef97d8f..d7e51a8f3 100644
--- a/packages/contracts/contracts/tokens/EtherToken.sol
+++ b/packages/contracts/contracts/tokens/EtherToken.sol
@@ -19,7 +19,7 @@
pragma solidity ^0.4.11;
import "./UnlimitedAllowanceToken.sol";
-import "./../lib/SafeMath.sol";
+import "./../utils/SafeMath.sol";
contract EtherToken is UnlimitedAllowanceToken, SafeMath {
diff --git a/packages/contracts/contracts/tokens/EtherToken_v2.sol b/packages/contracts/contracts/tokens/EtherToken_v2.sol
index a501013e4..1ed668909 100644
--- a/packages/contracts/contracts/tokens/EtherToken_v2.sol
+++ b/packages/contracts/contracts/tokens/EtherToken_v2.sol
@@ -19,7 +19,7 @@
pragma solidity 0.4.18;
import "./UnlimitedAllowanceToken_v2.sol";
-import "./../lib/SafeMath_v2.sol";
+import "./../utils/SafeMath_v2.sol";
contract EtherToken_v2 is UnlimitedAllowanceToken_v2, SafeMath_v2 {
diff --git a/packages/contracts/contracts/utils/Ownable.sol b/packages/contracts/contracts/utils/Ownable.sol
new file mode 100644
index 000000000..5488896d7
--- /dev/null
+++ b/packages/contracts/contracts/utils/Ownable.sol
@@ -0,0 +1,27 @@
+pragma solidity ^0.4.11;
+
+/*
+ * Ownable
+ *
+ * Base contract with an owner.
+ * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
+ */
+
+contract Ownable {
+ address public owner;
+
+ function Ownable() {
+ owner = msg.sender;
+ }
+
+ modifier onlyOwner() {
+ require(msg.sender == owner);
+ _;
+ }
+
+ function transferOwnership(address newOwner) onlyOwner {
+ if (newOwner != address(0)) {
+ owner = newOwner;
+ }
+ }
+}
diff --git a/packages/contracts/contracts/utils/Ownable_v2.sol b/packages/contracts/contracts/utils/Ownable_v2.sol
new file mode 100644
index 000000000..8cdf5985f
--- /dev/null
+++ b/packages/contracts/contracts/utils/Ownable_v2.sol
@@ -0,0 +1,32 @@
+pragma solidity 0.4.18;
+
+/*
+ * Ownable
+ *
+ * Base contract with an owner.
+ * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
+ */
+
+contract Ownable_v2 {
+ address public owner;
+
+ function Ownable_v2()
+ public
+ {
+ owner = msg.sender;
+ }
+
+ modifier onlyOwner() {
+ require(msg.sender == owner);
+ _;
+ }
+
+ function transferOwnership(address newOwner)
+ public
+ onlyOwner
+ {
+ if (newOwner != address(0)) {
+ owner = newOwner;
+ }
+ }
+}
diff --git a/packages/contracts/contracts/utils/SafeMath.sol b/packages/contracts/contracts/utils/SafeMath.sol
new file mode 100644
index 000000000..cf8ac3265
--- /dev/null
+++ b/packages/contracts/contracts/utils/SafeMath.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/utils/SafeMath_v2.sol b/packages/contracts/contracts/utils/SafeMath_v2.sol
new file mode 100644
index 000000000..3a4bbb8fb
--- /dev/null
+++ b/packages/contracts/contracts/utils/SafeMath_v2.sol
@@ -0,0 +1,73 @@
+pragma solidity 0.4.18;
+
+contract SafeMath_v2 {
+ function safeMul(uint a, uint b)
+ internal
+ pure
+ returns (uint256)
+ {
+ uint c = a * b;
+ assert(a == 0 || c / a == b);
+ return c;
+ }
+
+ function safeDiv(uint a, uint b)
+ internal
+ pure
+ returns (uint256)
+ {
+ uint c = a / b;
+ return c;
+ }
+
+ function safeSub(uint a, uint b)
+ internal
+ pure
+ returns (uint256)
+ {
+ assert(b <= a);
+ return a - b;
+ }
+
+ function safeAdd(uint a, uint b)
+ internal
+ pure
+ returns (uint256)
+ {
+ uint c = a + b;
+ assert(c >= a);
+ return c;
+ }
+
+ function max64(uint64 a, uint64 b)
+ internal
+ pure
+ returns (uint256)
+ {
+ return a >= b ? a : b;
+ }
+
+ function min64(uint64 a, uint64 b)
+ internal
+ pure
+ returns (uint256)
+ {
+ return a < b ? a : b;
+ }
+
+ function max256(uint256 a, uint256 b)
+ internal
+ pure
+ returns (uint256)
+ {
+ return a >= b ? a : b;
+ }
+
+ function min256(uint256 a, uint256 b)
+ internal
+ pure
+ returns (uint256)
+ {
+ return a < b ? a : b;
+ }
+}