diff options
-rw-r--r-- | src/artifacts/exchange/Exchange_v1.json | 30 | ||||
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 27 | ||||
-rw-r--r-- | src/types.ts | 13 |
3 files changed, 26 insertions, 44 deletions
diff --git a/src/artifacts/exchange/Exchange_v1.json b/src/artifacts/exchange/Exchange_v1.json index 6dccff2cb..3962a62a3 100644 --- a/src/artifacts/exchange/Exchange_v1.json +++ b/src/artifacts/exchange/Exchange_v1.json @@ -153,11 +153,11 @@ "type": "uint256[6][]" }, { - "name": "fillValueT", + "name": "fillTakerTokenAmount", "type": "uint256" }, { - "name": "shouldCheckTransfer", + "name": "shouldThrowOnInsufficientBalanceOrAllowance", "type": "bool" }, { @@ -173,32 +173,10 @@ "type": "bytes32[]" } ], - "name": "fillUpTo", - "outputs": [ - { - "name": "filledValueT", - "type": "uint256" - } - ], - "payable": false, - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "a", - "type": "uint256" - }, - { - "name": "b", - "type": "uint256" - } - ], - "name": "min", + "name": "fillOrdersUpTo", "outputs": [ { - "name": "min", + "name": "filledTakerTokenAmount", "type": "uint256" } ], diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 32dfc29cc..861d9cf2c 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -207,7 +207,7 @@ export class ExchangeWrapper extends ContractWrapper { * If fill amount is not reached - it fills as much of the fill amount as possible and succeeds. * @param signedOrders The array of signedOrders that you would like to fill until * takerTokenFillAmount is reached. - * @param takerTokenFillAmount The total amount of the takerTokens you would like to fill. + * @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill. * @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 @@ -217,8 +217,9 @@ export class ExchangeWrapper extends ContractWrapper { * @return The amount of the orders that was filled (in taker token baseUnits). */ @decorators.contractCallErrorHandler - public async fillOrdersUpToAsync(signedOrders: SignedOrder[], takerTokenFillAmount: BigNumber.BigNumber, - shouldCheckTransfer: boolean, takerAddress: string): Promise<BigNumber.BigNumber> { + public async fillOrdersUpToAsync(signedOrders: SignedOrder[], fillTakerTokenAmount: BigNumber.BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + takerAddress: string): Promise<BigNumber.BigNumber> { assert.doesConformToSchema('signedOrders', signedOrders, signedOrdersSchema); const takerTokenAddresses = _.map(signedOrders, signedOrder => signedOrder.takerTokenAddress); assert.hasAtMostOneUniqueValue(takerTokenAddresses, @@ -226,12 +227,12 @@ export class ExchangeWrapper extends ContractWrapper { const exchangeContractAddresses = _.map(signedOrders, signedOrder => signedOrder.exchangeContractAddress); assert.hasAtMostOneUniqueValue(exchangeContractAddresses, ExchangeContractErrs.BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS); - assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); - assert.isBoolean('shouldCheckTransfer', shouldCheckTransfer); + assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount); + assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); for (const signedOrder of signedOrders) { await this._validateFillOrderAndThrowIfInvalidAsync( - signedOrder, takerTokenFillAmount, takerAddress); + signedOrder, fillTakerTokenAmount, takerAddress); } if (_.isEmpty(signedOrders)) { return new BigNumber(0); // no-op @@ -251,11 +252,11 @@ export class ExchangeWrapper extends ContractWrapper { ); const exchangeInstance = await this._getExchangeContractAsync(exchangeContractAddresses[0]); - const gas = await exchangeInstance.fillUpTo.estimateGas( + const gas = await exchangeInstance.fillOrdersUpTo.estimateGas( orderAddressesArray, orderValuesArray, - takerTokenFillAmount, - shouldCheckTransfer, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, vArray, rArray, sArray, @@ -263,11 +264,11 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const response: ContractResponse = await exchangeInstance.fillUpTo( + const response: ContractResponse = await exchangeInstance.fillOrdersUpTo( orderAddressesArray, orderValuesArray, - takerTokenFillAmount, - shouldCheckTransfer, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, vArray, rArray, sArray, @@ -278,7 +279,7 @@ export class ExchangeWrapper extends ContractWrapper { ); this._throwErrorLogsAsErrors(response.logs); let filledTakerTokenAmount = new BigNumber(0); - const filledAmounts = _.each(response.logs, log => { + _.each(response.logs, log => { filledTakerTokenAmount = filledTakerTokenAmount.plus((log.args as LogFillContractEventArgs).filledValueT); }); return filledTakerTokenAmount; diff --git a/src/types.ts b/src/types.ts index 4962dc016..029640f64 100644 --- a/src/types.ts +++ b/src/types.ts @@ -83,11 +83,14 @@ export interface ExchangeContract extends ContractInstance { estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillAmounts: BigNumber.BigNumber[], shouldCheckTransfer: boolean, v: number[], r: string[], s: string[], txOpts?: TxOpts) => number; }; - fillUpTo: { - (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillAmount: BigNumber.BigNumber, - shouldCheckTransfer: boolean, v: number[], r: string[], s: string[], txOpts?: TxOpts): ContractResponse; - estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillAmount: BigNumber.BigNumber, - shouldCheckTransfer: boolean, v: number[], r: string[], s: string[], txOpts?: TxOpts) => number; + fillOrdersUpTo: { + (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmount: BigNumber.BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number[], r: string[], s: string[], txOpts?: TxOpts): ContractResponse; + estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + fillTakerTokenAmount: BigNumber.BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number[], r: string[], s: string[], txOpts?: TxOpts) => number; }; cancelOrder: { (orderAddresses: OrderAddresses, orderValues: OrderValues, canceltakerTokenAmount: BigNumber.BigNumber, |