diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-05-05 05:30:49 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-05-25 06:39:19 +0800 |
commit | 23df5cc201b3494c39389ac4cb4de346d7cbbd00 (patch) | |
tree | 4ed1fc7a0a57d3432070c66056571731f384d16c /packages | |
parent | bc550c3265cfcb92785d90c075a120d8c90d15f7 (diff) | |
download | dexon-sol-tools-23df5cc201b3494c39389ac4cb4de346d7cbbd00.tar dexon-sol-tools-23df5cc201b3494c39389ac4cb4de346d7cbbd00.tar.gz dexon-sol-tools-23df5cc201b3494c39389ac4cb4de346d7cbbd00.tar.bz2 dexon-sol-tools-23df5cc201b3494c39389ac4cb4de346d7cbbd00.tar.lz dexon-sol-tools-23df5cc201b3494c39389ac4cb4de346d7cbbd00.tar.xz dexon-sol-tools-23df5cc201b3494c39389ac4cb4de346d7cbbd00.tar.zst dexon-sol-tools-23df5cc201b3494c39389ac4cb4de346d7cbbd00.zip |
Update MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress to use a mapping of registered proxies
Diffstat (limited to 'packages')
-rw-r--r-- | packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol index 3d44e4c07..cc5808813 100644 --- a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol @@ -18,15 +18,19 @@ pragma solidity ^0.4.10; -import { MultiSigWalletWithTimeLock } from "../MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol"; +import "../MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol"; -contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWalletWithTimeLock { +contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is + MultiSigWalletWithTimeLock +{ + event AssetProxyRegistration(address assetProxyContract, bool isRegistered); - address public TOKEN_TRANSFER_PROXY_CONTRACT; + // Mapping of AssetProxy contract address => approved to execute removeAuthorizedAddress without time lock. + mapping (address => bool) public isAssetProxyRegistered; - modifier validRemoveAuthorizedAddressTx(uint transactionId) { + modifier validRemoveAuthorizedAddressTx(uint256 transactionId) { Transaction storage tx = transactions[transactionId]; - require(tx.destination == TOKEN_TRANSFER_PROXY_CONTRACT); + require(isAssetProxyRegistered[tx.destination]); require(isFunctionRemoveAuthorizedAddress(tx.data)); _; } @@ -35,21 +39,36 @@ contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWall /// @param _owners List of initial owners. /// @param _required Number of required confirmations. /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds. - /// @param _tokenTransferProxy Address of TokenTransferProxy contract. + /// @param _assetProxyContracts Array of AssetProxy contract addresses. function MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress( - address[] _owners, - uint _required, - uint _secondsTimeLocked, - address _tokenTransferProxy) + address[] memory _owners, + uint256 _required, + uint256 _secondsTimeLocked, + address[] memory _assetProxyContracts) public MultiSigWalletWithTimeLock(_owners, _required, _secondsTimeLocked) { - TOKEN_TRANSFER_PROXY_CONTRACT = _tokenTransferProxy; + for (uint256 i = 0; i < _assetProxyContracts.length; i++) { + require(_assetProxyContracts[i] != address(0)); + isAssetProxyRegistered[_assetProxyContracts[i]] = true; + } + } + + /// @dev Sets approval for calling removeAuthorizedAddress on an AssetProxy contract without a timelock. + /// @param assetProxyContract Address of AssetProxy contract. + /// @param isRegistered Status of approval for AssetProxy contract. + function registerAssetProxy(address assetProxyContract, bool isRegistered) + public + onlyWallet + notNull(assetProxyContract) + { + isAssetProxyRegistered[assetProxyContract] = isRegistered; + AssetProxyRegistration(assetProxyContract, isRegistered); } /// @dev Allows execution of removeAuthorizedAddress without time lock. /// @param transactionId Transaction ID. - function executeRemoveAuthorizedAddress(uint transactionId) + function executeRemoveAuthorizedAddress(uint256 transactionId) public notExecuted(transactionId) fullyConfirmed(transactionId) @@ -68,15 +87,26 @@ contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWall /// @dev Compares first 4 bytes of byte array to removeAuthorizedAddress function signature. /// @param data Transaction data. /// @return Successful if data is a call to removeAuthorizedAddress. - function isFunctionRemoveAuthorizedAddress(bytes data) + function isFunctionRemoveAuthorizedAddress(bytes memory data) public - constant + pure returns (bool) { - bytes4 removeAuthorizedAddressSignature = bytes4(sha3("removeAuthorizedAddress(address)")); - for (uint i = 0; i < 4; i++) { - require(data[i] == removeAuthorizedAddressSignature[i]); - } + bytes4 removeAuthorizedAddressSelector = bytes4(keccak256("removeAuthorizedAddress(address)")); + bytes4 first4Bytes = readFirst4(data); + require(removeAuthorizedAddressSelector == first4Bytes); return true; } + + function readFirst4(bytes memory data) + public + pure + returns (bytes4 result) + { + require(data.length >= 4); + assembly { + result := mload(add(data, 32)) + } + return result; + } } |