Remove moved RevertErrors

This commit is contained in:
Jacob Evans
2019-11-22 13:14:25 +11:00
parent 9c42241269
commit ad8caa2b51
55 changed files with 67 additions and 1086 deletions

View File

@@ -1,55 +0,0 @@
import { BigNumber, RevertError } from '@0x/utils';
// tslint:disable:max-classes-per-file
export class AuthorizedAddressMismatchError extends RevertError {
constructor(authorized?: string, target?: string) {
super('AuthorizedAddressMismatchError', 'AuthorizedAddressMismatchError(address authorized, address target)', {
authorized,
target,
});
}
}
export class IndexOutOfBoundsError extends RevertError {
constructor(index?: BigNumber, len?: BigNumber) {
super('IndexOutOfBoundsError', 'IndexOutOfBoundsError(uint256 index, uint256 len)', { index, len });
}
}
export class SenderNotAuthorizedError extends RevertError {
constructor(sender?: string) {
super('SenderNotAuthorizedError', 'SenderNotAuthorizedError(address sender)', { sender });
}
}
export class TargetAlreadyAuthorizedError extends RevertError {
constructor(target?: string) {
super('TargetAlreadyAuthorizedError', 'TargetAlreadyAuthorizedError(address target)', { target });
}
}
export class TargetNotAuthorizedError extends RevertError {
constructor(target?: string) {
super('TargetNotAuthorizedError', 'TargetNotAuthorizedError(address target)', { target });
}
}
export class ZeroCantBeAuthorizedError extends RevertError {
constructor() {
super('ZeroCantBeAuthorizedError', 'ZeroCantBeAuthorizedError()', {});
}
}
const types = [
AuthorizedAddressMismatchError,
IndexOutOfBoundsError,
SenderNotAuthorizedError,
TargetAlreadyAuthorizedError,
TargetNotAuthorizedError,
ZeroCantBeAuthorizedError,
];
// Register the types we've defined.
for (const type of types) {
RevertError.registerType(type);
}

View File

@@ -4,9 +4,11 @@ export * from './wrappers';
import * as ReferenceFunctionsToExport from './reference_functions';
export import ReferenceFunctions = ReferenceFunctionsToExport;
export import AuthorizableRevertErrors = require('./authorizable_revert_errors');
export import LibAddressArrayRevertErrors = require('./lib_address_array_revert_errors');
export import LibBytesRevertErrors = require('./lib_bytes_revert_errors');
export import OwnableRevertErrors = require('./ownable_revert_errors');
export import ReentrancyGuardRevertErrors = require('./reentrancy_guard_revert_errors');
export import SafeMathRevertErrors = require('./safe_math_revert_errors');
export {
AuthorizableRevertErrors,
LibAddressArrayRevertErrors,
LibBytesRevertErrors,
OwnableRevertErrors,
ReentrancyGuardRevertErrors,
SafeMathRevertErrors,
} from '@0x/utils';

View File

@@ -1,13 +0,0 @@
import { BigNumber, RevertError } from '@0x/utils';
export class MismanagedMemoryError extends RevertError {
constructor(freeMemPtr?: BigNumber, addressArrayEndPtr?: BigNumber) {
super('MismanagedMemoryError', 'MismanagedMemoryError(uint256 freeMemPtr, uint256 addressArrayEndPtr)', {
freeMemPtr,
addressArrayEndPtr,
});
}
}
// Register the MismanagedMemoryError type
RevertError.registerType(MismanagedMemoryError);

View File

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

View File

@@ -1,24 +0,0 @@
import { RevertError } from '@0x/utils';
// tslint:disable:max-classes-per-file
export class OnlyOwnerError extends RevertError {
constructor(sender?: string, owner?: string) {
super('OnlyOwnerError', 'OnlyOwnerError(address sender, address owner)', {
sender,
owner,
});
}
}
export class TransferOwnerToZeroError extends RevertError {
constructor() {
super('TransferOwnerToZeroError', 'TransferOwnerToZeroError()', {});
}
}
const types = [OnlyOwnerError, TransferOwnerToZeroError];
// Register the types we've defined.
for (const type of types) {
RevertError.registerType(type);
}

View File

@@ -1,10 +0,0 @@
import { RevertError } from '@0x/utils';
export class IllegalReentrancyError extends RevertError {
constructor() {
super('IllegalReentrancyError', 'IllegalReentrancyError()', {});
}
}
// Register the IllegalReentrancyError type
RevertError.registerType(IllegalReentrancyError);

View File

