aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/util')
-rw-r--r--packages/contracts/util/artifacts.ts31
-rw-r--r--packages/contracts/util/balances.ts30
-rw-r--r--packages/contracts/util/constants.ts14
-rw-r--r--packages/contracts/util/crypto.ts43
-rw-r--r--packages/contracts/util/exchange_wrapper.ts230
-rw-r--r--packages/contracts/util/formatters.ts111
-rw-r--r--packages/contracts/util/multi_sig_wrapper.ts43
-rw-r--r--packages/contracts/util/order_factory.ts37
-rw-r--r--packages/contracts/util/signed_order_utils.ts58
-rw-r--r--packages/contracts/util/token_registry_wrapper.ts60
-rw-r--r--packages/contracts/util/types.ts102
11 files changed, 0 insertions, 759 deletions
diff --git a/packages/contracts/util/artifacts.ts b/packages/contracts/util/artifacts.ts
deleted file mode 100644
index 8511b0082..000000000
--- a/packages/contracts/util/artifacts.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { ContractArtifact } from '@0xproject/sol-compiler';
-
-import * as AccountLevels from '../src/artifacts/AccountLevels.json';
-import * as Arbitrage from '../src/artifacts/Arbitrage.json';
-import * as DummyToken from '../src/artifacts/DummyToken.json';
-import * as EtherDelta from '../src/artifacts/EtherDelta.json';
-import * as Exchange from '../src/artifacts/Exchange.json';
-import * as MaliciousToken from '../src/artifacts/MaliciousToken.json';
-import * as MultiSigWalletWithTimeLock from '../src/artifacts/MultiSigWalletWithTimeLock.json';
-import * as MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress from '../src/artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json';
-import * as Token from '../src/artifacts/Token.json';
-import * as TokenRegistry from '../src/artifacts/TokenRegistry.json';
-import * as TokenTransferProxy from '../src/artifacts/TokenTransferProxy.json';
-import * as EtherToken from '../src/artifacts/WETH9.json';
-import * as ZRX from '../src/artifacts/ZRXToken.json';
-
-export const artifacts = {
- AccountLevels: (AccountLevels as any) as ContractArtifact,
- Arbitrage: (Arbitrage as any) as ContractArtifact,
- EtherDelta: (EtherDelta as any) as ContractArtifact,
- ZRX: (ZRX as any) as ContractArtifact,
- DummyToken: (DummyToken as any) as ContractArtifact,
- Token: (Token as any) as ContractArtifact,
- Exchange: (Exchange as any) as ContractArtifact,
- EtherToken: (EtherToken as any) as ContractArtifact,
- TokenRegistry: (TokenRegistry as any) as ContractArtifact,
- MaliciousToken: (MaliciousToken as any) as ContractArtifact,
- TokenTransferProxy: (TokenTransferProxy as any) as ContractArtifact,
- MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact,
- MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress: (MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress as any) as ContractArtifact,
-};
diff --git a/packages/contracts/util/balances.ts b/packages/contracts/util/balances.ts
deleted file mode 100644
index d03d4b3c5..000000000
--- a/packages/contracts/util/balances.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-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: DummyTokenContract[];
- private _ownerAddresses: string[];
- constructor(tokenContractInstances: DummyTokenContract[], ownerAddresses: string[]) {
- this._tokenContractInstances = tokenContractInstances;
- this._ownerAddresses = ownerAddresses;
- }
- public async getAsync(): Promise<BalancesByOwner> {
- const balancesByOwner: BalancesByOwner = {};
- for (const tokenContractInstance of this._tokenContractInstances) {
- for (const ownerAddress of this._ownerAddresses) {
- let balance = await tokenContractInstance.balanceOf.callAsync(ownerAddress);
- balance = new BigNumber(balance);
- if (_.isUndefined(balancesByOwner[ownerAddress])) {
- balancesByOwner[ownerAddress] = {};
- }
- balancesByOwner[ownerAddress][tokenContractInstance.address] = balance;
- }
- }
- return balancesByOwner;
- }
-}
diff --git a/packages/contracts/util/constants.ts b/packages/contracts/util/constants.ts
deleted file mode 100644
index d287986b7..000000000
--- a/packages/contracts/util/constants.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { BigNumber } from '@0xproject/utils';
-
-export const constants = {
- INVALID_OPCODE: 'invalid opcode',
- REVERT: 'revert',
- TESTRPC_NETWORK_ID: 50,
- MAX_ETHERTOKEN_WITHDRAW_GAS: 43000,
- MAX_TOKEN_TRANSFERFROM_GAS: 80000,
- MAX_TOKEN_APPROVE_GAS: 60000,
- DUMMY_TOKEN_NAME: '',
- DUMMY_TOKEN_SYMBOL: '',
- DUMMY_TOKEN_DECIMALS: new BigNumber(18),
- DUMMY_TOKEN_TOTAL_SUPPLY: new BigNumber(0),
-};
diff --git a/packages/contracts/util/crypto.ts b/packages/contracts/util/crypto.ts
deleted file mode 100644
index 3661b3afd..000000000
--- a/packages/contracts/util/crypto.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import BN = require('bn.js');
-import ABI = require('ethereumjs-abi');
-import ethUtil = require('ethereumjs-util');
-import * as _ from 'lodash';
-
-export const crypto = {
- /**
- * We convert types from JS to Solidity as follows:
- * BigNumber -> uint256
- * number -> uint8
- * string -> string
- * boolean -> bool
- * valid Ethereum address -> address
- */
- solSHA3(args: any[]): Buffer {
- return crypto._solHash(args, ABI.soliditySHA3);
- },
- solSHA256(args: any[]): Buffer {
- return crypto._solHash(args, ABI.soliditySHA256);
- },
- _solHash(args: any[], hashFunction: (types: string[], values: any[]) => Buffer): Buffer {
- const argTypes: string[] = [];
- _.each(args, (arg, i) => {
- const isNumber = _.isFinite(arg);
- if (isNumber) {
- argTypes.push('uint8');
- } else if (arg.isBigNumber) {
- argTypes.push('uint256');
- args[i] = new BN(arg.toString(10), 10);
- } else if (ethUtil.isValidAddress(arg)) {
- argTypes.push('address');
- } else if (_.isString(arg)) {
- argTypes.push('string');
- } else if (_.isBoolean(arg)) {
- argTypes.push('bool');
- } else {
- throw new Error(`Unable to guess arg type: ${arg}`);
- }
- });
- const hash = hashFunction(argTypes, args);
- return hash;
- },
-};
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts
deleted file mode 100644
index f016067fe..000000000
--- a/packages/contracts/util/exchange_wrapper.ts
+++ /dev/null
@@ -1,230 +0,0 @@
-import { SignedOrder, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
-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 { signedOrderUtils } from './signed_order_utils';
-
-export class ExchangeWrapper {
- private _exchange: ExchangeContract;
- private _zeroEx: ZeroEx;
- constructor(exchangeContract: ExchangeContract, zeroEx: ZeroEx) {
- this._exchange = exchangeContract;
- this._zeroEx = zeroEx;
- }
- public async fillOrderAsync(
- signedOrder: SignedOrder,
- from: string,
- opts: {
- fillTakerTokenAmount?: BigNumber;
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {},
- ): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
- const params = signedOrderUtils.createFill(
- signedOrder,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmount,
- );
- const txHash = await this._exchange.fillOrder.sendTransactionAsync(
- params.orderAddresses,
- params.orderValues,
- params.fillTakerTokenAmount,
- params.shouldThrowOnInsufficientBalanceOrAllowance,
- params.v,
- params.r,
- params.s,
- { from },
- );
- const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
- _.each(tx.logs, log => wrapLogBigNumbers(log));
- return tx;
- }
- public async cancelOrderAsync(
- signedOrder: SignedOrder,
- from: string,
- opts: { cancelTakerTokenAmount?: BigNumber } = {},
- ): Promise<TransactionReceiptWithDecodedLogs> {
- const params = signedOrderUtils.createCancel(signedOrder, opts.cancelTakerTokenAmount);
- const txHash = await this._exchange.cancelOrder.sendTransactionAsync(
- params.orderAddresses,
- params.orderValues,
- params.cancelTakerTokenAmount,
- { from },
- );
- const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
- _.each(tx.logs, log => wrapLogBigNumbers(log));
- return tx;
- }
- public async fillOrKillOrderAsync(
- signedOrder: SignedOrder,
- from: string,
- opts: { fillTakerTokenAmount?: BigNumber } = {},
- ): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = true;
- const params = signedOrderUtils.createFill(
- signedOrder,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmount,
- );
- const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync(
- params.orderAddresses,
- params.orderValues,
- params.fillTakerTokenAmount,
- params.v,
- params.r,
- params.s,
- { from },
- );
- const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
- _.each(tx.logs, log => wrapLogBigNumbers(log));
- return tx;
- }
- public async batchFillOrdersAsync(
- orders: SignedOrder[],
- from: string,
- opts: {
- fillTakerTokenAmounts?: BigNumber[];
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {},
- ): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
- const params = formatters.createBatchFill(
- orders,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmounts,
- );
- const txHash = await this._exchange.batchFillOrders.sendTransactionAsync(
- params.orderAddresses,
- params.orderValues,
- params.fillTakerTokenAmounts,
- params.shouldThrowOnInsufficientBalanceOrAllowance,
- params.v,
- params.r,
- params.s,
- { from },
- );
- const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
- _.each(tx.logs, log => wrapLogBigNumbers(log));
- return tx;
- }
- public async batchFillOrKillOrdersAsync(
- orders: SignedOrder[],
- from: string,
- opts: { fillTakerTokenAmounts?: BigNumber[]; shouldThrowOnInsufficientBalanceOrAllowance?: boolean } = {},
- ): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
- const params = formatters.createBatchFill(
- orders,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmounts,
- );
- const txHash = await this._exchange.batchFillOrKillOrders.sendTransactionAsync(
- params.orderAddresses,
- params.orderValues,
- params.fillTakerTokenAmounts,
- params.v,
- params.r,
- params.s,
- { from },
- );
- const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
- _.each(tx.logs, log => wrapLogBigNumbers(log));
- return tx;
- }
- public async fillOrdersUpToAsync(
- orders: SignedOrder[],
- from: string,
- opts: { fillTakerTokenAmount: BigNumber; shouldThrowOnInsufficientBalanceOrAllowance?: boolean },
- ): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
- const params = formatters.createFillUpTo(
- orders,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmount,
- );
- const txHash = await this._exchange.fillOrdersUpTo.sendTransactionAsync(
- params.orderAddresses,
- params.orderValues,
- params.fillTakerTokenAmount,
- params.shouldThrowOnInsufficientBalanceOrAllowance,
- params.v,
- params.r,
- params.s,
- { from },
- );
- const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
- _.each(tx.logs, log => wrapLogBigNumbers(log));
- return tx;
- }
- public async batchCancelOrdersAsync(
- orders: SignedOrder[],
- from: string,
- opts: { cancelTakerTokenAmounts?: BigNumber[] } = {},
- ): Promise<TransactionReceiptWithDecodedLogs> {
- const params = formatters.createBatchCancel(orders, opts.cancelTakerTokenAmounts);
- const txHash = await this._exchange.batchCancelOrders.sendTransactionAsync(
- params.orderAddresses,
- params.orderValues,
- params.cancelTakerTokenAmounts,
- { from },
- );
- const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
- _.each(tx.logs, log => wrapLogBigNumbers(log));
- return tx;
- }
- public async getOrderHashAsync(signedOrder: SignedOrder): Promise<string> {
- const shouldThrowOnInsufficientBalanceOrAllowance = false;
- const params = signedOrderUtils.getOrderAddressesAndValues(signedOrder);
- const orderHash = await this._exchange.getOrderHash.callAsync(params.orderAddresses, params.orderValues);
- return orderHash;
- }
- public async isValidSignatureAsync(signedOrder: SignedOrder): Promise<boolean> {
- const isValidSignature = await this._exchange.isValidSignature.callAsync(
- signedOrder.maker,
- ZeroEx.getOrderHashHex(signedOrder),
- signedOrder.ecSignature.v,
- signedOrder.ecSignature.r,
- signedOrder.ecSignature.s,
- );
- return isValidSignature;
- }
- public async isRoundingErrorAsync(
- numerator: BigNumber,
- denominator: BigNumber,
- target: BigNumber,
- ): Promise<boolean> {
- const isRoundingError = await this._exchange.isRoundingError.callAsync(numerator, denominator, target);
- return isRoundingError;
- }
- public async getPartialAmountAsync(
- numerator: BigNumber,
- denominator: BigNumber,
- target: BigNumber,
- ): Promise<BigNumber> {
- const partialAmount = new BigNumber(
- await this._exchange.getPartialAmount.callAsync(numerator, denominator, target),
- );
- return partialAmount;
- }
-}
-
-function wrapLogBigNumbers(log: any): any {
- const argNames = _.keys(log.args);
- for (const argName of argNames) {
- const isWeb3BigNumber = _.startsWith(log.args[argName].constructor.toString(), 'function BigNumber(');
- if (isWeb3BigNumber) {
- log.args[argName] = new BigNumber(log.args[argName]);
- }
- }
-}
diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts
deleted file mode 100644
index 3e3b67495..000000000
--- a/packages/contracts/util/formatters.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-import { SignedOrder } from '0x.js';
-import { BigNumber } from '@0xproject/utils';
-import * as _ from 'lodash';
-
-import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types';
-
-export const formatters = {
- createBatchFill(
- signedOrders: SignedOrder[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- fillTakerTokenAmounts: BigNumber[] = [],
- ): BatchFillOrders {
- const batchFill: BatchFillOrders = {
- orderAddresses: [],
- orderValues: [],
- fillTakerTokenAmounts,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v: [],
- r: [],
- s: [],
- };
- _.forEach(signedOrders, signedOrder => {
- batchFill.orderAddresses.push([
- signedOrder.maker,
- signedOrder.taker,
- signedOrder.makerTokenAddress,
- signedOrder.takerTokenAddress,
- signedOrder.feeRecipient,
- ]);
- batchFill.orderValues.push([
- signedOrder.makerTokenAmount,
- signedOrder.takerTokenAmount,
- signedOrder.makerFee,
- signedOrder.takerFee,
- signedOrder.expirationUnixTimestampSec,
- signedOrder.salt,
- ]);
- batchFill.v.push(signedOrder.ecSignature.v);
- batchFill.r.push(signedOrder.ecSignature.r);
- batchFill.s.push(signedOrder.ecSignature.s);
- if (fillTakerTokenAmounts.length < signedOrders.length) {
- batchFill.fillTakerTokenAmounts.push(signedOrder.takerTokenAmount);
- }
- });
- return batchFill;
- },
- createFillUpTo(
- signedOrders: SignedOrder[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- fillTakerTokenAmount: BigNumber,
- ): FillOrdersUpTo {
- const fillUpTo: FillOrdersUpTo = {
- orderAddresses: [],
- orderValues: [],
- fillTakerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v: [],
- r: [],
- s: [],
- };
- signedOrders.forEach(signedOrder => {
- fillUpTo.orderAddresses.push([
- signedOrder.maker,
- signedOrder.taker,
- signedOrder.makerTokenAddress,
- signedOrder.takerTokenAddress,
- signedOrder.feeRecipient,
- ]);
- fillUpTo.orderValues.push([
- signedOrder.makerTokenAmount,
- signedOrder.takerTokenAmount,
- signedOrder.makerFee,
- signedOrder.takerFee,
- signedOrder.expirationUnixTimestampSec,
- signedOrder.salt,
- ]);
- fillUpTo.v.push(signedOrder.ecSignature.v);
- fillUpTo.r.push(signedOrder.ecSignature.r);
- fillUpTo.s.push(signedOrder.ecSignature.s);
- });
- return fillUpTo;
- },
- createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []): BatchCancelOrders {
- const batchCancel: BatchCancelOrders = {
- orderAddresses: [],
- orderValues: [],
- cancelTakerTokenAmounts,
- };
- signedOrders.forEach(signedOrder => {
- batchCancel.orderAddresses.push([
- signedOrder.maker,
- signedOrder.taker,
- signedOrder.makerTokenAddress,
- signedOrder.takerTokenAddress,
- signedOrder.feeRecipient,
- ]);
- batchCancel.orderValues.push([
- signedOrder.makerTokenAmount,
- signedOrder.takerTokenAmount,
- signedOrder.makerFee,
- signedOrder.takerFee,
- signedOrder.expirationUnixTimestampSec,
- signedOrder.salt,
- ]);
- if (cancelTakerTokenAmounts.length < signedOrders.length) {
- batchCancel.cancelTakerTokenAmounts.push(signedOrder.takerTokenAmount);
- }
- });
- return batchCancel;
- },
-};
diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts
deleted file mode 100644
index c66106b9a..000000000
--- a/packages/contracts/util/multi_sig_wrapper.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { AbiDefinition, MethodAbi } from '@0xproject/types';
-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: MultiSigWalletContract;
- public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]): string {
- const abiEntity = _.find(abi, { name }) as MethodAbi;
- if (_.isUndefined(abiEntity)) {
- throw new Error(`Did not find abi entry for name: ${name}`);
- }
- const types = _.map(abiEntity.inputs, input => input.type);
- const funcSig = ethUtil.bufferToHex(ABI.methodID(name, types));
- const argsData = _.map(args, arg => {
- const target = _.isBoolean(arg) ? +arg : arg;
- const targetBuff = ethUtil.toBuffer(target);
- return ethUtil.setLengthLeft(targetBuff, 32).toString('hex');
- });
- return funcSig + argsData.join('');
- }
- constructor(multiSigContract: MultiSigWalletContract) {
- this._multiSig = multiSigContract;
- }
- public async submitTransactionAsync(
- destination: string,
- from: string,
- dataParams: TransactionDataParams,
- value: BigNumber = new BigNumber(0),
- ): Promise<string> {
- const { name, abi, args = [] } = dataParams;
- const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args);
- return this._multiSig.submitTransaction.sendTransactionAsync(destination, value, encoded, {
- from,
- });
- }
-}
diff --git a/packages/contracts/util/order_factory.ts b/packages/contracts/util/order_factory.ts
deleted file mode 100644
index 8ba5df24a..000000000
--- a/packages/contracts/util/order_factory.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { Order, SignedOrder, ZeroEx } from '0x.js';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import * as _ from 'lodash';
-
-import { DefaultOrderParams } from './types';
-
-export class OrderFactory {
- private _defaultOrderParams: Partial<Order>;
- private _zeroEx: ZeroEx;
- constructor(zeroEx: ZeroEx, defaultOrderParams: Partial<Order>) {
- this._defaultOrderParams = defaultOrderParams;
- this._zeroEx = zeroEx;
- }
- public async newSignedOrderAsync(customOrderParams: Partial<Order> = {}): Promise<SignedOrder> {
- const randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000));
- const order = ({
- expirationUnixTimestampSec: randomExpiration,
- salt: ZeroEx.generatePseudoRandomSalt(),
- taker: ZeroEx.NULL_ADDRESS,
- ...this._defaultOrderParams,
- ...customOrderParams,
- } as any) as Order;
- const orderHashHex = ZeroEx.getOrderHashHex(order);
- const shouldAddPersonalMessagePrefix = false;
- const ecSignature = await this._zeroEx.signOrderHashAsync(
- orderHashHex,
- order.maker,
- shouldAddPersonalMessagePrefix,
- );
- const signedOrder = {
- ...order,
- ecSignature,
- };
- return signedOrder;
- }
-}
diff --git a/packages/contracts/util/signed_order_utils.ts b/packages/contracts/util/signed_order_utils.ts
deleted file mode 100644
index 30a2814e7..000000000
--- a/packages/contracts/util/signed_order_utils.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { SignedOrder } from '0x.js';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import ethUtil = require('ethereumjs-util');
-import * as _ from 'lodash';
-
-import { crypto } from './crypto';
-
-interface OrderAddressesAndValues {
- orderAddresses: string[];
- orderValues: BigNumber[];
-}
-
-interface OrderCancel extends OrderAddressesAndValues {
- cancelTakerTokenAmount: BigNumber;
-}
-
-export const signedOrderUtils = {
- createFill: (
- signedOrder: SignedOrder,
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean,
- fillTakerTokenAmount?: BigNumber,
- ) => {
- const fill = {
- ...signedOrderUtils.getOrderAddressesAndValues(signedOrder),
- fillTakerTokenAmount: fillTakerTokenAmount || signedOrder.takerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance: !!shouldThrowOnInsufficientBalanceOrAllowance,
- ...signedOrder.ecSignature,
- };
- return fill;
- },
- createCancel(signedOrder: SignedOrder, cancelTakerTokenAmount?: BigNumber): OrderCancel {
- const cancel = {
- ...signedOrderUtils.getOrderAddressesAndValues(signedOrder),
- cancelTakerTokenAmount: cancelTakerTokenAmount || signedOrder.takerTokenAmount,
- };
- return cancel;
- },
- getOrderAddressesAndValues(signedOrder: SignedOrder): OrderAddressesAndValues {
- return {
- orderAddresses: [
- signedOrder.maker,
- signedOrder.taker,
- signedOrder.makerTokenAddress,
- signedOrder.takerTokenAddress,
- signedOrder.feeRecipient,
- ],
- orderValues: [
- signedOrder.makerTokenAmount,
- signedOrder.takerTokenAmount,
- signedOrder.makerFee,
- signedOrder.takerFee,
- signedOrder.expirationUnixTimestampSec,
- signedOrder.salt,
- ],
- };
- },
-};
diff --git a/packages/contracts/util/token_registry_wrapper.ts b/packages/contracts/util/token_registry_wrapper.ts
deleted file mode 100644
index bed62fa53..000000000
--- a/packages/contracts/util/token_registry_wrapper.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import * as Web3 from 'web3';
-
-import { TokenRegistryContract } from '../src/contract_wrappers/generated/token_registry';
-
-import { Token } from './types';
-
-export class TokenRegWrapper {
- private _tokenReg: TokenRegistryContract;
- constructor(tokenRegContract: TokenRegistryContract) {
- this._tokenReg = tokenRegContract;
- }
- public async addTokenAsync(token: Token, from: string): Promise<string> {
- const tx = this._tokenReg.addToken.sendTransactionAsync(
- token.address as string,
- token.name,
- token.symbol,
- token.decimals,
- token.ipfsHash,
- token.swarmHash,
- { from },
- );
- return tx;
- }
- public async getTokenMetaDataAsync(tokenAddress: string): Promise<Token> {
- const data = await this._tokenReg.getTokenMetaData.callAsync(tokenAddress);
- const token: Token = {
- address: data[0],
- name: data[1],
- symbol: data[2],
- decimals: data[3],
- ipfsHash: data[4],
- swarmHash: data[5],
- };
- return token;
- }
- public async getTokenByNameAsync(tokenName: string): Promise<Token> {
- const data = await this._tokenReg.getTokenByName.callAsync(tokenName);
- const token: Token = {
- address: data[0],
- name: data[1],
- symbol: data[2],
- decimals: data[3],
- ipfsHash: data[4],
- swarmHash: data[5],
- };
- return token;
- }
- public async getTokenBySymbolAsync(tokenSymbol: string): Promise<Token> {
- const data = await this._tokenReg.getTokenBySymbol.callAsync(tokenSymbol);
- const token: Token = {
- address: data[0],
- name: data[1],
- symbol: data[2],
- decimals: data[3],
- ipfsHash: data[4],
- swarmHash: data[5],
- };
- return token;
- }
-}
diff --git a/packages/contracts/util/types.ts b/packages/contracts/util/types.ts
deleted file mode 100644
index 9bc412433..000000000
--- a/packages/contracts/util/types.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-import { AbiDefinition, ContractAbi } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-
-export interface BalancesByOwner {
- [ownerAddress: string]: {
- [tokenAddress: string]: BigNumber;
- };
-}
-
-export interface SubmissionContractEventArgs {
- transactionId: BigNumber;
-}
-
-export interface BatchFillOrders {
- orderAddresses: string[][];
- orderValues: BigNumber[][];
- fillTakerTokenAmounts: BigNumber[];
- shouldThrowOnInsufficientBalanceOrAllowance: boolean;
- v: number[];
- r: string[];
- s: string[];
-}
-
-export interface FillOrdersUpTo {
- orderAddresses: string[][];
- orderValues: BigNumber[][];
- fillTakerTokenAmount: BigNumber;
- shouldThrowOnInsufficientBalanceOrAllowance: boolean;
- v: number[];
- r: string[];
- s: string[];
-}
-
-export interface BatchCancelOrders {
- orderAddresses: string[][];
- orderValues: BigNumber[][];
- cancelTakerTokenAmounts: BigNumber[];
-}
-
-export interface DefaultOrderParams {
- exchangeContractAddress: string;
- maker: string;
- feeRecipient: string;
- makerTokenAddress: string;
- takerTokenAddress: string;
- makerTokenAmount: BigNumber;
- takerTokenAmount: BigNumber;
- makerFee: BigNumber;
- takerFee: BigNumber;
-}
-
-export interface TransactionDataParams {
- name: string;
- abi: AbiDefinition[];
- args: any[];
-}
-
-export interface MultiSigConfig {
- owners: string[];
- confirmationsRequired: number;
- secondsRequired: number;
-}
-
-export interface MultiSigConfigByNetwork {
- [networkName: string]: MultiSigConfig;
-}
-
-export interface Token {
- address?: string;
- name: string;
- symbol: string;
- decimals: number;
- ipfsHash: string;
- swarmHash: string;
-}
-
-export interface TokenInfoByNetwork {
- development: Token[];
- live: Token[];
-}
-
-export enum ExchangeContractErrs {
- ERROR_ORDER_EXPIRED,
- ERROR_ORDER_FULLY_FILLED_OR_CANCELLED,
- ERROR_ROUNDING_ERROR_TOO_LARGE,
- ERROR_INSUFFICIENT_BALANCE_OR_ALLOWANCE,
-}
-
-export enum ContractName {
- TokenTransferProxy = 'TokenTransferProxy',
- TokenRegistry = 'TokenRegistry',
- MultiSigWalletWithTimeLock = 'MultiSigWalletWithTimeLock',
- Exchange = 'Exchange',
- ZRXToken = 'ZRXToken',
- DummyToken = 'DummyToken',
- EtherToken = 'WETH9',
- MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress = 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
- MaliciousToken = 'MaliciousToken',
- AccountLevels = 'AccountLevels',
- EtherDelta = 'EtherDelta',
- Arbitrage = 'Arbitrage',
-}