aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util
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
parenta264c36a48d224a55c2ef883f207692752ca74c7 (diff)
downloaddexon-0x-contracts-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.tar.gz
dexon-0x-contracts-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.tar.zst
dexon-0x-contracts-4cc5bbaf19d2388b0be0669a6249bf92f60c712c.zip
Change utils
Diffstat (limited to 'packages/contracts/util')
-rw-r--r--packages/contracts/util/balances.ts6
-rw-r--r--packages/contracts/util/exchange_wrapper.ts42
-rw-r--r--packages/contracts/util/multi_sig_wrapper.ts13
-rw-r--r--packages/contracts/util/token_registry_wrapper.ts12
4 files changed, 41 insertions, 32 deletions
diff --git a/packages/contracts/util/balances.ts b/packages/contracts/util/balances.ts
index 5bcb5145f..0abc305d8 100644
--- a/packages/contracts/util/balances.ts
+++ b/packages/contracts/util/balances.ts
@@ -2,12 +2,14 @@ import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
+import { DummyTokenContract } from '../src/contract_wrappers/generated/dummy_token';
+
import { BalancesByOwner } from './types';
export class Balances {
- private _tokenContractInstances: Web3.ContractInstance[];
+ private _tokenContractInstances: DummyTokenContract[];
private _ownerAddresses: string[];
- constructor(tokenContractInstances: Web3.ContractInstance[], ownerAddresses: string[]) {
+ constructor(tokenContractInstances: DummyTokenContract[], ownerAddresses: string[]) {
this._tokenContractInstances = tokenContractInstances;
this._ownerAddresses = ownerAddresses;
}
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;
}
diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts
index 0a066df53..3b83ccb7b 100644
--- a/packages/contracts/util/multi_sig_wrapper.ts
+++ b/packages/contracts/util/multi_sig_wrapper.ts
@@ -1,12 +1,15 @@
+import { BigNumber } from '@0xproject/utils';
import ABI = require('ethereumjs-abi');
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import * as Web3 from 'web3';
+import { MultiSigWalletContract } from '../src/contract_wrappers/generated/multi_sig_wallet';
+
import { TransactionDataParams } from './types';
export class MultiSigWrapper {
- private _multiSig: Web3.ContractInstance;
+ private _multiSig: MultiSigWalletContract;
public static encodeFnArgs(name: string, abi: Web3.AbiDefinition[], args: any[]) {
const abiEntity = _.find(abi, { name }) as Web3.MethodAbi;
if (_.isUndefined(abiEntity)) {
@@ -21,18 +24,18 @@ export class MultiSigWrapper {
});
return funcSig + argsData.join('');
}
- constructor(multiSigContractInstance: Web3.ContractInstance) {
- this._multiSig = multiSigContractInstance;
+ constructor(multiSigContract: MultiSigWalletContract) {
+ this._multiSig = multiSigContract;
}
public async submitTransactionAsync(
destination: string,
from: string,
dataParams: TransactionDataParams,
- value: number = 0,
+ value: BigNumber = new BigNumber(0),
) {
const { name, abi, args = [] } = dataParams;
const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args);
- return this._multiSig.submitTransaction(destination, value, encoded, {
+ return this._multiSig.submitTransaction.sendTransactionAsync(destination, value, encoded, {
from,
});
}
diff --git a/packages/contracts/util/token_registry_wrapper.ts b/packages/contracts/util/token_registry_wrapper.ts
index 033b72d10..6539a6da8 100644
--- a/packages/contracts/util/token_registry_wrapper.ts
+++ b/packages/contracts/util/token_registry_wrapper.ts
@@ -1,15 +1,17 @@
import * as Web3 from 'web3';
+import { TokenRegistryContract } from '../src/contract_wrappers/generated/token_registry';
+
import { Token } from './types';
export class TokenRegWrapper {
- private _tokenReg: Web3.ContractInstance;
- constructor(tokenRegContractInstance: Web3.ContractInstance) {
- this._tokenReg = tokenRegContractInstance;
+ private _tokenReg: TokenRegistryContract;
+ constructor(tokenRegContract: TokenRegistryContract) {
+ this._tokenReg = tokenRegContract;
}
public addTokenAsync(token: Token, from: string) {
- const tx = this._tokenReg.addToken(
- token.address,
+ const tx = this._tokenReg.addToken.sendTransactionAsync(
+ token.address as string,
token.name,
token.symbol,
token.decimals,