aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts3
-rw-r--r--src/types.ts1
-rw-r--r--test/exchange_wrapper_test.ts11
3 files changed, 14 insertions, 1 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 7a5b6ac8c..e53754e07 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -116,6 +116,9 @@ export class ExchangeWrapper extends ContractWrapper {
if (fillAmount.eq(0)) {
throw new Error(FillOrderValidationErrs.FILL_AMOUNT_IS_ZERO);
}
+ if (signedOrder.taker !== constants.NULL_ADDRESS && signedOrder.taker !== senderAddress) {
+ throw new Error(FillOrderValidationErrs.NOT_A_TAKER);
+ }
}
private async getExchangeInstanceOrThrowAsync(): Promise<ExchangeContract> {
const contractInstance = await this.instantiateContractIfExistsAsync((ExchangeArtifacts as any));
diff --git a/src/types.ts b/src/types.ts
index d9ed0b6bf..d6970bc0b 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -81,6 +81,7 @@ export enum ExchangeContractErrs {
export const FillOrderValidationErrs = strEnum([
'FILL_AMOUNT_IS_ZERO',
+ 'NOT_A_TAKER',
]);
export type FillOrderValidationErrs = keyof typeof FillOrderValidationErrs;
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 4867427ae..c5cbc58be 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -129,13 +129,22 @@ describe('ExchangeWrapper', () => {
describe('failed fills', () => {
it('should throw when the fill amount is zero', async () => {
const maker = userAddresses[0];
- const taker = userAddresses[1];
+ const taker = userAddresses[0];
const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker,
5, addressBySymbol.MLN, 5, addressBySymbol.GNT);
const fillAmount = new BigNumber(0);
expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount))
.to.be.rejectedWith(FillOrderValidationErrs.FILL_AMOUNT_IS_ZERO);
});
+ it('should throw when sender is not a taker', async () => {
+ const maker = userAddresses[0];
+ const taker = userAddresses[1];
+ const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker,
+ 5, addressBySymbol.MLN, 5, addressBySymbol.GNT);
+ const fillAmount = new BigNumber(5);
+ expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount))
+ .to.be.rejectedWith(FillOrderValidationErrs.NOT_A_TAKER);
+ });
});
describe('successful fills', () => {
afterEach('reset default account', () => {