aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js')
-rw-r--r--packages/0x.js/CHANGELOG.md221
-rw-r--r--packages/0x.js/package.json15
-rw-r--r--packages/0x.js/src/0x.ts2
-rw-r--r--packages/0x.js/src/contract.ts2
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts6
-rw-r--r--packages/0x.js/src/contract_wrappers/token_wrapper.ts2
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts2
-rw-r--r--packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts2
-rw-r--r--packages/0x.js/src/types.ts2
-rw-r--r--packages/0x.js/src/utils/abi_decoder.ts2
-rw-r--r--packages/0x.js/src/utils/assert.ts84
-rw-r--r--packages/0x.js/src/utils/order_state_utils.ts6
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts16
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts8
-rw-r--r--packages/0x.js/test/token_registry_wrapper_test.ts2
-rw-r--r--packages/0x.js/tslint.json2
16 files changed, 266 insertions, 108 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
new file mode 100644
index 000000000..b31e05923
--- /dev/null
+++ b/packages/0x.js/CHANGELOG.md
@@ -0,0 +1,221 @@
+# CHANGELOG
+
+v0.24.0 - _November 13, 2017_
+------------------------
+ * Standardise on Cancelled over Canceled
+ * Add missing `DecodedLogEvent` type to exported types
+
+v0.23.0 - _November 12, 2017_
+------------------------
+ * Fixed unhandled promise rejection error in subscribe methods (#209)
+ * Subscribe callbacks now receive an error object as their first argument
+
+v0.22.6 - _November 10, 2017_
+------------------------
+ * Add a timeout parameter to transaction awaiting (#206)
+
+v0.22.5 - _November 7, 2017_
+------------------------
+ * Re-publish v0.22.4 to fix publishing issue
+
+v0.22.4 - _October 25, 2017_
+------------------------
+ * Upgraded bignumber.js to a new version that ships with native typings
+
+v0.22.3 - _October 25, 2017_
+------------------------
+ * Fixed an issue with new version of testrpc and unlimited proxy allowance (#199)
+
+v0.22.2 - _October 24, 2017_
+------------------------
+ * Fixed rounding of maker fill amount and incorrect validation of partial fees (#197)
+
+v0.22.0 - _October 16, 2017_
+------------------------
+ * Started using `OrderFillRequest` interface instead of `OrderFillOrKillRequest` interface for `zeroEx.exchange.batchFillOrKill` (#187)
+ * Removed `OrderFillOrKillRequest` (#187)
+
+v0.21.4 - _October 13, 2017_
+------------------------
+ * Made 0x.js more type-safe by making `getLogsAsync` and `subscribe/subscribeAsync` generics parametrized with arg type (#194)
+
+v0.21.3 - _October 12, 2017_
+------------------------
+ * Fixed a bug causing order fills to throw `INSUFFICIENT_TAKER_ALLOWANCE` (#193)
+
+v0.21.2 - _October 11, 2017_
+------------------------
+ * Exported `ContractEventArg` as a public type (#190)
+
+v0.21.1 - _October 11, 2017_
+------------------------
+ * Fixed a bug in subscriptions (#189)
+
+v0.21.0 - _October 10, 2017_
+------------------------
+ * Complete rewrite of subscription logic (#182)
+ * Subscriptions no longer return historical logs. If you want them - use `getLogsAsync`
+ * Subscriptions now use [ethereumjs-blockstream](https://github.com/ethereumjs/ethereumjs-blockstream) under the hood
+ * Subscriptions correctly handle block re-orgs (forks)
+ * Subscriptions correctly backfill logs (connection problems)
+ * They no longer setup filters on the underlying nodes, so you can use them with infura without a filter Subprovider
+ * Removed `ContractEventEmitter` and added `LogEvent`
+ * Renamed `zeroEx.token.subscribeAsync` to `zeroEx.token.subscribe`
+ * Added `zeroEx.token.unsubscribe` and `zeroEx.exchange.unsubscribe`
+ * Renamed `zeroEx.exchange.stopWatchingAllEventsAsync` to `zeroEx.exhange.unsubscribeAll`
+ * Renamed `zeroEx.token.stopWatchingAllEventsAsync` to `zeroEx.token.unsubscribeAll`
+ * Fixed the batch fills validation by emulating all balance & proxy allowance changes (#185)
+
+v0.20.0 - _October 5, 2017_
+------------------------
+ * Add `zeroEx.token.getLogsAsync` (#178)
+ * Add `zeroEx.exchange.getLogsAsync` (#178)
+ * Fixed fees validation when one of the tokens transferred is ZRX (#181)
+
+v0.19.0 - _September 29, 2017_
+------------------------
+ * Made order validation optional (#172)
+ * Added Ropsten testnet support (#173)
+ * Fixed a bug causing awaitTransactionMinedAsync to DDos backend nodes (#175)
+
+v0.18.0 - _September 26, 2017_
+------------------------
+ * Added `zeroEx.exchange.validateOrderFillableOrThrowAsync` to simplify orderbook pruning (#170)
+
+v0.17.0 - _September 26, 2017_
+------------------------
+ * Made `zeroEx.exchange.getZRXTokenAddressAsync` public (#171)
+
+v0.16.0 - _September 20, 2017_
+------------------------
+ * Added the ability to specify custom contract addresses to be used with 0x.js (#165)
+ * ZeroExConfig.exchangeContractAddress
+ * ZeroExConfig.tokenRegistryContractAddress
+ * ZeroExConfig.etherTokenContractAddress
+ * Added `zeroEx.tokenRegistry.getContractAddressAsync` (#165)
+
+v0.15.0 - _September 8, 2017_
+------------------------
+ * Added the ability to specify a historical `blockNumber` at which to query the blockchain's state when calling a token or exchange method (#161)
+
+v0.14.2 - _September 7, 2017_
+------------------------
+ * Fixed an issue with bignumber.js types not found (#160)
+
+v0.14.1 - _September 7, 2017_
+------------------------
+ * Fixed an issue with Artifact type not found (#159)
+
+v0.14.0 - _September 6, 2017_
+------------------------
+ * Added `zeroEx.exchange.throwLogErrorsAsErrors` method to public interface (#157)
+ * Fixed an issue with overlapping async intervals in `zeroEx.awaitTransactionMinedAsync` (#157)
+ * Fixed an issue with log decoder returning `BigNumber`s as `strings` (#157)
+
+v0.13.0 - _September 6, 2017_
+------------------------
+ * Made all the functions submitting transactions to the network to immediately return transaction hash (#151)
+ * Added `zeroEx.awaitTransactionMinedAsync` (#151)
+ * Added `TransactionReceiptWithDecodedLogs`, `LogWithDecodedArgs`, `DecodedLogArgs` to public types (#151)
+ * Added signature validation to `validateFillOrderThrowIfInvalidAsync` (#152)
+
+v0.12.1 - _September 2, 2017_
+------------------------
+ * Added the support for web3@1.x.x provider (#142)
+ * Added the optional `zeroExConfig` parameter to the constructor of `ZeroEx` (#139)
+ * Added the ability to specify `gasPrice` when instantiating `ZeroEx` (#139)
+
+v0.11.0 - _August 24, 2017_
+------------------------
+ * Added `zeroEx.token.setUnlimitedProxyAllowanceAsync` (#137)
+ * Added `zeroEx.token.setUnlimitedAllowanceAsync` (#137)
+ * Added `zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS` (#137)
+
+v0.10.4 - _Aug 24, 2017_
+------------------------
+ * Fixed a bug where checksummed addresses were being pulled from artifacts and not lower-cased. (#135)
+
+v0.10.1 - _Aug 24, 2017_
+------------------------
+ * Added `zeroEx.exchange.validateFillOrderThrowIfInvalidAsync` (#128)
+ * Added `zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync` (#128)
+ * Added `zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync` (#128)
+ * Added `zeroEx.exchange.isRoundingErrorAsync` (#128)
+ * Added `zeroEx.proxy.getContractAddressAsync` (#130)
+ * Added `zeroEx.tokenRegistry.getTokenAddressesAsync` (#132)
+ * Added `zeroEx.tokenRegistry.getTokenAddressBySymbolIfExistsAsync` (#132)
+ * Added `zeroEx.tokenRegistry.getTokenAddressByNameIfExistsAsync` (#132)
+ * Added `zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync` (#132)
+ * Added `zeroEx.tokenRegistry.getTokenByNameIfExistsAsync` (#132)
+ * Added clear error message when checksummed address is passed to a public method (#124)
+ * Fixes the description of `shouldThrowOnInsufficientBalanceOrAllowance` in docs (#127)
+
+v0.9.3 - _Aug 22, 2017_
+------------------------
+ * Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
+
+v0.9.2 - _Aug 21, 2017_
+------------------------
+ * *This version was unpublished because of a publishing issue.*
+ * Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
+
+v0.9.1 - _Aug. 16, 2017_
+------------------------
+ * Fixed the bug causing `zeroEx.token.getBalanceAsync()` to fail if no addresses available (#120)
+
+v0.9.0 - _Jul. 26, 2017_
+------------------------
+ * Migrated to the new version of smart contracts (#101)
+ * Removed the ability to call methods on multiple authorized Exchange smart contracts (#106)
+ * Made `zeroEx.getOrderHashHex` a static method (#107)
+ * Cached `net_version` requests and invalidate the cache on calls to `setProvider` (#95)
+ * Renamed `zeroEx.exchange.batchCancelOrderAsync` to `zeroEx.exchange.batchCancelOrdersAsync`
+ * Renamed `zeroEx.exchange.batchFillOrderAsync` to `zeroEx.exchange.batchFillOrdersAsync`
+ * Updated to typescript v2.4 (#104)
+ * Fixed an issue with incorrect balance/allowance validation when ZRX is one of the tokens traded (#109)
+
+v0.8.0 - _Jul. 4, 2017_
+------------------------
+ * Added the ability to call methods on different authorized versions of the Exchange smart contract (#82)
+ * Updated contract artifacts to reflect latest changes to the smart contracts (0xproject/contracts#59)
+ * Added `zeroEx.proxy.isAuthorizedAsync` and `zeroEx.proxy.getAuthorizedAddressesAsync` (#89)
+ * Added `zeroEx.token.subscribeAsync` (#90)
+ * Made contract invalidation functions private (#90)
+ * `zeroEx.token.invalidateContractInstancesAsync`
+ * `zeroEx.exchange.invalidateContractInstancesAsync`
+ * `zeroEx.proxy.invalidateContractInstance`
+ * `zeroEx.tokenRegistry.invalidateContractInstance`
+ * Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance
+
+v0.7.1 - _Jun. 26, 2017_
+------------------------
+ * Added the ability to convert Ether to wrapped Ether tokens and back via `zeroEx.etherToken.depostAsync` and `zeroEx.etherToken.withdrawAsync` (#81)
+
+v0.7.0 - _Jun. 22, 2017_
+------------------------
+ * Added Kovan smart contract artifacts (#78)
+ * Started returning fillAmount from `fillOrderAsync` and `fillUpToAsync` (#72)
+ * Started returning cancelledAmount from `cancelOrderAsync` (#72)
+ * Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`
+
+v0.6.2 - _Jun. 21, 2017_
+------------------------
+ * Reduced bundle size
+ * Improved documentation
+
+v0.6.1 - _Jun. 19, 2017_
+------------------------
+ * Improved documentation
+
+v0.6.0 - _Jun. 19, 2017_
+------------------------
+ * Made `ZeroEx` class accept `Web3Provider` instance instead of `Web3` instance
+ * Added types for contract event arguments
+
+v0.5.2 - _Jun. 15, 2017_
+------------------------
+ * Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page
+
+v0.5.1 - _Jun. 15, 2017_
+------------------------
+ * Added `postpublish` script to publish to Github Releases with assets.
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 6e30df612..0204d723f 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -1,6 +1,6 @@
{
"name": "0x.js",
- "version": "0.23.0",
+ "version": "0.25.1",
"description": "A javascript library for interacting with the 0x protocol",
"keywords": [
"0x.js",
@@ -13,12 +13,13 @@
"types": "lib/src/index.d.ts",
"scripts": {
"prebuild": "npm run clean",
- "build": "run-p build:umd:prod build:commonjs",
+ "build": "run-p build:umd:prod build:commonjs; exit 0;",
"prepublishOnly": "run-p build",
"postpublish": "run-s release docs:json upload_docs_json",
"release": "publish-release --assets _bundles/index.js,_bundles/index.min.js --tag $(git describe --tags) --owner 0xProject --repo 0x.js",
"upload_docs_json": "aws s3 cp docs/index.json s3://0xjs-docs-jsons/$(git describe --tags).json --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type aplication/json",
"lint": "tslint src/**/*.ts test/**/*.ts",
+ "test:circleci": "run-s test:coverage report_test_coverage; if [ $CIRCLE_BRANCH = \"development\" ]; then yarn test:umd; fi",
"test": "run-s clean test:commonjs",
"test:umd": "./scripts/test_umd.sh",
"test:coverage": "nyc npm run test --all",
@@ -48,6 +49,7 @@
"node": ">=6.0.0"
},
"devDependencies": {
+ "@0xproject/tslint-config": "^0.1.0",
"@types/jsonschema": "^1.1.1",
"@types/lodash": "^4.14.64",
"@types/mocha": "^2.2.41",
@@ -75,8 +77,7 @@
"sinon": "^4.0.0",
"source-map-support": "^0.5.0",
"truffle-hdwallet-provider": "^0.0.3",
- "tslint": "~5.5.0",
- "tslint-config-0xproject": "^0.0.2",
+ "tslint": "5.8.0",
"typedoc": "~0.8.0",
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
@@ -86,8 +87,10 @@
"webpack": "^3.1.0"
},
"dependencies": {
- "0x-json-schemas": "^0.6.1",
- "bignumber.js": "^4.1.0",
+ "@0xproject/assert": "^0.0.4",
+ "@0xproject/json-schemas": "^0.6.7",
+ "bignumber.js": "~4.1.0",
+ "bn.js": "4.11.8",
"compare-versions": "^3.0.1",
"es6-promisify": "^5.0.0",
"ethereumjs-abi": "^0.6.4",
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index fe765bbbe..85c2b7724 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -1,6 +1,6 @@
import * as _ from 'lodash';
import BigNumber from 'bignumber.js';
-import {SchemaValidator, schemas} from '0x-json-schemas';
+import {SchemaValidator, schemas} from '@0xproject/json-schemas';
import {bigNumberConfigs} from './bignumber_config';
import * as ethUtil from 'ethereumjs-util';
import {Web3Wrapper} from './web3_wrapper';
diff --git a/packages/0x.js/src/contract.ts b/packages/0x.js/src/contract.ts
index 1aacc65dc..7ccd336d6 100644
--- a/packages/0x.js/src/contract.ts
+++ b/packages/0x.js/src/contract.ts
@@ -1,7 +1,7 @@
import * as Web3 from 'web3';
import * as _ from 'lodash';
import promisify = require('es6-promisify');
-import {SchemaValidator, schemas} from '0x-json-schemas';
+import {SchemaValidator, schemas} from '@0xproject/json-schemas';
import {AbiType} from './types';
export class Contract implements Web3.ContractInstance {
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 654637a38..3e631b73e 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -1,7 +1,7 @@
import * as _ from 'lodash';
import * as Web3 from 'web3';
import BigNumber from 'bignumber.js';
-import {schemas} from '0x-json-schemas';
+import {schemas} from '@0xproject/json-schemas';
import {Web3Wrapper} from '../web3_wrapper';
import {
ECSignature,
@@ -95,7 +95,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param orderHash The hex encoded orderHash for which you would like to retrieve the
* unavailable takerAmount.
* @param methodOpts Optional arguments this method accepts.
- * @return The amount of the order (in taker tokens) that has either been filled or canceled.
+ * @return The amount of the order (in taker tokens) that has either been filled or cancelled.
*/
public async getUnavailableTakerAmountAsync(orderHash: string,
methodOpts?: MethodOpts): Promise<BigNumber> {
@@ -133,7 +133,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param methodOpts Optional arguments this method accepts.
* @return The amount of the order (in taker tokens) that has been cancelled.
*/
- public async getCanceledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {
+ public async getCancelledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const exchangeContract = await this._getExchangeContractAsync();
diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
index 614ac19d4..4b89d3cfc 100644
--- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
@@ -1,6 +1,6 @@
import * as _ from 'lodash';
import BigNumber from 'bignumber.js';
-import {schemas} from '0x-json-schemas';
+import {schemas} from '@0xproject/json-schemas';
import {Web3Wrapper} from '../web3_wrapper';
import {assert} from '../utils/assert';
import {constants} from '../utils/constants';
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 2b9d7997e..bafd7a994 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -1,5 +1,5 @@
import * as _ from 'lodash';
-import {schemas} from '0x-json-schemas';
+import {schemas} from '@0xproject/json-schemas';
import {ZeroEx} from '../0x';
import {EventWatcher} from './event_watcher';
import {assert} from '../utils/assert';
diff --git a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
index 9d74da096..666d8363c 100644
--- a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
+++ b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
@@ -42,7 +42,7 @@ export class OrderFilledCancelledLazyStore {
const methodOpts = {
defaultBlock: BlockParamLiteral.Pending,
};
- const cancelledTakerAmount = await this.exchange.getCanceledTakerAmountAsync(orderHash, methodOpts);
+ const cancelledTakerAmount = await this.exchange.getCancelledTakerAmountAsync(orderHash, methodOpts);
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);
}
const cachedCancelled = this.cancelledTakerAmount[orderHash];
diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts
index da1971387..71089f9a1 100644
--- a/packages/0x.js/src/types.ts
+++ b/packages/0x.js/src/types.ts
@@ -488,7 +488,7 @@ export interface OrderRelevantState {
makerFeeBalance: BigNumber;
makerFeeProxyAllowance: BigNumber;
filledTakerTokenAmount: BigNumber;
- canceledTakerTokenAmount: BigNumber;
+ cancelledTakerTokenAmount: BigNumber;
remainingFillableMakerTokenAmount: BigNumber;
remainingFillableTakerTokenAmount: BigNumber;
}
diff --git a/packages/0x.js/src/utils/abi_decoder.ts b/packages/0x.js/src/utils/abi_decoder.ts
index 840ad9be0..df0fb2d6f 100644
--- a/packages/0x.js/src/utils/abi_decoder.ts
+++ b/packages/0x.js/src/utils/abi_decoder.ts
@@ -34,7 +34,7 @@ export class AbiDecoder {
value = this.padZeros(new BigNumber(value).toString(16));
} else if (param.type === SolidityTypes.Uint256 ||
param.type === SolidityTypes.Uint8 ||
- param.type === SolidityTypes.Uint ) {
+ param.type === SolidityTypes.Uint) {
value = new BigNumber(value);
}
decodedParams[param.name] = value;
diff --git a/packages/0x.js/src/utils/assert.ts b/packages/0x.js/src/utils/assert.ts
index e5c9439f3..63d975c03 100644
--- a/packages/0x.js/src/utils/assert.ts
+++ b/packages/0x.js/src/utils/assert.ts
@@ -1,66 +1,24 @@
import * as _ from 'lodash';
import * as Web3 from 'web3';
import BigNumber from 'bignumber.js';
-import {SchemaValidator, Schema} from '0x-json-schemas';
+import {SchemaValidator, Schema} from '@0xproject/json-schemas';
+import {assert as sharedAssert} from '@0xproject/assert';
import {Web3Wrapper} from '../web3_wrapper';
import {signatureUtils} from '../utils/signature_utils';
import {ECSignature} from '../types';
const HEX_REGEX = /^0x[0-9A-F]*$/i;
-export const assert = {
- isBigNumber(variableName: string, value: BigNumber): void {
- const isBigNumber = _.isObject(value) && (value as any).isBigNumber;
- this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value));
- },
- isValidBaseUnitAmount(variableName: string, value: BigNumber) {
- assert.isBigNumber(variableName, value);
- const hasDecimals = value.decimalPlaces() !== 0;
- this.assert(
- !hasDecimals, `${variableName} should be in baseUnits (no decimals), found value: ${value.toNumber()}`,
- );
- },
+export const assert = _.extend({}, sharedAssert, {
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
const isValidSignature = signatureUtils.isValidSignature(orderHash, ecSignature, signerAddress);
this.assert(isValidSignature, `Expected order with hash '${orderHash}' to have a valid signature`);
},
- isUndefined(value: any, variableName?: string): void {
- this.assert(_.isUndefined(value), this.typeAssertionMessage(variableName, 'undefined', value));
- },
- isString(variableName: string, value: string): void {
- this.assert(_.isString(value), this.typeAssertionMessage(variableName, 'string', value));
- },
- isFunction(variableName: string, value: any): void {
- this.assert(_.isFunction(value), this.typeAssertionMessage(variableName, 'function', value));
- },
- isHexString(variableName: string, value: string): void {
- this.assert(_.isString(value) && HEX_REGEX.test(value),
- this.typeAssertionMessage(variableName, 'HexString', value));
- },
- isETHAddressHex(variableName: string, value: string): void {
- const web3 = new Web3();
- this.assert(web3.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value));
- this.assert(
- web3.isAddress(value) && value.toLowerCase() === value,
- `Checksummed addresses are not supported. Convert ${variableName} to lower case before passing`,
- );
- },
- doesBelongToStringEnum(variableName: string, value: string,
- stringEnum: any /* There is no base type for every string enum */): void {
- const doesBelongToStringEnum = !_.isUndefined(stringEnum[value]);
- const enumValues = _.keys(stringEnum);
- const enumValuesAsStrings = _.map(enumValues, enumValue => `'${enumValue}'`);
- const enumValuesAsString = enumValuesAsStrings.join(', ');
- assert.assert(
- doesBelongToStringEnum,
- `Expected ${variableName} to be one of: ${enumValuesAsString}, encountered: ${value}`,
- );
- },
async isSenderAddressAsync(variableName: string, senderAddressHex: string,
web3Wrapper: Web3Wrapper): Promise<void> {
- assert.isETHAddressHex(variableName, senderAddressHex);
+ sharedAssert.isETHAddressHex(variableName, senderAddressHex);
const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex);
- assert.assert(isSenderAddressAvailable,
+ sharedAssert.assert(isSenderAddressAvailable,
`Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
);
},
@@ -68,34 +26,4 @@ export const assert = {
const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
this.assert(!_.isEmpty(availableAddresses), 'No addresses were available on the provided web3 provider');
},
- hasAtMostOneUniqueValue(value: any[], errMsg: string): void {
- this.assert(_.uniq(value).length <= 1, errMsg);
- },
- isNumber(variableName: string, value: number): void {
- this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value));
- },
- isBoolean(variableName: string, value: boolean): void {
- this.assert(_.isBoolean(value), this.typeAssertionMessage(variableName, 'boolean', value));
- },
- isWeb3Provider(variableName: string, value: Web3.Provider): void {
- const isWeb3Provider = _.isFunction((value as any).send) || _.isFunction((value as any).sendAsync);
- this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Web3.Provider', value));
- },
- doesConformToSchema(variableName: string, value: any, schema: Schema): void {
- const schemaValidator = new SchemaValidator();
- const validationResult = schemaValidator.validate(value, schema);
- const hasValidationErrors = validationResult.errors.length > 0;
- const msg = `Expected ${variableName} to conform to schema ${schema.id}
-Encountered: ${JSON.stringify(value, null, '\t')}
-Validation errors: ${validationResult.errors.join(', ')}`;
- this.assert(!hasValidationErrors, msg);
- },
- assert(condition: boolean, message: string): void {
- if (!condition) {
- throw new Error(message);
- }
- },
- typeAssertionMessage(variableName: string, type: string, value: any): string {
- return `Expected ${variableName} to be of type ${type}, encountered: ${value}`;
- },
-};
+});
diff --git a/packages/0x.js/src/utils/order_state_utils.ts b/packages/0x.js/src/utils/order_state_utils.ts
index af6392c81..123584f90 100644
--- a/packages/0x.js/src/utils/order_state_utils.ts
+++ b/packages/0x.js/src/utils/order_state_utils.ts
@@ -69,7 +69,7 @@ export class OrderStateUtils {
zrxTokenAddress, signedOrder.maker,
);
const filledTakerTokenAmount = await this.orderFilledCancelledLazyStore.getFilledTakerAmountAsync(orderHash);
- const canceledTakerTokenAmount = await this.orderFilledCancelledLazyStore.getCancelledTakerAmountAsync(
+ const cancelledTakerTokenAmount = await this.orderFilledCancelledLazyStore.getCancelledTakerAmountAsync(
orderHash,
);
const unavailableTakerTokenAmount = await exchange.getUnavailableTakerAmountAsync(orderHash);
@@ -90,14 +90,14 @@ export class OrderStateUtils {
makerFeeBalance,
makerFeeProxyAllowance,
filledTakerTokenAmount,
- canceledTakerTokenAmount,
+ cancelledTakerTokenAmount,
remainingFillableMakerTokenAmount,
remainingFillableTakerTokenAmount,
};
return orderRelevantState;
}
private validateIfOrderIsValid(signedOrder: SignedOrder, orderRelevantState: OrderRelevantState): void {
- const unavailableTakerTokenAmount = orderRelevantState.canceledTakerTokenAmount.add(
+ const unavailableTakerTokenAmount = orderRelevantState.cancelledTakerTokenAmount.add(
orderRelevantState.filledTakerTokenAmount,
);
const availableTakerTokenAmount = signedOrder.takerTokenAmount.minus(unavailableTakerTokenAmount);
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts
index 26b8c1e0e..add89a3b2 100644
--- a/packages/0x.js/test/exchange_wrapper_test.ts
+++ b/packages/0x.js/test/exchange_wrapper_test.ts
@@ -443,7 +443,7 @@ describe('ExchangeWrapper', () => {
it('should cancel an order', async () => {
const txHash = await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount);
await zeroEx.awaitTransactionMinedAsync(txHash);
- const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex);
+ const cancelledAmount = await zeroEx.exchange.getCancelledTakerAmountAsync(orderHashHex);
expect(cancelledAmount).to.be.bignumber.equal(cancelAmount);
});
});
@@ -502,8 +502,8 @@ describe('ExchangeWrapper', () => {
describe('successful batch cancels', () => {
it('should cancel a batch of orders', async () => {
await zeroEx.exchange.batchCancelOrdersAsync(cancelBatch);
- const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex);
- const anotherCancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(
+ const cancelledAmount = await zeroEx.exchange.getCancelledTakerAmountAsync(orderHashHex);
+ const anotherCancelledAmount = await zeroEx.exchange.getCancelledTakerAmountAsync(
anotherOrderHashHex,
);
expect(cancelledAmount).to.be.bignumber.equal(cancelAmount);
@@ -592,23 +592,23 @@ describe('ExchangeWrapper', () => {
expect(filledValueT).to.be.bignumber.equal(partialFillAmount);
});
});
- describe('#getCanceledTakerAmountAsync', () => {
+ describe('#getCancelledTakerAmountAsync', () => {
it('should throw if passed an invalid orderHash', async () => {
const invalidOrderHashHex = '0x123';
- return expect(zeroEx.exchange.getCanceledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
+ return expect(zeroEx.exchange.getCancelledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
});
it('should return zero if passed a valid but non-existent orderHash', async () => {
- const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(NON_EXISTENT_ORDER_HASH);
+ const cancelledValueT = await zeroEx.exchange.getCancelledTakerAmountAsync(NON_EXISTENT_ORDER_HASH);
expect(cancelledValueT).to.be.bignumber.equal(0);
});
it('should return the cancelledValueT for a valid and partially filled orderHash', async () => {
- const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash);
+ const cancelledValueT = await zeroEx.exchange.getCancelledTakerAmountAsync(orderHash);
expect(cancelledValueT).to.be.bignumber.equal(0);
});
it('should return the cancelledValueT for a valid and cancelled orderHash', async () => {
const cancelAmount = fillableAmount.minus(partialFillAmount);
await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount);
- const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash);
+ const cancelledValueT = await zeroEx.exchange.getCancelledTakerAmountAsync(orderHash);
expect(cancelledValueT).to.be.bignumber.equal(cancelAmount);
});
});
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts
index 03b1f36a4..a112bac1d 100644
--- a/packages/0x.js/test/order_state_watcher_test.ts
+++ b/packages/0x.js/test/order_state_watcher_test.ts
@@ -61,6 +61,12 @@ describe('OrderStateWatcher', () => {
[makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
web3Wrapper = (zeroEx as any)._web3Wrapper;
});
+ beforeEach(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ afterEach(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
describe('#removeOrder', async () => {
it('should successfully remove existing order', async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
@@ -377,7 +383,7 @@ describe('OrderStateWatcher', () => {
const validOrderState = orderState as OrderStateValid;
expect(validOrderState.orderHash).to.be.equal(orderHash);
const orderRelevantState = validOrderState.orderRelevantState;
- expect(orderRelevantState.canceledTakerTokenAmount).to.be.bignumber.equal(cancelAmountInBaseUnits);
+ expect(orderRelevantState.cancelledTakerTokenAmount).to.be.bignumber.equal(cancelAmountInBaseUnits);
done();
});
zeroEx.orderStateWatcher.subscribe(callback);
diff --git a/packages/0x.js/test/token_registry_wrapper_test.ts b/packages/0x.js/test/token_registry_wrapper_test.ts
index 6b5dd517e..d3497451b 100644
--- a/packages/0x.js/test/token_registry_wrapper_test.ts
+++ b/packages/0x.js/test/token_registry_wrapper_test.ts
@@ -1,7 +1,7 @@
import * as _ from 'lodash';
import 'mocha';
import * as chai from 'chai';
-import {SchemaValidator, schemas} from '0x-json-schemas';
+import {SchemaValidator, schemas} from '@0xproject/json-schemas';
import {chaiSetup} from './utils/chai_setup';
import {web3Factory} from './utils/web3_factory';
import {ZeroEx, Token} from '../src';
diff --git a/packages/0x.js/tslint.json b/packages/0x.js/tslint.json
index 5842a872a..a07795151 100644
--- a/packages/0x.js/tslint.json
+++ b/packages/0x.js/tslint.json
@@ -1,5 +1,5 @@
{
"extends": [
- "tslint-config-0xproject"
+ "@0xproject/tslint-config"
]
}