diff --git a/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol b/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol index c6b1e7b718..232c744d80 100644 --- a/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol +++ b/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol @@ -71,9 +71,9 @@ library LibExchangeRichErrors { bytes4 internal constant SIGNATURE_VALIDATOR_NOT_APPROVED_ERROR_SELECTOR = 0xa15c0d06; - // bytes4(keccak256("SignatureValidatorError(bytes32,address,address,bytes,bytes)")) - bytes4 internal constant SIGNATURE_VALIDATOR_ERROR_SELECTOR = - 0xa23838b8; + // bytes4(keccak256("EIP1271SignatureError(address,bytes,bytes,bytes)")) + bytes4 internal constant EIP1271_SIGNATURE_ERROR_SELECTOR = + 0x5bd0428d; // bytes4(keccak256("SignatureWalletError(bytes32,address,bytes,bytes)")) bytes4 internal constant SIGNATURE_WALLET_ERROR_SELECTOR = @@ -164,12 +164,12 @@ library LibExchangeRichErrors { return SIGNATURE_VALIDATOR_NOT_APPROVED_ERROR_SELECTOR; } - function SignatureValidatorErrorSelector() + function EIP1271SignatureErrorSelector() internal pure returns (bytes4) { - return SIGNATURE_VALIDATOR_ERROR_SELECTOR; + return EIP1271_SIGNATURE_ERROR_SELECTOR; } function SignatureWalletErrorSelector() @@ -363,10 +363,9 @@ library LibExchangeRichErrors { ); } - function SignatureValidatorError( - bytes32 hash, - address signerAddress, - address validatorAddress, + function EIP1271SignatureError( + address verifyingContractAddress, + bytes memory data, bytes memory signature, bytes memory errorData ) @@ -375,10 +374,9 @@ library LibExchangeRichErrors { returns (bytes memory) { return abi.encodeWithSelector( - SIGNATURE_VALIDATOR_ERROR_SELECTOR, - hash, - signerAddress, - validatorAddress, + EIP1271_SIGNATURE_ERROR_SELECTOR, + verifyingContractAddress, + data, signature, errorData ); @@ -386,7 +384,7 @@ library LibExchangeRichErrors { function SignatureWalletError( bytes32 hash, - address signerAddress, + address walletAddress, bytes memory signature, bytes memory errorData ) @@ -397,7 +395,7 @@ library LibExchangeRichErrors { return abi.encodeWithSelector( SIGNATURE_WALLET_ERROR_SELECTOR, hash, - signerAddress, + walletAddress, signature, errorData ); diff --git a/contracts/exchange/contracts/src/libs/LibExchangeRichErrorDecoder.sol b/contracts/exchange/contracts/src/libs/LibExchangeRichErrorDecoder.sol index da3de9cd3a..81b6f97630 100644 --- a/contracts/exchange/contracts/src/libs/LibExchangeRichErrorDecoder.sol +++ b/contracts/exchange/contracts/src/libs/LibExchangeRichErrorDecoder.sol @@ -56,21 +56,20 @@ contract LibExchangeRichErrorDecoder { /// @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 decodeSignatureValidatorError(bytes memory encoded) + function decodeEIP1271SignatureError(bytes memory encoded) public pure returns ( - bytes32 hash, - address signerAddress, - address validatorAddress, + address verifyingContractAddress, + bytes memory data, bytes memory signature, bytes memory errorData ) { - _assertSelectorBytes(encoded, LibExchangeRichErrors.SignatureValidatorErrorSelector()); - (hash, signerAddress, validatorAddress, signature, errorData) = abi.decode( + _assertSelectorBytes(encoded, LibExchangeRichErrors.EIP1271SignatureErrorSelector()); + (verifyingContractAddress, data, signature, errorData) = abi.decode( encoded.sliceDestructive(4, encoded.length), - (bytes32, address, address, bytes, bytes) + (address, bytes, bytes, bytes) ); } diff --git a/contracts/exchange/test/lib_exchange_rich_error_decoder.ts b/contracts/exchange/test/lib_exchange_rich_error_decoder.ts index 0a724e1cb6..bf58515a86 100644 --- a/contracts/exchange/test/lib_exchange_rich_error_decoder.ts +++ b/contracts/exchange/test/lib_exchange_rich_error_decoder.ts @@ -61,17 +61,12 @@ blockchainTests.resets('LibExchangeRichErrorDecoder', ({ provider, txDefaults }) const orderHash = orderUtils.generatePseudoRandomOrderHash(); const signer = addressUtils.generatePseudoRandomAddress(); const validator = addressUtils.generatePseudoRandomAddress(); + const data = hexRandom(ERROR_DATA_LENGTH); const signature = hexRandom(SIGNATURE_LENGTH); const errorData = hexRandom(ERROR_DATA_LENGTH); createDecodeTest(ExchangeRevertErrors.SignatureError, [errorCode, orderHash, signer, signature]); createDecodeTest(ExchangeRevertErrors.SignatureValidatorNotApprovedError, [signer, validator]); - createDecodeTest(ExchangeRevertErrors.SignatureValidatorError, [ - orderHash, - signer, - validator, - signature, - errorData, - ]); + createDecodeTest(ExchangeRevertErrors.EIP1271SignatureError, [validator, data, signature, errorData]); createDecodeTest(ExchangeRevertErrors.SignatureWalletError, [orderHash, signer, signature, errorData]); })(); diff --git a/packages/order-utils/src/exchange_revert_errors.ts b/packages/order-utils/src/exchange_revert_errors.ts index 939a56e8bb..81ae0c2a77 100644 --- a/packages/order-utils/src/exchange_revert_errors.ts +++ b/packages/order-utils/src/exchange_revert_errors.ts @@ -88,15 +88,14 @@ export class SignatureWalletError extends RevertError { } } -export class SignatureValidatorError extends RevertError { - constructor(hash?: string, signer?: string, validator?: string, signature?: string, errorData?: string) { +export class EIP1271SignatureError extends RevertError { + constructor(verifyingContractAddress?: string, data?: string, signature?: string, errorData?: string) { super( - 'SignatureValidatorError', - 'SignatureValidatorError(bytes32 hash, address signer, address validator, bytes signature, bytes errorData)', + 'EIP1271SignatureError', + 'EIP1271SignatureError(address verifyingContractAddress, bytes data, bytes signature, bytes errorData)', { - hash, - signer, - validator, + verifyingContractAddress, + data, signature, errorData, }, @@ -266,7 +265,7 @@ const types = [ SignatureError, SignatureValidatorNotApprovedError, SignatureWalletError, - SignatureValidatorError, + EIP1271SignatureError, InvalidSenderError, InvalidTakerError, InvalidMakerError,