diff options
Diffstat (limited to 'packages/contracts/src/utils')
-rw-r--r-- | packages/contracts/src/utils/address_utils.ts | 4 | ||||
-rw-r--r-- | packages/contracts/src/utils/constants.ts | 15 | ||||
-rw-r--r-- | packages/contracts/src/utils/erc721_wrapper.ts | 4 | ||||
-rw-r--r-- | packages/contracts/src/utils/exchange_wrapper.ts | 11 | ||||
-rw-r--r-- | packages/contracts/src/utils/order_factory.ts | 9 | ||||
-rw-r--r-- | packages/contracts/src/utils/transaction_factory.ts | 4 |
6 files changed, 24 insertions, 23 deletions
diff --git a/packages/contracts/src/utils/address_utils.ts b/packages/contracts/src/utils/address_utils.ts index 01a7a6fd4..dc63459f9 100644 --- a/packages/contracts/src/utils/address_utils.ts +++ b/packages/contracts/src/utils/address_utils.ts @@ -1,10 +1,10 @@ -import { ZeroEx } from '0x.js'; +import { generatePseudoRandomSalt } from '@0xproject/order-utils'; import { crypto } from './crypto'; export const addressUtils = { generatePseudoRandomAddress(): string { - const randomBigNum = ZeroEx.generatePseudoRandomSalt(); + const randomBigNum = generatePseudoRandomSalt(); const randomBuff = crypto.solSHA3([randomBigNum]); const randomAddress = `0x${randomBuff.slice(0, 20).toString('hex')}`; return randomAddress; diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts index 3fd2a0a3b..e45e51c04 100644 --- a/packages/contracts/src/utils/constants.ts +++ b/packages/contracts/src/utils/constants.ts @@ -1,5 +1,5 @@ -import { ZeroEx } from '0x.js'; import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3_wrapper'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; @@ -30,13 +30,14 @@ export const constants = { NUM_DUMMY_ERC20_TO_DEPLOY: 3, NUM_DUMMY_ERC721_TO_DEPLOY: 1, NUM_ERC721_TOKENS_TO_MINT: 2, + NULL_ADDRESS: '0x0000000000000000000000000000000000000000', TESTRPC_PRIVATE_KEYS: _.map(TESTRPC_PRIVATE_KEYS_STRINGS, privateKeyString => ethUtil.toBuffer(privateKeyString)), - INITIAL_ERC20_BALANCE: ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18), - INITIAL_ERC20_ALLOWANCE: ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18), + INITIAL_ERC20_BALANCE: Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18), + INITIAL_ERC20_ALLOWANCE: Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18), STATIC_ORDER_PARAMS: { - makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18), - takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18), - makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), - takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), + makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), + takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18), + makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), + takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), }, }; diff --git a/packages/contracts/src/utils/erc721_wrapper.ts b/packages/contracts/src/utils/erc721_wrapper.ts index 5b5de262f..bf8953a49 100644 --- a/packages/contracts/src/utils/erc721_wrapper.ts +++ b/packages/contracts/src/utils/erc721_wrapper.ts @@ -1,4 +1,4 @@ -import { ZeroEx } from '0x.js'; +import { generatePseudoRandomSalt } from '@0xproject/order-utils'; import { Provider } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; @@ -54,7 +54,7 @@ export class ERC721Wrapper { _.forEach(this._dummyTokenContracts, dummyTokenContract => { _.forEach(this._tokenOwnerAddresses, tokenOwnerAddress => { _.forEach(_.range(constants.NUM_ERC721_TOKENS_TO_MINT), () => { - const tokenId = ZeroEx.generatePseudoRandomSalt(); + const tokenId = generatePseudoRandomSalt(); setBalancePromises.push( dummyTokenContract.mint.sendTransactionAsync(tokenOwnerAddress, tokenId, { from: this._contractOwnerAddress, diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts index 46531fa3f..98d5e27f9 100644 --- a/packages/contracts/src/utils/exchange_wrapper.ts +++ b/packages/contracts/src/utils/exchange_wrapper.ts @@ -1,5 +1,6 @@ -import { TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js'; +import { TransactionReceiptWithDecodedLogs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import * as Web3 from 'web3'; @@ -14,10 +15,8 @@ import { AssetProxyId, OrderInfo, SignedOrder, SignedTransaction } from './types export class ExchangeWrapper { private _exchange: ExchangeContract; private _logDecoder: LogDecoder = new LogDecoder(constants.TESTRPC_NETWORK_ID); - private _zeroEx: ZeroEx; - constructor(exchangeContract: ExchangeContract, zeroEx: ZeroEx) { + constructor(exchangeContract: ExchangeContract) { this._exchange = exchangeContract; - this._zeroEx = zeroEx; } public async fillOrderAsync( signedOrder: SignedOrder, @@ -196,7 +195,7 @@ export class ExchangeWrapper { opts: { oldAssetProxyAddressIfExists?: string } = {}, ): Promise<TransactionReceiptWithDecodedLogs> { const oldAssetProxyAddress = _.isUndefined(opts.oldAssetProxyAddressIfExists) - ? ZeroEx.NULL_ADDRESS + ? constants.NULL_ADDRESS : opts.oldAssetProxyAddressIfExists; const txHash = await this._exchange.registerAssetProxy.sendTransactionAsync( assetProxyId, @@ -246,7 +245,7 @@ export class ExchangeWrapper { return tx; } private async _getTxWithDecodedExchangeLogsAsync(txHash: string) { - const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash); + const tx = await Web3Wrapper.awaitTransactionMinedAsync(txHash); tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address); tx.logs = _.map(tx.logs, log => this._logDecoder.decodeLogOrThrow(log)); return tx; diff --git a/packages/contracts/src/utils/order_factory.ts b/packages/contracts/src/utils/order_factory.ts index 044e9b865..86b3d5ac7 100644 --- a/packages/contracts/src/utils/order_factory.ts +++ b/packages/contracts/src/utils/order_factory.ts @@ -1,7 +1,8 @@ -import { ZeroEx } from '0x.js'; +import { generatePseudoRandomSalt } from '@0xproject/order-utils'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; +import { constants } from './constants'; import { orderUtils } from './order_utils'; import { signingUtils } from './signing_utils'; import { SignatureType, SignedOrder, UnsignedOrder } from './types'; @@ -19,10 +20,10 @@ export class OrderFactory { ): SignedOrder { const randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000)); const order = ({ - senderAddress: ZeroEx.NULL_ADDRESS, + senderAddress: constants.NULL_ADDRESS, expirationTimeSeconds: randomExpiration, - salt: ZeroEx.generatePseudoRandomSalt(), - takerAddress: ZeroEx.NULL_ADDRESS, + salt: generatePseudoRandomSalt(), + takerAddress: constants.NULL_ADDRESS, ...this._defaultOrderParams, ...customOrderParams, } as any) as UnsignedOrder; diff --git a/packages/contracts/src/utils/transaction_factory.ts b/packages/contracts/src/utils/transaction_factory.ts index 3a4f48330..941bff96d 100644 --- a/packages/contracts/src/utils/transaction_factory.ts +++ b/packages/contracts/src/utils/transaction_factory.ts @@ -1,4 +1,4 @@ -import { ZeroEx } from '0x.js'; +import { generatePseudoRandomSalt } from '@0xproject/order-utils'; import { BigNumber } from '@0xproject/utils'; import * as ethUtil from 'ethereumjs-util'; @@ -20,7 +20,7 @@ export class TransactionFactory { data: string, signatureType: SignatureType = SignatureType.Ecrecover, ): SignedTransaction { - const salt = ZeroEx.generatePseudoRandomSalt(); + const salt = generatePseudoRandomSalt(); const txHash = crypto.solSHA3([this._exchangeAddress, salt, ethUtil.toBuffer(data)]); const signature = signingUtils.signMessage(txHash, this._privateKey, signatureType); const signedTx = { |