aboutsummaryrefslogtreecommitdiffstats
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
parentb774a9f91ca1200ef9cef1b6fb0d3396df5d59ed (diff)
downloaddexon-0x-contracts-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.tar.gz
dexon-0x-contracts-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.tar.zst
dexon-0x-contracts-7cbd408c24cf87755dca10d6dbcb5f4e99d6be17.zip
Migrate batchFillOrders
-rw-r--r--src/artifacts/exchange/Exchange_v1.json6
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts36
-rw-r--r--src/types.ts13
3 files changed, 31 insertions, 24 deletions
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<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,
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,