diff options
author | Assaf <apackin@gmail.com> | 2017-10-11 07:52:43 +0800 |
---|---|---|
committer | Assaf <apackin@gmail.com> | 2017-10-11 07:52:43 +0800 |
commit | c8b54f3bac33f28c315c7018b3185f59e9a474dc (patch) | |
tree | a829bd9b51b7284ea97e9c2a2f5f1efe43302cb5 /src/contract_wrappers | |
parent | 233f97891c4e9fa88c339a29bd2ebc12096dbccb (diff) | |
download | dexon-sol-tools-c8b54f3bac33f28c315c7018b3185f59e9a474dc.tar dexon-sol-tools-c8b54f3bac33f28c315c7018b3185f59e9a474dc.tar.gz dexon-sol-tools-c8b54f3bac33f28c315c7018b3185f59e9a474dc.tar.bz2 dexon-sol-tools-c8b54f3bac33f28c315c7018b3185f59e9a474dc.tar.lz dexon-sol-tools-c8b54f3bac33f28c315c7018b3185f59e9a474dc.tar.xz dexon-sol-tools-c8b54f3bac33f28c315c7018b3185f59e9a474dc.tar.zst dexon-sol-tools-c8b54f3bac33f28c315c7018b3185f59e9a474dc.zip |
Use OrderFillRequest interface for batchFillOrKill
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 9e4936de6..e7b4a437f 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -11,7 +11,6 @@ import { OrderValues, OrderAddresses, Order, - OrderFillOrKillRequest, SignedOrder, ContractEvent, ExchangeEvents, @@ -452,26 +451,26 @@ export class ExchangeWrapper extends ContractWrapper { /** * Batch version of fillOrKill. Allows a taker to specify a batch of orders that will either be atomically * filled (each to the specified fillAmount) or aborted. - * @param orderFillOrKillRequests An array of objects that conform to the OrderFillOrKillRequest interface. + * @param orderFillRequests An array of objects that conform to the OrderFillRequest interface. * @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. * @param orderTransactionOpts Optional arguments this method accepts. * @return Transaction hash. */ @decorators.contractCallErrorHandler - public async batchFillOrKillAsync(orderFillOrKillRequests: OrderFillOrKillRequest[], + public async batchFillOrKillAsync(orderFillRequests: OrderFillRequest[], takerAddress: string, orderTransactionOpts?: OrderTransactionOpts): Promise<string> { - assert.doesConformToSchema('orderFillOrKillRequests', orderFillOrKillRequests, - schemas.orderFillOrKillRequestsSchema); + assert.doesConformToSchema('orderFillRequests', orderFillRequests, + schemas.orderFillRequestsSchema); const exchangeContractAddresses = _.map( - orderFillOrKillRequests, - orderFillOrKillRequest => orderFillOrKillRequest.signedOrder.exchangeContractAddress, + orderFillRequests, + orderFillRequest => orderFillRequest.signedOrder.exchangeContractAddress, ); assert.hasAtMostOneUniqueValue(exchangeContractAddresses, ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); - if (_.isEmpty(orderFillOrKillRequests)) { + if (_.isEmpty(orderFillRequests)) { throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem); } const exchangeInstance = await this._getExchangeContractAsync(); @@ -482,18 +481,18 @@ export class ExchangeWrapper extends ContractWrapper { if (shouldValidate) { const zrxTokenAddress = await this.getZRXTokenAddressAsync(); const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper); - for (const orderFillOrKillRequest of orderFillOrKillRequests) { + for (const orderFillRequest of orderFillRequests) { await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync( - exchangeTradeEmulator, orderFillOrKillRequest.signedOrder, orderFillOrKillRequest.fillTakerAmount, + exchangeTradeEmulator, orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount, takerAddress, zrxTokenAddress, ); } } - const orderAddressesValuesAndTakerTokenFillAmounts = _.map(orderFillOrKillRequests, request => { + const orderAddressesValuesAndTakerTokenFillAmounts = _.map(orderFillRequests, request => { return [ ...ExchangeWrapper._getOrderAddressesAndValues(request.signedOrder), - request.fillTakerAmount, + request.takerTokenFillAmount, request.signedOrder.ecSignature.v, request.signedOrder.ecSignature.r, request.signedOrder.ecSignature.s, |