From 7cbd408c24cf87755dca10d6dbcb5f4e99d6be17 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 7 Jul 2017 15:47:12 -0700 Subject: Migrate batchFillOrders --- src/artifacts/exchange/Exchange_v1.json | 6 +++--- src/contract_wrappers/exchange_wrapper.ts | 36 +++++++++++++++++-------------- src/types.ts | 13 ++++++----- 3 files changed, 31 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/artifacts/exchange/Exchange_v1.json b/src/artifacts/exchange/Exchange_v1.json index 8a724a2de..106dc70a1 100644 --- a/src/artifacts/exchange/Exchange_v1.json +++ b/src/artifacts/exchange/Exchange_v1.json @@ -271,11 +271,11 @@ "type": "uint256[6][]" }, { - "name": "fillValuesT", + "name": "fillTakerTokenAmounts", "type": "uint256[]" }, { - "name": "shouldCheckTransfer", + "name": "shouldThrowOnInsufficientBalanceOrAllowance", "type": "bool" }, { @@ -291,7 +291,7 @@ "type": "bytes32[]" } ], - "name": "batchFill", + "name": "batchFillOrders", "outputs": [ { "name": "success", diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 95420cbff..686208995 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -292,17 +292,21 @@ export class ExchangeWrapper extends ContractWrapper { * Executes multiple fills atomically in a single transaction. * If shouldCheckTransfer is set to true, it will continue filling subsequent orders even when earlier ones fail. * When shouldCheckTransfer is set to false, if any fill fails, the entire batch fails. - * @param orderFillRequests An array of objects that conform to the OrderFillRequest interface. - * @param shouldCheckTransfer Whether or not you wish for the contract call to throw if upon - * execution any of the tokens cannot be transferred. If set to false, - * the call will continue to fill subsequent signedOrders even when some - * cannot be filled. - * @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. + * @param orderFillRequests An array of objects that conform to the + * OrderFillRequest interface. + * @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw + * if upon execution any of the tokens cannot be + * transferred. If set to false, the call will continue to + * fill subsequent signedOrders even when some + * cannot be filled. + * @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 batchFillOrdersAsync(orderFillRequests: OrderFillRequest[], - shouldCheckTransfer: boolean, takerAddress: string): Promise { + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + takerAddress: string): Promise { assert.doesConformToSchema('orderFillRequests', orderFillRequests, orderFillRequestsSchema); const exchangeContractAddresses = _.map( orderFillRequests, @@ -310,7 +314,7 @@ export class ExchangeWrapper extends ContractWrapper { ); assert.hasAtMostOneUniqueValue(exchangeContractAddresses, ExchangeContractErrs.BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS); - assert.isBoolean('shouldCheckTransfer', shouldCheckTransfer); + assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); for (const orderFillRequest of orderFillRequests) { await this._validateFillOrderAndThrowIfInvalidAsync( @@ -330,16 +334,16 @@ export class ExchangeWrapper extends ContractWrapper { ]; }); // We use _.unzip because _.unzip doesn't type check if values have different types :'( - const [orderAddressesArray, orderValuesArray, takerTokenFillAmountArray, vArray, rArray, sArray] = _.unzip( + const [orderAddressesArray, orderValuesArray, fillTakerTokenAmounts, vArray, rArray, sArray] = _.unzip( orderAddressesValuesAmountsAndSignatureArray, ); const exchangeInstance = await this._getExchangeContractAsync(exchangeContractAddresses[0]); - const gas = await exchangeInstance.batchFill.estimateGas( + const gas = await exchangeInstance.batchFillOrders.estimateGas( orderAddressesArray, orderValuesArray, - takerTokenFillAmountArray, - shouldCheckTransfer, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, vArray, rArray, sArray, @@ -347,11 +351,11 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const response: ContractResponse = await exchangeInstance.batchFill( + const response: ContractResponse = await exchangeInstance.batchFillOrders( orderAddressesArray, orderValuesArray, - takerTokenFillAmountArray, - shouldCheckTransfer, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, vArray, rArray, sArray, diff --git a/src/types.ts b/src/types.ts index bf5a0281a..b854aac66 100644 --- a/src/types.ts +++ b/src/types.ts @@ -80,11 +80,14 @@ export interface ExchangeContract extends ContractInstance { shouldThrowOnInsufficientBalanceOrAllowance: boolean, v: number, r: string, s: string, txOpts?: TxOpts) => number; }; - batchFill: { - (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillAmounts: BigNumber.BigNumber[], - shouldCheckTransfer: boolean, v: number[], r: string[], s: string[], txOpts?: TxOpts): ContractResponse; - estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillAmounts: BigNumber.BigNumber[], - shouldCheckTransfer: boolean, v: number[], r: string[], s: string[], txOpts?: TxOpts) => number; + batchFillOrders: { + (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmounts: BigNumber.BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number[], r: string[], s: string[], txOpts?: TxOpts): ContractResponse; + estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + fillTakerTokenAmounts: BigNumber.BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number[], r: string[], s: string[], txOpts?: TxOpts) => number; }; fillOrdersUpTo: { (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmount: BigNumber.BigNumber, -- cgit v1.2.3