@0x/contracts-exchange
: Fix linearization issues.
This commit is contained in:
committed by
Amir Bandeali
parent
eb9b2f355e
commit
588ca3a315
@@ -26,7 +26,7 @@ import "./MixinTransferSimulator.sol";
|
||||
|
||||
|
||||
// solhint-disable no-empty-blocks
|
||||
// MixinAssetProxyDispatcher, MixinExchangeCore, MixinExchangeRichErrors,
|
||||
// MixinAssetProxyDispatcher, MixinExchangeCore, MixinExchangeRichErrors,
|
||||
// and MixinTransactions are all inherited via the other Mixins that are
|
||||
// used.
|
||||
contract Exchange is
|
||||
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
|
||||
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.5.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
||||
|
||||
|
||||
contract MixinCommon {
|
||||
// Defined in MixinSignatureValidator
|
||||
function _isValidOrderWithHashSignature(
|
||||
LibOrder.Order memory order,
|
||||
bytes32 orderHash,
|
||||
address signerAddress,
|
||||
bytes memory signature
|
||||
)
|
||||
internal
|
||||
view
|
||||
returns (bool isValid);
|
||||
|
||||
// Defined in MixinSignatureValidator
|
||||
function _isValidTransactionWithHashSignature(
|
||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
||||
bytes32 transactionHash,
|
||||
address signerAddress,
|
||||
bytes memory signature
|
||||
)
|
||||
internal
|
||||
view
|
||||
returns (bool isValid);
|
||||
|
||||
// Defined in MixinSignatureValidator
|
||||
function doesSignatureRequireRegularValidation(
|
||||
bytes32 hash,
|
||||
address signerAddress,
|
||||
bytes memory signature
|
||||
)
|
||||
public
|
||||
pure
|
||||
returns (bool needsRegularValidation);
|
||||
|
||||
// Defined in MixinTransactions
|
||||
function _getCurrentContextAddress()
|
||||
internal
|
||||
view
|
||||
returns (address);
|
||||
}
|
@@ -18,7 +18,6 @@
|
||||
pragma solidity ^0.5.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
||||
@@ -26,8 +25,7 @@ import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||
import "./interfaces/IExchangeCore.sol";
|
||||
import "./MixinAssetProxyDispatcher.sol";
|
||||
import "./MixinExchangeRichErrors.sol";
|
||||
import "./MixinCommon.sol";
|
||||
import "./MixinSignatureValidator.sol";
|
||||
|
||||
|
||||
contract MixinExchangeCore is
|
||||
@@ -35,10 +33,8 @@ contract MixinExchangeCore is
|
||||
LibExchangeSelectors,
|
||||
LibMath,
|
||||
LibFillResults,
|
||||
LibOrder,
|
||||
ReentrancyGuard,
|
||||
MixinCommon,
|
||||
MixinAssetProxyDispatcher
|
||||
MixinAssetProxyDispatcher,
|
||||
MixinSignatureValidator
|
||||
{
|
||||
using LibBytes for bytes;
|
||||
|
||||
|
@@ -28,17 +28,17 @@ import "./interfaces/IWallet.sol";
|
||||
import "./interfaces/IEIP1271Wallet.sol";
|
||||
import "./interfaces/ISignatureValidator.sol";
|
||||
import "./MixinExchangeRichErrors.sol";
|
||||
import "./MixinCommon.sol";
|
||||
import "./MixinTransactions.sol";
|
||||
|
||||
|
||||
contract MixinSignatureValidator is
|
||||
ISignatureValidator,
|
||||
MixinExchangeRichErrors,
|
||||
ReentrancyGuard,
|
||||
LibEIP1271,
|
||||
LibOrder,
|
||||
LibZeroExTransaction,
|
||||
LibEIP1271,
|
||||
ReentrancyGuard,
|
||||
MixinCommon,
|
||||
MixinExchangeRichErrors
|
||||
ISignatureValidator,
|
||||
MixinTransactions
|
||||
{
|
||||
using LibBytes for bytes;
|
||||
|
||||
|
@@ -21,15 +21,15 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
||||
import "./interfaces/ITransactions.sol";
|
||||
import "./interfaces/ISignatureValidator.sol";
|
||||
import "./MixinExchangeRichErrors.sol";
|
||||
import "./MixinSignatureValidator.sol";
|
||||
|
||||
|
||||
contract MixinTransactions is
|
||||
ITransactions,
|
||||
LibZeroExTransaction,
|
||||
MixinExchangeRichErrors,
|
||||
MixinSignatureValidator
|
||||
LibZeroExTransaction,
|
||||
ISignatureValidator,
|
||||
ITransactions
|
||||
{
|
||||
// Mapping of transaction hash => executed
|
||||
// This prevents transactions from being executed more than once.
|
||||
|
@@ -112,4 +112,26 @@ contract ISignatureValidator {
|
||||
public
|
||||
pure
|
||||
returns (bool needsRegularValidation);
|
||||
|
||||
// Defined in MixinSignatureValidator
|
||||
function _isValidOrderWithHashSignature(
|
||||
LibOrder.Order memory order,
|
||||
bytes32 orderHash,
|
||||
address signerAddress,
|
||||
bytes memory signature
|
||||
)
|
||||
internal
|
||||
view
|
||||
returns (bool isValid);
|
||||
|
||||
// Defined in MixinSignatureValidator
|
||||
function _isValidTransactionWithHashSignature(
|
||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
||||
bytes32 transactionHash,
|
||||
address signerAddress,
|
||||
bytes memory signature
|
||||
)
|
||||
internal
|
||||
view
|
||||
returns (bool isValid);
|
||||
}
|
||||
|
@@ -48,4 +48,14 @@ contract ITransactions {
|
||||
)
|
||||
public
|
||||
returns (bytes[] memory);
|
||||
|
||||
/// @dev The current function will be called in the context of this address (either 0x transaction signer or `msg.sender`).
|
||||
/// If calling a fill function, this address will represent the taker.
|
||||
/// If calling a cancel function, this address will represent the maker.
|
||||
/// @return Signer of 0x transaction if entry point is `executeTransaction`.
|
||||
/// `msg.sender` if entry point is any other function.
|
||||
function _getCurrentContextAddress()
|
||||
internal
|
||||
view
|
||||
returns (address);
|
||||
}
|
||||
|
@@ -89,23 +89,6 @@ contract LibExchangeRichErrorDecoder is
|
||||
validatorAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||
}
|
||||
|
||||
/// @dev Decompose an ABI-encoded SignatureOrderValidatorNotApprovedError.
|
||||
/// @param encoded ABI-encoded revert error.
|
||||
/// @return signerAddress The expected signer of the hash.
|
||||
/// @return validatorAddress The expected validator.
|
||||
function decodeSignatureOrderValidatorNotApprovedError(bytes memory encoded)
|
||||
public
|
||||
pure
|
||||
returns (
|
||||
address signerAddress,
|
||||
address validatorAddress
|
||||
)
|
||||
{
|
||||
_assertSelectorBytes(encoded, SIGNATURE_ORDER_VALIDATOR_NOT_APPROVED_ERROR_SELECTOR);
|
||||
signerAddress = _readErrorParameterAsAddress(encoded, 0);
|
||||
validatorAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||
}
|
||||
|
||||
/// @dev Decompose an ABI-encoded SignatureWalletError.
|
||||
/// @param encoded ABI-encoded revert error.
|
||||
/// @return errorCode The error code.
|
||||
@@ -129,54 +112,6 @@ contract LibExchangeRichErrorDecoder is
|
||||
errorData = _readErrorParameterAsBytes(encoded, 3);
|
||||
}
|
||||
|
||||
/// @dev Decompose an ABI-encoded SignatureOrderValidatorError.
|
||||
/// @param encoded ABI-encoded revert error.
|
||||
/// @return errorCode The error code.
|
||||
/// @return signerAddress The expected signer of the hash.
|
||||
/// @return signature The full signature bytes.
|
||||
/// @return errorData The revert data thrown by the validator contract.
|
||||
function decodeSignatureOrderValidatorError(bytes memory encoded)
|
||||
public
|
||||
pure
|
||||
returns (
|
||||
bytes32 hash,
|
||||
address signerAddress,
|
||||
address validatorAddress,
|
||||
bytes memory signature,
|
||||
bytes memory errorData
|
||||
)
|
||||
{
|
||||
_assertSelectorBytes(encoded, SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR);
|
||||
hash = _readErrorParameterAsBytes32(encoded, 0);
|
||||
signerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||
validatorAddress = _readErrorParameterAsAddress(encoded, 2);
|
||||
signature = _readErrorParameterAsBytes(encoded, 3);
|
||||
errorData = _readErrorParameterAsBytes(encoded, 4);
|
||||
}
|
||||
|
||||
/// @dev Decompose an ABI-encoded SignatureOrderWalletError.
|
||||
/// @param encoded ABI-encoded revert error.
|
||||
/// @return errorCode The error code.
|
||||
/// @return signerAddress The expected signer of the hash.
|
||||
/// @return signature The full signature bytes.
|
||||
/// @return errorData The revert data thrown by the validator contract.
|
||||
function decodeSignatureOrderWalletError(bytes memory encoded)
|
||||
public
|
||||
pure
|
||||
returns (
|
||||
bytes32 hash,
|
||||
address signerAddress,
|
||||
bytes memory signature,
|
||||
bytes memory errorData
|
||||
)
|
||||
{
|
||||
_assertSelectorBytes(encoded, SIGNATURE_ORDER_WALLET_ERROR_SELECTOR);
|
||||
hash = _readErrorParameterAsBytes32(encoded, 0);
|
||||
signerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||
signature = _readErrorParameterAsBytes(encoded, 2);
|
||||
errorData = _readErrorParameterAsBytes(encoded, 3);
|
||||
}
|
||||
|
||||
/// @dev Decompose an ABI-encoded OrderStatusError.
|
||||
/// @param encoded ABI-encoded revert error.
|
||||
/// @return orderHash The order hash.
|
||||
|
@@ -81,7 +81,7 @@ contract TestValidatorWallet is
|
||||
/// @dev The data type of a hash.
|
||||
mapping (bytes32 => DataType) internal _hashDataTypes;
|
||||
/// @dev keccak256 of the expected signature data for a hash.
|
||||
mapping (bytes32 => DataType) internal _hashSignatureHashes;
|
||||
mapping (bytes32 => bytes32) internal _hashSignatureHashes;
|
||||
|
||||
constructor(address exchange) public {
|
||||
_exchange = ISimplifiedExchange(exchange);
|
||||
|
Reference in New Issue
Block a user