diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-08 17:00:36 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-08 17:00:36 +0800 |
commit | 5d464d87e07003c231fca55e87b95cc7e1e9e978 (patch) | |
tree | bb5fdc0219f1ee5ca848a9f92c135e4d9e8b1ce5 /src/contract_wrappers/exchange_wrapper.ts | |
parent | 01c33ef8b7929ae936fd4bb84bb5d3aee3e63e8d (diff) | |
download | dexon-0x-contracts-5d464d87e07003c231fca55e87b95cc7e1e9e978.tar.gz dexon-0x-contracts-5d464d87e07003c231fca55e87b95cc7e1e9e978.tar.zst dexon-0x-contracts-5d464d87e07003c231fca55e87b95cc7e1e9e978.zip |
Don't use batchFillOrderAsync for fillOrderAsync
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index a15df5a77..dffb9df13 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -134,10 +134,44 @@ export class ExchangeWrapper extends ContractWrapper { */ public async fillOrderAsync(signedOrder: SignedOrder, takerTokenFillAmount: BigNumber.BigNumber, shouldCheckTransfer: boolean, takerAddress: string): Promise<void> { - await this.batchFillOrderAsync([{ - signedOrder, + assert.doesConformToSchema('signedOrder', + SchemaValidator.convertToJSONSchemaCompatibleObject(signedOrder as object), + signedOrderSchema); + assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); + assert.isBoolean('shouldCheckTransfer', shouldCheckTransfer); + await assert.isSenderAddressAsync('takerAddress', takerAddress, this.web3Wrapper); + + const exchangeInstance = await this.getExchangeContractAsync(); + await this.validateFillOrderAndThrowIfInvalidAsync(signedOrder, takerTokenFillAmount, takerAddress); + + const [orderAddresses, orderValues] = ExchangeWrapper.getOrderAddressesAndValues(signedOrder); + + const gas = await exchangeInstance.fill.estimateGas( + orderAddresses, + orderValues, takerTokenFillAmount, - }], shouldCheckTransfer, takerAddress); + shouldCheckTransfer, + signedOrder.ecSignature.v, + signedOrder.ecSignature.r, + signedOrder.ecSignature.s, + { + from: takerAddress, + }, + ); + const response: ContractResponse = await exchangeInstance.fill( + orderAddresses, + orderValues, + takerTokenFillAmount, + shouldCheckTransfer, + signedOrder.ecSignature.v, + signedOrder.ecSignature.r, + signedOrder.ecSignature.s, + { + from: takerAddress, + gas, + }, + ); + this.throwErrorLogsAsErrors(response.logs); } /** * Batched version of fillOrderAsync. Executes fills atomically in a single transaction. |