aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-07-08 06:47:12 +0800
committerFabio Berger <me@fabioberger.com>2017-07-11 15:30:14 +0800
commit7cbd408c24cf87755dca10d6dbcb5f4e99d6be17 (patch)
tree425fdd536888081b400fc98ccb7c9d8f94fe1876 /src/contract_wrappers
parentb774a9f91ca1200ef9cef1b6fb0d3396df5d59ed (diff)
downloaddexon-sol-tools-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.tar
dexon-sol-tools-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.tar.gz
dexon-sol-tools-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.tar.bz2
dexon-sol-tools-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.tar.lz
dexon-sol-tools-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.tar.xz
dexon-sol-tools-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.tar.zst
dexon-sol-tools-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.zip
Migrate batchFillOrders
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts36
1 files changed, 20 insertions, 16 deletions
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<void> {
+ shouldThrowOnInsufficientBalanceOrAllowance: boolean,
+ takerAddress: string): Promise<void> {
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<any> because _.unzip doesn't type check if values have different types :'(
- const [orderAddressesArray, orderValuesArray, takerTokenFillAmountArray, vArray, rArray, sArray] = _.unzip<any>(
+ const [orderAddressesArray, orderValuesArray, fillTakerTokenAmounts, vArray, rArray, sArray] = _.unzip<any>(
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,