aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-04-17 02:47:28 +0800
committerGitHub <noreply@github.com>2018-04-17 02:47:28 +0800
commitd263f7783fabe89cc9714b596068eccdc5babc1c (patch)
tree54a5c8f0a88320f3df8330d95506aea96e808bd3 /packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol
parent1fcf3c5dc44d10648e14d6b10c174930eecf27b1 (diff)
parentd8ef76fd5efe63ec8f6205a73494ce388e64391f (diff)
downloaddexon-sol-tools-d263f7783fabe89cc9714b596068eccdc5babc1c.tar
dexon-sol-tools-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.gz
dexon-sol-tools-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.bz2
dexon-sol-tools-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.lz
dexon-sol-tools-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.xz
dexon-sol-tools-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.zst
dexon-sol-tools-d263f7783fabe89cc9714b596068eccdc5babc1c.zip
Merge pull request #512 from 0xProject/feature/resolver
Dependencies resolver for deployer
Diffstat (limited to 'packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol')
-rw-r--r--packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol115
1 files changed, 115 insertions, 0 deletions
diff --git a/packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol b/packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol
new file mode 100644
index 000000000..44570d459
--- /dev/null
+++ b/packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol
@@ -0,0 +1,115 @@
+/*
+
+ 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.14;
+
+import { Ownable } from "zeppelin-solidity/contracts/ownership/Ownable.sol";
+import { ERC20 as Token } from "zeppelin-solidity/contracts/token/ERC20/ERC20.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>
+contract TokenTransferProxy is Ownable {
+
+ /// @dev Only authorized addresses can invoke functions with this modifier.
+ modifier onlyAuthorized {
+ require(authorized[msg.sender]);
+ _;
+ }
+
+ modifier targetAuthorized(address target) {
+ require(authorized[target]);
+ _;
+ }
+
+ modifier targetNotAuthorized(address target) {
+ require(!authorized[target]);
+ _;
+ }
+
+ mapping (address => bool) public authorized;
+ address[] public authorities;
+
+ event LogAuthorizedAddressAdded(address indexed target, address indexed caller);
+ event LogAuthorizedAddressRemoved(address indexed target, address indexed caller);
+
+ /*
+ * Public functions
+ */
+
+ /// @dev Authorizes an address.
+ /// @param target Address to authorize.
+ function addAuthorizedAddress(address target)
+ public
+ onlyOwner
+ targetNotAuthorized(target)
+ {
+ authorized[target] = true;
+ authorities.push(target);
+ LogAuthorizedAddressAdded(target, msg.sender);
+ }
+
+ /// @dev Removes authorizion of an address.
+ /// @param target Address to remove authorization from.
+ function removeAuthorizedAddress(address target)
+ public
+ onlyOwner
+ targetAuthorized(target)
+ {
+ delete authorized[target];
+ for (uint i = 0; i < authorities.length; i++) {
+ if (authorities[i] == target) {
+ authorities[i] = authorities[authorities.length - 1];
+ authorities.length -= 1;
+ break;
+ }
+ }
+ LogAuthorizedAddressRemoved(target, msg.sender);
+ }
+
+ /// @dev Calls into ERC20 Token contract, invoking transferFrom.
+ /// @param token Address of token to transfer.
+ /// @param from Address to transfer token from.
+ /// @param to Address to transfer token to.
+ /// @param value Amount of token to transfer.
+ /// @return Success of transfer.
+ function transferFrom(
+ address token,
+ address from,
+ address to,
+ uint value)
+ public
+ onlyAuthorized
+ returns (bool)
+ {
+ return Token(token).transferFrom(from, to, value);
+ }
+
+ /*
+ * Public constant functions
+ */
+
+ /// @dev Gets all authorized addresses.
+ /// @return Array of authorized addresses.
+ function getAuthorizedAddresses()
+ public
+ constant
+ returns (address[])
+ {
+ return authorities;
+ }
+}