aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-01 21:12:27 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-01 21:13:32 +0800
commit07cdfa655be81862f7ff40fe5ac6fdb38d780370 (patch)
tree4f1e206b043b2bef0db12f39934b094dfeea7e83 /src/contract_wrappers
parent88316455b74d2ecde1da55bf2bb36b6c9b46bcb1 (diff)
downloaddexon-sol-tools-07cdfa655be81862f7ff40fe5ac6fdb38d780370.tar
dexon-sol-tools-07cdfa655be81862f7ff40fe5ac6fdb38d780370.tar.gz
dexon-sol-tools-07cdfa655be81862f7ff40fe5ac6fdb38d780370.tar.bz2
dexon-sol-tools-07cdfa655be81862f7ff40fe5ac6fdb38d780370.tar.lz
dexon-sol-tools-07cdfa655be81862f7ff40fe5ac6fdb38d780370.tar.xz
dexon-sol-tools-07cdfa655be81862f7ff40fe5ac6fdb38d780370.tar.zst
dexon-sol-tools-07cdfa655be81862f7ff40fe5ac6fdb38d780370.zip
Add FILL_AMOUNT_IS_ZERO check
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index d1763e307..7a5b6ac8c 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -4,6 +4,7 @@ import {
ECSignature,
ExchangeContract,
ExchangeContractErrs,
+ FillOrderValidationErrs,
OrderValues,
OrderAddresses,
SignedOrder,
@@ -66,6 +67,8 @@ export class ExchangeWrapper extends ContractWrapper {
const senderAddress = await this.web3Wrapper.getSenderAddressOrThrowAsync();
const exchangeInstance = await this.getExchangeInstanceOrThrowAsync();
+ this.validateFillOrder(signedOrder, fillAmount, senderAddress, shouldCheckTransfer);
+
const orderAddresses: OrderAddresses = [
signedOrder.maker,
signedOrder.taker,
@@ -108,6 +111,12 @@ export class ExchangeWrapper extends ContractWrapper {
);
this.throwErrorLogsAsErrors(response.logs);
}
+ private validateFillOrder(signedOrder: SignedOrder, fillAmount: BigNumber.BigNumber, senderAddress: string,
+ shouldCheckTransfer: boolean = true) {
+ if (fillAmount.eq(0)) {
+ throw new Error(FillOrderValidationErrs.FILL_AMOUNT_IS_ZERO);
+ }
+ }
private async getExchangeInstanceOrThrowAsync(): Promise<ExchangeContract> {
const contractInstance = await this.instantiateContractIfExistsAsync((ExchangeArtifacts as any));
return contractInstance as ExchangeContract;