protocol/contracts/staking/src/fixed_math_revert_errors.ts
F. Eugene Aumson f11d8a5bd8
@0x/order-utils refactors for v3: orderParsingUtils, signatureUtils, orderHashUtils, RevertErrors, transactionHashUtils (#2321)
* move orderParsingUtils from order-utils to connect

* Remove many functions from signatureUtils

Removed from the exported object, that is.  All of them are used in
other existing code, so they were all moved to be as local to their
usage as possible.

* remove orderHashUtils.isValidOrderHash()

* Move all *RevertErrors from order-utils...

...into their respective @0x/contracts- packages.

* Refactor @0x/order-utils' orderHashUtils away

- Move existing routines into @0x/contracts-test-utils

- Migrate non-contract-test callers to a newly-exposed getOrderHash()
method in DevUtils.

* Move all *RevertErrors from @0x/utils...

...into their respective @0x/contracts- packages.

* rm transactionHashUtils.isValidTransactionHash()

* DevUtils.sol: Fail yarn test if too big to deploy

* Refactor @0x/order-utils transactionHashUtils away

- Move existing routines into @0x/contracts-test-utils

- Migrate non-contract-test callers to a newly-exposed
getTransactionHash() method in DevUtils.

* Consolidate `Removed export...` CHANGELOG entries

* Rm EthBalanceChecker from devutils wrapper exports

* Stop importing from '.' or '.../src'

* fix builds

* fix prettier; dangling promise

* increase max bundle size
2019-11-14 17:14:24 -05:00

51 lines
1.3 KiB
TypeScript

import { BigNumber, RevertError } from '@0x/utils';
// tslint:disable:max-classes-per-file
export enum ValueErrorCodes {
TooSmall,
TooLarge,
}
export enum BinOpErrorCodes {
AdditionOverflow,
MultiplicationOverflow,
DivisionByZero,
DivisionOverflow,
}
export class SignedValueError extends RevertError {
constructor(error?: ValueErrorCodes, n?: BigNumber | number | string) {
super('SignedValueError', 'SignedValueError(uint8 error, int256 n)', {
error,
n,
});
}
}
export class UnsignedValueError extends RevertError {
constructor(error?: ValueErrorCodes, n?: BigNumber | number | string) {
super('UnsignedValueError', 'UnsignedValueError(uint8 error, uint256 n)', {
error,
n,
});
}
}
export class BinOpError extends RevertError {
constructor(error?: BinOpErrorCodes, a?: BigNumber | number | string, b?: BigNumber | number | string) {
super('BinOpError', 'BinOpError(uint8 error, int256 a, int256 b)', {
error,
a,
b,
});
}
}
const types = [SignedValueError, UnsignedValueError, BinOpError];
// Register the types we've defined.
for (const type of types) {
RevertError.registerType(type);
}