RFQ order with 0 txOrigin is INVALID (#50)

This commit is contained in:
Steve Marx 2020-11-25 14:15:59 -05:00 committed by GitHub
parent ad337271d3
commit 9653eb9e70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -41,6 +41,10 @@
{
"note": "Remove protocol fees from all RFQ orders and add `taker` field to RFQ orders",
"pr": 45
},
{
"note": "Fix getRfqOrderInfo() to return status INVALID when missing txOrigin",
"pr": 50
}
]
},

View File

@ -651,6 +651,11 @@ contract NativeOrdersFeature is
order.salt,
minValidSalt
);
// Check for missing txOrigin.
if (order.txOrigin == address(0)) {
orderInfo.status = LibNativeOrder.OrderStatus.INVALID;
}
}
/// @dev Get the canonical hash of a limit order.

View File

@ -365,6 +365,16 @@ blockchainTests.resets('NativeOrdersFeature', env => {
takerTokenFilledAmount: fillAmount,
});
});
it('invalid origin', async () => {
const order = getTestRfqOrder({ txOrigin: NULL_ADDRESS });
const info = await zeroEx.getRfqOrderInfo(order).callAsync();
assertOrderInfoEquals(info, {
status: OrderStatus.Invalid,
orderHash: order.getHash(),
takerTokenFilledAmount: ZERO_AMOUNT,
});
});
});
describe('cancelLimitOrder()', async () => {
@ -1216,7 +1226,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestRfqOrder({ txOrigin: NULL_ADDRESS });
const tx = fillRfqOrderAsync(order, order.takerAmount, notTaker);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableByOriginError(order.getHash(), notTaker, order.txOrigin),
new RevertErrors.OrderNotFillableError(order.getHash(), OrderStatus.Invalid),
);
});