Move LibExchangeRichErrors to exchange-libs package
This commit is contained in:
parent
d3b8070fd6
commit
dc31294440
@ -21,8 +21,8 @@ pragma experimental ABIEncoderV2;
|
|||||||
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
|
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
|
||||||
import "@0x/contracts-exchange/contracts/src/LibExchangeRichErrors.sol";
|
|
||||||
import "@0x/contracts-exchange/contracts/src/libs/LibExchangeRichErrorDecoder.sol";
|
import "@0x/contracts-exchange/contracts/src/libs/LibExchangeRichErrorDecoder.sol";
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
|
|
||||||
|
@ -19,12 +19,44 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "./LibOrder.sol";
|
||||||
import "./interfaces/IExchangeRichErrors.sol";
|
|
||||||
|
|
||||||
|
|
||||||
library LibExchangeRichErrors {
|
library LibExchangeRichErrors {
|
||||||
|
|
||||||
|
enum AssetProxyDispatchErrorCodes {
|
||||||
|
INVALID_ASSET_DATA_LENGTH,
|
||||||
|
UNKNOWN_ASSET_PROXY
|
||||||
|
}
|
||||||
|
|
||||||
|
enum BatchMatchOrdersErrorCodes {
|
||||||
|
ZERO_LEFT_ORDERS,
|
||||||
|
ZERO_RIGHT_ORDERS,
|
||||||
|
INVALID_LENGTH_LEFT_SIGNATURES,
|
||||||
|
INVALID_LENGTH_RIGHT_SIGNATURES
|
||||||
|
}
|
||||||
|
|
||||||
|
enum FillErrorCodes {
|
||||||
|
INVALID_TAKER_AMOUNT,
|
||||||
|
TAKER_OVERPAY,
|
||||||
|
OVERFILL,
|
||||||
|
INVALID_FILL_PRICE
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SignatureErrorCodes {
|
||||||
|
BAD_SIGNATURE,
|
||||||
|
INVALID_LENGTH,
|
||||||
|
UNSUPPORTED,
|
||||||
|
ILLEGAL,
|
||||||
|
INAPPROPRIATE_SIGNATURE_TYPE
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TransactionErrorCodes {
|
||||||
|
NO_REENTRANCY,
|
||||||
|
ALREADY_EXECUTED,
|
||||||
|
EXPIRED
|
||||||
|
}
|
||||||
|
|
||||||
// bytes4(keccak256("SignatureError(uint8,bytes32,address,bytes)"))
|
// bytes4(keccak256("SignatureError(uint8,bytes32,address,bytes)"))
|
||||||
bytes4 internal constant SIGNATURE_ERROR_SELECTOR =
|
bytes4 internal constant SIGNATURE_ERROR_SELECTOR =
|
||||||
0x7e5a2318;
|
0x7e5a2318;
|
||||||
@ -255,7 +287,7 @@ library LibExchangeRichErrors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function BatchMatchOrdersError(
|
function BatchMatchOrdersError(
|
||||||
IExchangeRichErrors.BatchMatchOrdersErrorCodes errorCode
|
BatchMatchOrdersErrorCodes errorCode
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
@ -268,7 +300,7 @@ library LibExchangeRichErrors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SignatureError(
|
function SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes errorCode,
|
SignatureErrorCodes errorCode,
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signerAddress,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
@ -387,7 +419,7 @@ library LibExchangeRichErrors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function FillError(
|
function FillError(
|
||||||
IExchangeRichErrors.FillErrorCodes errorCode,
|
FillErrorCodes errorCode,
|
||||||
bytes32 orderHash
|
bytes32 orderHash
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@ -447,7 +479,7 @@ library LibExchangeRichErrors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function AssetProxyDispatchError(
|
function AssetProxyDispatchError(
|
||||||
IExchangeRichErrors.AssetProxyDispatchErrorCodes errorCode,
|
AssetProxyDispatchErrorCodes errorCode,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
bytes memory assetData
|
bytes memory assetData
|
||||||
)
|
)
|
||||||
@ -496,7 +528,7 @@ library LibExchangeRichErrors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function TransactionError(
|
function TransactionError(
|
||||||
IExchangeRichErrors.TransactionErrorCodes errorCode,
|
TransactionErrorCodes errorCode,
|
||||||
bytes32 transactionHash
|
bytes32 transactionHash
|
||||||
)
|
)
|
||||||
internal
|
internal
|
@ -19,18 +19,18 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
||||||
import "./MixinMatchOrders.sol";
|
import "./MixinMatchOrders.sol";
|
||||||
import "./MixinSignatureValidator.sol";
|
|
||||||
import "./MixinWrapperFunctions.sol";
|
import "./MixinWrapperFunctions.sol";
|
||||||
import "./MixinTransferSimulator.sol";
|
import "./MixinTransferSimulator.sol";
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
// solhint-disable no-empty-blocks
|
||||||
// MixinAssetProxyDispatcher, MixinExchangeCore, MixinExchangeRichErrors,
|
// MixinAssetProxyDispatcher, MixinExchangeCore, MixinSignatureValidator,
|
||||||
// and MixinTransactions are all inherited via the other Mixins that are
|
// and MixinTransactions are all inherited via the other Mixins that are
|
||||||
// used.
|
// used.
|
||||||
contract Exchange is
|
contract Exchange is
|
||||||
MixinSignatureValidator,
|
LibEIP712ExchangeDomain,
|
||||||
MixinMatchOrders,
|
MixinMatchOrders,
|
||||||
MixinWrapperFunctions,
|
MixinWrapperFunctions,
|
||||||
MixinTransferSimulator
|
MixinTransferSimulator
|
||||||
@ -42,12 +42,5 @@ contract Exchange is
|
|||||||
constructor (uint256 chainId)
|
constructor (uint256 chainId)
|
||||||
public
|
public
|
||||||
LibEIP712ExchangeDomain(chainId, address(0))
|
LibEIP712ExchangeDomain(chainId, address(0))
|
||||||
MixinExchangeCore()
|
|
||||||
MixinMatchOrders()
|
|
||||||
MixinSignatureValidator()
|
|
||||||
MixinTransactions()
|
|
||||||
MixinAssetProxyDispatcher()
|
|
||||||
MixinTransferSimulator()
|
|
||||||
MixinWrapperFunctions()
|
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,9 @@ pragma solidity ^0.5.9;
|
|||||||
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
|
||||||
import "./interfaces/IAssetProxy.sol";
|
import "./interfaces/IAssetProxy.sol";
|
||||||
import "./interfaces/IAssetProxyDispatcher.sol";
|
import "./interfaces/IAssetProxyDispatcher.sol";
|
||||||
import "./interfaces/IExchangeRichErrors.sol";
|
|
||||||
import "./LibExchangeRichErrors.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MixinAssetProxyDispatcher is
|
contract MixinAssetProxyDispatcher is
|
||||||
@ -89,7 +88,7 @@ contract MixinAssetProxyDispatcher is
|
|||||||
// Ensure assetData length is valid
|
// Ensure assetData length is valid
|
||||||
if (assetData.length <= 3) {
|
if (assetData.length <= 3) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.AssetProxyDispatchError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.AssetProxyDispatchError(
|
||||||
IExchangeRichErrors.AssetProxyDispatchErrorCodes.INVALID_ASSET_DATA_LENGTH,
|
LibExchangeRichErrors.AssetProxyDispatchErrorCodes.INVALID_ASSET_DATA_LENGTH,
|
||||||
orderHash,
|
orderHash,
|
||||||
assetData
|
assetData
|
||||||
));
|
));
|
||||||
@ -102,7 +101,7 @@ contract MixinAssetProxyDispatcher is
|
|||||||
// Ensure that assetProxy exists
|
// Ensure that assetProxy exists
|
||||||
if (assetProxy == address(0)) {
|
if (assetProxy == address(0)) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.AssetProxyDispatchError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.AssetProxyDispatchError(
|
||||||
IExchangeRichErrors.AssetProxyDispatchErrorCodes.UNKNOWN_ASSET_PROXY,
|
LibExchangeRichErrors.AssetProxyDispatchErrorCodes.UNKNOWN_ASSET_PROXY,
|
||||||
orderHash,
|
orderHash,
|
||||||
assetData
|
assetData
|
||||||
));
|
));
|
||||||
|
@ -24,9 +24,8 @@ import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
|||||||
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
|
||||||
import "./interfaces/IExchangeCore.sol";
|
import "./interfaces/IExchangeCore.sol";
|
||||||
import "./interfaces/IExchangeRichErrors.sol";
|
|
||||||
import "./LibExchangeRichErrors.sol";
|
|
||||||
import "./MixinAssetProxyDispatcher.sol";
|
import "./MixinAssetProxyDispatcher.sol";
|
||||||
import "./MixinSignatureValidator.sol";
|
import "./MixinSignatureValidator.sol";
|
||||||
|
|
||||||
@ -368,7 +367,7 @@ contract MixinExchangeCore is
|
|||||||
orderInfo.orderHash,
|
orderInfo.orderHash,
|
||||||
signature)) {
|
signature)) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes.BAD_SIGNATURE,
|
LibExchangeRichErrors.SignatureErrorCodes.BAD_SIGNATURE,
|
||||||
orderInfo.orderHash,
|
orderInfo.orderHash,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
signature
|
signature
|
||||||
|
@ -18,9 +18,8 @@ import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
|||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
||||||
import "./interfaces/IExchangeRichErrors.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
|
||||||
import "./interfaces/IMatchOrders.sol";
|
import "./interfaces/IMatchOrders.sol";
|
||||||
import "./LibExchangeRichErrors.sol";
|
|
||||||
import "./MixinExchangeCore.sol";
|
import "./MixinExchangeCore.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -197,24 +196,24 @@ contract MixinMatchOrders is
|
|||||||
// Ensure that the left and right orders have nonzero lengths.
|
// Ensure that the left and right orders have nonzero lengths.
|
||||||
if (leftOrders.length == 0) {
|
if (leftOrders.length == 0) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
|
||||||
IExchangeRichErrors.BatchMatchOrdersErrorCodes.ZERO_LEFT_ORDERS
|
LibExchangeRichErrors.BatchMatchOrdersErrorCodes.ZERO_LEFT_ORDERS
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (rightOrders.length == 0) {
|
if (rightOrders.length == 0) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
|
||||||
IExchangeRichErrors.BatchMatchOrdersErrorCodes.ZERO_RIGHT_ORDERS
|
LibExchangeRichErrors.BatchMatchOrdersErrorCodes.ZERO_RIGHT_ORDERS
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the left and right arrays are compatible.
|
// Ensure that the left and right arrays are compatible.
|
||||||
if (leftOrders.length != leftSignatures.length) {
|
if (leftOrders.length != leftSignatures.length) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
|
||||||
IExchangeRichErrors.BatchMatchOrdersErrorCodes.INVALID_LENGTH_LEFT_SIGNATURES
|
LibExchangeRichErrors.BatchMatchOrdersErrorCodes.INVALID_LENGTH_LEFT_SIGNATURES
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (rightOrders.length != rightSignatures.length) {
|
if (rightOrders.length != rightSignatures.length) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
|
||||||
IExchangeRichErrors.BatchMatchOrdersErrorCodes.INVALID_LENGTH_RIGHT_SIGNATURES
|
LibExchangeRichErrors.BatchMatchOrdersErrorCodes.INVALID_LENGTH_RIGHT_SIGNATURES
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,10 @@ import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
|||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
|
||||||
import "./interfaces/IWallet.sol";
|
import "./interfaces/IWallet.sol";
|
||||||
import "./interfaces/IEIP1271Wallet.sol";
|
import "./interfaces/IEIP1271Wallet.sol";
|
||||||
import "./interfaces/IExchangeRichErrors.sol";
|
|
||||||
import "./interfaces/ISignatureValidator.sol";
|
import "./interfaces/ISignatureValidator.sol";
|
||||||
import "./LibExchangeRichErrors.sol";
|
|
||||||
import "./MixinTransactions.sol";
|
import "./MixinTransactions.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +111,7 @@ contract MixinSignatureValidator is
|
|||||||
signatureType == SignatureType.EIP1271Wallet
|
signatureType == SignatureType.EIP1271Wallet
|
||||||
) {
|
) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes.INAPPROPRIATE_SIGNATURE_TYPE,
|
LibExchangeRichErrors.SignatureErrorCodes.INAPPROPRIATE_SIGNATURE_TYPE,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -308,7 +307,7 @@ contract MixinSignatureValidator is
|
|||||||
if (signatureType == SignatureType.Invalid) {
|
if (signatureType == SignatureType.Invalid) {
|
||||||
if (signature.length != 1) {
|
if (signature.length != 1) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
LibExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -320,7 +319,7 @@ contract MixinSignatureValidator is
|
|||||||
} else if (signatureType == SignatureType.EIP712) {
|
} else if (signatureType == SignatureType.EIP712) {
|
||||||
if (signature.length != 66) {
|
if (signature.length != 66) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
LibExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -341,7 +340,7 @@ contract MixinSignatureValidator is
|
|||||||
} else if (signatureType == SignatureType.EthSign) {
|
} else if (signatureType == SignatureType.EthSign) {
|
||||||
if (signature.length != 66) {
|
if (signature.length != 66) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
LibExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -400,7 +399,7 @@ contract MixinSignatureValidator is
|
|||||||
|
|
||||||
if (signature.length == 0) {
|
if (signature.length == 0) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
LibExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -413,7 +412,7 @@ contract MixinSignatureValidator is
|
|||||||
// Ensure signature is supported
|
// Ensure signature is supported
|
||||||
if (signatureTypeRaw >= uint8(SignatureType.NSignatureTypes)) {
|
if (signatureTypeRaw >= uint8(SignatureType.NSignatureTypes)) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes.UNSUPPORTED,
|
LibExchangeRichErrors.SignatureErrorCodes.UNSUPPORTED,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -427,7 +426,7 @@ contract MixinSignatureValidator is
|
|||||||
// also the initialization value for the enum type.
|
// also the initialization value for the enum type.
|
||||||
if (SignatureType(signatureTypeRaw) == SignatureType.Illegal) {
|
if (SignatureType(signatureTypeRaw) == SignatureType.Illegal) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
IExchangeRichErrors.SignatureErrorCodes.ILLEGAL,
|
LibExchangeRichErrors.SignatureErrorCodes.ILLEGAL,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
|
@ -21,11 +21,10 @@ pragma experimental ABIEncoderV2;
|
|||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||||
import "./interfaces/IExchangeRichErrors.sol";
|
|
||||||
import "./interfaces/ITransactions.sol";
|
import "./interfaces/ITransactions.sol";
|
||||||
import "./interfaces/ISignatureValidator.sol";
|
import "./interfaces/ISignatureValidator.sol";
|
||||||
import "./LibExchangeRichErrors.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MixinTransactions is
|
contract MixinTransactions is
|
||||||
@ -92,7 +91,7 @@ contract MixinTransactions is
|
|||||||
// solhint-disable-next-line not-rely-on-time
|
// solhint-disable-next-line not-rely-on-time
|
||||||
if (block.timestamp >= transaction.expirationTimeSeconds) {
|
if (block.timestamp >= transaction.expirationTimeSeconds) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.TransactionError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.TransactionError(
|
||||||
IExchangeRichErrors.TransactionErrorCodes.EXPIRED,
|
LibExchangeRichErrors.TransactionErrorCodes.EXPIRED,
|
||||||
transactionHash
|
transactionHash
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -100,7 +99,7 @@ contract MixinTransactions is
|
|||||||
// Prevent reentrancy
|
// Prevent reentrancy
|
||||||
if (currentContextAddress != address(0)) {
|
if (currentContextAddress != address(0)) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.TransactionError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.TransactionError(
|
||||||
IExchangeRichErrors.TransactionErrorCodes.NO_REENTRANCY,
|
LibExchangeRichErrors.TransactionErrorCodes.NO_REENTRANCY,
|
||||||
transactionHash
|
transactionHash
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -108,7 +107,7 @@ contract MixinTransactions is
|
|||||||
// Validate transaction has not been executed
|
// Validate transaction has not been executed
|
||||||
if (transactionsExecuted[transactionHash]) {
|
if (transactionsExecuted[transactionHash]) {
|
||||||
LibRichErrors.rrevert(LibExchangeRichErrors.TransactionError(
|
LibRichErrors.rrevert(LibExchangeRichErrors.TransactionError(
|
||||||
IExchangeRichErrors.TransactionErrorCodes.ALREADY_EXECUTED,
|
LibExchangeRichErrors.TransactionErrorCodes.ALREADY_EXECUTED,
|
||||||
transactionHash
|
transactionHash
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
|||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
|
||||||
import "./interfaces/IExchangeCore.sol";
|
import "./interfaces/IExchangeCore.sol";
|
||||||
import "./interfaces/IExchangeRichErrors.sol";
|
|
||||||
import "./interfaces/IWrapperFunctions.sol";
|
import "./interfaces/IWrapperFunctions.sol";
|
||||||
import "./LibExchangeRichErrors.sol";
|
|
||||||
import "./MixinExchangeCore.sol";
|
import "./MixinExchangeCore.sol";
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,14 +19,12 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "../interfaces/IExchangeRichErrors.sol";
|
|
||||||
import "../LibExchangeRichErrors.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract LibExchangeRichErrorDecoder is
|
contract LibExchangeRichErrorDecoder {
|
||||||
IExchangeRichErrors
|
|
||||||
{
|
|
||||||
/// @dev Decompose an ABI-encoded SignatureError.
|
/// @dev Decompose an ABI-encoded SignatureError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return errorCode The error code.
|
/// @return errorCode The error code.
|
||||||
@ -36,14 +34,14 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
SignatureErrorCodes errorCode,
|
LibExchangeRichErrors.SignatureErrorCodes errorCode,
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signerAddress,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, LibExchangeRichErrors.SignatureErrorSelector());
|
_assertSelectorBytes(encoded, LibExchangeRichErrors.SignatureErrorSelector());
|
||||||
errorCode = SignatureErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = LibExchangeRichErrors.SignatureErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
hash = _readErrorParameterAsBytes32(encoded, 1);
|
hash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
signerAddress = _readErrorParameterAsAddress(encoded, 2);
|
signerAddress = _readErrorParameterAsAddress(encoded, 2);
|
||||||
signature = _readErrorParameterAsBytes(encoded, 3);
|
signature = _readErrorParameterAsBytes(encoded, 3);
|
||||||
@ -189,12 +187,12 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
FillErrorCodes errorCode,
|
LibExchangeRichErrors.FillErrorCodes errorCode,
|
||||||
bytes32 orderHash
|
bytes32 orderHash
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, LibExchangeRichErrors.FillErrorSelector());
|
_assertSelectorBytes(encoded, LibExchangeRichErrors.FillErrorSelector());
|
||||||
errorCode = FillErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = LibExchangeRichErrors.FillErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
orderHash = _readErrorParameterAsBytes32(encoded, 1);
|
orderHash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,13 +237,13 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
AssetProxyDispatchErrorCodes errorCode,
|
LibExchangeRichErrors.AssetProxyDispatchErrorCodes errorCode,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
bytes memory assetData
|
bytes memory assetData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, LibExchangeRichErrors.AssetProxyDispatchErrorSelector());
|
_assertSelectorBytes(encoded, LibExchangeRichErrors.AssetProxyDispatchErrorSelector());
|
||||||
errorCode = AssetProxyDispatchErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = LibExchangeRichErrors.AssetProxyDispatchErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
orderHash = _readErrorParameterAsBytes32(encoded, 1);
|
orderHash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
assetData = _readErrorParameterAsBytes(encoded, 2);
|
assetData = _readErrorParameterAsBytes(encoded, 2);
|
||||||
}
|
}
|
||||||
@ -295,12 +293,12 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
TransactionErrorCodes errorCode,
|
LibExchangeRichErrors.TransactionErrorCodes errorCode,
|
||||||
bytes32 transactionHash
|
bytes32 transactionHash
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, LibExchangeRichErrors.TransactionErrorSelector());
|
_assertSelectorBytes(encoded, LibExchangeRichErrors.TransactionErrorSelector());
|
||||||
errorCode = TransactionErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = LibExchangeRichErrors.TransactionErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
transactionHash = _readErrorParameterAsBytes32(encoded, 1);
|
transactionHash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis": "./generated-artifacts/@(Exchange|ExchangeWrapper|IAssetProxyDispatcher|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|IWallet|IWrapperFunctions|IsolatedExchange|ReentrancyTester|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestSignatureValidator|TestValidatorWallet|TestWrapperFunctions|Whitelist).json",
|
"abis": "./generated-artifacts/@(Exchange|ExchangeWrapper|IAssetProxy|IAssetProxyDispatcher|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|ITransferSimulator|IWallet|IWrapperFunctions|IsolatedExchange|LibExchangeRichErrorDecoder|MixinAssetProxyDispatcher|MixinExchangeCore|MixinMatchOrders|MixinSignatureValidator|MixinTransactions|MixinTransferSimulator|MixinWrapperFunctions|ReentrantERC20Token|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestSignatureValidator|TestValidatorWallet|Whitelist).json",
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -12,7 +12,6 @@ import * as IAssetProxyDispatcher from '../generated-artifacts/IAssetProxyDispat
|
|||||||
import * as IEIP1271Wallet from '../generated-artifacts/IEIP1271Wallet.json';
|
import * as IEIP1271Wallet from '../generated-artifacts/IEIP1271Wallet.json';
|
||||||
import * as IExchange from '../generated-artifacts/IExchange.json';
|
import * as IExchange from '../generated-artifacts/IExchange.json';
|
||||||
import * as IExchangeCore from '../generated-artifacts/IExchangeCore.json';
|
import * as IExchangeCore from '../generated-artifacts/IExchangeCore.json';
|
||||||
import * as IExchangeRichErrors from '../generated-artifacts/IExchangeRichErrors.json';
|
|
||||||
import * as IMatchOrders from '../generated-artifacts/IMatchOrders.json';
|
import * as IMatchOrders from '../generated-artifacts/IMatchOrders.json';
|
||||||
import * as ISignatureValidator from '../generated-artifacts/ISignatureValidator.json';
|
import * as ISignatureValidator from '../generated-artifacts/ISignatureValidator.json';
|
||||||
import * as ITransactions from '../generated-artifacts/ITransactions.json';
|
import * as ITransactions from '../generated-artifacts/ITransactions.json';
|
||||||
@ -21,7 +20,6 @@ import * as IWallet from '../generated-artifacts/IWallet.json';
|
|||||||
import * as IWrapperFunctions from '../generated-artifacts/IWrapperFunctions.json';
|
import * as IWrapperFunctions from '../generated-artifacts/IWrapperFunctions.json';
|
||||||
import * as IsolatedExchange from '../generated-artifacts/IsolatedExchange.json';
|
import * as IsolatedExchange from '../generated-artifacts/IsolatedExchange.json';
|
||||||
import * as LibExchangeRichErrorDecoder from '../generated-artifacts/LibExchangeRichErrorDecoder.json';
|
import * as LibExchangeRichErrorDecoder from '../generated-artifacts/LibExchangeRichErrorDecoder.json';
|
||||||
import * as LibExchangeRichErrors from '../generated-artifacts/LibExchangeRichErrors.json';
|
|
||||||
import * as MixinAssetProxyDispatcher from '../generated-artifacts/MixinAssetProxyDispatcher.json';
|
import * as MixinAssetProxyDispatcher from '../generated-artifacts/MixinAssetProxyDispatcher.json';
|
||||||
import * as MixinExchangeCore from '../generated-artifacts/MixinExchangeCore.json';
|
import * as MixinExchangeCore from '../generated-artifacts/MixinExchangeCore.json';
|
||||||
import * as MixinMatchOrders from '../generated-artifacts/MixinMatchOrders.json';
|
import * as MixinMatchOrders from '../generated-artifacts/MixinMatchOrders.json';
|
||||||
@ -41,7 +39,6 @@ export const artifacts = {
|
|||||||
ExchangeWrapper: ExchangeWrapper as ContractArtifact,
|
ExchangeWrapper: ExchangeWrapper as ContractArtifact,
|
||||||
Whitelist: Whitelist as ContractArtifact,
|
Whitelist: Whitelist as ContractArtifact,
|
||||||
Exchange: Exchange as ContractArtifact,
|
Exchange: Exchange as ContractArtifact,
|
||||||
LibExchangeRichErrors: LibExchangeRichErrors as ContractArtifact,
|
|
||||||
MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact,
|
MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact,
|
||||||
MixinExchangeCore: MixinExchangeCore as ContractArtifact,
|
MixinExchangeCore: MixinExchangeCore as ContractArtifact,
|
||||||
MixinMatchOrders: MixinMatchOrders as ContractArtifact,
|
MixinMatchOrders: MixinMatchOrders as ContractArtifact,
|
||||||
@ -54,7 +51,6 @@ export const artifacts = {
|
|||||||
IEIP1271Wallet: IEIP1271Wallet as ContractArtifact,
|
IEIP1271Wallet: IEIP1271Wallet as ContractArtifact,
|
||||||
IExchange: IExchange as ContractArtifact,
|
IExchange: IExchange as ContractArtifact,
|
||||||
IExchangeCore: IExchangeCore as ContractArtifact,
|
IExchangeCore: IExchangeCore as ContractArtifact,
|
||||||
IExchangeRichErrors: IExchangeRichErrors as ContractArtifact,
|
|
||||||
IMatchOrders: IMatchOrders as ContractArtifact,
|
IMatchOrders: IMatchOrders as ContractArtifact,
|
||||||
ISignatureValidator: ISignatureValidator as ContractArtifact,
|
ISignatureValidator: ISignatureValidator as ContractArtifact,
|
||||||
ITransactions: ITransactions as ContractArtifact,
|
ITransactions: ITransactions as ContractArtifact,
|
||||||
|
@ -10,7 +10,6 @@ export * from '../generated-wrappers/i_asset_proxy_dispatcher';
|
|||||||
export * from '../generated-wrappers/i_e_i_p1271_wallet';
|
export * from '../generated-wrappers/i_e_i_p1271_wallet';
|
||||||
export * from '../generated-wrappers/i_exchange';
|
export * from '../generated-wrappers/i_exchange';
|
||||||
export * from '../generated-wrappers/i_exchange_core';
|
export * from '../generated-wrappers/i_exchange_core';
|
||||||
export * from '../generated-wrappers/i_exchange_rich_errors';
|
|
||||||
export * from '../generated-wrappers/i_match_orders';
|
export * from '../generated-wrappers/i_match_orders';
|
||||||
export * from '../generated-wrappers/i_signature_validator';
|
export * from '../generated-wrappers/i_signature_validator';
|
||||||
export * from '../generated-wrappers/i_transactions';
|
export * from '../generated-wrappers/i_transactions';
|
||||||
@ -19,7 +18,6 @@ export * from '../generated-wrappers/i_wallet';
|
|||||||
export * from '../generated-wrappers/i_wrapper_functions';
|
export * from '../generated-wrappers/i_wrapper_functions';
|
||||||
export * from '../generated-wrappers/isolated_exchange';
|
export * from '../generated-wrappers/isolated_exchange';
|
||||||
export * from '../generated-wrappers/lib_exchange_rich_error_decoder';
|
export * from '../generated-wrappers/lib_exchange_rich_error_decoder';
|
||||||
export * from '../generated-wrappers/lib_exchange_rich_errors';
|
|
||||||
export * from '../generated-wrappers/mixin_asset_proxy_dispatcher';
|
export * from '../generated-wrappers/mixin_asset_proxy_dispatcher';
|
||||||
export * from '../generated-wrappers/mixin_exchange_core';
|
export * from '../generated-wrappers/mixin_exchange_core';
|
||||||
export * from '../generated-wrappers/mixin_match_orders';
|
export * from '../generated-wrappers/mixin_match_orders';
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
"generated-artifacts/IEIP1271Wallet.json",
|
"generated-artifacts/IEIP1271Wallet.json",
|
||||||
"generated-artifacts/IExchange.json",
|
"generated-artifacts/IExchange.json",
|
||||||
"generated-artifacts/IExchangeCore.json",
|
"generated-artifacts/IExchangeCore.json",
|
||||||
"generated-artifacts/IExchangeRichErrors.json",
|
|
||||||
"generated-artifacts/IMatchOrders.json",
|
"generated-artifacts/IMatchOrders.json",
|
||||||
"generated-artifacts/ISignatureValidator.json",
|
"generated-artifacts/ISignatureValidator.json",
|
||||||
"generated-artifacts/ITransactions.json",
|
"generated-artifacts/ITransactions.json",
|
||||||
@ -20,7 +19,6 @@
|
|||||||
"generated-artifacts/IsolatedExchange.json",
|
"generated-artifacts/IsolatedExchange.json",
|
||||||
"generated-artifacts/ReentrancyTester.json",
|
"generated-artifacts/ReentrancyTester.json",
|
||||||
"generated-artifacts/LibExchangeRichErrorDecoder.json",
|
"generated-artifacts/LibExchangeRichErrorDecoder.json",
|
||||||
"generated-artifacts/LibExchangeRichErrors.json",
|
|
||||||
"generated-artifacts/MixinAssetProxyDispatcher.json",
|
"generated-artifacts/MixinAssetProxyDispatcher.json",
|
||||||
"generated-artifacts/MixinExchangeCore.json",
|
"generated-artifacts/MixinExchangeCore.json",
|
||||||
"generated-artifacts/MixinMatchOrders.json",
|
"generated-artifacts/MixinMatchOrders.json",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user