aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-21 22:30:26 +0800
committerGitHub <noreply@github.com>2018-03-21 22:30:26 +0800
commit8d01956c3ec7e580284091c91f7be2c0b0081695 (patch)
tree33b95a07fb78332a065dd5b55fbd72aeb7f5e8dc
parent7d9c357409c25996f9c448dffd69007f69b9d8d6 (diff)
parent1dda8c146816a6b7fe1ab17a437a4349dece674c (diff)
downloaddexon-sol-tools-8d01956c3ec7e580284091c91f7be2c0b0081695.tar
dexon-sol-tools-8d01956c3ec7e580284091c91f7be2c0b0081695.tar.gz
dexon-sol-tools-8d01956c3ec7e580284091c91f7be2c0b0081695.tar.bz2
dexon-sol-tools-8d01956c3ec7e580284091c91f7be2c0b0081695.tar.lz
dexon-sol-tools-8d01956c3ec7e580284091c91f7be2c0b0081695.tar.xz
dexon-sol-tools-8d01956c3ec7e580284091c91f7be2c0b0081695.tar.zst
dexon-sol-tools-8d01956c3ec7e580284091c91f7be2c0b0081695.zip
Merge pull request #470 from 0xProject/fix/fillOrdersUpToValidation
Fix a bug causing fillOrdersUpTo validation to fail because of some e…
-rw-r--r--packages/0x.js/CHANGELOG.md1
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts3
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts13
3 files changed, 17 insertions, 0 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index 7ce7126cb..fa3b3db91 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -3,6 +3,7 @@
## v0.34.0 - _TBD_
* Update Kovan EtherToken artifact address to match TokenRegistry.
+ * Fix the bug causing `zeroEx.exchange.fillOrdersUpToAsync` validation to fail if there were some extra orders passed (#470)
## v0.33.2 - _March 18, 2018_
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 6414985e6..124750d81 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -281,6 +281,9 @@ export class ExchangeWrapper extends ContractWrapper {
zrxTokenAddress,
);
filledTakerTokenAmount = filledTakerTokenAmount.plus(singleFilledTakerTokenAmount);
+ if (filledTakerTokenAmount.eq(fillTakerTokenAmount)) {
+ break;
+ }
}
}
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts
index 0a4ea608d..cfc390bae 100644
--- a/packages/0x.js/test/exchange_wrapper_test.ts
+++ b/packages/0x.js/test/exchange_wrapper_test.ts
@@ -596,6 +596,19 @@ describe('ExchangeWrapper', () => {
const remainingFillAmount = fillableAmount.minus(1);
expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount);
});
+ it('should successfully fill up to specified amount and leave the rest of the orders untouched', async () => {
+ const txHash = await zeroEx.exchange.fillOrdersUpToAsync(
+ signedOrders,
+ fillableAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ );
+ await zeroEx.awaitTransactionMinedAsync(txHash);
+ const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex);
+ const zeroAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex);
+ expect(filledAmount).to.be.bignumber.equal(fillableAmount);
+ expect(zeroAmount).to.be.bignumber.equal(0);
+ });
it('should successfully fill up to specified amount even if filling all orders would fail', async () => {
const missingBalance = new BigNumber(1); // User will still have enough balance to fill up to 9,
// but won't have 10 to fully fill all orders in a batch.