aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/utils
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-03-10 05:44:08 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:16 +0800
commit2bd1ddd1296b4b3706bf91934e00c02508ca7c6f (patch)
treeac826de12c7e715827a5d29a87186de67d218606 /packages/contracts/src/utils
parent20a37bdd1d082151fb322335b6c138465dac2c64 (diff)
downloaddexon-sol-tools-2bd1ddd1296b4b3706bf91934e00c02508ca7c6f.tar
dexon-sol-tools-2bd1ddd1296b4b3706bf91934e00c02508ca7c6f.tar.gz
dexon-sol-tools-2bd1ddd1296b4b3706bf91934e00c02508ca7c6f.tar.bz2
dexon-sol-tools-2bd1ddd1296b4b3706bf91934e00c02508ca7c6f.tar.lz
dexon-sol-tools-2bd1ddd1296b4b3706bf91934e00c02508ca7c6f.tar.xz
dexon-sol-tools-2bd1ddd1296b4b3706bf91934e00c02508ca7c6f.tar.zst
dexon-sol-tools-2bd1ddd1296b4b3706bf91934e00c02508ca7c6f.zip
Add tests for fillOrderNoThrow based functions
Diffstat (limited to 'packages/contracts/src/utils')
-rw-r--r--packages/contracts/src/utils/exchange_wrapper.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts
index 9dd414be2..b53519871 100644
--- a/packages/contracts/src/utils/exchange_wrapper.ts
+++ b/packages/contracts/src/utils/exchange_wrapper.ts
@@ -144,6 +144,27 @@ export class ExchangeWrapper {
});
return tx;
}
+ public async batchFillOrdersNoThrowAsync(
+ orders: SignedOrder[],
+ from: string,
+ opts: { takerTokenFillAmounts?: BigNumber[] } = {},
+ ): Promise<TransactionReceiptWithDecodedLogs> {
+ const params = formatters.createBatchFill(orders, opts.takerTokenFillAmounts);
+ const txHash = await this._exchange.batchFillOrdersNoThrow.sendTransactionAsync(
+ params.orders,
+ params.takerTokenFillAmounts,
+ params.signatures,
+ { from },
+ );
+ const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
+ tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
+ tx.logs = _.map(tx.logs, log => {
+ const logWithDecodedArgs = this._logDecoder.decodeLogOrThrow(log);
+ wrapLogBigNumbers(logWithDecodedArgs);
+ return logWithDecodedArgs;
+ });
+ return tx;
+ }
public async marketFillOrdersAsync(
orders: SignedOrder[],
from: string,
@@ -165,6 +186,27 @@ export class ExchangeWrapper {
});
return tx;
}
+ public async marketFillOrdersNoThrowAsync(
+ orders: SignedOrder[],
+ from: string,
+ opts: { takerTokenFillAmount: BigNumber },
+ ): Promise<TransactionReceiptWithDecodedLogs> {
+ const params = formatters.createMarketFillOrders(orders, opts.takerTokenFillAmount);
+ const txHash = await this._exchange.marketFillOrdersNoThrow.sendTransactionAsync(
+ params.orders,
+ params.takerTokenFillAmount,
+ params.signatures,
+ { from },
+ );
+ const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
+ tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
+ tx.logs = _.map(tx.logs, log => {
+ const logWithDecodedArgs = this._logDecoder.decodeLogOrThrow(log);
+ wrapLogBigNumbers(logWithDecodedArgs);
+ return logWithDecodedArgs;
+ });
+ return tx;
+ }
public async batchCancelOrdersAsync(
orders: SignedOrder[],
from: string,