Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2116 from 0xProject/feat/3.0/eip1271-selectors
Browse files Browse the repository at this point in the history
Add 4 byte ids to `EIP1271Wallet.isValidSignature` data
  • Loading branch information
abandeali1 authored Aug 30, 2019
2 parents 63f051a + b20503c commit a5996b3
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 569 deletions.
115 changes: 0 additions & 115 deletions contracts/exchange/contracts/examples/ExchangeWrapper.sol

This file was deleted.

149 changes: 0 additions & 149 deletions contracts/exchange/contracts/examples/Whitelist.sol

This file was deleted.

25 changes: 21 additions & 4 deletions contracts/exchange/contracts/src/MixinSignatureValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import "@0x/contracts-exchange-libs/contracts/src/LibExchangeRichErrors.sol";
import "./interfaces/IWallet.sol";
import "./interfaces/IEIP1271Wallet.sol";
import "./interfaces/ISignatureValidator.sol";
import "./interfaces/IEIP1271Data.sol";
import "./MixinTransactions.sol";


Expand Down Expand Up @@ -220,15 +221,23 @@ contract MixinSignatureValidator is
if (signatureType == SignatureType.Validator) {
// The entire order is verified by a validator contract.
isValid = _validateBytesWithValidator(
abi.encode(order, orderHash),
abi.encodeWithSelector(
IEIP1271Data(address(0)).OrderWithHash.selector,
order,
orderHash
),
orderHash,
signerAddress,
signature
);
} else if (signatureType == SignatureType.EIP1271Wallet) {
// The entire order is verified by a wallet contract.
isValid = _validateBytesWithWallet(
abi.encode(order, orderHash),
abi.encodeWithSelector(
IEIP1271Data(address(0)).OrderWithHash.selector,
order,
orderHash
),
orderHash,
signerAddress,
signature
Expand Down Expand Up @@ -268,15 +277,23 @@ contract MixinSignatureValidator is
if (signatureType == SignatureType.Validator) {
// The entire transaction is verified by a validator contract.
isValid = _validateBytesWithValidator(
abi.encode(transaction, transactionHash),
abi.encodeWithSelector(
IEIP1271Data(address(0)).ZeroExTransactionWithHash.selector,
transaction,
transactionHash
),
transactionHash,
signerAddress,
signature
);
} else if (signatureType == SignatureType.EIP1271Wallet) {
// The entire transaction is verified by a wallet contract.
isValid = _validateBytesWithWallet(
abi.encode(transaction, transactionHash),
abi.encodeWithSelector(
IEIP1271Data(address(0)).ZeroExTransactionWithHash.selector,
transaction,
transactionHash
),
transactionHash,
signerAddress,
signature
Expand Down
48 changes: 48 additions & 0 deletions contracts/exchange/contracts/src/interfaces/IEIP1271Data.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright 2019 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";


// solhint-disable
contract IEIP1271Data {

/// @dev This function's selector is used when ABI encoding the order
/// and hash into a byte array before calling `isValidSignature`.
/// This function serves no other purpose.
function OrderWithHash(
LibOrder.Order calldata order,
bytes32 orderHash
)
external
pure;

/// @dev This function's selector is used when ABI encoding the transaction
/// and hash into a byte array before calling `isValidSignature`.
/// This function serves no other purpose.
function ZeroExTransactionWithHash(
LibZeroExTransaction.ZeroExTransaction calldata transaction,
bytes32 transactionHash
)
external
pure;
}
Loading

0 comments on commit a5996b3

Please sign in to comment.