@@ -1,6 +1,4 @@
import { BigNumber } from '@0x/utils';
import SafeMathRevertErrors = require('./safe_math_revert_errors');
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
const MAX_UINT256 = new BigNumber(2).pow(256).minus(1);

View File

@@ -1,62 +0,0 @@
import { BigNumber, RevertError } from '@0x/utils';
// tslint:disable:max-classes-per-file
export enum BinOpErrorCodes {
AdditionOverflow,
MultiplicationOverflow,
SubtractionUnderflow,
DivisionByZero,
}
export enum DowncastErrorCodes {
ValueTooLargeToDowncastToUint32,
ValueTooLargeToDowncastToUint64,
ValueTooLargeToDowncastToUint96,
}
export class Uint256BinOpError extends RevertError {
constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint256BinOpError', 'Uint256BinOpError(uint8 error, uint256 a, uint256 b)', {
error,
a,
b,
});
}
}
export class Uint96BinOpError extends RevertError {
constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint96BinOpError', 'Uint96BinOpError(uint8 error, uint96 a, uint96 b)', {
error,
a,
b,
});
}
}
export class Uint64BinOpError extends RevertError {
constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint64BinOpError', 'Uint64BinOpError(uint8 error, uint64 a, uint64 b)', {
error,
a,
b,
});
}
}
export class Uint256DowncastError extends RevertError {
constructor(error?: DowncastErrorCodes, a?: BigNumber) {
super('Uint256DowncastError', 'Uint256DowncastError(uint8 error, uint256 a)', {
error,
a,
});
}
}
const types = [Uint256BinOpError, Uint96BinOpError, Uint64BinOpError, Uint256DowncastError];
// Register the types we've defined.
for (const type of types) {
RevertError.registerType(type);
}

View File

@@ -1,10 +1,7 @@
import { blockchainTests, constants, expect } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';
import { AuthorizableRevertErrors, BigNumber, OwnableRevertErrors } from '@0x/utils';
import * as _ from 'lodash';
import AuthorizableRevertErrors = require('../src/authorizable_revert_errors');
import OwnableRevertErrors = require('../src/ownable_revert_errors');
import { artifacts } from './artifacts';
import { TestAuthorizableContract } from './wrappers';

View File

@@ -1,11 +1,9 @@
import { chaiSetup, provider, randomAddress, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { BigNumber } from '@0x/utils';
import { BigNumber, LibAddressArrayRevertErrors } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import LibAddressArrayRevertErrors = require('../src/lib_address_array_revert_errors');
import { artifacts } from './artifacts';
import { TestLibAddressArrayContract } from './wrappers';

View File

@@ -1,11 +1,9 @@
import { blockchainTests, constants, expect } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';
import { BigNumber, LibBytesRevertErrors } from '@0x/utils';
import BN = require('bn.js');
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
import LibBytesRevertErrors = require('../src/lib_bytes_revert_errors');
import { artifacts } from './artifacts';
import { TestLibBytesContract } from './wrappers';

View File

@@ -1,9 +1,8 @@
import { blockchainTests, constants, describe, expect } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
import * as _ from 'lodash';
import * as ReferenceFunctions from '../src/reference_functions';
import SafeMathRevertErrors = require('../src/safe_math_revert_errors');
import { artifacts } from './artifacts';
import { TestLibSafeMathContract } from './wrappers';

View File

@@ -1,6 +1,5 @@
import { blockchainTests, constants, expect, filterLogsToArguments } from '@0x/contracts-test-utils';
import OwnableRevertErrors = require('../src/ownable_revert_errors');
import { OwnableRevertErrors } from '@0x/utils';
import { artifacts } from './artifacts';
import { IOwnableEvents, IOwnableOwnershipTransferredEventArgs, TestOwnableContract } from './wrappers';

View File

@@ -3,7 +3,7 @@ import { BlockchainLifecycle } from '@0x/dev-utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import ReentrancyGuardRevertErrors = require('../src/reentrancy_guard_revert_errors');
import { ReentrancyGuardRevertErrors } from '@0x/utils';
import { artifacts } from './artifacts';
import { TestReentrancyGuardContract } from './wrappers';

View File

@@ -1,7 +1,7 @@
import { constants, describe, expect } from '@0x/contracts-test-utils';
import { SafeMathRevertErrors } from '@0x/utils';
import { safeAdd, safeDiv, safeMul, safeSub } from '../src/reference_functions';
import SafeMathRevertErrors = require('../src/safe_math_revert_errors');
describe('Reference Functions', () => {
const { ONE_ETHER, MAX_UINT256, ZERO_AMOUNT } = constants;