@0x:contracts-utils Added RichErrors to LibBytes

This commit is contained in:
James Towle
2019-07-08 21:27:17 -05:00
committed by Amir Bandeali
parent c788db785b
commit d3db2dcfbb
8 changed files with 479 additions and 166 deletions

View File

@@ -1,3 +1,4 @@
import * as LibBytesRevertErrors from './lib_bytes_revert_errors';
import * as OwnableRevertErrors from './ownable_revert_errors';
import * as SafeMathRevertErrors from './safe_math_revert_errors';
@@ -28,4 +29,4 @@ export {
AnyRevertError,
} from './revert_error';
export { OwnableRevertErrors, SafeMathRevertErrors };
export { LibBytesRevertErrors, OwnableRevertErrors, SafeMathRevertErrors };

View File

@@ -0,0 +1,30 @@
import { BigNumber } from './configured_bignumber';
import { RevertError } from './revert_error';
export enum InvalidByteOperationErrorCodes {
FromLessThanOrEqualsToRequired,
ToLessThanOrEqualsLengthRequired,
LengthGreaterThanZeroRequired,
LengthGreaterThanOrEqualsFourRequired,
LengthGreaterThanOrEqualsTwentyRequired,
LengthGreaterThanOrEqualsThirtyTwoRequired,
LengthGreaterThanOrEqualsNestedBytesLengthRequired,
DestinationLengthGreaterThanOrEqualSourceLengthRequired,
}
export class InvalidByteOperationError extends RevertError {
constructor(error?: InvalidByteOperationErrorCodes, endpoint?: BigNumber, required?: BigNumber) {
super(
'InvalidByteOperationError',
'InvalidByteOperationError(uint8 error, uint256 endpoint, uint256 required)',
{
error,
endpoint,
required,
},
);
}
}
// Register the InvalidByteOperationError type
RevertError.registerType(InvalidByteOperationError);