@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
This commit is contained in:
F. Eugene Aumson
2019-11-14 17:14:24 -05:00
committed by GitHub
parent f0d7d10fe7
commit f11d8a5bd8
132 changed files with 584 additions and 653 deletions

View File

@@ -1,2 +1,3 @@
export * from './artifacts';
export * from './wrappers';
export import ForwarderRevertErrors = require('./revert_errors');

View File

@@ -0,0 +1,101 @@
import { BigNumber, RevertError } from '@0x/utils';
// tslint:disable:max-classes-per-file
export class UnregisteredAssetProxyError extends RevertError {
constructor() {
super('UnregisteredAssetProxyError', 'UnregisteredAssetProxyError()', {});
}
}
export class UnsupportedAssetProxyError extends RevertError {
constructor(proxyId?: string) {
super('UnsupportedAssetProxyError', 'UnsupportedAssetProxyError(bytes4 proxyId)', { proxyId });
}
}
export class CompleteBuyFailedError extends RevertError {
constructor(
expectedAssetBuyAmount?: BigNumber | number | string,
actualAssetBuyAmount?: BigNumber | number | string,
) {
super(
'CompleteBuyFailedError',
'CompleteBuyFailedError(uint256 expectedAssetBuyAmount, uint256 actualAssetBuyAmount)',
{ expectedAssetBuyAmount, actualAssetBuyAmount },
);
}
}
export class UnsupportedFeeError extends RevertError {
constructor(takerFeeAssetData?: string) {
super('UnsupportedFeeError', 'UnsupportedFeeError(bytes takerFeeAssetData)', { takerFeeAssetData });
}
}
export class FeePercentageTooLargeError extends RevertError {
constructor(feePercentage?: BigNumber | number | string) {
super('FeePercentageTooLargeError', 'FeePercentageTooLargeError(uint256 feePercentage)', {
feePercentage,
});
}
}
export class InsufficientEthForFeeError extends RevertError {
constructor(ethFeeRequired?: BigNumber | number | string, ethAvailable?: BigNumber | number | string) {
super(
'InsufficientEthForFeeError',
'InsufficientEthForFeeError(uint256 ethFeeRequired, uint256 ethAvailable)',
{ ethFeeRequired, ethAvailable },
);
}
}
export class OverspentWethError extends RevertError {
constructor(wethSpent?: BigNumber | number | string, msgValue?: BigNumber | number | string) {
super('OverspentWethError', 'OverspentWethError(uint256 wethSpent, uint256 msgValue)', {
wethSpent,
msgValue,
});
}
}
export class DefaultFunctionWethContractOnlyError extends RevertError {
constructor(senderAddress?: string) {
super('DefaultFunctionWethContractOnlyError', 'DefaultFunctionWethContractOnlyError(address senderAddress)', {
senderAddress,
});
}
}
export class MsgValueCannotEqualZeroError extends RevertError {
constructor() {
super('MsgValueCannotEqualZeroError', 'MsgValueCannotEqualZeroError()', {});
}
}
export class Erc721AmountMustEqualOneError extends RevertError {
constructor(amount?: BigNumber | number | string) {
super('Erc721AmountMustEqualOneError', 'Erc721AmountMustEqualOneError(uint256 amount)', {
amount,
});
}
}
const types = [
UnregisteredAssetProxyError,
UnsupportedAssetProxyError,
CompleteBuyFailedError,
UnsupportedFeeError,
FeePercentageTooLargeError,
InsufficientEthForFeeError,
OverspentWethError,
DefaultFunctionWethContractOnlyError,
MsgValueCannotEqualZeroError,
Erc721AmountMustEqualOneError,
];
// Register the types we've defined.
for (const type of types) {
RevertError.registerType(type);
}