Add new rich revert errors
This commit is contained in:
parent
e5706606a0
commit
f792d403e5
@ -36,6 +36,12 @@ library LibExchangeRichErrors {
|
|||||||
INVALID_LENGTH_RIGHT_SIGNATURES
|
INVALID_LENGTH_RIGHT_SIGNATURES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ExchangeContextErrorCodes {
|
||||||
|
INVALID_MAKER,
|
||||||
|
INVALID_TAKER,
|
||||||
|
INVALID_SENDER
|
||||||
|
}
|
||||||
|
|
||||||
enum FillErrorCodes {
|
enum FillErrorCodes {
|
||||||
INVALID_TAKER_AMOUNT,
|
INVALID_TAKER_AMOUNT,
|
||||||
TAKER_OVERPAY,
|
TAKER_OVERPAY,
|
||||||
@ -83,22 +89,14 @@ library LibExchangeRichErrors {
|
|||||||
bytes4 internal constant ORDER_STATUS_ERROR_SELECTOR =
|
bytes4 internal constant ORDER_STATUS_ERROR_SELECTOR =
|
||||||
0xfdb6ca8d;
|
0xfdb6ca8d;
|
||||||
|
|
||||||
// bytes4(keccak256("InvalidSenderError(bytes32,address)"))
|
// bytes4(keccak256("ExchangeInvalidContextError(uint8,bytes32,address)"))
|
||||||
bytes4 internal constant INVALID_SENDER_ERROR_SELECTOR =
|
bytes4 internal constant EXCHANGE_INVALID_CONTEXT_ERROR_SELECTOR =
|
||||||
0x95b59997;
|
0xe53c76c8;
|
||||||
|
|
||||||
// bytes4(keccak256("InvalidMakerError(bytes32,address)"))
|
|
||||||
bytes4 internal constant INVALID_MAKER_ERROR_SELECTOR =
|
|
||||||
0x26bf55d9;
|
|
||||||
|
|
||||||
// bytes4(keccak256("FillError(uint8,bytes32)"))
|
// bytes4(keccak256("FillError(uint8,bytes32)"))
|
||||||
bytes4 internal constant FILL_ERROR_SELECTOR =
|
bytes4 internal constant FILL_ERROR_SELECTOR =
|
||||||
0xe94a7ed0;
|
0xe94a7ed0;
|
||||||
|
|
||||||
// bytes4(keccak256("InvalidTakerError(bytes32,address)"))
|
|
||||||
bytes4 internal constant INVALID_TAKER_ERROR_SELECTOR =
|
|
||||||
0xfdb328be;
|
|
||||||
|
|
||||||
// bytes4(keccak256("OrderEpochError(address,address,uint256)"))
|
// bytes4(keccak256("OrderEpochError(address,address,uint256)"))
|
||||||
bytes4 internal constant ORDER_EPOCH_ERROR_SELECTOR =
|
bytes4 internal constant ORDER_EPOCH_ERROR_SELECTOR =
|
||||||
0x4ad31275;
|
0x4ad31275;
|
||||||
@ -147,6 +145,10 @@ library LibExchangeRichErrors {
|
|||||||
bytes4 internal constant BATCH_MATCH_ORDERS_ERROR_SELECTOR =
|
bytes4 internal constant BATCH_MATCH_ORDERS_ERROR_SELECTOR =
|
||||||
0xd4092f4f;
|
0xd4092f4f;
|
||||||
|
|
||||||
|
// bytes4(keccak256("PayProtocolFeeError(bytes32,uint256,address,address,bytes)"))
|
||||||
|
bytes4 internal constant PAY_PROTOCOL_FEE_ERROR_SELECTOR =
|
||||||
|
0x87cb1e75;
|
||||||
|
|
||||||
// solhint-disable func-name-mixedcase
|
// solhint-disable func-name-mixedcase
|
||||||
function SignatureErrorSelector()
|
function SignatureErrorSelector()
|
||||||
internal
|
internal
|
||||||
@ -188,20 +190,12 @@ library LibExchangeRichErrors {
|
|||||||
return ORDER_STATUS_ERROR_SELECTOR;
|
return ORDER_STATUS_ERROR_SELECTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
function InvalidSenderErrorSelector()
|
function ExchangeInvalidContextErrorSelector()
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
returns (bytes4)
|
returns (bytes4)
|
||||||
{
|
{
|
||||||
return INVALID_SENDER_ERROR_SELECTOR;
|
return EXCHANGE_INVALID_CONTEXT_ERROR_SELECTOR;
|
||||||
}
|
|
||||||
|
|
||||||
function InvalidMakerErrorSelector()
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes4)
|
|
||||||
{
|
|
||||||
return INVALID_MAKER_ERROR_SELECTOR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function FillErrorSelector()
|
function FillErrorSelector()
|
||||||
@ -212,14 +206,6 @@ library LibExchangeRichErrors {
|
|||||||
return FILL_ERROR_SELECTOR;
|
return FILL_ERROR_SELECTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
function InvalidTakerErrorSelector()
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes4)
|
|
||||||
{
|
|
||||||
return INVALID_TAKER_ERROR_SELECTOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
function OrderEpochErrorSelector()
|
function OrderEpochErrorSelector()
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
@ -316,6 +302,14 @@ library LibExchangeRichErrors {
|
|||||||
return TRANSACTION_INVALID_CONTEXT_ERROR_SELECTOR;
|
return TRANSACTION_INVALID_CONTEXT_ERROR_SELECTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PayProtocolFeeErrorSelector()
|
||||||
|
internal
|
||||||
|
pure
|
||||||
|
returns (bytes4)
|
||||||
|
{
|
||||||
|
return PAY_PROTOCOL_FEE_ERROR_SELECTOR;
|
||||||
|
}
|
||||||
|
|
||||||
function BatchMatchOrdersError(
|
function BatchMatchOrdersError(
|
||||||
BatchMatchOrdersErrorCodes errorCode
|
BatchMatchOrdersErrorCodes errorCode
|
||||||
)
|
)
|
||||||
@ -416,33 +410,20 @@ library LibExchangeRichErrors {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function InvalidSenderError(
|
function ExchangeInvalidContextError(
|
||||||
|
ExchangeContextErrorCodes errorCode,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address senderAddress
|
address contextAddress
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
returns (bytes memory)
|
returns (bytes memory)
|
||||||
{
|
{
|
||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
INVALID_SENDER_ERROR_SELECTOR,
|
EXCHANGE_INVALID_CONTEXT_ERROR_SELECTOR,
|
||||||
|
errorCode,
|
||||||
orderHash,
|
orderHash,
|
||||||
senderAddress
|
contextAddress
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function InvalidMakerError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
address makerAddress
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory)
|
|
||||||
{
|
|
||||||
return abi.encodeWithSelector(
|
|
||||||
INVALID_MAKER_ERROR_SELECTOR,
|
|
||||||
orderHash,
|
|
||||||
makerAddress
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,21 +442,6 @@ library LibExchangeRichErrors {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function InvalidTakerError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
address takerAddress
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory)
|
|
||||||
{
|
|
||||||
return abi.encodeWithSelector(
|
|
||||||
INVALID_TAKER_ERROR_SELECTOR,
|
|
||||||
orderHash,
|
|
||||||
takerAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function OrderEpochError(
|
function OrderEpochError(
|
||||||
address makerAddress,
|
address makerAddress,
|
||||||
address orderSenderAddress,
|
address orderSenderAddress,
|
||||||
@ -652,4 +618,25 @@ library LibExchangeRichErrors {
|
|||||||
actualAssetFillAmount
|
actualAssetFillAmount
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PayProtocolFeeError(
|
||||||
|
bytes32 orderHash,
|
||||||
|
uint256 protocolFee,
|
||||||
|
address makerAddress,
|
||||||
|
address takerAddress,
|
||||||
|
bytes memory errorData
|
||||||
|
)
|
||||||
|
internal
|
||||||
|
pure
|
||||||
|
returns (bytes memory)
|
||||||
|
{
|
||||||
|
return abi.encodeWithSelector(
|
||||||
|
PAY_PROTOCOL_FEE_ERROR_SELECTOR,
|
||||||
|
orderHash,
|
||||||
|
protocolFee,
|
||||||
|
makerAddress,
|
||||||
|
takerAddress,
|
||||||
|
errorData
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,12 @@ export enum BatchMatchOrdersErrorCodes {
|
|||||||
InvalidLengthRightSignatures,
|
InvalidLengthRightSignatures,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum ExchangeContextErrorCodes {
|
||||||
|
InvalidMaker,
|
||||||
|
InvalidTaker,
|
||||||
|
InvalidSender,
|
||||||
|
}
|
||||||
|
|
||||||
export enum FillErrorCode {
|
export enum FillErrorCode {
|
||||||
InvalidTakerAmount,
|
InvalidTakerAmount,
|
||||||
TakerOverpay,
|
TakerOverpay,
|
||||||
@ -109,24 +115,6 @@ export class OrderStatusError extends RevertError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InvalidSenderError extends RevertError {
|
|
||||||
constructor(orderHash?: string, sender?: string) {
|
|
||||||
super('InvalidSenderError', 'InvalidSenderError(bytes32 orderHash, address sender)', { orderHash, sender });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class InvalidTakerError extends RevertError {
|
|
||||||
constructor(orderHash?: string, taker?: string) {
|
|
||||||
super('InvalidTakerError', 'InvalidTakerError(bytes32 orderHash, address taker)', { orderHash, taker });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class InvalidMakerError extends RevertError {
|
|
||||||
constructor(orderHash?: string, maker?: string) {
|
|
||||||
super('InvalidMakerError', 'InvalidMakerError(bytes32 orderHash, address maker)', { orderHash, maker });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class FillError extends RevertError {
|
export class FillError extends RevertError {
|
||||||
constructor(error?: FillErrorCode, orderHash?: string) {
|
constructor(error?: FillErrorCode, orderHash?: string) {
|
||||||
super('FillError', 'FillError(uint8 error, bytes32 orderHash)', { error, orderHash });
|
super('FillError', 'FillError(uint8 error, bytes32 orderHash)', { error, orderHash });
|
||||||
@ -259,6 +247,31 @@ export class IncompleteFillError extends RevertError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ExchangeInvalidContextError extends RevertError {
|
||||||
|
constructor(error?: ExchangeContextErrorCodes, orderHash?: string, contextAddress?: string) {
|
||||||
|
super(
|
||||||
|
'ExchangeInvalidContextError',
|
||||||
|
'ExchangeInvalidContextError(uint8 error, bytes32 orderHash, address contextAddress)',
|
||||||
|
{ error, orderHash, contextAddress },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class PayProtocolFeeError extends RevertError {
|
||||||
|
constructor(
|
||||||
|
orderHash?: string,
|
||||||
|
protocolFee?: BigNumber,
|
||||||
|
makerAddress?: string,
|
||||||
|
takerAddress?: string,
|
||||||
|
errorData?: string,
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
'PayProtocolFeeError',
|
||||||
|
'PayProtocolFeeError(bytes32 orderHash, uint256 protocolFee, address makerAddress, address takerAddress, bytes errorData)',
|
||||||
|
{ orderHash, protocolFee, makerAddress, takerAddress, errorData },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const types = [
|
const types = [
|
||||||
BatchMatchOrdersError,
|
BatchMatchOrdersError,
|
||||||
OrderStatusError,
|
OrderStatusError,
|
||||||
@ -266,9 +279,6 @@ const types = [
|
|||||||
SignatureValidatorNotApprovedError,
|
SignatureValidatorNotApprovedError,
|
||||||
SignatureWalletError,
|
SignatureWalletError,
|
||||||
EIP1271SignatureError,
|
EIP1271SignatureError,
|
||||||
InvalidSenderError,
|
|
||||||
InvalidTakerError,
|
|
||||||
InvalidMakerError,
|
|
||||||
FillError,
|
FillError,
|
||||||
OrderEpochError,
|
OrderEpochError,
|
||||||
AssetProxyExistsError,
|
AssetProxyExistsError,
|
||||||
@ -276,9 +286,13 @@ const types = [
|
|||||||
AssetProxyTransferError,
|
AssetProxyTransferError,
|
||||||
NegativeSpreadError,
|
NegativeSpreadError,
|
||||||
TransactionError,
|
TransactionError,
|
||||||
|
TransactionGasPriceError,
|
||||||
|
TransactionInvalidContextError,
|
||||||
TransactionSignatureError,
|
TransactionSignatureError,
|
||||||
TransactionExecutionError,
|
TransactionExecutionError,
|
||||||
IncompleteFillError,
|
IncompleteFillError,
|
||||||
|
PayProtocolFeeError,
|
||||||
|
ExchangeInvalidContextError,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Register the types we've defined.
|
// Register the types we've defined.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user