aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-06-11 19:50:59 +0800
committerGitHub <noreply@github.com>2017-06-11 19:50:59 +0800
commitbbe9a811fb28417377ec3d089e0cdd3693480c35 (patch)
tree0813864d3920321e64acadebdacfd1525ea4e998 /src/contract_wrappers
parent6b152edb985d836c91c6d816c03cc15e77be2c6e (diff)
parent4e56c299263cf6a3397a1d7b95fb92a8b61da3c0 (diff)
downloaddexon-sol-tools-bbe9a811fb28417377ec3d089e0cdd3693480c35.tar
dexon-sol-tools-bbe9a811fb28417377ec3d089e0cdd3693480c35.tar.gz
dexon-sol-tools-bbe9a811fb28417377ec3d089e0cdd3693480c35.tar.bz2
dexon-sol-tools-bbe9a811fb28417377ec3d089e0cdd3693480c35.tar.lz
dexon-sol-tools-bbe9a811fb28417377ec3d089e0cdd3693480c35.tar.xz
dexon-sol-tools-bbe9a811fb28417377ec3d089e0cdd3693480c35.tar.zst
dexon-sol-tools-bbe9a811fb28417377ec3d089e0cdd3693480c35.zip
Merge branch 'master' into private
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 232d84789..a08901004 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -35,6 +35,7 @@ import {orderFillOrKillRequestsSchema} from '../schemas/order_fill_or_kill_reque
import {signedOrderSchema, orderSchema} from '../schemas/order_schemas';
import {constants} from '../utils/constants';
import {TokenWrapper} from './token_wrapper';
+import {decorators} from '../utils/decorators';
export class ExchangeWrapper extends ContractWrapper {
private _exchangeContractErrCodesToMsg = {
@@ -79,44 +80,44 @@ export class ExchangeWrapper extends ContractWrapper {
* Returns the unavailable takerAmount of an order. Unavailable amount is defined as the total
* amount that has been filled or cancelled. The remaining takerAmount can be calculated by
* subtracting the unavailable amount from the total order takerAmount.
- * @param orderHashHex The hex encoded orderHash for which you would like to retrieve the
- * unavailable takerAmount.
+ * @param orderHash The hex encoded orderHash for which you would like to retrieve the
+ * unavailable takerAmount.
* @return The amount of the order (in taker tokens) that has either been filled or canceled.
*/
- public async getUnavailableTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
- assert.isValidOrderHash('orderHashHex', orderHashHex);
+ public async getUnavailableTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHash', orderHash);
const exchangeContract = await this._getExchangeContractAsync();
- let unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHashHex);
+ let unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
unavailableAmountInBaseUnits = new BigNumber(unavailableAmountInBaseUnits);
return unavailableAmountInBaseUnits;
}
/**
* Retrieve the takerAmount of an order that has already been filled.
- * @param orderHashHex The hex encoded orderHash for which you would like to retrieve the filled takerAmount.
+ * @param orderHash The hex encoded orderHash for which you would like to retrieve the filled takerAmount.
* @return The amount of the order (in taker tokens) that has already been filled.
*/
- public async getFilledTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
- assert.isValidOrderHash('orderHashHex', orderHashHex);
+ public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHash', orderHash);
const exchangeContract = await this._getExchangeContractAsync();
- let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHashHex);
+ let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits);
return fillAmountInBaseUnits;
}
/**
* Retrieve the takerAmount of an order that has been cancelled.
- * @param orderHashHex The hex encoded orderHash for which you would like to retrieve the
- * cancelled takerAmount.
+ * @param orderHash The hex encoded orderHash for which you would like to retrieve the
+ * cancelled takerAmount.
* @return The amount of the order (in taker tokens) that has been cancelled.
*/
- public async getCanceledTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
- assert.isValidOrderHash('orderHashHex', orderHashHex);
+ public async getCanceledTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHash', orderHash);
const exchangeContract = await this._getExchangeContractAsync();
- let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHashHex);
+ let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits);
return cancelledAmountInBaseUnits;
@@ -135,6 +136,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Web3.Provider passed to 0x.js.
*/
+ @decorators.contractCallErrorHandler
public async fillOrderAsync(signedOrder: SignedOrder, takerTokenFillAmount: BigNumber.BigNumber,
shouldCheckTransfer: boolean, takerAddress: string): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, signedOrderSchema);
@@ -188,6 +190,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param takerAddress The user Ethereum address who would like to fill these orders.
* Must be available via the supplied Web3.Provider passed to 0x.js.
*/
+ @decorators.contractCallErrorHandler
public async fillOrdersUpToAsync(signedOrders: SignedOrder[], takerTokenFillAmount: BigNumber.BigNumber,
shouldCheckTransfer: boolean, takerAddress: string): Promise<void> {
const takerTokenAddresses = _.map(signedOrders, signedOrder => signedOrder.takerTokenAddress);
@@ -259,6 +262,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param takerAddress The user Ethereum address who would like to fill these orders.
* Must be available via the supplied Web3.Provider passed to 0x.js.
*/
+ @decorators.contractCallErrorHandler
public async batchFillOrderAsync(orderFillRequests: OrderFillRequest[],
shouldCheckTransfer: boolean, takerAddress: string): Promise<void> {
assert.isBoolean('shouldCheckTransfer', shouldCheckTransfer);
@@ -323,6 +327,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Web3.Provider passed to 0x.js.
*/
+ @decorators.contractCallErrorHandler
public async fillOrKillOrderAsync(signedOrder: SignedOrder, takerTokenFillAmount: BigNumber.BigNumber,
takerAddress: string): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, signedOrderSchema);
@@ -369,6 +374,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param takerAddress The user Ethereum address who would like to fill there orders.
* Must be available via the supplied Web3.Provider passed to 0x.js.
*/
+ @decorators.contractCallErrorHandler
public async batchFillOrKillAsync(orderFillOrKillRequests: OrderFillOrKillRequest[],
takerAddress: string): Promise<void> {
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
@@ -424,6 +430,7 @@ export class ExchangeWrapper extends ContractWrapper {
* The order you would like to cancel.
* @param takerTokenCancelAmount The amount (specified in taker tokens) that you would like to cancel.
*/
+ @decorators.contractCallErrorHandler
public async cancelOrderAsync(
order: Order|SignedOrder, takerTokenCancelAmount: BigNumber.BigNumber): Promise<void> {
assert.doesConformToSchema('order', order, orderSchema);
@@ -459,6 +466,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param orderCancellationRequests An array of JS objects that conform to the OrderCancellationRequest
* interface.
*/
+ @decorators.contractCallErrorHandler
public async batchCancelOrderAsync(orderCancellationRequests: OrderCancellationRequest[]): Promise<void> {
const makers = _.map(orderCancellationRequests, cancellationRequest => cancellationRequest.order.maker);
assert.hasAtMostOneUniqueValue(makers, ExchangeContractErrs.MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH_DISALLOWED);