aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util/exchange_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-06 23:40:25 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-02-07 09:27:47 +0800
commit4cc5bbaf19d2388b0be0669a6249bf92f60c712c (patch)
tree2151ea75dd433d027d35cd12798405c63886f163 /packages/contracts/util/exchange_wrapper.ts
parenta264c36a48d224a55c2ef883f207692752ca74c7 (diff)
downloaddexon-sol-tools-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.tar
dexon-sol-tools-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.tar.gz
dexon-sol-tools-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.tar.bz2
dexon-sol-tools-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.tar.lz
dexon-sol-tools-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.tar.xz
dexon-sol-tools-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.tar.zst
dexon-sol-tools-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.zip
Change utils
Diffstat (limited to 'packages/contracts/util/exchange_wrapper.ts')
-rw-r--r--packages/contracts/util/exchange_wrapper.ts42
1 files changed, 22 insertions, 20 deletions
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts
index 7a07239f5..b749cd72e 100644
--- a/packages/contracts/util/exchange_wrapper.ts
+++ b/packages/contracts/util/exchange_wrapper.ts
@@ -3,14 +3,16 @@ import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
+import { ExchangeContract } from '../src/contract_wrappers/generated/exchange';
+
import { formatters } from './formatters';
import { Order } from './order';
export class ExchangeWrapper {
- private _exchange: Web3.ContractInstance;
+ private _exchange: ExchangeContract;
private _zeroEx: ZeroEx;
- constructor(exchangeContractInstance: Web3.ContractInstance, zeroEx: ZeroEx) {
- this._exchange = exchangeContractInstance;
+ constructor(exchangeContract: ExchangeContract, zeroEx: ZeroEx) {
+ this._exchange = exchangeContract;
this._zeroEx = zeroEx;
}
public async fillOrderAsync(
@@ -23,14 +25,14 @@ export class ExchangeWrapper {
): Promise<TransactionReceiptWithDecodedLogs> {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
- const txHash = await this._exchange.fillOrder(
+ const txHash = await this._exchange.fillOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
params.shouldThrowOnInsufficientBalanceOrAllowance,
- params.v,
- params.r,
- params.s,
+ params.v as number,
+ params.r as string,
+ params.s as string,
{ from },
);
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
@@ -44,7 +46,7 @@ export class ExchangeWrapper {
opts: { cancelTakerTokenAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const params = order.createCancel(opts.cancelTakerTokenAmount);
- const txHash = await this._exchange.cancelOrder(
+ const txHash = await this._exchange.cancelOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.cancelTakerTokenAmount,
@@ -62,13 +64,13 @@ export class ExchangeWrapper {
): Promise<TransactionReceiptWithDecodedLogs> {
const shouldThrowOnInsufficientBalanceOrAllowance = true;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
- const txHash = await this._exchange.fillOrKillOrder(
+ const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
- params.v,
- params.r,
- params.s,
+ params.v as number,
+ params.r as string,
+ params.s as string,
{ from },
);
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
@@ -90,7 +92,7 @@ export class ExchangeWrapper {
shouldThrowOnInsufficientBalanceOrAllowance,
opts.fillTakerTokenAmounts,
);
- const txHash = await this._exchange.batchFillOrders(
+ const txHash = await this._exchange.batchFillOrders.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmounts,
@@ -116,7 +118,7 @@ export class ExchangeWrapper {
shouldThrowOnInsufficientBalanceOrAllowance,
opts.fillTakerTokenAmounts,
);
- const txHash = await this._exchange.batchFillOrKillOrders(
+ const txHash = await this._exchange.batchFillOrKillOrders.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmounts,
@@ -141,7 +143,7 @@ export class ExchangeWrapper {
shouldThrowOnInsufficientBalanceOrAllowance,
opts.fillTakerTokenAmount,
);
- const txHash = await this._exchange.fillOrdersUpTo(
+ const txHash = await this._exchange.fillOrdersUpTo.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
@@ -162,7 +164,7 @@ export class ExchangeWrapper {
opts: { cancelTakerTokenAmounts?: BigNumber[] } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const params = formatters.createBatchCancel(orders, opts.cancelTakerTokenAmounts);
- const txHash = await this._exchange.batchCancelOrders(
+ const txHash = await this._exchange.batchCancelOrders.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.cancelTakerTokenAmounts,
@@ -182,10 +184,10 @@ export class ExchangeWrapper {
public async isValidSignatureAsync(order: Order): Promise<boolean> {
const isValidSignature = await this._exchange.isValidSignature(
order.params.maker,
- order.params.orderHashHex,
- order.params.v,
- order.params.r,
- order.params.s,
+ order.params.orderHashHex as string,
+ order.params.v as number,
+ order.params.r as string,
+ order.params.s as string,
);
return isValidSignature;
}