aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-09-26 17:01:33 +0800
committerFabio Berger <me@fabioberger.com>2017-09-26 17:01:33 +0800
commit5e92ca039c593028694a1453b39e55c127e96ba5 (patch)
treeb026864d4df60352af7a47d801ea5573d2a136cd /src/contract_wrappers
parent0a19a7e8d165a3df33e862d761492c9b4382ed24 (diff)
downloaddexon-sol-tools-5e92ca039c593028694a1453b39e55c127e96ba5.tar
dexon-sol-tools-5e92ca039c593028694a1453b39e55c127e96ba5.tar.gz
dexon-sol-tools-5e92ca039c593028694a1453b39e55c127e96ba5.tar.bz2
dexon-sol-tools-5e92ca039c593028694a1453b39e55c127e96ba5.tar.lz
dexon-sol-tools-5e92ca039c593028694a1453b39e55c127e96ba5.tar.xz
dexon-sol-tools-5e92ca039c593028694a1453b39e55c127e96ba5.tar.zst
dexon-sol-tools-5e92ca039c593028694a1453b39e55c127e96ba5.zip
Add validateOrderFillableThrowIfNotFillableAsync to public methods in order to validate orders in an orderbook without a specific taker in mind
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 54d7f62d5..b56431082 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -28,6 +28,7 @@ import {
LogCancelContractEventArgs,
LogWithDecodedArgs,
MethodOpts,
+ ValidateOrderFillableOpts,
} from '../types';
import {assert} from '../utils/assert';
import {utils} from '../utils/utils';
@@ -624,6 +625,24 @@ export class ExchangeWrapper extends ContractWrapper {
return exchangeAddress;
}
/**
+ * Checks if order is still fillable and throws an error otherwise.
+ * @param signedOrder An object that conforms to the SignedOrder interface. The
+ * signedOrder you wish to validate.
+ * @param opts An object that conforms to the ValidateOrderFillableOpts
+ * interface. Allows specifying a specific fillTakerTokenAmount
+ * to validate for.
+ */
+ public async validateOrderFillableThrowIfNotFillableAsync(
+ signedOrder: SignedOrder, opts: ValidateOrderFillableOpts,
+ ): Promise<void> {
+ assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
+ const zrxTokenAddress = await this._getZRXTokenAddressAsync();
+ const expectedFillTakerTokenAmount = !_.isUndefined(opts) ? opts.expectedFillTakerTokenAmount : undefined;
+ await this._orderValidationUtils.validateOrderFillableThrowIfNotFillableAsync(
+ signedOrder, zrxTokenAddress, expectedFillTakerTokenAmount,
+ );
+ }
+ /**
* Checks if order fill will succeed and throws an error otherwise.
* @param signedOrder An object that conforms to the SignedOrder interface. The
* signedOrder you wish to fill.