Merge branch 'development' into feature/addJsonSchemas
* development: Improve description Alphabetize Add exit 0 to 0x.js build command Add snapshot save and revert to order_state_watcher_test.ts Fix changelog Use tslint v5.8.0 everywhere and use the tslint-config sub-package instead of the old repo as a dep. in the rest of the sub-packages. Add tslint-config sub-package Fix tslint issue Public interface has changed, moved to minor version Update changelog Renamed canceled to cancelled
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
# CHANGELOG
|
||||
|
||||
v0.24.0 - _November 13, 2017_
|
||||
------------------------
|
||||
* Standardise on Cancelled over Canceled
|
||||
|
||||
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)
|
||||
|
@@ -13,7 +13,7 @@
|
||||
"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",
|
||||
@@ -76,20 +76,20 @@
|
||||
"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",
|
||||
"typedoc": "~0.8.0",
|
||||
"types-bn": "^0.0.1",
|
||||
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
|
||||
"typescript": "~2.6.1",
|
||||
"web3-provider-engine": "^13.0.1",
|
||||
"web3-typescript-typings": "^0.7.1",
|
||||
"webpack": "^3.1.0"
|
||||
"webpack": "^3.1.0",
|
||||
"@0xproject/tslint-config": "0.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "0.0.3",
|
||||
"@0xproject/json-schemas": "0.6.6",
|
||||
"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",
|
||||
@@ -99,6 +99,7 @@
|
||||
"js-sha3": "^0.6.1",
|
||||
"lodash": "^4.17.4",
|
||||
"publish-release": "^1.3.3",
|
||||
"tslint": "5.8.0",
|
||||
"uuid": "^3.1.0",
|
||||
"web3": "^0.20.0"
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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];
|
||||
|
@@ -488,7 +488,7 @@ export interface OrderRelevantState {
|
||||
makerFeeBalance: BigNumber;
|
||||
makerFeeProxyAllowance: BigNumber;
|
||||
filledTakerTokenAmount: BigNumber;
|
||||
canceledTakerTokenAmount: BigNumber;
|
||||
cancelledTakerTokenAmount: BigNumber;
|
||||
remainingFillableMakerTokenAmount: BigNumber;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -67,7 +67,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);
|
||||
@@ -85,13 +85,13 @@ export class OrderStateUtils {
|
||||
makerFeeBalance,
|
||||
makerFeeProxyAllowance,
|
||||
filledTakerTokenAmount,
|
||||
canceledTakerTokenAmount,
|
||||
cancelledTakerTokenAmount,
|
||||
remainingFillableMakerTokenAmount,
|
||||
};
|
||||
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);
|
||||
|
@@ -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);
|
||||
});
|
||||
});
|
||||
|
@@ -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(
|
||||
@@ -345,7 +351,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);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": [
|
||||
"tslint-config-0xproject"
|
||||
"@0xproject/tslint-config"
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user