aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-24 02:18:31 +0800
committerGitHub <noreply@github.com>2018-03-24 02:18:31 +0800
commitf30353087f9c4ec4fa5e096a065c9749e1164984 (patch)
tree4d7968160890b5efa358593e743411c7b8652556 /packages/0x.js
parent7ef6bd4b14b7502617c6929010d4a9991e1d577d (diff)
parentbed7d87b7ff64989051e6b2115a1c77e1e72ff55 (diff)
downloaddexon-0x-contracts-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.gz
dexon-0x-contracts-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.zst
dexon-0x-contracts-f30353087f9c4ec4fa5e096a065c9749e1164984.zip
Merge branch 'development' into feature/deployer-improvements
Diffstat (limited to 'packages/0x.js')
-rw-r--r--packages/0x.js/CHANGELOG.md1
-rw-r--r--packages/0x.js/package.json15
-rw-r--r--packages/0x.js/src/0x.ts4
-rw-r--r--packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts4
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts5
-rw-r--r--packages/0x.js/src/contract_wrappers/token_wrapper.ts2
-rw-r--r--packages/0x.js/src/monorepo_scripts/stage_docs.ts (renamed from packages/0x.js/src/monorepo_scripts/stagedocs.ts)0
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts2
-rw-r--r--packages/0x.js/test/0x.js_test.ts6
-rw-r--r--packages/0x.js/test/ether_token_wrapper_test.ts2
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts13
11 files changed, 35 insertions, 19 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/package.json b/packages/0x.js/package.json
index d1374468c..5f5b32aac 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -15,8 +15,6 @@
"build:watch": "tsc -w",
"prebuild": "run-s clean generate_contract_wrappers",
"build": "run-p build:umd:prod build:commonjs; exit 0;",
- "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
- "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "run-s test:coverage",
@@ -28,7 +26,10 @@
"build:umd:prod": "NODE_ENV=production webpack",
"build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"test:commonjs": "run-s build:commonjs run_mocha",
- "run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit"
+ "run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit",
+ "docs:stage": "yarn build && node ./scripts/stage_docs.js",
+ "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
+ "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
},
"config": {
"artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken",
@@ -38,11 +39,9 @@
"packages/0x.js/_bundles/index.min.js"
],
"docPublishConfigs": {
- "extraFileIncludes": [
- "../types/src/index.ts"
- ],
- "s3BucketPath": "s3://0xjs-docs-jsons/",
- "s3StagingBucketPath": "s3://staging-0xjs-docs-jsons/"
+ "extraFileIncludes": ["../types/src/index.ts", "./src/contract_wrappers/generated/ether_token.ts", "./src/contract_wrappers/generated/token.ts", "./src/contract_wrappers/generated/exchange.ts"],
+ "s3BucketPath": "s3://doc-jsons/0x.js/",
+ "s3StagingBucketPath": "s3://staging-doc-jsons/0x.js/"
}
}
},
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index 09da4b046..0dd728ff1 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -83,7 +83,7 @@ export class ZeroEx {
}
/**
* Generates a pseudo-random 256-bit salt.
- * The salt can be included in an 0x order, ensuring that the order generates a unique orderHash
+ * The salt can be included in a 0x order, ensuring that the order generates a unique orderHash
* and will not collide with other outstanding orders that are identical in all other parameters.
* @return A pseudo-random 256-bit number that can be used as a salt.
*/
@@ -260,7 +260,7 @@ export class ZeroEx {
msgHashHex = ethUtil.bufferToHex(msgHashBuff);
}
- const signature = await this._web3Wrapper.signTransactionAsync(normalizedSignerAddress, msgHashHex);
+ const signature = await this._web3Wrapper.signMessageAsync(normalizedSignerAddress, msgHashHex);
// HACK: There is no consensus on whether the signatureHex string should be formatted as
// v + r + s OR r + s + v, and different clients (even different versions of the same client)
diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
index 42f8213a2..4a4da116b 100644
--- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
@@ -64,7 +64,7 @@ export class EtherTokenWrapper extends ContractWrapper {
* equivalent number of wrapped ETH tokens.
* @param etherTokenAddress EtherToken address you wish to withdraw from.
* @param amountInWei Amount of ETH in Wei the caller wishes to withdraw.
- * @param withdrawer The hex encoded user Ethereum address that would like to make the withdrawl.
+ * @param withdrawer The hex encoded user Ethereum address that would like to make the withdrawal.
* @param txOpts Transaction parameters.
* @return Transaction hash.
*/
@@ -96,7 +96,7 @@ export class EtherTokenWrapper extends ContractWrapper {
}
/**
* Gets historical logs without creating a subscription
- * @param etherTokenAddress An address of the ether token that emmited the logs.
+ * @param etherTokenAddress An address of the ether token that emitted the logs.
* @param eventName The ether token contract event you would like to subscribe to.
* @param blockRange Block range to get logs from.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 6414985e6..59bd4db6b 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;
+ }
}
}
@@ -857,7 +860,7 @@ export class ExchangeWrapper extends ContractWrapper {
return isRoundingError;
}
/**
- * Checks if logs contain LogError, which is emmited by Exchange contract on transaction failure.
+ * Checks if logs contain LogError, which is emitted by Exchange contract on transaction failure.
* @param logs Transaction logs as returned by `zeroEx.awaitTransactionMinedAsync`
*/
public throwLogErrorsAsErrors(logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>): void {
diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
index 0f688cb71..e350dfb92 100644
--- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
@@ -385,7 +385,7 @@ export class TokenWrapper extends ContractWrapper {
}
/**
* Gets historical logs without creating a subscription
- * @param tokenAddress An address of the token that emmited the logs.
+ * @param tokenAddress An address of the token that emitted the logs.
* @param eventName The token contract event you would like to subscribe to.
* @param blockRange Block range to get logs from.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
diff --git a/packages/0x.js/src/monorepo_scripts/stagedocs.ts b/packages/0x.js/src/monorepo_scripts/stage_docs.ts
index e732ac8eb..e732ac8eb 100644
--- a/packages/0x.js/src/monorepo_scripts/stagedocs.ts
+++ b/packages/0x.js/src/monorepo_scripts/stage_docs.ts
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts
index f7515e59e..9cccadb7f 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -59,7 +59,7 @@ const DEFAULT_CLEANUP_JOB_INTERVAL_MS = 1000 * 60 * 60; // 1h
/**
* This class includes all the functionality related to watching a set of orders
* for potential changes in order validity/fillability. The orderWatcher notifies
- * the subscriber of these changes so that a final decison can be made on whether
+ * the subscriber of these changes so that a final decision can be made on whether
* the order should be deemed invalid.
*/
export class OrderStateWatcher {
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index d1f601c92..d61847d1d 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -41,11 +41,11 @@ describe('ZeroEx library', () => {
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.be.undefined();
// Check that all nested web3 wrapper instances return the updated provider
- const nestedWeb3WrapperProvider = (zeroEx as any)._web3Wrapper.getCurrentProvider();
+ const nestedWeb3WrapperProvider = (zeroEx as any)._web3Wrapper.getProvider();
expect(nestedWeb3WrapperProvider.zeroExTestId).to.be.a('number');
- const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getCurrentProvider();
+ const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getProvider();
expect(exchangeWeb3WrapperProvider.zeroExTestId).to.be.a('number');
- const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any)._web3Wrapper.getCurrentProvider();
+ const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any)._web3Wrapper.getProvider();
expect(tokenRegistryWeb3WrapperProvider.zeroExTestId).to.be.a('number');
});
});
diff --git a/packages/0x.js/test/ether_token_wrapper_test.ts b/packages/0x.js/test/ether_token_wrapper_test.ts
index da6d95d07..6237ccf23 100644
--- a/packages/0x.js/test/ether_token_wrapper_test.ts
+++ b/packages/0x.js/test/ether_token_wrapper_test.ts
@@ -137,7 +137,7 @@ describe('EtherTokenWrapper', () => {
gasCost = expectedETHBalance.minus(postETHBalance);
expect(gasCost).to.be.bignumber.lte(MAX_REASONABLE_GAS_COST_IN_WEI);
});
- it('should throw if user has insufficient WETH balance for withdrawl', async () => {
+ it('should throw if user has insufficient WETH balance for withdrawal', async () => {
const preWETHBalance = await zeroEx.token.getBalanceAsync(wethContractAddress, addressWithETH);
expect(preWETHBalance).to.be.bignumber.equal(0);
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.