Create private functions for encoding orders/transactions with their hash to be passed into EIP1271 compliant contract
This commit is contained in:
parent
49725c8c33
commit
e5706606a0
@ -229,11 +229,7 @@ contract MixinSignatureValidator is
|
|||||||
if (signatureType == SignatureType.Validator) {
|
if (signatureType == SignatureType.Validator) {
|
||||||
// The entire order is verified by a validator contract.
|
// The entire order is verified by a validator contract.
|
||||||
isValid = _validateBytesWithValidator(
|
isValid = _validateBytesWithValidator(
|
||||||
abi.encodeWithSelector(
|
_encodeEIP1271OrderWithHash(order, orderHash),
|
||||||
IEIP1271Data(address(0)).OrderWithHash.selector,
|
|
||||||
order,
|
|
||||||
orderHash
|
|
||||||
),
|
|
||||||
orderHash,
|
orderHash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -241,11 +237,7 @@ contract MixinSignatureValidator is
|
|||||||
} else if (signatureType == SignatureType.EIP1271Wallet) {
|
} else if (signatureType == SignatureType.EIP1271Wallet) {
|
||||||
// The entire order is verified by a wallet contract.
|
// The entire order is verified by a wallet contract.
|
||||||
isValid = _validateBytesWithWallet(
|
isValid = _validateBytesWithWallet(
|
||||||
abi.encodeWithSelector(
|
_encodeEIP1271OrderWithHash(order, orderHash),
|
||||||
IEIP1271Data(address(0)).OrderWithHash.selector,
|
|
||||||
order,
|
|
||||||
orderHash
|
|
||||||
),
|
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
);
|
);
|
||||||
@ -285,11 +277,7 @@ contract MixinSignatureValidator is
|
|||||||
if (signatureType == SignatureType.Validator) {
|
if (signatureType == SignatureType.Validator) {
|
||||||
// The entire transaction is verified by a validator contract.
|
// The entire transaction is verified by a validator contract.
|
||||||
isValid = _validateBytesWithValidator(
|
isValid = _validateBytesWithValidator(
|
||||||
abi.encodeWithSelector(
|
_encodeEIP1271TransactionWithHash(transaction, transactionHash),
|
||||||
IEIP1271Data(address(0)).ZeroExTransactionWithHash.selector,
|
|
||||||
transaction,
|
|
||||||
transactionHash
|
|
||||||
),
|
|
||||||
transactionHash,
|
transactionHash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -297,11 +285,7 @@ contract MixinSignatureValidator is
|
|||||||
} else if (signatureType == SignatureType.EIP1271Wallet) {
|
} else if (signatureType == SignatureType.EIP1271Wallet) {
|
||||||
// The entire transaction is verified by a wallet contract.
|
// The entire transaction is verified by a wallet contract.
|
||||||
isValid = _validateBytesWithWallet(
|
isValid = _validateBytesWithWallet(
|
||||||
abi.encodeWithSelector(
|
_encodeEIP1271TransactionWithHash(transaction, transactionHash),
|
||||||
IEIP1271Data(address(0)).ZeroExTransactionWithHash.selector,
|
|
||||||
transaction,
|
|
||||||
transactionHash
|
|
||||||
),
|
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
);
|
);
|
||||||
@ -481,6 +465,40 @@ contract MixinSignatureValidator is
|
|||||||
return signatureType;
|
return signatureType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev ABI encodes an order and hash with a selector to be passed into
|
||||||
|
/// an EIP1271 compliant `isValidSignature` function.
|
||||||
|
function _encodeEIP1271OrderWithHash(
|
||||||
|
LibOrder.Order memory order,
|
||||||
|
bytes32 orderHash
|
||||||
|
)
|
||||||
|
private
|
||||||
|
pure
|
||||||
|
returns (bytes memory encoded)
|
||||||
|
{
|
||||||
|
return abi.encodeWithSelector(
|
||||||
|
IEIP1271Data(address(0)).OrderWithHash.selector,
|
||||||
|
order,
|
||||||
|
orderHash
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev ABI encodes a transaction and hash with a selector to be passed into
|
||||||
|
/// an EIP1271 compliant `isValidSignature` function.
|
||||||
|
function _encodeEIP1271TransactionWithHash(
|
||||||
|
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
||||||
|
bytes32 transactionHash
|
||||||
|
)
|
||||||
|
private
|
||||||
|
pure
|
||||||
|
returns (bytes memory encoded)
|
||||||
|
{
|
||||||
|
return abi.encodeWithSelector(
|
||||||
|
IEIP1271Data(address(0)).ZeroExTransactionWithHash.selector,
|
||||||
|
transaction,
|
||||||
|
transactionHash
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Verifies a hash and signature using logic defined by Wallet contract.
|
/// @dev Verifies a hash and signature using logic defined by Wallet contract.
|
||||||
/// @param hash Any 32 byte hash.
|
/// @param hash Any 32 byte hash.
|
||||||
/// @param walletAddress Address that should have signed the given hash
|
/// @param walletAddress Address that should have signed the given hash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user