@0x:contracts-exchange
Updated MixinSignatureValidator to use library RichErrors
This commit is contained in:
parent
5a491b2624
commit
015c35f2b2
@ -21,18 +21,19 @@ pragma experimental ABIEncoderV2;
|
|||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibEIP1271.sol";
|
import "@0x/contracts-utils/contracts/src/LibEIP1271.sol";
|
||||||
|
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
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 "./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 "./MixinExchangeRichErrors.sol";
|
import "./LibExchangeRichErrors.sol";
|
||||||
import "./MixinTransactions.sol";
|
import "./MixinTransactions.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinSignatureValidator is
|
contract MixinSignatureValidator is
|
||||||
MixinExchangeRichErrors,
|
|
||||||
ReentrancyGuard,
|
ReentrancyGuard,
|
||||||
LibEIP1271,
|
LibEIP1271,
|
||||||
LibOrder,
|
LibOrder,
|
||||||
@ -104,8 +105,8 @@ contract MixinSignatureValidator is
|
|||||||
signatureType == SignatureType.Validator ||
|
signatureType == SignatureType.Validator ||
|
||||||
signatureType == SignatureType.EIP1271Wallet
|
signatureType == SignatureType.EIP1271Wallet
|
||||||
) {
|
) {
|
||||||
_rrevert(SignatureError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
SignatureErrorCodes.INAPPROPRIATE_SIGNATURE_TYPE,
|
IExchangeRichErrors.SignatureErrorCodes.INAPPROPRIATE_SIGNATURE_TYPE,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -308,8 +309,8 @@ contract MixinSignatureValidator is
|
|||||||
// a correctly formatted but incorrect signature.
|
// a correctly formatted but incorrect signature.
|
||||||
if (signatureType == SignatureType.Invalid) {
|
if (signatureType == SignatureType.Invalid) {
|
||||||
if (signature.length != 1) {
|
if (signature.length != 1) {
|
||||||
_rrevert(SignatureError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
SignatureErrorCodes.INVALID_LENGTH,
|
IExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -320,8 +321,8 @@ contract MixinSignatureValidator is
|
|||||||
// Signature using EIP712
|
// Signature using EIP712
|
||||||
} else if (signatureType == SignatureType.EIP712) {
|
} else if (signatureType == SignatureType.EIP712) {
|
||||||
if (signature.length != 66) {
|
if (signature.length != 66) {
|
||||||
_rrevert(SignatureError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
SignatureErrorCodes.INVALID_LENGTH,
|
IExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -341,8 +342,8 @@ contract MixinSignatureValidator is
|
|||||||
// Signed using web3.eth_sign
|
// Signed using web3.eth_sign
|
||||||
} else if (signatureType == SignatureType.EthSign) {
|
} else if (signatureType == SignatureType.EthSign) {
|
||||||
if (signature.length != 66) {
|
if (signature.length != 66) {
|
||||||
_rrevert(SignatureError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
SignatureErrorCodes.INVALID_LENGTH,
|
IExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -389,8 +390,8 @@ contract MixinSignatureValidator is
|
|||||||
returns (SignatureType signatureType)
|
returns (SignatureType signatureType)
|
||||||
{
|
{
|
||||||
if (signature.length == 0) {
|
if (signature.length == 0) {
|
||||||
_rrevert(SignatureError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
SignatureErrorCodes.INVALID_LENGTH,
|
IExchangeRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -402,8 +403,8 @@ contract MixinSignatureValidator is
|
|||||||
|
|
||||||
// Ensure signature is supported
|
// Ensure signature is supported
|
||||||
if (signatureTypeRaw >= uint8(SignatureType.NSignatureTypes)) {
|
if (signatureTypeRaw >= uint8(SignatureType.NSignatureTypes)) {
|
||||||
_rrevert(SignatureError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
SignatureErrorCodes.UNSUPPORTED,
|
IExchangeRichErrors.SignatureErrorCodes.UNSUPPORTED,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -416,8 +417,8 @@ contract MixinSignatureValidator is
|
|||||||
// it an explicit option. This aids testing and analysis. It is
|
// it an explicit option. This aids testing and analysis. It 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) {
|
||||||
_rrevert(SignatureError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureError(
|
||||||
SignatureErrorCodes.ILLEGAL,
|
IExchangeRichErrors.SignatureErrorCodes.ILLEGAL,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@ -471,7 +472,7 @@ contract MixinSignatureValidator is
|
|||||||
return returnData.readUint256(0) == 1;
|
return returnData.readUint256(0) == 1;
|
||||||
}
|
}
|
||||||
// Static call to verifier failed.
|
// Static call to verifier failed.
|
||||||
_rrevert(SignatureWalletError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureWalletError(
|
||||||
hash,
|
hash,
|
||||||
walletAddress,
|
walletAddress,
|
||||||
signature,
|
signature,
|
||||||
@ -525,7 +526,7 @@ contract MixinSignatureValidator is
|
|||||||
return returnData.readBytes4(0) == EIP1271_MAGIC_VALUE;
|
return returnData.readBytes4(0) == EIP1271_MAGIC_VALUE;
|
||||||
}
|
}
|
||||||
// Static call to verifier failed.
|
// Static call to verifier failed.
|
||||||
_rrevert(SignatureWalletError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureWalletError(
|
||||||
hash,
|
hash,
|
||||||
walletAddress,
|
walletAddress,
|
||||||
signature,
|
signature,
|
||||||
@ -561,7 +562,7 @@ contract MixinSignatureValidator is
|
|||||||
address validatorAddress = signature.readAddress(signatureLength - 21);
|
address validatorAddress = signature.readAddress(signatureLength - 21);
|
||||||
// Ensure signer has approved validator.
|
// Ensure signer has approved validator.
|
||||||
if (!allowedValidators[signerAddress][validatorAddress]) {
|
if (!allowedValidators[signerAddress][validatorAddress]) {
|
||||||
_rrevert(SignatureValidatorNotApprovedError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureValidatorNotApprovedError(
|
||||||
signerAddress,
|
signerAddress,
|
||||||
validatorAddress
|
validatorAddress
|
||||||
));
|
));
|
||||||
@ -589,7 +590,7 @@ contract MixinSignatureValidator is
|
|||||||
return returnData.readBytes4(0) == EIP1271_MAGIC_VALUE;
|
return returnData.readBytes4(0) == EIP1271_MAGIC_VALUE;
|
||||||
}
|
}
|
||||||
// Static call to verifier failed.
|
// Static call to verifier failed.
|
||||||
_rrevert(SignatureValidatorError(
|
LibRichErrors._rrevert(LibExchangeRichErrors.SignatureValidatorError(
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
validatorAddress,
|
validatorAddress,
|
||||||
|
@ -36,7 +36,7 @@ const expect = chai.expect;
|
|||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
|
|
||||||
// tslint:disable:no-unnecessary-type-assertion
|
// tslint:disable:no-unnecessary-type-assertion
|
||||||
describe.only('Exchange wrappers', () => {
|
describe('Exchange wrappers', () => {
|
||||||
let chainId: number;
|
let chainId: number;
|
||||||
let makerAddress: string;
|
let makerAddress: string;
|
||||||
let owner: string;
|
let owner: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user