aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-07-11 03:46:53 +0800
committerGitHub <noreply@github.com>2018-07-11 03:46:53 +0800
commitaf7e02de2789efd3e73f60bf92b700ccec8ba520 (patch)
tree892cc61220dd4bbc769ef0e43c034b9a780103b0 /packages/contracts/src
parent2625cbbfed087dae55c62950a9260145cf5ca8e6 (diff)
parent092ca6bcf5de2d94ff503f11233c87d428eedcb8 (diff)
downloaddexon-sol-tools-af7e02de2789efd3e73f60bf92b700ccec8ba520.tar
dexon-sol-tools-af7e02de2789efd3e73f60bf92b700ccec8ba520.tar.gz
dexon-sol-tools-af7e02de2789efd3e73f60bf92b700ccec8ba520.tar.bz2
dexon-sol-tools-af7e02de2789efd3e73f60bf92b700ccec8ba520.tar.lz
dexon-sol-tools-af7e02de2789efd3e73f60bf92b700ccec8ba520.tar.xz
dexon-sol-tools-af7e02de2789efd3e73f60bf92b700ccec8ba520.tar.zst
dexon-sol-tools-af7e02de2789efd3e73f60bf92b700ccec8ba520.zip
Merge pull request #837 from 0xProject/fix/contracts/assetProxyOwnerVersion
Use 0.4.10 in AssetProxyOwner
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol27
-rw-r--r--packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol23
-rw-r--r--packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol3
3 files changed, 43 insertions, 10 deletions
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol b/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol
index e7cf4ab5c..8b7333646 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol
@@ -16,16 +16,14 @@
*/
-pragma solidity ^0.4.10;
+pragma solidity 0.4.10;
import "../../multisig/MultiSigWalletWithTimeLock.sol";
-import "../../utils/LibBytes/LibBytes.sol";
contract AssetProxyOwner is
MultiSigWalletWithTimeLock
{
- using LibBytes for bytes;
event AssetProxyRegistration(address assetProxyContract, bool isRegistered);
@@ -40,7 +38,7 @@ contract AssetProxyOwner is
modifier validRemoveAuthorizedAddressAtIndexTx(uint256 transactionId) {
Transaction storage tx = transactions[transactionId];
require(isAssetProxyRegistered[tx.destination]);
- require(tx.data.readBytes4(0) == REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR);
+ require(readBytes4(tx.data, 0) == REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR);
_;
}
@@ -97,4 +95,25 @@ contract AssetProxyOwner is
tx.executed = false;
}
}
+
+ /// @dev Reads an unpadded bytes4 value from a position in a byte array.
+ /// @param b Byte array containing a bytes4 value.
+ /// @param index Index in byte array of bytes4 value.
+ /// @return bytes4 value from byte array.
+ function readBytes4(
+ bytes memory b,
+ uint256 index
+ )
+ internal
+ returns (bytes4 result)
+ {
+ require(b.length >= index + 4);
+ assembly {
+ result := mload(add(b, 32))
+ // Solidity does not require us to clean the trailing bytes.
+ // We do it anyway
+ result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000)
+ }
+ return result;
+ }
}
diff --git a/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol b/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
index d6b6b29f2..75e782d43 100644
--- a/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
+++ b/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
@@ -16,7 +16,7 @@
*/
-pragma solidity 0.4.24;
+pragma solidity 0.4.10;
import "../../protocol/AssetProxyOwner/AssetProxyOwner.sol";
@@ -26,7 +26,7 @@ contract TestAssetProxyOwner is
AssetProxyOwner
{
- constructor(
+ function TestAssetProxyOwner(
address[] memory _owners,
address[] memory _assetProxyContracts,
uint256 _required,
@@ -38,7 +38,6 @@ contract TestAssetProxyOwner is
function testValidRemoveAuthorizedAddressAtIndexTx(uint256 id)
public
- view
validRemoveAuthorizedAddressAtIndexTx(id)
returns (bool)
{
@@ -51,9 +50,23 @@ contract TestAssetProxyOwner is
/// @return Successful if data is a call to `removeAuthorizedAddressAtIndex`.
function isFunctionRemoveAuthorizedAddressAtIndex(bytes memory data)
public
- pure
returns (bool)
{
- return data.readBytes4(0) == REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR;
+ return readBytes4(data, 0) == REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR;
+ }
+
+ /// @dev Reads an unpadded bytes4 value from a position in a byte array.
+ /// @param b Byte array containing a bytes4 value.
+ /// @param index Index in byte array of bytes4 value.
+ /// @return bytes4 value from byte array.
+ function publicReadBytes4(
+ bytes memory b,
+ uint256 index
+ )
+ public
+ returns (bytes4 result)
+ {
+ result = readBytes4(b, index);
+ return result;
}
}
diff --git a/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol b/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol
index 01d34fa8f..504e950a8 100644
--- a/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol
+++ b/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol
@@ -457,7 +457,8 @@ library LibBytes {
/// @return bytes4 value from byte array.
function readBytes4(
bytes memory b,
- uint256 index)
+ uint256 index
+ )
internal
pure
returns (bytes4 result)