Lawrence Forman edda1edc50
@0x/protocol-utils (#76)
* add new packages

* `@0x/protocol-utils`: Update with latest code from `@0x/contracs-zero-ex` + misc stuff

* @0x/contracts-zero-ex`: Switch to using `@0x/protocol-utils` in most places

* @0x/protocol-types`: Delete this package.

* regen yarn lock

* `@0x/contracts-zero-ex`: Unpin `@0x/protocol-utils` dep.

* `@0x/contracts-integrations`: Fix borken test

* update changelogs

* `@0x/protocol-utils`: Update deps

* `@0x/protocol-utils`: add tests

* `@0x/protocol-utils`: More tests

* `@0x/protocol-utils`: Update readme.

* update deps

* run prettier

* `@0x/contract-artifacts`: Regenerate artifacts

* `@0x/contract-wrappers`: Regenerate wrappers

* `@0x/protocol-utils`: Update changelog

* `@0x/contract-wrappers`: Export stuff for doc gen

* `@0x/protocol-utils`: Use `Web3Wrapper.signTypedDataV4Async()` for MM compatibility.

* upgrade org deps

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-08 22:08:52 -05:00

129 lines
3.9 KiB
TypeScript

// tslint:disable: max-classes-per-file
import { Numberish, RevertError } from '@0x/utils';
import { OrderStatus } from '../orders';
export class ProtocolFeeRefundFailed extends RevertError {
constructor(receiver?: string, refundAmount?: Numberish) {
super('ProtocolFeeRefundFailed', 'ProtocolFeeRefundFailed(address receiver, uint256 refundAmount)', {
receiver,
refundAmount,
});
}
}
export class OrderNotFillableByOriginError extends RevertError {
constructor(orderHash?: string, txOrigin?: string, orderTxOrigin?: string) {
super(
'OrderNotFillableByOriginError',
'OrderNotFillableByOriginError(bytes32 orderHash, address txOrigin, address orderTxOrigin)',
{
orderHash,
txOrigin,
orderTxOrigin,
},
);
}
}
export class OrderNotFillableError extends RevertError {
constructor(orderHash?: string, orderStatus?: OrderStatus) {
super('OrderNotFillableError', 'OrderNotFillableError(bytes32 orderHash, uint8 orderStatus)', {
orderHash,
orderStatus,
});
}
}
export class OrderNotSignedByMakerError extends RevertError {
constructor(orderHash?: string, signer?: string, maker?: string) {
super(
'OrderNotSignedByMakerError',
'OrderNotSignedByMakerError(bytes32 orderHash, address signer, address maker)',
{
orderHash,
signer,
maker,
},
);
}
}
export class OrderNotFillableBySenderError extends RevertError {
constructor(orderHash?: string, sender?: string, orderSender?: string) {
super(
'OrderNotFillableBySenderError',
'OrderNotFillableBySenderError(bytes32 orderHash, address sender, address orderSender)',
{
orderHash,
sender,
orderSender,
},
);
}
}
export class OrderNotFillableByTakerError extends RevertError {
constructor(orderHash?: string, taker?: string, orderTaker?: string) {
super(
'OrderNotFillableByTakerError',
'OrderNotFillableByTakerError(bytes32 orderHash, address taker, address orderTaker)',
{
orderHash,
taker,
orderTaker,
},
);
}
}
export class CancelSaltTooLowError extends RevertError {
constructor(minValidSalt?: Numberish, oldMinValidSalt?: Numberish) {
super('CancelSaltTooLowError', 'CancelSaltTooLowError(uint256 minValidSalt, uint256 oldMinValidSalt)', {
minValidSalt,
oldMinValidSalt,
});
}
}
export class FillOrKillFailedError extends RevertError {
constructor(orderHash?: string, takerTokenFilledAmount?: Numberish, takerTokenFillAmount?: Numberish) {
super(
'FillOrKillFailedError',
'FillOrKillFailedError(bytes32 orderHash, uint256 takerTokenFilledAmount, uint256 takerTokenFillAmount)',
{
orderHash,
takerTokenFilledAmount,
takerTokenFillAmount,
},
);
}
}
export class OnlyOrderMakerAllowed extends RevertError {
constructor(orderHash?: string, sender?: string, maker?: string) {
super('OnlyOrderMakerAllowed', 'OnlyOrderMakerAllowed(bytes32 orderHash, address sender, address maker)', {
orderHash,
sender,
maker,
});
}
}
const types = [
ProtocolFeeRefundFailed,
OrderNotFillableByOriginError,
OrderNotFillableError,
OrderNotSignedByMakerError,
OrderNotFillableBySenderError,
OrderNotFillableByTakerError,
CancelSaltTooLowError,
FillOrKillFailedError,
OnlyOrderMakerAllowed,
];
// Register the types we've defined.
for (const type of types) {
RevertError.registerType(type);
}