Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Making 0x libraries public, significantly increases gas usage at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
asoong committed Aug 9, 2018
1 parent 26c28fa commit 9687851
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
Expand Up @@ -77,7 +77,7 @@ library ZeroExOrderDataHandler {
function parseERC20TokenAddress(
bytes _assetData
)
internal
public
pure
returns(address)
{
Expand All @@ -100,7 +100,7 @@ library ZeroExOrderDataHandler {
bytes _ordersData,
uint256 _offset
)
internal
public
pure
returns (OrderHeader)
{
Expand Down Expand Up @@ -144,10 +144,10 @@ library ZeroExOrderDataHandler {
*/
function parseZeroExOrder(
bytes _ordersData,
OrderHeader memory _header,
OrderHeader _header,
uint256 _offset
)
internal
public
pure
returns(LibOrder.Order memory)
{
Expand Down
5 changes: 4 additions & 1 deletion test/core/exchange-wrappers/zeroExExchangeWrapper.spec.ts
Expand Up @@ -270,7 +270,10 @@ contract('ZeroExExchangeWrapper', accounts => {
});

it('should receipt the correct amounts of taker tokens and set allowances on ZeroEx/Set proxies', async () => {
await subject();
const txHash = await subject();

const receipt = await web3.eth.getTransactionReceipt(txHash);
console.log(receipt.gasUsed);

// First maker token
const firstTakerTokenBalance = await zeroExOrderMakerToken.balanceOf.callAsync(zeroExExchangeWrapper.address);
Expand Down
7 changes: 5 additions & 2 deletions test/core/extensions/coreIssuanceOrder.spec.ts
Expand Up @@ -185,11 +185,14 @@ contract('CoreIssuanceOrder', accounts => {
);
}

it('transfers the full maker token amount from the maker', async () => {
it.only('transfers the full maker token amount from the maker', async () => {
const existingBalance = await makerToken.balanceOf.callAsync(signerAccount);
await assertTokenBalance(makerToken, DEPLOYED_TOKEN_QUANTITY.div(2), signerAccount);

await subject();
const txHash = await subject();

const receipt = await web3.eth.getTransactionReceipt(txHash);
console.log(receipt.gasUsed);

const fullMakerTokenAmount = ether(10);
const expectedNewBalance = existingBalance.sub(fullMakerTokenAmount);
Expand Down
17 changes: 14 additions & 3 deletions utils/exchangeWrapper.ts
@@ -1,18 +1,22 @@
import { TakerWalletWrapperContract } from '../types/generated/taker_wallet_wrapper';
import { TransferProxyContract } from '../types/generated/transfer_proxy';
import { ZeroExExchangeWrapperContract } from '../types/generated/zero_ex_exchange_wrapper';
import {
TakerWalletWrapperContract,
TransferProxyContract,
ZeroExExchangeWrapperContract
} from '../utils/contracts';

import { Address } from '../types/common.js';
import { DEFAULT_GAS } from './constants';

const ERC20Wrapper = artifacts.require('ERC20Wrapper');
const TakerWalletWrapper = artifacts.require('TakerWalletWrapper');
const ZeroExOrderDataHandler = artifacts.require('ZeroExOrderDataHandler');
const ZeroExExchangeWrapper = artifacts.require('ZeroExExchangeWrapper');


export class ExchangeWrapper {
private _contractOwnerAddress: Address;
private _truffleERC20Wrapper: any;
private _truffleZeroExOrderDataHandler: any;

constructor(contractOwnerAddress: Address) {
this._contractOwnerAddress = contractOwnerAddress;
Expand Down Expand Up @@ -48,6 +52,13 @@ export class ExchangeWrapper {
transferProxy: TransferProxyContract,
from: Address = this._contractOwnerAddress
): Promise<ZeroExExchangeWrapperContract> {
if (!this._truffleZeroExOrderDataHandler) {
this._truffleZeroExOrderDataHandler = await ZeroExOrderDataHandler.new(
{ from: this._contractOwnerAddress },
);
}

await ZeroExExchangeWrapper.link('ZeroExOrderDataHandler', this._truffleZeroExOrderDataHandler.address);
const zeroExExchangeWrapperInstance = await ZeroExExchangeWrapper.new(
zeroExExchange,
zeroExProxy,
Expand Down

0 comments on commit 9687851

Please sign in to comment.