aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-02-08 02:27:22 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-02-08 02:27:22 +0800
commitf3c6cce4559d096a2f3babfc7af670d078a6f0dd (patch)
tree580c59d474d52affc57593d25eb1d0acd480d4b0 /packages/contracts/util
parentd9b1d31e7310f7f554f1740f93e4ccd5b5db90f5 (diff)
parenta26e77074fdf5ea7a754a7a676ebd752668d3c82 (diff)
downloaddexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar
dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.gz
dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.bz2
dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.lz
dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.xz
dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.zst
dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.zip
Merge branch 'development' into feature/testnet-faucets/queue-by-network
* development: (24 commits) Fix Remco's github name in CODEOWNERS Fix ABI error message Stop using definite assignment assertion cause prettier doesn't handle that Special-case ZRXToken snake case conversion Fix linter errors Generate contract wrappers on pre-build Add missing async Remove noImplicitThis Tslint disable no-consecutive-blank-lines in generated files Change compiled sources in contracts Change utils Change tests Add base_contract.ts Remove generated files .gitignore gemerated files Change the list of generated wrappers Change contract templates Add indices for index parameters so that their names don't collide Use abi-gen for events in 0x.js Fix artifacts path ...
Diffstat (limited to 'packages/contracts/util')
-rw-r--r--packages/contracts/util/artifacts.ts20
-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.ts14
5 files changed, 52 insertions, 43 deletions
diff --git a/packages/contracts/util/artifacts.ts b/packages/contracts/util/artifacts.ts
index fd9380d1d..7c375c1b7 100644
--- a/packages/contracts/util/artifacts.ts
+++ b/packages/contracts/util/artifacts.ts
@@ -1,13 +1,13 @@
-import * as DummyTokenArtifact from '../artifacts/DummyToken.json';
-import * as ExchangeArtifact from '../artifacts/Exchange.json';
-import * as MaliciousTokenArtifact from '../artifacts/MaliciousToken.json';
-import * as MultiSigWalletWithTimeLockArtifact from '../artifacts/MultiSigWalletWithTimeLock.json';
-import * as MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact from '../artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json';
-import * as TokenArtifact from '../artifacts/Token.json';
-import * as TokenRegistryArtifact from '../artifacts/TokenRegistry.json';
-import * as TokenTransferProxyArtifact from '../artifacts/TokenTransferProxy.json';
-import * as EtherTokenArtifact from '../artifacts/WETH9.json';
-import * as ZRXArtifact from '../artifacts/ZRXToken.json';
+import * as DummyTokenArtifact from '../src/artifacts/DummyToken.json';
+import * as ExchangeArtifact from '../src/artifacts/Exchange.json';
+import * as MaliciousTokenArtifact from '../src/artifacts/MaliciousToken.json';
+import * as MultiSigWalletWithTimeLockArtifact from '../src/artifacts/MultiSigWalletWithTimeLock.json';
+import * as MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact from '../src/artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json';
+import * as TokenArtifact from '../src/artifacts/Token.json';
+import * as TokenRegistryArtifact from '../src/artifacts/TokenRegistry.json';
+import * as TokenTransferProxyArtifact from '../src/artifacts/TokenTransferProxy.json';
+import * as EtherTokenArtifact from '../src/artifacts/WETH9.json';
+import * as ZRXArtifact from '../src/artifacts/ZRXToken.json';
import { Artifact } from './types';
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..d0af17103 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,
+ public async addTokenAsync(token: Token, from: string) {
+ const tx = this._tokenReg.addToken.sendTransactionAsync(
+ token.address as string,
token.name,
token.symbol,
token.decimals,