aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/exchange_wrapper.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-07 23:53:52 +0800
committerFabio Berger <me@fabioberger.com>2017-06-07 23:53:52 +0800
commit9e855b4c6ad3baef8be3a725ca26b679c2542c00 (patch)
tree7ce9999e88c3cbb1ca4c491cef4b6db5660dd7af /src/contract_wrappers/exchange_wrapper.ts
parentbc441015b672c310bd4b4a67fcf9a98e28793883 (diff)
downloaddexon-sol-tools-9e855b4c6ad3baef8be3a725ca26b679c2542c00.tar
dexon-sol-tools-9e855b4c6ad3baef8be3a725ca26b679c2542c00.tar.gz
dexon-sol-tools-9e855b4c6ad3baef8be3a725ca26b679c2542c00.tar.bz2
dexon-sol-tools-9e855b4c6ad3baef8be3a725ca26b679c2542c00.tar.lz
dexon-sol-tools-9e855b4c6ad3baef8be3a725ca26b679c2542c00.tar.xz
dexon-sol-tools-9e855b4c6ad3baef8be3a725ca26b679c2542c00.tar.zst
dexon-sol-tools-9e855b4c6ad3baef8be3a725ca26b679c2542c00.zip
Remove catch of invalid jump throws since there are many reasons the contracts could throw this error
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index d25b8aa29..4f132656e 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -189,7 +189,7 @@ export class ExchangeWrapper extends ContractWrapper {
await this.validateFillOrderAndThrowIfInvalidAsync(signedOrder, fillTakerAmount, takerAddress);
// Check that fillValue available >= fillTakerAmount
- const orderHashHex = utils.getOrderHashHex(signedOrder, exchangeInstance.address);
+ const orderHashHex = await this.getOrderHashHexAsync(signedOrder);
const unavailableTakerAmount = await this.getUnavailableTakerAmountAsync(orderHashHex);
const remainingTakerAmount = signedOrder.takerTokenAmount.minus(unavailableTakerAmount);
if (remainingTakerAmount < fillTakerAmount) {
@@ -209,28 +209,19 @@ export class ExchangeWrapper extends ContractWrapper {
from: takerAddress,
},
);
- try {
- const response: ContractResponse = await exchangeInstance.fillOrKill(
- orderAddresses,
- orderValues,
- fillTakerAmount,
- signedOrder.ecSignature.v,
- signedOrder.ecSignature.r,
- signedOrder.ecSignature.s,
- {
- from: takerAddress,
- gas,
- },
- );
- this.throwErrorLogsAsErrors(response.logs);
- } catch (err) {
- // There is a potential race condition where when the cancellation is broadcasted, a sufficient
- // fillAmount is available, but by the time the transaction gets mined, it no longer is. Instead of
- // throwing an invalid jump exception, we would rather give the user a more helpful error message.
- if (_.includes(err, constants.INVALID_JUMP_IDENTIFIER)) {
- throw new Error(ExchangeContractErrs.INSUFFICIENT_REMAINING_FILL_AMOUNT);
- }
- }
+ const response: ContractResponse = await exchangeInstance.fillOrKill(
+ orderAddresses,
+ orderValues,
+ fillTakerAmount,
+ signedOrder.ecSignature.v,
+ signedOrder.ecSignature.r,
+ signedOrder.ecSignature.s,
+ {
+ from: takerAddress,
+ gas,
+ },
+ );
+ this.throwErrorLogsAsErrors(response.logs);
}
/**
* Cancel a given fill amount of an order. Cancellations are cumulative.
@@ -293,7 +284,6 @@ export class ExchangeWrapper extends ContractWrapper {
this.exchangeLogEventObjs.push(logEventObj);
}
private async getOrderHashHexAsync(order: Order|SignedOrder): Promise<string> {
- const [orderAddresses, orderValues] = ExchangeWrapper.getOrderAddressesAndValues(order);
const exchangeInstance = await this.getExchangeContractAsync();
const orderHashHex = utils.getOrderHashHex(order, exchangeInstance.address);
return orderHashHex;