In @0x/contracts-exchange: Change parameter order and naming of some rich revert errors.

In `@0x/order-utils`: Change parameter order for `OrderStatusError`.
This commit is contained in:
Lawrence Forman
2019-04-23 11:46:02 -04:00
committed by Amir Bandeali
parent fdaee1375c
commit d942c47f08
8 changed files with 71 additions and 44 deletions

View File

@@ -277,7 +277,10 @@ describe('Exchange core', () => {
signedOrder = await orderFactory.newSignedOrderAsync();
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.FullyFilled, orderHashHex);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
orderHashHex,
OrderStatus.FullyFilled,
);
const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
return expect(tx).to.revertWith(expectedError);
});
@@ -510,8 +513,8 @@ describe('Exchange core', () => {
});
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
OrderStatus.InvalidMakerAssetAmount,
orderHash,
OrderStatus.InvalidMakerAssetAmount,
);
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
return expect(tx).to.revertWith(expectedError);
@@ -523,8 +526,8 @@ describe('Exchange core', () => {
});
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
OrderStatus.InvalidTakerAssetAmount,
orderHash,
OrderStatus.InvalidTakerAssetAmount,
);
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
return expect(tx).to.revertWith(expectedError);
@@ -533,7 +536,10 @@ describe('Exchange core', () => {
it('should be able to cancel an order', async () => {
await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHash);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
orderHash,
OrderStatus.Cancelled,
);
const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
takerAssetFillAmount: signedOrder.takerAssetAmount.div(2),
});
@@ -558,7 +564,10 @@ describe('Exchange core', () => {
it('should throw if already cancelled', async () => {
await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHash);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
orderHash,
OrderStatus.Cancelled,
);
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
return expect(tx).to.revertWith(expectedError);
});
@@ -569,7 +578,10 @@ describe('Exchange core', () => {
expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10),
});
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Expired, orderHash);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
orderHash,
OrderStatus.Expired,
);
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
return expect(tx).to.revertWith(expectedError);
});

View File

@@ -1127,7 +1127,10 @@ describe('matchOrders', () => {
// Cancel left order
await exchangeWrapper.cancelOrderAsync(signedOrderLeft, signedOrderLeft.makerAddress);
// Match orders
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHashHexLeft);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
orderHashHexLeft,
OrderStatus.Cancelled,
);
const tx = exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress);
return expect(tx).to.revertWith(expectedError);
});
@@ -1146,7 +1149,10 @@ describe('matchOrders', () => {
// Cancel right order
await exchangeWrapper.cancelOrderAsync(signedOrderRight, signedOrderRight.makerAddress);
// Match orders
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHashHexRight);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
orderHashHexRight,
OrderStatus.Cancelled,
);
const tx = exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress);
return expect(tx).to.revertWith(expectedError);
});

View File

@@ -940,7 +940,7 @@ function validationErrorToRevertError(order: Order, reason: RevertReason): Rever
case RevertReason.InvalidTaker:
return new ExchangeRevertErrors.InvalidTakerError(orderHash);
case RevertReason.OrderUnfillable:
return new ExchangeRevertErrors.OrderStatusError(undefined, orderHash);
return new ExchangeRevertErrors.OrderStatusError(orderHash);
case RevertReason.InvalidTakerAmount:
return new ExchangeRevertErrors.FillError(ExchangeRevertErrors.FillErrorCode.InvalidTakerAmount, orderHash);
case RevertReason.TakerOverpay:

View File

@@ -213,7 +213,10 @@ describe('Exchange wrappers', () => {
expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10),
});
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Expired, orderHashHex);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
orderHashHex,
OrderStatus.Expired,
);
const tx = exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress);
return expect(tx).to.revertWith(expectedError);
});
@@ -594,7 +597,10 @@ describe('Exchange wrappers', () => {
await exchangeWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress);
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrders[0]);
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.FullyFilled, orderHashHex);
const expectedError = new ExchangeRevertErrors.OrderStatusError(
orderHashHex,
OrderStatus.FullyFilled,
);
const tx = exchangeWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
takerAssetFillAmounts,
});