aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-06-22 05:26:34 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-06-22 13:45:15 +0800
commit607b44e01d16e38dd293c95f1f3d1fabfd7f6e2b (patch)
tree15ed72cbf6dc266115785a1b2fe5c1ca4190736a /packages/contracts/src
parent2d98193c832958844579e1c44d2771f5b11b6dbf (diff)
downloaddexon-sol-tools-607b44e01d16e38dd293c95f1f3d1fabfd7f6e2b.tar
dexon-sol-tools-607b44e01d16e38dd293c95f1f3d1fabfd7f6e2b.tar.gz
dexon-sol-tools-607b44e01d16e38dd293c95f1f3d1fabfd7f6e2b.tar.bz2
dexon-sol-tools-607b44e01d16e38dd293c95f1f3d1fabfd7f6e2b.tar.lz
dexon-sol-tools-607b44e01d16e38dd293c95f1f3d1fabfd7f6e2b.tar.xz
dexon-sol-tools-607b44e01d16e38dd293c95f1f3d1fabfd7f6e2b.tar.zst
dexon-sol-tools-607b44e01d16e38dd293c95f1f3d1fabfd7f6e2b.zip
Check that assetProxy exists before attempting transfer
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol7
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol23
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol45
3 files changed, 48 insertions, 27 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol
index 9dc9e6525..6e3156e8a 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol
+++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol
@@ -53,7 +53,12 @@ contract MixinERC721Transfer is
bytes memory receiverData
) = decodeERC721AssetData(assetData);
- ERC721Token(token).safeTransferFrom(from, to, tokenId, receiverData);
+ ERC721Token(token).safeTransferFrom(
+ from,
+ to,
+ tokenId,
+ receiverData
+ );
}
/// @dev Decodes ERC721 Asset data.
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol
index 9e0246303..f85019012 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol
@@ -47,7 +47,7 @@ contract MixinAssetProxyDispatcher is
onlyOwner
{
// Ensure the existing asset proxy is not unintentionally overwritten
- address currentAssetProxy = address(assetProxies[assetProxyId]);
+ address currentAssetProxy = assetProxies[assetProxyId];
require(
oldAssetProxy == currentAssetProxy,
ASSET_PROXY_MISMATCH
@@ -66,7 +66,11 @@ contract MixinAssetProxyDispatcher is
// Add asset proxy and log registration.
assetProxies[assetProxyId] = assetProxy;
- emit AssetProxySet(assetProxyId, newAssetProxy, oldAssetProxy);
+ emit AssetProxySet(
+ assetProxyId,
+ newAssetProxy,
+ oldAssetProxy
+ );
}
/// @dev Gets an asset proxy.
@@ -77,8 +81,7 @@ contract MixinAssetProxyDispatcher is
view
returns (address)
{
- address assetProxy = address(assetProxies[assetProxyId]);
- return assetProxy;
+ return assetProxies[assetProxyId];
}
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
@@ -100,8 +103,18 @@ contract MixinAssetProxyDispatcher is
if (amount > 0) {
// Lookup assetProxy
IAssetProxy assetProxy = assetProxies[assetProxyId];
+ // Ensure that assetProxy exists
+ require(
+ assetProxy != address(0),
+ ASSET_PROXY_DOES_NOT_EXIST
+ );
// transferFrom will either succeed or throw.
- assetProxy.transferFrom(assetData, from, to, amount);
+ assetProxy.transferFrom(
+ assetData,
+ from,
+ to,
+ amount
+ );
}
}
}
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol b/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol
index aab428e74..a43f0f927 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol
@@ -20,42 +20,45 @@ pragma solidity ^0.4.24;
contract LibExchangeErrors {
/// Order validation errors ///
- string constant ORDER_UNFILLABLE = "ORDER_UNFILLABLE"; // Order cannot be filled.
- string constant INVALID_MAKER = "INVALID_MAKER"; // Invalid makerAddress.
- string constant INVALID_TAKER = "INVALID_TAKER"; // Invalid takerAddress.
- string constant INVALID_SENDER = "INVALID_SENDER"; // Invalid `msg.sender`.
- string constant INVALID_ORDER_SIGNATURE = "INVALID_ORDER_SIGNATURE"; // Signature validation failed.
+ string constant ORDER_UNFILLABLE = "ORDER_UNFILLABLE"; // Order cannot be filled.
+ string constant INVALID_MAKER = "INVALID_MAKER"; // Invalid makerAddress.
+ string constant INVALID_TAKER = "INVALID_TAKER"; // Invalid takerAddress.
+ string constant INVALID_SENDER = "INVALID_SENDER"; // Invalid `msg.sender`.
+ string constant INVALID_ORDER_SIGNATURE = "INVALID_ORDER_SIGNATURE"; // Signature validation failed.
/// fillOrder validation errors ///
- string constant INVALID_TAKER_AMOUNT = "INVALID_TAKER_AMOUNT"; // takerAssetFillAmount cannot equal 0.
- string constant ROUNDING_ERROR = "ROUNDING_ERROR"; // Rounding error greater than 0.1% of takerAssetFillAmount.
+ string constant INVALID_TAKER_AMOUNT = "INVALID_TAKER_AMOUNT"; // takerAssetFillAmount cannot equal 0.
+ string constant ROUNDING_ERROR = "ROUNDING_ERROR"; // Rounding error greater than 0.1% of takerAssetFillAmount.
/// Signature validation errors ///
- string constant INVALID_SIGNATURE = "INVALID_SIGNATURE"; // Signature validation failed.
- string constant SIGNATURE_ILLEGAL = "SIGNATURE_ILLEGAL"; // Signature type is illegal.
- string constant SIGNATURE_UNSUPPORTED = "SIGNATURE_UNSUPPORTED"; // Signature type unsupported.
+ string constant INVALID_SIGNATURE = "INVALID_SIGNATURE"; // Signature validation failed.
+ string constant SIGNATURE_ILLEGAL = "SIGNATURE_ILLEGAL"; // Signature type is illegal.
+ string constant SIGNATURE_UNSUPPORTED = "SIGNATURE_UNSUPPORTED"; // Signature type unsupported.
/// cancelOrdersUptTo errors ///
- string constant INVALID_NEW_ORDER_EPOCH = "INVALID_NEW_ORDER_EPOCH"; // Specified salt must be greater than or equal to existing orderEpoch.
+ string constant INVALID_NEW_ORDER_EPOCH = "INVALID_NEW_ORDER_EPOCH"; // Specified salt must be greater than or equal to existing orderEpoch.
/// fillOrKillOrder errors ///
- string constant COMPLETE_FILL_FAILED = "COMPLETE_FILL_FAILED"; // Desired takerAssetFillAmount could not be completely filled.
+ string constant COMPLETE_FILL_FAILED = "COMPLETE_FILL_FAILED"; // Desired takerAssetFillAmount could not be completely filled.
/// matchOrders errors ///
- string constant NEGATIVE_SPREAD_REQUIRED = "NEGATIVE_SPREAD_REQUIRED"; // Matched orders must have a negative spread.
+ string constant NEGATIVE_SPREAD_REQUIRED = "NEGATIVE_SPREAD_REQUIRED"; // Matched orders must have a negative spread.
/// Transaction errors ///
- string constant REENTRANCY_ILLEGAL = "REENTRANCY_ILLEGAL"; // Recursive reentrancy is not allowed.
- string constant INVALID_TX_HASH = "INVALID_TX_HASH"; // Transaction has already been executed.
- string constant INVALID_TX_SIGNATURE = "INVALID_TX_SIGNATURE"; // Signature validation failed.
- string constant FAILED_EXECUTION = "FAILED_EXECUTION"; // Transaction execution failed.
+ string constant REENTRANCY_ILLEGAL = "REENTRANCY_ILLEGAL"; // Recursive reentrancy is not allowed.
+ string constant INVALID_TX_HASH = "INVALID_TX_HASH"; // Transaction has already been executed.
+ string constant INVALID_TX_SIGNATURE = "INVALID_TX_SIGNATURE"; // Signature validation failed.
+ string constant FAILED_EXECUTION = "FAILED_EXECUTION"; // Transaction execution failed.
/// registerAssetProxy errors ///
- string constant ASSET_PROXY_MISMATCH = "ASSET_PROXY_MISMATCH"; // oldAssetProxy proxy does not match currentAssetProxy.
- string constant ASSET_PROXY_ID_MISMATCH = "ASSET_PROXY_ID_MISMATCH"; // newAssetProxyId does not match given assetProxyId.
+ string constant ASSET_PROXY_MISMATCH = "ASSET_PROXY_MISMATCH"; // oldAssetProxy proxy does not match currentAssetProxy.
+ string constant ASSET_PROXY_ID_MISMATCH = "ASSET_PROXY_ID_MISMATCH"; // newAssetProxyId does not match given assetProxyId.
+
+ /// dispatchTransferFrom errors ///
+ string constant ASSET_PROXY_DOES_NOT_EXIST = "ASSET_PROXY_DOES_NOT_EXIST"; // No assetProxy registered at given id.
/// Length validation errors ///
string constant LENGTH_GREATER_THAN_0_REQUIRED = "LENGTH_GREATER_THAN_0_REQUIRED"; // Byte array must have a length greater than 0.
- string constant LENGTH_0_REQUIRED = "LENGTH_0_REQUIRED"; // Byte array must have a length of 0.
- string constant LENGTH_65_REQUIRED = "LENGTH_65_REQUIRED"; // Byte array must have a length of 65.
+ string constant LENGTH_0_REQUIRED = "LENGTH_0_REQUIRED"; // Byte array must have a length of 0.
+ string constant LENGTH_65_REQUIRED = "LENGTH_65_REQUIRED"; // Byte array must have a length of 65.
}