Switch order of parameters in some rich reverts for easier dirty parsing.
This commit is contained in:
committed by
Amir Bandeali
parent
8194e3d3c5
commit
ac18359410
@@ -85,9 +85,9 @@ contract MixinAssetProxyDispatcher is
|
||||
// Ensure assetData length is valid
|
||||
if (assetData.length <= 3) {
|
||||
rrevert(AssetProxyDispatchError(
|
||||
AssetProxyDispatchErrorCodes.INVALID_ASSET_DATA_LENGTH,
|
||||
orderHash,
|
||||
assetData,
|
||||
AssetProxyDispatchErrorCodes.INVALID_ASSET_DATA_LENGTH
|
||||
assetData
|
||||
));
|
||||
}
|
||||
|
||||
@@ -104,9 +104,9 @@ contract MixinAssetProxyDispatcher is
|
||||
// Ensure that assetProxy exists
|
||||
if (assetProxy == address(0)) {
|
||||
rrevert(AssetProxyDispatchError(
|
||||
AssetProxyDispatchErrorCodes.UNKNOWN_ASSET_PROXY,
|
||||
orderHash,
|
||||
assetData,
|
||||
AssetProxyDispatchErrorCodes.UNKNOWN_ASSET_PROXY
|
||||
assetData
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -219,18 +219,20 @@ contract MixinExchangeCore is
|
||||
// Compute proportional fill amounts
|
||||
fillResults = calculateFillResults(order, takerAssetFilledAmount);
|
||||
|
||||
bytes32 orderHash = orderInfo.orderHash;
|
||||
|
||||
// Update exchange internal state
|
||||
updateFilledState(
|
||||
order,
|
||||
takerAddress,
|
||||
orderInfo.orderHash,
|
||||
orderHash,
|
||||
orderInfo.orderTakerAssetFilledAmount,
|
||||
fillResults
|
||||
);
|
||||
|
||||
// Settle order
|
||||
settleOrder(
|
||||
orderInfo.orderHash,
|
||||
orderHash,
|
||||
order,
|
||||
takerAddress,
|
||||
fillResults
|
||||
@@ -329,8 +331,8 @@ contract MixinExchangeCore is
|
||||
// An order can only be filled if its status is FILLABLE.
|
||||
if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) {
|
||||
rrevert(OrderStatusError(
|
||||
orderInfo.orderHash,
|
||||
OrderStatus(orderInfo.orderStatus)
|
||||
OrderStatus(orderInfo.orderStatus),
|
||||
orderInfo.orderHash
|
||||
));
|
||||
}
|
||||
|
||||
@@ -356,8 +358,8 @@ contract MixinExchangeCore is
|
||||
signature
|
||||
)) {
|
||||
rrevert(SignatureError(
|
||||
orderInfo.orderHash,
|
||||
SignatureErrorCodes.BAD_SIGNATURE
|
||||
SignatureErrorCodes.BAD_SIGNATURE,
|
||||
orderInfo.orderHash
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -382,14 +384,14 @@ contract MixinExchangeCore is
|
||||
// Revert if fill amount is invalid
|
||||
// TODO: reconsider necessity for v2.1
|
||||
if (takerAssetFillAmount == 0) {
|
||||
rrevert(FillError(orderInfo.orderHash, FillErrorCodes.INVALID_TAKER_AMOUNT));
|
||||
rrevert(FillError(FillErrorCodes.INVALID_TAKER_AMOUNT, orderInfo.orderHash));
|
||||
}
|
||||
|
||||
// Make sure taker does not pay more than desired amount
|
||||
// NOTE: This assertion should never fail, it is here
|
||||
// as an extra defence against potential bugs.
|
||||
if (takerAssetFilledAmount > takerAssetFillAmount) {
|
||||
rrevert(FillError(orderInfo.orderHash, FillErrorCodes.TAKER_OVERPAY));
|
||||
rrevert(FillError(FillErrorCodes.TAKER_OVERPAY, orderInfo.orderHash));
|
||||
}
|
||||
|
||||
// Make sure order is not overfilled
|
||||
@@ -397,7 +399,7 @@ contract MixinExchangeCore is
|
||||
// as an extra defence against potential bugs.
|
||||
if (safeAdd(orderInfo.orderTakerAssetFilledAmount, takerAssetFilledAmount)
|
||||
> order.takerAssetAmount) {
|
||||
rrevert(FillError(orderInfo.orderHash, FillErrorCodes.OVERFILL));
|
||||
rrevert(FillError(FillErrorCodes.OVERFILL, orderInfo.orderHash));
|
||||
}
|
||||
|
||||
// Make sure order is filled at acceptable price.
|
||||
@@ -419,7 +421,7 @@ contract MixinExchangeCore is
|
||||
// as an extra defence against potential bugs.
|
||||
if (safeMul(makerAssetFilledAmount, order.takerAssetAmount)
|
||||
> safeMul(order.makerAssetAmount, takerAssetFilledAmount)) {
|
||||
rrevert(FillError(orderInfo.orderHash, FillErrorCodes.INVALID_FILL_PRICE));
|
||||
rrevert(FillError(FillErrorCodes.INVALID_FILL_PRICE, orderInfo.orderHash));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +438,7 @@ contract MixinExchangeCore is
|
||||
// Ensure order is valid
|
||||
// An order can only be cancelled if its status is FILLABLE.
|
||||
if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) {
|
||||
rrevert(OrderStatusError(orderInfo.orderHash, OrderStatus(orderInfo.orderStatus)));
|
||||
rrevert(OrderStatusError(OrderStatus(orderInfo.orderStatus), orderInfo.orderHash));
|
||||
}
|
||||
|
||||
// Validate sender is allowed to cancel this order
|
||||
|
||||
@@ -29,8 +29,8 @@ contract MixinExchangeRichErrors is
|
||||
{
|
||||
// solhint-disable func-name-mixedcase
|
||||
function SignatureError(
|
||||
bytes32 orderHash,
|
||||
SignatureErrorCodes error
|
||||
SignatureErrorCodes error,
|
||||
bytes32 orderHash
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -38,14 +38,14 @@ contract MixinExchangeRichErrors is
|
||||
{
|
||||
return abi.encodeWithSelector(
|
||||
SIGNATURE_ERROR_SELECTOR,
|
||||
orderHash,
|
||||
error
|
||||
error,
|
||||
orderHash
|
||||
);
|
||||
}
|
||||
|
||||
function OrderStatusError(
|
||||
bytes32 orderHash,
|
||||
LibOrder.OrderStatus orderStatus
|
||||
LibOrder.OrderStatus orderStatus,
|
||||
bytes32 orderHash
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -53,8 +53,8 @@ contract MixinExchangeRichErrors is
|
||||
{
|
||||
return abi.encodeWithSelector(
|
||||
ORDER_STATUS_ERROR_SELECTOR,
|
||||
orderHash,
|
||||
uint8(orderStatus)
|
||||
orderStatus,
|
||||
orderHash
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ contract MixinExchangeRichErrors is
|
||||
}
|
||||
|
||||
function FillError(
|
||||
bytes32 orderHash,
|
||||
FillErrorCodes error
|
||||
FillErrorCodes error,
|
||||
bytes32 orderHash
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -98,8 +98,8 @@ contract MixinExchangeRichErrors is
|
||||
{
|
||||
return abi.encodeWithSelector(
|
||||
FILL_ERROR_SELECTOR,
|
||||
orderHash,
|
||||
uint8(error)
|
||||
error,
|
||||
orderHash
|
||||
);
|
||||
}
|
||||
|
||||
@@ -149,9 +149,9 @@ contract MixinExchangeRichErrors is
|
||||
}
|
||||
|
||||
function AssetProxyDispatchError(
|
||||
AssetProxyDispatchErrorCodes error,
|
||||
bytes32 orderHash,
|
||||
bytes memory assetData,
|
||||
AssetProxyDispatchErrorCodes error
|
||||
bytes memory assetData
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -159,9 +159,9 @@ contract MixinExchangeRichErrors is
|
||||
{
|
||||
return abi.encodeWithSelector(
|
||||
ASSET_PROXY_DISPATCH_ERROR_SELECTOR,
|
||||
error,
|
||||
orderHash,
|
||||
assetData,
|
||||
uint8(error)
|
||||
assetData
|
||||
);
|
||||
}
|
||||
|
||||
@@ -198,8 +198,8 @@ contract MixinExchangeRichErrors is
|
||||
}
|
||||
|
||||
function TransactionError(
|
||||
bytes32 transactionHash,
|
||||
TransactionErrorCodes error
|
||||
TransactionErrorCodes error,
|
||||
bytes32 transactionHash
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -207,8 +207,8 @@ contract MixinExchangeRichErrors is
|
||||
{
|
||||
return abi.encodeWithSelector(
|
||||
TRANSACTION_ERROR_SELECTOR,
|
||||
transactionHash,
|
||||
error
|
||||
error,
|
||||
transactionHash
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ contract MixinSignatureValidator is
|
||||
signature
|
||||
)) {
|
||||
rrevert(SignatureError(
|
||||
hash,
|
||||
SignatureErrorCodes.BAD_SIGNATURE
|
||||
SignatureErrorCodes.BAD_SIGNATURE,
|
||||
hash
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ contract MixinSignatureValidator is
|
||||
returns (bool isValid)
|
||||
{
|
||||
if (signature.length == 0) {
|
||||
rrevert(SignatureError(hash, SignatureErrorCodes.INVALID_LENGTH));
|
||||
rrevert(SignatureError(SignatureErrorCodes.INVALID_LENGTH, hash));
|
||||
}
|
||||
|
||||
// Pop last byte off of signature byte array.
|
||||
@@ -110,7 +110,7 @@ contract MixinSignatureValidator is
|
||||
|
||||
// Ensure signature is supported
|
||||
if (signatureTypeRaw >= uint8(SignatureType.NSignatureTypes)) {
|
||||
rrevert(SignatureError(hash, SignatureErrorCodes.UNSUPPORTED));
|
||||
rrevert(SignatureError(SignatureErrorCodes.UNSUPPORTED, hash));
|
||||
}
|
||||
|
||||
SignatureType signatureType = SignatureType(signatureTypeRaw);
|
||||
@@ -128,8 +128,8 @@ contract MixinSignatureValidator is
|
||||
// also the initialization value for the enum type.
|
||||
if (signatureType == SignatureType.Illegal) {
|
||||
rrevert(SignatureError(
|
||||
hash,
|
||||
SignatureErrorCodes.ILLEGAL
|
||||
SignatureErrorCodes.ILLEGAL,
|
||||
hash
|
||||
));
|
||||
|
||||
// Always invalid signature.
|
||||
@@ -139,8 +139,8 @@ contract MixinSignatureValidator is
|
||||
} else if (signatureType == SignatureType.Invalid) {
|
||||
if (signature.length != 0) {
|
||||
rrevert(SignatureError(
|
||||
hash,
|
||||
SignatureErrorCodes.INVALID_LENGTH
|
||||
SignatureErrorCodes.INVALID_LENGTH,
|
||||
hash
|
||||
));
|
||||
}
|
||||
isValid = false;
|
||||
@@ -150,8 +150,8 @@ contract MixinSignatureValidator is
|
||||
} else if (signatureType == SignatureType.EIP712) {
|
||||
if (signature.length != 65) {
|
||||
rrevert(SignatureError(
|
||||
hash,
|
||||
SignatureErrorCodes.INVALID_LENGTH
|
||||
SignatureErrorCodes.INVALID_LENGTH,
|
||||
hash
|
||||
));
|
||||
}
|
||||
v = uint8(signature[0]);
|
||||
@@ -170,8 +170,8 @@ contract MixinSignatureValidator is
|
||||
} else if (signatureType == SignatureType.EthSign) {
|
||||
if (signature.length != 65) {
|
||||
rrevert(SignatureError(
|
||||
hash,
|
||||
SignatureErrorCodes.INVALID_LENGTH
|
||||
SignatureErrorCodes.INVALID_LENGTH,
|
||||
hash
|
||||
));
|
||||
}
|
||||
v = uint8(signature[0]);
|
||||
@@ -233,7 +233,7 @@ contract MixinSignatureValidator is
|
||||
// that we currently support. In this case returning false
|
||||
// may lead the caller to incorrectly believe that the
|
||||
// signature was invalid.)
|
||||
rrevert(SignatureError(hash, SignatureErrorCodes.UNSUPPORTED));
|
||||
rrevert(SignatureError(SignatureErrorCodes.UNSUPPORTED, hash));
|
||||
}
|
||||
|
||||
/// @dev Verifies signature using logic defined by Wallet contract.
|
||||
@@ -275,7 +275,7 @@ contract MixinSignatureValidator is
|
||||
}
|
||||
if (didSucceed)
|
||||
return isValid;
|
||||
rrevert(SignatureError(hash, SignatureErrorCodes.WALLET_ERROR));
|
||||
rrevert(SignatureError(SignatureErrorCodes.WALLET_ERROR, hash));
|
||||
}
|
||||
|
||||
/// @dev Verifies signature using logic defined by Validator contract.
|
||||
@@ -319,7 +319,6 @@ contract MixinSignatureValidator is
|
||||
}
|
||||
if (didSucceed)
|
||||
return isValid;
|
||||
rrevert(
|
||||
SignatureError(hash, SignatureErrorCodes.VALIDATOR_ERROR));
|
||||
rrevert(SignatureError(SignatureErrorCodes.VALIDATOR_ERROR, hash));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,16 +53,16 @@ contract MixinTransactions is
|
||||
// Prevent reentrancy
|
||||
if (currentContextAddress != address(0)) {
|
||||
rrevert(TransactionError(
|
||||
transactionHash,
|
||||
TransactionErrorCodes.NO_REENTRANCY
|
||||
TransactionErrorCodes.NO_REENTRANCY,
|
||||
transactionHash
|
||||
));
|
||||
}
|
||||
|
||||
// Validate transaction has not been executed
|
||||
if (transactions[transactionHash]) {
|
||||
rrevert(TransactionError(
|
||||
transactionHash,
|
||||
TransactionErrorCodes.ALREADY_EXECUTED
|
||||
TransactionErrorCodes.ALREADY_EXECUTED,
|
||||
transactionHash
|
||||
));
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ contract MixinTransactions is
|
||||
signerAddress,
|
||||
signature)) {
|
||||
rrevert(TransactionError(
|
||||
transactionHash,
|
||||
TransactionErrorCodes.BAD_SIGNATURE
|
||||
TransactionErrorCodes.BAD_SIGNATURE,
|
||||
transactionHash
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,22 +54,22 @@ contract MExchangeRichErrors is
|
||||
|
||||
// solhint-disable func-name-mixedcase
|
||||
bytes4 internal constant SIGNATURE_ERROR_SELECTOR =
|
||||
bytes4(keccak256("SignatureError(bytes32,uint8)"));
|
||||
bytes4(keccak256("SignatureError(uint8,bytes32)"));
|
||||
|
||||
function SignatureError(
|
||||
bytes32 orderHash,
|
||||
SignatureErrorCodes error
|
||||
SignatureErrorCodes error,
|
||||
bytes32 orderHash
|
||||
)
|
||||
internal
|
||||
pure
|
||||
returns (bytes memory);
|
||||
|
||||
bytes4 internal constant ORDER_STATUS_ERROR_SELECTOR =
|
||||
bytes4(keccak256("OrderStatusError(bytes32,uint8)"));
|
||||
bytes4(keccak256("OrderStatusError(uint8,bytes32)"));
|
||||
|
||||
function OrderStatusError(
|
||||
bytes32 orderHash,
|
||||
LibOrder.OrderStatus orderStatus
|
||||
LibOrder.OrderStatus orderStatus,
|
||||
bytes32 orderHash
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -98,11 +98,11 @@ contract MExchangeRichErrors is
|
||||
returns (bytes memory);
|
||||
|
||||
bytes4 internal constant FILL_ERROR_SELECTOR =
|
||||
bytes4(keccak256("FillError(bytes32,uint8)"));
|
||||
bytes4(keccak256("FillError(uint8,bytes32)"));
|
||||
|
||||
function FillError(
|
||||
bytes32 orderHash,
|
||||
FillErrorCodes error
|
||||
FillErrorCodes error,
|
||||
bytes32 orderHash
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -142,12 +142,12 @@ contract MExchangeRichErrors is
|
||||
returns (bytes memory);
|
||||
|
||||
bytes4 internal constant ASSET_PROXY_DISPATCH_ERROR_SELECTOR =
|
||||
bytes4(keccak256("AssetProxyDispatchError(bytes32,bytes,uint8)"));
|
||||
bytes4(keccak256("AssetProxyDispatchError(uint8,bytes32,bytes)"));
|
||||
|
||||
function AssetProxyDispatchError(
|
||||
AssetProxyDispatchErrorCodes error,
|
||||
bytes32 orderHash,
|
||||
bytes memory assetData,
|
||||
AssetProxyDispatchErrorCodes error
|
||||
bytes memory assetData
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -177,11 +177,11 @@ contract MExchangeRichErrors is
|
||||
returns (bytes memory);
|
||||
|
||||
bytes4 internal constant TRANSACTION_ERROR_SELECTOR =
|
||||
bytes4(keccak256("TransactionError(bytes32,uint8)"));
|
||||
bytes4(keccak256("TransactionError(uint8,bytes32)"));
|
||||
|
||||
function TransactionError(
|
||||
bytes32 transactionHash,
|
||||
TransactionErrorCodes error
|
||||
TransactionErrorCodes error,
|
||||
bytes32 transactionHash
|
||||
)
|
||||
internal
|
||||
pure
|
||||
|
||||
@@ -54,7 +54,7 @@ const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
// tslint:disable:no-unnecessary-type-assertion
|
||||
describe.only('Exchange core', () => {
|
||||
describe('Exchange core', () => {
|
||||
let chainId: number;
|
||||
let makerAddress: string;
|
||||
let owner: string;
|
||||
@@ -263,8 +263,8 @@ describe.only('Exchange core', () => {
|
||||
const invalidSigHex = `0x${invalidSigBuff.toString('hex')}`;
|
||||
signedOrder.signature = invalidSigHex;
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.BadSignature,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
@@ -274,7 +274,7 @@ describe.only('Exchange core', () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.FullyFilled);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.FullyFilled, orderHashHex);
|
||||
const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
@@ -297,8 +297,8 @@ describe.only('Exchange core', () => {
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
signedOrder.signature = `0x0${SignatureType.Wallet}`;
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.WalletError,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
@@ -314,8 +314,8 @@ describe.only('Exchange core', () => {
|
||||
signedOrder.signature = `${maliciousValidator.address}0${SignatureType.Validator}`;
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.ValidatorError,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
@@ -503,8 +503,8 @@ describe.only('Exchange core', () => {
|
||||
});
|
||||
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(
|
||||
orderHash,
|
||||
OrderStatus.InvalidMakerAssetAmount,
|
||||
orderHash,
|
||||
);
|
||||
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
@@ -516,8 +516,8 @@ describe.only('Exchange core', () => {
|
||||
});
|
||||
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(
|
||||
orderHash,
|
||||
OrderStatus.InvalidTakerAssetAmount,
|
||||
orderHash,
|
||||
);
|
||||
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
@@ -526,7 +526,7 @@ describe.only('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(orderHash, OrderStatus.Cancelled);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHash);
|
||||
const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
|
||||
takerAssetFillAmount: signedOrder.takerAssetAmount.div(2),
|
||||
});
|
||||
@@ -551,7 +551,7 @@ describe.only('Exchange core', () => {
|
||||
it('should throw if already cancelled', async () => {
|
||||
await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
|
||||
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHash, OrderStatus.Cancelled);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHash);
|
||||
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
@@ -562,7 +562,7 @@ describe.only('Exchange core', () => {
|
||||
expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10),
|
||||
});
|
||||
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHash, OrderStatus.Expired);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Expired, orderHash);
|
||||
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
@@ -274,9 +274,9 @@ describe('AssetProxyDispatcher', () => {
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const amount = new BigNumber(10);
|
||||
const expectedError = new ExchangeRevertErrors.AssetProxyDispatchError(
|
||||
ExchangeRevertErrors.AssetProxyDispatchErrorCode.UnknownAssetProxy,
|
||||
orderHash,
|
||||
encodedAssetData,
|
||||
ExchangeRevertErrors.AssetProxyDispatchErrorCode.UnknownAssetProxy,
|
||||
);
|
||||
const tx = assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
|
||||
orderHash,
|
||||
|
||||
@@ -1126,7 +1126,7 @@ describe('matchOrders', () => {
|
||||
// Cancel left order
|
||||
await exchangeWrapper.cancelOrderAsync(signedOrderLeft, signedOrderLeft.makerAddress);
|
||||
// Match orders
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHexLeft, OrderStatus.Cancelled);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHashHexLeft);
|
||||
const tx = exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
@@ -1145,7 +1145,7 @@ describe('matchOrders', () => {
|
||||
// Cancel right order
|
||||
await exchangeWrapper.cancelOrderAsync(signedOrderRight, signedOrderRight.makerAddress);
|
||||
// Match orders
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHexRight, OrderStatus.Cancelled);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHashHexRight);
|
||||
const tx = exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
@@ -1189,8 +1189,8 @@ describe('matchOrders', () => {
|
||||
};
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(reconstructedOrderRight);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.BadSignature,
|
||||
orderHashHex,
|
||||
);
|
||||
// Match orders
|
||||
const tx = exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress);
|
||||
@@ -1214,8 +1214,8 @@ describe('matchOrders', () => {
|
||||
};
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(reconstructedOrderRight);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.BadSignature,
|
||||
orderHashHex,
|
||||
);
|
||||
// Match orders
|
||||
const tx = exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress);
|
||||
|
||||
@@ -130,8 +130,8 @@ describe('MixinSignatureValidator', () => {
|
||||
const emptySignature = '0x';
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.InvalidLength,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = signatureValidator.publicIsValidSignature.callAsync(
|
||||
orderHashHex,
|
||||
@@ -146,8 +146,8 @@ describe('MixinSignatureValidator', () => {
|
||||
const unsupportedSignatureHex = `0x${Buffer.from([unsupportedSignatureType]).toString('hex')}`;
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.Unsupported,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = signatureValidator.publicIsValidSignature.callAsync(
|
||||
orderHashHex,
|
||||
@@ -161,8 +161,8 @@ describe('MixinSignatureValidator', () => {
|
||||
const unsupportedSignatureHex = `0x${Buffer.from([SignatureType.Illegal]).toString('hex')}`;
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.Illegal,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = signatureValidator.publicIsValidSignature.callAsync(
|
||||
orderHashHex,
|
||||
@@ -190,8 +190,8 @@ describe('MixinSignatureValidator', () => {
|
||||
const signatureHex = ethUtil.bufferToHex(signatureBuffer);
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.InvalidLength,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = signatureValidator.publicIsValidSignature.callAsync(
|
||||
orderHashHex,
|
||||
@@ -352,8 +352,8 @@ describe('MixinSignatureValidator', () => {
|
||||
]);
|
||||
const signatureHex = ethUtil.bufferToHex(signature);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.WalletError,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = signatureValidator.publicIsValidSignature.callAsync(
|
||||
orderHashHex,
|
||||
@@ -400,8 +400,8 @@ describe('MixinSignatureValidator', () => {
|
||||
const signatureHex = ethUtil.bufferToHex(signature);
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.ValidatorError,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = signatureValidator.publicIsValidSignature.callAsync(orderHashHex, signerAddress, signatureHex);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
|
||||
@@ -203,8 +203,8 @@ describe('Exchange transactions', () => {
|
||||
await exchangeWrapper.executeTransactionAsync(signedTx, senderAddress);
|
||||
const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTx);
|
||||
const expectedError = new ExchangeRevertErrors.TransactionError(
|
||||
transactionHashHex,
|
||||
ExchangeRevertErrors.TransactionErrorCode.AlreadyExecuted,
|
||||
transactionHashHex,
|
||||
);
|
||||
const tx = exchangeWrapper.executeTransactionAsync(signedTx, senderAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
@@ -237,7 +237,7 @@ describe('Exchange transactions', () => {
|
||||
it('should cancel the order when signed by maker and called by sender', async () => {
|
||||
await exchangeWrapper.executeTransactionAsync(signedTx, senderAddress);
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.Cancelled);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHashHex);
|
||||
const tx = exchangeWrapper.fillOrderAsync(signedOrder, senderAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
@@ -285,7 +285,7 @@ describe('Exchange transactions', () => {
|
||||
const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedFillTx);
|
||||
const expectedError = new ExchangeRevertErrors.TransactionExecutionError(
|
||||
transactionHashHex,
|
||||
new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.Cancelled).encode(),
|
||||
new ExchangeRevertErrors.OrderStatusError(OrderStatus.Cancelled, orderHashHex).encode(),
|
||||
);
|
||||
const tx = exchangeWrapperContract.fillOrder.sendTransactionAsync(
|
||||
orderWithoutDomain,
|
||||
|
||||
@@ -944,15 +944,15 @@ function validationErrorToRevertError(order: Order, reason: RevertReason): Rever
|
||||
case RevertReason.InvalidTaker:
|
||||
return new ExchangeRevertErrors.InvalidTakerError(orderHash);
|
||||
case RevertReason.OrderUnfillable:
|
||||
return new ExchangeRevertErrors.OrderStatusError(orderHash);
|
||||
return new ExchangeRevertErrors.OrderStatusError(undefined, orderHash);
|
||||
case RevertReason.InvalidTakerAmount:
|
||||
return new ExchangeRevertErrors.FillError(orderHash, ExchangeRevertErrors.FillErrorCode.InvalidTakerAmount);
|
||||
return new ExchangeRevertErrors.FillError(ExchangeRevertErrors.FillErrorCode.InvalidTakerAmount, orderHash);
|
||||
case RevertReason.TakerOverpay:
|
||||
return new ExchangeRevertErrors.FillError(orderHash, ExchangeRevertErrors.FillErrorCode.TakerOverpay);
|
||||
return new ExchangeRevertErrors.FillError(ExchangeRevertErrors.FillErrorCode.TakerOverpay, orderHash);
|
||||
case RevertReason.OrderOverfill:
|
||||
return new ExchangeRevertErrors.FillError(orderHash, ExchangeRevertErrors.FillErrorCode.Overfill);
|
||||
return new ExchangeRevertErrors.FillError(ExchangeRevertErrors.FillErrorCode.Overfill, orderHash);
|
||||
case RevertReason.InvalidFillPrice:
|
||||
return new ExchangeRevertErrors.FillError(orderHash, ExchangeRevertErrors.FillErrorCode.InvalidFillPrice);
|
||||
return new ExchangeRevertErrors.FillError(ExchangeRevertErrors.FillErrorCode.InvalidFillPrice, orderHash);
|
||||
case RevertReason.TransferFailed:
|
||||
return new ExchangeRevertErrors.AssetProxyTransferError(orderHash, undefined, RevertReason.TransferFailed);
|
||||
default:
|
||||
|
||||
@@ -207,7 +207,7 @@ describe('Exchange wrappers', () => {
|
||||
expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10),
|
||||
});
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.Expired);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.Expired, orderHashHex);
|
||||
const tx = exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
@@ -587,7 +587,7 @@ describe('Exchange wrappers', () => {
|
||||
|
||||
await exchangeWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress);
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrders[0]);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.FullyFilled);
|
||||
const expectedError = new ExchangeRevertErrors.OrderStatusError(OrderStatus.FullyFilled, orderHashHex);
|
||||
const tx = exchangeWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
|
||||
takerAssetFillAmounts,
|
||||
});
|
||||
@@ -833,8 +833,8 @@ describe('Exchange wrappers', () => {
|
||||
};
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(reconstructedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.BadSignature,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
|
||||
takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
||||
@@ -1096,8 +1096,8 @@ describe('Exchange wrappers', () => {
|
||||
};
|
||||
const orderHashHex = orderHashUtils.getOrderHashHex(reconstructedOrder);
|
||||
const expectedError = new ExchangeRevertErrors.SignatureError(
|
||||
orderHashHex,
|
||||
ExchangeRevertErrors.SignatureErrorCode.BadSignature,
|
||||
orderHashHex,
|
||||
);
|
||||
const tx = exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
|
||||
makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
||||
|
||||
Reference in New Issue
Block a user