Merge pull request #2454 from 0xProject/fix/dev-utils/and-another-one
Another one...
This commit is contained in:
commit
fd47947e55
@ -118,22 +118,14 @@ contract OrderValidationUtils is
|
||||
transferableTakerAssetAmount
|
||||
);
|
||||
|
||||
// Execute the maker transfers.
|
||||
fillableTakerAssetAmount = LibOrderTransferSimulation.getSimulatedOrderMakerTransferResults(
|
||||
exchangeAddress,
|
||||
order,
|
||||
order.takerAddress,
|
||||
fillableTakerAssetAmount
|
||||
) == LibOrderTransferSimulation.OrderTransferResults.TransfersSuccessful ? fillableTakerAssetAmount : 0;
|
||||
|
||||
if (!_isAssetDataValid(order.takerAssetData)) {
|
||||
fillableTakerAssetAmount = 0;
|
||||
}
|
||||
|
||||
if (order.takerFee != 0 && !_isAssetDataValid(order.takerFeeAssetData)) {
|
||||
// Ensure that all of the asset data is valid. Fee asset data only needs
|
||||
// to be valid if the fees are nonzero.
|
||||
if (!_areOrderAssetDatasValid(order)) {
|
||||
fillableTakerAssetAmount = 0;
|
||||
}
|
||||
|
||||
// If the order is not fillable, then the fillable taker asset amount is
|
||||
// zero by definition.
|
||||
if (orderInfo.orderStatus != LibOrder.OrderStatus.FILLABLE) {
|
||||
fillableTakerAssetAmount = 0;
|
||||
}
|
||||
@ -210,6 +202,21 @@ contract OrderValidationUtils is
|
||||
return transferableAssetAmount;
|
||||
}
|
||||
|
||||
/// @dev Checks that the asset data contained in a ZeroEx is valid and returns
|
||||
/// a boolean that indicates whether or not the asset data was found to be valid.
|
||||
/// @param order A ZeroEx order to validate.
|
||||
/// @return The validatity of the asset data.
|
||||
function _areOrderAssetDatasValid(LibOrder.Order memory order)
|
||||
internal
|
||||
pure
|
||||
returns (bool)
|
||||
{
|
||||
return _isAssetDataValid(order.makerAssetData) &&
|
||||
(order.makerFee == 0 || _isAssetDataValid(order.makerFeeAssetData)) &&
|
||||
_isAssetDataValid(order.takerAssetData) &&
|
||||
(order.takerFee == 0 || _isAssetDataValid(order.takerFeeAssetData));
|
||||
}
|
||||
|
||||
/// @dev This function handles the edge cases around taker validation. This function
|
||||
/// currently attempts to find duplicate ERC721 token's in the taker
|
||||
/// multiAssetData.
|
||||
|
@ -434,6 +434,25 @@ blockchainTests.resets('OrderValidationUtils/OrderTransferSimulatorUtils', env =
|
||||
expect(fillableTakerAssetAmount).to.bignumber.equal(signedOrder.takerAssetAmount);
|
||||
expect(isValidSignature).to.equal(true);
|
||||
});
|
||||
it('should not revert when rounding errors occur', async () => {
|
||||
signedOrder = await maker.signOrderAsync({
|
||||
makerAssetAmount: new BigNumber('2040250070'),
|
||||
takerAssetAmount: new BigNumber('2040250070000000000000'),
|
||||
makerFee: new BigNumber(0),
|
||||
takerFee: new BigNumber(0),
|
||||
});
|
||||
await erc20Token.setBalance(maker.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync();
|
||||
await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({
|
||||
from: maker.address,
|
||||
});
|
||||
await erc20Token2.setBalance(taker.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync();
|
||||
await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({
|
||||
from: taker.address,
|
||||
});
|
||||
await taker.configureERC20TokenAsync(deployment.tokens.weth, deployment.staking.stakingProxy.address);
|
||||
await taker.fillOrderAsync(signedOrder, new BigNumber('2040250069999999999990'));
|
||||
await devUtils.getOrderRelevantState(signedOrder, signedOrder.signature).callAsync();
|
||||
});
|
||||
});
|
||||
describe('getOrderRelevantStates', async () => {
|
||||
it('should return the correct information for multiple orders', async () => {
|
||||
|
@ -17,7 +17,7 @@
|
||||
"zrxVault": "0xba7f8b5fb1b19c1211c5d49550fcd149177a5eaf",
|
||||
"staking": "0x2a17c35ff147b32f13f19f2e311446eeb02503f3",
|
||||
"stakingProxy": "0xa26e80e7dea86279c6d778d702cc413e6cffa777",
|
||||
"devUtils": "0x161793cdca4ff9e766a706c2c49c36ac1340bbcd",
|
||||
"devUtils": "0xb1a3d901bad1df7d710fc8d008db7cdd6bbbffe6",
|
||||
"erc20BridgeProxy": "0x8ed95d1746bf1e4dab58d8ed4724f1ef95b20db0",
|
||||
"uniswapBridge": "0x533344cfdf2a3e911e2cf4c6f5ed08e791f5355f",
|
||||
"erc20BridgeSampler": "0x774c53ee7604af93cd3ed1cd25a788a9e0c06fb2",
|
||||
@ -44,7 +44,7 @@
|
||||
"multiAssetProxy": "0xab8fbd189c569ccdee3a4d929bb7f557be4028f6",
|
||||
"staticCallProxy": "0xe1b97e47aa3796276033a5341e884d2ba46b6ac1",
|
||||
"erc1155Proxy": "0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d",
|
||||
"devUtils": "0x161793cdca4ff9e766a706c2c49c36ac1340bbcd",
|
||||
"devUtils": "0xb1a3d901bad1df7d710fc8d008db7cdd6bbbffe6",
|
||||
"zrxVault": "0xffd161026865ad8b4ab28a76840474935eec4dfa",
|
||||
"staking": "0x986b588e472b712385579d172494fe2685669504",
|
||||
"stakingProxy": "0xfaabcee42ab6b9c649794ac6c133711071897ee9",
|
||||
@ -74,7 +74,7 @@
|
||||
"multiAssetProxy": "0xb34cde0ad3a83d04abebc0b66e75196f22216621",
|
||||
"staticCallProxy": "0xe1b97e47aa3796276033a5341e884d2ba46b6ac1",
|
||||
"erc1155Proxy": "0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d",
|
||||
"devUtils": "0x161793cdca4ff9e766a706c2c49c36ac1340bbcd",
|
||||
"devUtils": "0xb1a3d901bad1df7d710fc8d008db7cdd6bbbffe6",
|
||||
"zrxVault": "0xa5bf6ac73bc40790fc6ffc9dbbbce76c9176e224",
|
||||
"staking": "0x7cbe3c09cba24f26db24d9100ee915fa9fa21f5b",
|
||||
"stakingProxy": "0xc6ad5277ea225ac05e271eb14a7ebb480cd9dd9f",
|
||||
@ -104,7 +104,7 @@
|
||||
"multiAssetProxy": "0xf6313a772c222f51c28f2304c0703b8cf5428fd8",
|
||||
"staticCallProxy": "0x48e94bdb9033640d45ea7c721e25f380f8bffa43",
|
||||
"erc1155Proxy": "0x64517fa2b480ba3678a2a3c0cf08ef7fd4fad36f",
|
||||
"devUtils": "0x161793cdca4ff9e766a706c2c49c36ac1340bbcd",
|
||||
"devUtils": "0xb1a3d901bad1df7d710fc8d008db7cdd6bbbffe6",
|
||||
"zrxVault": "0xf36eabdfe986b35b62c8fd5a98a7f2aebb79b291",
|
||||
"staking": "0x32b06d5611a03737a5f1834a24ccd641033fd89c",
|
||||
"stakingProxy": "0xbab9145f1d57cd4bb0c9aa2d1ece0a5b6e734d34",
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user