Updated all instances of deployFrom0xArtifactAsync

This commit is contained in:
Greg Hysen 2019-07-26 17:51:52 +02:00
parent df746c5ff4
commit d8cf9d54aa
59 changed files with 10373 additions and 10718 deletions

View File

@ -37,6 +37,7 @@ describe('Authorizable', () => {
artifacts.MixinAuthorizable, artifacts.MixinAuthorizable,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
}); });
beforeEach(async () => { beforeEach(async () => {

View File

@ -23,7 +23,7 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { ERC1155ProxyContract, ERC1155ProxyWrapper } from '../src'; import { artifacts, ERC1155ProxyContract, ERC1155ProxyWrapper } from '../src';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@ -89,6 +89,7 @@ describe('ERC1155Proxy', () => {
erc1155Artifacts.DummyERC1155Receiver, erc1155Artifacts.DummyERC1155Receiver,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
receiverContract = erc1155Receiver.address; receiverContract = erc1155Receiver.address;
await erc1155ProxyWrapper.setBalancesAndAllowancesAsync(); await erc1155ProxyWrapper.setBalancesAndAllowancesAsync();

View File

@ -101,6 +101,7 @@ describe('Asset Transfer Proxies', () => {
artifacts.MultiAssetProxy, artifacts.MultiAssetProxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
// Configure ERC20Proxy // Configure ERC20Proxy
@ -173,6 +174,7 @@ describe('Asset Transfer Proxies', () => {
erc20Artifacts.DummyNoReturnERC20Token, erc20Artifacts.DummyNoReturnERC20Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_DECIMALS,
@ -182,6 +184,7 @@ describe('Asset Transfer Proxies', () => {
erc20Artifacts.DummyMultipleReturnERC20Token, erc20Artifacts.DummyMultipleReturnERC20Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_DECIMALS,
@ -224,6 +227,7 @@ describe('Asset Transfer Proxies', () => {
erc721Artifacts.DummyERC721Receiver, erc721Artifacts.DummyERC721Receiver,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
await erc721Wrapper.setBalancesAndAllowancesAsync(); await erc721Wrapper.setBalancesAndAllowancesAsync();

View File

@ -41,12 +41,14 @@ describe('StaticCallProxy', () => {
artifacts.StaticCallProxy, artifacts.StaticCallProxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
staticCallProxy = new IAssetProxyContract(staticCallProxyWithoutTransferFrom.address, provider, txDefaults); staticCallProxy = new IAssetProxyContract(staticCallProxyWithoutTransferFrom.address, provider, txDefaults);
staticCallTarget = await TestStaticCallTargetContract.deployFrom0xArtifactAsync( staticCallTarget = await TestStaticCallTargetContract.deployFrom0xArtifactAsync(
artifacts.TestStaticCallTarget, artifacts.TestStaticCallTarget,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
}); });
beforeEach(async () => { beforeEach(async () => {

View File

@ -54,6 +54,7 @@ export class ERC1155ProxyWrapper {
erc1155Artifacts.ERC1155Mintable, erc1155Artifacts.ERC1155Mintable,
this._provider, this._provider,
txDefaults, txDefaults,
artifacts,
); );
const erc1155Wrapper = new Erc1155Wrapper(erc1155Contract, this._provider, this._contractOwnerAddress); const erc1155Wrapper = new Erc1155Wrapper(erc1155Contract, this._provider, this._contractOwnerAddress);
this._dummyTokenWrappers.push(erc1155Wrapper); this._dummyTokenWrappers.push(erc1155Wrapper);
@ -69,6 +70,7 @@ export class ERC1155ProxyWrapper {
artifacts.ERC1155Proxy, artifacts.ERC1155Proxy,
this._provider, this._provider,
txDefaults, txDefaults,
artifacts,
); );
this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync();
return this._proxyContract; return this._proxyContract;

View File

@ -37,6 +37,7 @@ export class ERC20Wrapper {
erc20Artifacts.DummyERC20Token, erc20Artifacts.DummyERC20Token,
this._provider, this._provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
decimals, decimals,
@ -51,6 +52,7 @@ export class ERC20Wrapper {
artifacts.ERC20Proxy, artifacts.ERC20Proxy,
this._provider, this._provider,
txDefaults, txDefaults,
artifacts,
); );
this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync();
return this._proxyContract; return this._proxyContract;

View File

@ -29,6 +29,7 @@ export class ERC721Wrapper {
erc721Artifacts.DummyERC721Token, erc721Artifacts.DummyERC721Token,
this._provider, this._provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
), ),
@ -41,6 +42,7 @@ export class ERC721Wrapper {
artifacts.ERC721Proxy, artifacts.ERC721Proxy,
this._provider, this._provider,
txDefaults, txDefaults,
artifacts,
); );
this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync();
return this._proxyContract; return this._proxyContract;

View File

@ -74,6 +74,7 @@ describe('Coordinator tests', () => {
exchangeArtifacts.Exchange, exchangeArtifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
artifacts,
assetDataUtils.encodeERC20AssetData(zrxToken.address), assetDataUtils.encodeERC20AssetData(zrxToken.address),
); );
@ -91,6 +92,7 @@ describe('Coordinator tests', () => {
artifacts.Coordinator, artifacts.Coordinator,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchange.address, exchange.address,
); );

View File

@ -25,6 +25,7 @@ describe('Libs tests', () => {
artifacts.Coordinator, artifacts.Coordinator,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchangeAddress, exchangeAddress,
); );
}); });

View File

@ -44,6 +44,7 @@ describe('Mixins tests', () => {
artifacts.Coordinator, artifacts.Coordinator,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchangeAddress, exchangeAddress,
); );
const accounts = await web3Wrapper.getAvailableAddressesAsync(); const accounts = await web3Wrapper.getAvailableAddressesAsync();

View File

@ -24,6 +24,7 @@ export class CoordinatorRegistryWrapper {
artifacts.CoordinatorRegistry, artifacts.CoordinatorRegistry,
this._provider, this._provider,
txDefaults, txDefaults,
artifacts,
); );
if (this._coordinatorRegistryContract === undefined) { if (this._coordinatorRegistryContract === undefined) {
throw new Error(`Failed to deploy Coordinator Registry contract.`); throw new Error(`Failed to deploy Coordinator Registry contract.`);

View File

@ -92,6 +92,7 @@ describe('LibAssetData', () => {
exchangeArtifacts.Exchange, exchangeArtifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.NULL_BYTES, constants.NULL_BYTES,
); );
@ -99,26 +100,31 @@ describe('LibAssetData', () => {
proxyArtifacts.ERC20Proxy, proxyArtifacts.ERC20Proxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync( erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync(
proxyArtifacts.ERC721Proxy, proxyArtifacts.ERC721Proxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
erc1155Proxy = await ERC1155ProxyContract.deployFrom0xArtifactAsync( erc1155Proxy = await ERC1155ProxyContract.deployFrom0xArtifactAsync(
proxyArtifacts.ERC1155Proxy, proxyArtifacts.ERC1155Proxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync( multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync(
proxyArtifacts.MultiAssetProxy, proxyArtifacts.MultiAssetProxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
staticCallProxy = await StaticCallProxyContract.deployFrom0xArtifactAsync( staticCallProxy = await StaticCallProxyContract.deployFrom0xArtifactAsync(
proxyArtifacts.StaticCallProxy, proxyArtifacts.StaticCallProxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address); await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address);
@ -131,6 +137,7 @@ describe('LibAssetData', () => {
artifacts.LibAssetData, artifacts.LibAssetData,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchange.address, exchange.address,
); );
@ -138,6 +145,7 @@ describe('LibAssetData', () => {
proxyArtifacts.TestStaticCallTarget, proxyArtifacts.TestStaticCallTarget,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
[tokenOwnerAddress] = await web3Wrapper.getAvailableAddressesAsync(); [tokenOwnerAddress] = await web3Wrapper.getAvailableAddressesAsync();
@ -146,6 +154,7 @@ describe('LibAssetData', () => {
erc20Artifacts.DummyERC20Token, erc20Artifacts.DummyERC20Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
'Dummy', 'Dummy',
'DUM', 'DUM',
new BigNumber(1), new BigNumber(1),
@ -156,6 +165,7 @@ describe('LibAssetData', () => {
erc721Artifacts.DummyERC721Token, erc721Artifacts.DummyERC721Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
'Dummy', 'Dummy',
'DUM', 'DUM',
); );
@ -172,6 +182,7 @@ describe('LibAssetData', () => {
erc1155Artifacts.ERC1155Mintable, erc1155Artifacts.ERC1155Mintable,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
const logDecoder = new LogDecoder(web3Wrapper, erc1155Artifacts); const logDecoder = new LogDecoder(web3Wrapper, erc1155Artifacts);

View File

@ -37,6 +37,7 @@ describe('LibTransactionDecoder', () => {
artifacts.LibTransactionDecoder, artifacts.LibTransactionDecoder,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
}); });
after(async () => { after(async () => {

View File

@ -83,6 +83,7 @@ describe('OrderValidationUtils', () => {
exchangeArtifacts.Exchange, exchangeArtifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
artifacts,
zrxAssetData, zrxAssetData,
); );
@ -90,6 +91,7 @@ describe('OrderValidationUtils', () => {
proxyArtifacts.MultiAssetProxy, proxyArtifacts.MultiAssetProxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
const exchangeWrapper = new ExchangeWrapper(exchange, provider); const exchangeWrapper = new ExchangeWrapper(exchange, provider);
await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
@ -102,6 +104,7 @@ describe('OrderValidationUtils', () => {
artifacts.DevUtils, artifacts.DevUtils,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchange.address, exchange.address,
zrxAssetData, zrxAssetData,
); );

View File

@ -60,11 +60,13 @@ describe('ERC1155Token', () => {
artifacts.ERC1155Mintable, artifacts.ERC1155Mintable,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
erc1155Receiver = await DummyERC1155ReceiverContract.deployFrom0xArtifactAsync( erc1155Receiver = await DummyERC1155ReceiverContract.deployFrom0xArtifactAsync(
artifacts.DummyERC1155Receiver, artifacts.DummyERC1155Receiver,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
receiver = erc1155Receiver.address; receiver = erc1155Receiver.address;
// create wrapper & mint erc1155 tokens // create wrapper & mint erc1155 tokens

View File

@ -37,6 +37,7 @@ describe('UnlimitedAllowanceToken', () => {
artifacts.DummyERC20Token, artifacts.DummyERC20Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_DECIMALS,

View File

@ -33,10 +33,15 @@ describe('EtherToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync(); const accounts = await web3Wrapper.getAvailableAddressesAsync();
account = accounts[0]; account = accounts[0];
etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, { etherToken = await WETH9Contract.deployFrom0xArtifactAsync(
gasPrice, artifacts.WETH9,
...txDefaults, provider,
}); {
gasPrice,
...txDefaults,
},
artifacts,
);
}); });
beforeEach(async () => { beforeEach(async () => {
await blockchainLifecycle.startAsync(); await blockchainLifecycle.startAsync();

View File

@ -26,7 +26,12 @@ describe('ZRXToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync(); const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0]; owner = accounts[0];
spender = accounts[1]; spender = accounts[1];
zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRXToken, provider, txDefaults); zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(
artifacts.ZRXToken,
provider,
txDefaults,
artifacts,
);
MAX_UINT = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; MAX_UINT = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
}); });
beforeEach(async () => { beforeEach(async () => {

View File

@ -48,6 +48,7 @@ describe('ERC721Token', () => {
artifacts.DummyERC721Token, artifacts.DummyERC721Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
); );
@ -55,6 +56,7 @@ describe('ERC721Token', () => {
artifacts.DummyERC721Receiver, artifacts.DummyERC721Receiver,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
logDecoder = new LogDecoder(web3Wrapper, artifacts); logDecoder = new LogDecoder(web3Wrapper, artifacts);
await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.awaitTransactionSuccessAsync(
@ -176,6 +178,7 @@ describe('ERC721Token', () => {
artifacts.DummyERC721Token, artifacts.DummyERC721Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
); );
@ -190,6 +193,7 @@ describe('ERC721Token', () => {
artifacts.InvalidERC721Receiver, artifacts.InvalidERC721Receiver,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
const from = owner; const from = owner;
const to = invalidErc721Receiver.address; const to = invalidErc721Receiver.address;
@ -237,6 +241,7 @@ describe('ERC721Token', () => {
artifacts.DummyERC721Token, artifacts.DummyERC721Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
); );
@ -251,6 +256,7 @@ describe('ERC721Token', () => {
artifacts.InvalidERC721Receiver, artifacts.InvalidERC721Receiver,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
const from = owner; const from = owner;
const to = invalidErc721Receiver.address; const to = invalidErc721Receiver.address;

View File

@ -32,6 +32,7 @@ const DECIMALS_DEFAULT = 18;
const MAX_WETH_FILL_PERCENTAGE = 95; const MAX_WETH_FILL_PERCENTAGE = 95;
describe(ContractName.Forwarder, () => { describe(ContractName.Forwarder, () => {
const dependencyArtifacts = { ...artifacts, ...erc20Artifacts, ...exchangeArtifacts };
let makerAddress: string; let makerAddress: string;
let owner: string; let owner: string;
let takerAddress: string; let takerAddress: string;
@ -88,7 +89,12 @@ describe(ContractName.Forwarder, () => {
const erc721Balances = await erc721Wrapper.getBalancesAsync(); const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address]; erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
wethContract = await WETH9Contract.deployFrom0xArtifactAsync(erc20Artifacts.WETH9, provider, txDefaults); wethContract = await WETH9Contract.deployFrom0xArtifactAsync(
erc20Artifacts.WETH9,
provider,
txDefaults,
dependencyArtifacts,
);
weth = new DummyERC20TokenContract(wethContract.address, provider); weth = new DummyERC20TokenContract(wethContract.address, provider);
erc20Wrapper.addDummyTokenContract(weth); erc20Wrapper.addDummyTokenContract(weth);
@ -98,6 +104,7 @@ describe(ContractName.Forwarder, () => {
exchangeArtifacts.Exchange, exchangeArtifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
zrxAssetData, zrxAssetData,
); );
exchangeWrapper = new ExchangeWrapper(exchangeInstance, provider); exchangeWrapper = new ExchangeWrapper(exchangeInstance, provider);
@ -131,6 +138,7 @@ describe(ContractName.Forwarder, () => {
artifacts.Forwarder, artifacts.Forwarder,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
exchangeInstance.address, exchangeInstance.address,
zrxAssetData, zrxAssetData,
wethAssetData, wethAssetData,
@ -169,6 +177,7 @@ describe(ContractName.Forwarder, () => {
exchangeArtifacts.Exchange, exchangeArtifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
zrxAssetData, zrxAssetData,
); );
return expectContractCreationFailedAsync( return expectContractCreationFailedAsync(
@ -176,6 +185,7 @@ describe(ContractName.Forwarder, () => {
artifacts.Forwarder, artifacts.Forwarder,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
exchangeInstance.address, exchangeInstance.address,
zrxAssetData, zrxAssetData,
wethAssetData, wethAssetData,

View File

@ -35,7 +35,7 @@ describe('Exchange libs', () => {
before(async () => { before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync(); const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0]; const makerAddress = accounts[0];
libs = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults); libs = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults, artifacts);
const defaultOrderParams = { const defaultOrderParams = {
...constants.STATIC_ORDER_PARAMS, ...constants.STATIC_ORDER_PARAMS,

View File

@ -119,11 +119,13 @@ describe('Exchange core', () => {
proxyArtifacts.MultiAssetProxy, proxyArtifacts.MultiAssetProxy,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
); );
staticCallProxy = await StaticCallProxyContract.deployFrom0xArtifactAsync( staticCallProxy = await StaticCallProxyContract.deployFrom0xArtifactAsync(
proxyArtifacts.StaticCallProxy, proxyArtifacts.StaticCallProxy,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
); );
const numDummyErc20ToDeploy = 3; const numDummyErc20ToDeploy = 3;
[erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync( [erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync(
@ -354,6 +356,7 @@ describe('Exchange core', () => {
erc20Artifacts.DummyNoReturnERC20Token, erc20Artifacts.DummyNoReturnERC20Token,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_DECIMALS,
@ -384,7 +387,7 @@ describe('Exchange core', () => {
const initialTakerZrxBalance = await zrxToken.balanceOf.callAsync(takerAddress); const initialTakerZrxBalance = await zrxToken.balanceOf.callAsync(takerAddress);
const initialFeeRecipientZrxBalance = await zrxToken.balanceOf.callAsync(feeRecipientAddress); const initialFeeRecipientZrxBalance = await zrxToken.balanceOf.callAsync(feeRecipientAddress);
const txReceipt = await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
const finalMakerBalanceA = await noReturnErc20Token.balanceOf.callAsync(makerAddress); const finalMakerBalanceA = await noReturnErc20Token.balanceOf.callAsync(makerAddress);
const finalMakerBalanceB = await erc20TokenB.balanceOf.callAsync(makerAddress); const finalMakerBalanceB = await erc20TokenB.balanceOf.callAsync(makerAddress);
@ -1479,6 +1482,7 @@ describe('Exchange core', () => {
proxyArtifacts.TestStaticCallTarget, proxyArtifacts.TestStaticCallTarget,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
); );
}); });
it('should revert if the staticcall is unsuccessful', async () => { it('should revert if the staticcall is unsuccessful', async () => {

View File

@ -137,6 +137,7 @@ describe('AssetProxyDispatcher', () => {
proxyArtifacts.ERC20Proxy, proxyArtifacts.ERC20Proxy,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
); );
// Register new ERC20 Transfer Proxy contract // Register new ERC20 Transfer Proxy contract
return expectTransactionFailedAsync( return expectTransactionFailedAsync(

View File

@ -6,4 +6,4 @@ export const dependencyArtifacts = {
...erc20Artifacts, ...erc20Artifacts,
...erc721Artifacts, ...erc721Artifacts,
...erc1155Artifacts, ...erc1155Artifacts,
}; };

View File

@ -1,25 +1,17 @@
import { artifacts as erc1155Artifacts } from '@0x/contracts-erc1155'; import { FillResults, formatters, OrderInfo, orderUtils, Web3ProviderEngine } from '@0x/contracts-test-utils';
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
import {
FillResults,
formatters,
OrderInfo,
orderUtils,
Web3ProviderEngine,
} from '@0x/contracts-test-utils';
import { SignedOrder, SignedZeroExTransaction } from '@0x/types'; import { SignedOrder, SignedZeroExTransaction } from '@0x/types';
import { AbiEncoder, BigNumber } from '@0x/utils'; import { AbiEncoder, BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import { MethodAbi, TransactionReceiptWithDecodedLogs, ZeroExProvider } from 'ethereum-types'; import { MethodAbi, TransactionReceiptWithDecodedLogs, ZeroExProvider } from 'ethereum-types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { artifacts, ExchangeContract } from '../../src'; import { ExchangeContract } from '../../src';
import { AbiDecodedFillOrderData } from './types'; import { AbiDecodedFillOrderData } from './types';
export class ExchangeWrapper { export class ExchangeWrapper {
private readonly _exchange: ExchangeContract; private readonly _exchange: ExchangeContract;
// tslint:disable no-unused-variable
private readonly _web3Wrapper: Web3Wrapper; private readonly _web3Wrapper: Web3Wrapper;
constructor(exchangeContract: ExchangeContract, provider: Web3ProviderEngine | ZeroExProvider) { constructor(exchangeContract: ExchangeContract, provider: Web3ProviderEngine | ZeroExProvider) {
this._exchange = exchangeContract; this._exchange = exchangeContract;
@ -186,7 +178,9 @@ export class ExchangeWrapper {
assetProxyAddress: string, assetProxyAddress: string,
from: string, from: string,
): Promise<TransactionReceiptWithDecodedLogs> { ): Promise<TransactionReceiptWithDecodedLogs> {
const txReceipt = await this._exchange.registerAssetProxy.awaitTransactionSuccessAsync(assetProxyAddress, { from }); const txReceipt = await this._exchange.registerAssetProxy.awaitTransactionSuccessAsync(assetProxyAddress, {
from,
});
return txReceipt; return txReceipt;
} }
public async executeTransactionAsync( public async executeTransactionAsync(

View File

@ -137,6 +137,7 @@ export async function fillOrderCombinatorialUtilsFactoryAsync(
libsArtifacts.TestLibs, libsArtifacts.TestLibs,
provider, provider,
txDefaults, txDefaults,
dependencyArtifacts,
); );
const fillOrderCombinatorialUtils = new FillOrderCombinatorialUtils( const fillOrderCombinatorialUtils = new FillOrderCombinatorialUtils(

View File

@ -130,6 +130,7 @@ describe(ContractName.BalanceThresholdFilter, () => {
artifacts.Exchange, artifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
artifacts,
zrxAssetData, zrxAssetData,
); );
exchangeWrapper = new ExchangeWrapper(exchangeInstance, provider); exchangeWrapper = new ExchangeWrapper(exchangeInstance, provider);
@ -148,6 +149,7 @@ describe(ContractName.BalanceThresholdFilter, () => {
artifacts.BalanceThresholdFilter, artifacts.BalanceThresholdFilter,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchangeInstance.address, exchangeInstance.address,
erc721BalanceThresholdAsset.address, erc721BalanceThresholdAsset.address,
erc721alanceThreshold, erc721alanceThreshold,
@ -157,6 +159,7 @@ describe(ContractName.BalanceThresholdFilter, () => {
artifacts.BalanceThresholdFilter, artifacts.BalanceThresholdFilter,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchangeInstance.address, exchangeInstance.address,
erc20BalanceThresholdAsset.address, erc20BalanceThresholdAsset.address,
erc20BalanceThreshold, erc20BalanceThreshold,

View File

@ -82,7 +82,7 @@ describe(ContractName.DutchAuction, () => {
const erc721Balances = await erc721Wrapper.getBalancesAsync(); const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address]; erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults); wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults, artifacts);
erc20Wrapper.addDummyTokenContract(wethContract as any); erc20Wrapper.addDummyTokenContract(wethContract as any);
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
@ -90,6 +90,7 @@ describe(ContractName.DutchAuction, () => {
artifacts.Exchange, artifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
artifacts,
zrxAssetData, zrxAssetData,
); );
const exchangeWrapper = new ExchangeWrapper(exchangeInstance, provider); const exchangeWrapper = new ExchangeWrapper(exchangeInstance, provider);
@ -107,6 +108,7 @@ describe(ContractName.DutchAuction, () => {
artifacts.DutchAuction, artifacts.DutchAuction,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchangeInstance.address, exchangeInstance.address,
); );
dutchAuctionContract = new DutchAuctionContract(dutchAuctionInstance.address, provider); dutchAuctionContract = new DutchAuctionContract(dutchAuctionInstance.address, provider);

View File

@ -103,12 +103,14 @@ describe('OrderMatcher', () => {
proxyArtifacts.ERC721Proxy, proxyArtifacts.ERC721Proxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
// Depoy exchange // Depoy exchange
exchange = await ExchangeContract.deployFrom0xArtifactAsync( exchange = await ExchangeContract.deployFrom0xArtifactAsync(
artifacts.Exchange, artifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
artifacts,
assetDataUtils.encodeERC20AssetData(zrxToken.address), assetDataUtils.encodeERC20AssetData(zrxToken.address),
); );
exchangeWrapper = new ExchangeWrapper(exchange, provider); exchangeWrapper = new ExchangeWrapper(exchange, provider);
@ -126,6 +128,7 @@ describe('OrderMatcher', () => {
artifacts.OrderMatcher, artifacts.OrderMatcher,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchange.address, exchange.address,
); );
// Set default addresses // Set default addresses
@ -198,6 +201,7 @@ describe('OrderMatcher', () => {
artifacts.Exchange, artifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.NULL_BYTES, constants.NULL_BYTES,
); );
return expectContractCreationFailedAsync( return expectContractCreationFailedAsync(
@ -205,6 +209,7 @@ describe('OrderMatcher', () => {
artifacts.OrderMatcher, artifacts.OrderMatcher,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchangeInstance.address, exchangeInstance.address,
) as any) as sendTransactionResult, ) as any) as sendTransactionResult,
RevertReason.UnregisteredAssetProxy, RevertReason.UnregisteredAssetProxy,
@ -727,6 +732,7 @@ describe('OrderMatcher', () => {
erc721Artifacts.DummyERC721Token, erc721Artifacts.DummyERC721Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
); );
@ -772,6 +778,7 @@ describe('OrderMatcher', () => {
erc721Artifacts.DummyERC721Token, erc721Artifacts.DummyERC721Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
); );
@ -789,6 +796,7 @@ describe('OrderMatcher', () => {
erc721Artifacts.DummyERC721Token, erc721Artifacts.DummyERC721Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL, constants.DUMMY_TOKEN_SYMBOL,
); );

View File

@ -61,17 +61,20 @@ describe('AssetProxyOwner', () => {
proxyArtifacts.MixinAuthorizable, proxyArtifacts.MixinAuthorizable,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
erc721Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync( erc721Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync(
proxyArtifacts.MixinAuthorizable, proxyArtifacts.MixinAuthorizable,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
const defaultAssetProxyContractAddresses: string[] = []; const defaultAssetProxyContractAddresses: string[] = [];
testAssetProxyOwner = await TestAssetProxyOwnerContract.deployFrom0xArtifactAsync( testAssetProxyOwner = await TestAssetProxyOwnerContract.deployFrom0xArtifactAsync(
artifacts.TestAssetProxyOwner, artifacts.TestAssetProxyOwner,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
defaultAssetProxyContractAddresses, defaultAssetProxyContractAddresses,
REQUIRED_APPROVALS, REQUIRED_APPROVALS,
@ -105,6 +108,7 @@ describe('AssetProxyOwner', () => {
artifacts.AssetProxyOwner, artifacts.AssetProxyOwner,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
assetProxyContractAddresses, assetProxyContractAddresses,
REQUIRED_APPROVALS, REQUIRED_APPROVALS,
@ -122,6 +126,7 @@ describe('AssetProxyOwner', () => {
artifacts.AssetProxyOwner, artifacts.AssetProxyOwner,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
assetProxyContractAddresses, assetProxyContractAddresses,
REQUIRED_APPROVALS, REQUIRED_APPROVALS,

View File

@ -66,6 +66,7 @@ describe('MultiSigWalletWithTimeLock', () => {
artifacts.MultiSigWalletWithTimeLock, artifacts.MultiSigWalletWithTimeLock,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
REQUIRED_APPROVALS, REQUIRED_APPROVALS,
secondsTimeLocked, secondsTimeLocked,
@ -81,6 +82,7 @@ describe('MultiSigWalletWithTimeLock', () => {
artifacts.MultiSigWalletWithTimeLock, artifacts.MultiSigWalletWithTimeLock,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
REQUIRED_APPROVALS, REQUIRED_APPROVALS,
secondsTimeLocked, secondsTimeLocked,
@ -135,6 +137,7 @@ describe('MultiSigWalletWithTimeLock', () => {
artifacts.MultiSigWalletWithTimeLock, artifacts.MultiSigWalletWithTimeLock,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
REQUIRED_APPROVALS, REQUIRED_APPROVALS,
secondsTimeLocked, secondsTimeLocked,
@ -198,6 +201,7 @@ describe('MultiSigWalletWithTimeLock', () => {
artifacts.TestRejectEther, artifacts.TestRejectEther,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
const data = constants.NULL_BYTES; const data = constants.NULL_BYTES;
const value = new BigNumber(10); const value = new BigNumber(10);
@ -234,6 +238,7 @@ describe('MultiSigWalletWithTimeLock', () => {
artifacts.MultiSigWalletWithTimeLock, artifacts.MultiSigWalletWithTimeLock,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
REQUIRED_APPROVALS, REQUIRED_APPROVALS,
secondsTimeLocked, secondsTimeLocked,
@ -308,6 +313,7 @@ describe('MultiSigWalletWithTimeLock', () => {
artifacts.MultiSigWalletWithTimeLock, artifacts.MultiSigWalletWithTimeLock,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
REQUIRED_APPROVALS, REQUIRED_APPROVALS,
SECONDS_TIME_LOCKED, SECONDS_TIME_LOCKED,

View File

@ -28,6 +28,7 @@ describe('LibAddressArray', () => {
artifacts.TestLibAddressArray, artifacts.TestLibAddressArray,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
}); });
after(async () => { after(async () => {

View File

@ -68,7 +68,12 @@ describe('LibBytes', () => {
testAddress = accounts[1]; testAddress = accounts[1];
testAddressB = accounts[2]; testAddressB = accounts[2];
// Deploy LibBytes // Deploy LibBytes
libBytes = await TestLibBytesContract.deployFrom0xArtifactAsync(artifacts.TestLibBytes, provider, txDefaults); libBytes = await TestLibBytesContract.deployFrom0xArtifactAsync(
artifacts.TestLibBytes,
provider,
txDefaults,
artifacts,
);
// Verify lengths of test data // Verify lengths of test data
const byteArrayShorterThan32BytesLength = ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength; const byteArrayShorterThan32BytesLength = ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength;
expect(byteArrayShorterThan32BytesLength).to.be.lessThan(32); expect(byteArrayShorterThan32BytesLength).to.be.lessThan(32);

View File

@ -24,6 +24,7 @@ describe('Libs', () => {
artifacts.TestConstants, artifacts.TestConstants,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
const isValid = await testConstants.assertValidZrxAssetData.callAsync(); const isValid = await testConstants.assertValidZrxAssetData.callAsync();
expect(isValid).to.be.equal(true); expect(isValid).to.be.equal(true);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,11 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { import { BaseContract,
BaseContract,
BlockRange, BlockRange,
EventCallback, EventCallback,
IndexedFilterValues, IndexedFilterValues,
SubscriptionManager, SubscriptionManager,PromiseWithTransactionHash } from '@0x/base-contract';
PromiseWithTransactionHash,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -29,9 +26,11 @@ import { SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert'; import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
import * as _ from 'lodash';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
export type CoordinatorRegistryEventArgs = CoordinatorRegistryCoordinatorEndpointSetEventArgs; export type CoordinatorRegistryEventArgs =
| CoordinatorRegistryCoordinatorEndpointSetEventArgs;
export enum CoordinatorRegistryEvents { export enum CoordinatorRegistryEvents {
CoordinatorEndpointSet = 'CoordinatorEndpointSet', CoordinatorEndpointSet = 'CoordinatorEndpointSet',
@ -42,30 +41,38 @@ export interface CoordinatorRegistryCoordinatorEndpointSetEventArgs extends Deco
coordinatorEndpoint: string; coordinatorEndpoint: string;
} }
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
export class CoordinatorRegistryContract extends BaseContract { export class CoordinatorRegistryContract extends BaseContract {
public setCoordinatorEndpoint = { public setCoordinatorEndpoint = {
async sendTransactionAsync(coordinatorEndpoint: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
assert.isString('coordinatorEndpoint', coordinatorEndpoint); coordinatorEndpoint: string,
const self = (this as any) as CoordinatorRegistryContract; txData?: Partial<TxData> | undefined,
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); ): Promise<string> {
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( assert.isString('coordinatorEndpoint', coordinatorEndpoint);
{ const self = this as any as CoordinatorRegistryContract;
to: self.address, const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
...txData, ]);
data: encodedData, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
}, {
self._web3Wrapper.getContractDefaults(), to: self.address,
self.setCoordinatorEndpoint.estimateGasAsync.bind(self, coordinatorEndpoint), ...txData,
); data: encodedData,
if (txDataWithDefaults.from !== undefined) { },
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); self._web3Wrapper.getContractDefaults(),
} self.setCoordinatorEndpoint.estimateGasAsync.bind(
self,
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); coordinatorEndpoint
return txHash; ),
);
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
coordinatorEndpoint: string, coordinatorEndpoint: string,
@ -73,45 +80,51 @@ export class CoordinatorRegistryContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('coordinatorEndpoint', coordinatorEndpoint); assert.isString('coordinatorEndpoint', coordinatorEndpoint);
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData); const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( , txData);
txHashPromise, return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
(async (): Promise<TransactionReceiptWithDecodedLogs> => { txHashPromise,
// When the transaction hash resolves, wait for it to be mined. (async (): Promise<TransactionReceiptWithDecodedLogs> => {
return self._web3Wrapper.awaitTransactionSuccessAsync( // When the transaction hash resolves, wait for it to be mined.
await txHashPromise, return self._web3Wrapper.awaitTransactionSuccessAsync(
pollingIntervalMs, await txHashPromise,
timeoutMs, pollingIntervalMs,
); timeoutMs,
})(), );
); })(),
);
}, },
async estimateGasAsync(coordinatorEndpoint: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
assert.isString('coordinatorEndpoint', coordinatorEndpoint); coordinatorEndpoint: string,
const self = (this as any) as CoordinatorRegistryContract; txData?: Partial<TxData> | undefined,
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); ): Promise<number> {
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( assert.isString('coordinatorEndpoint', coordinatorEndpoint);
{ const self = this as any as CoordinatorRegistryContract;
to: self.address, const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
...txData, ]);
data: encodedData, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
}, {
self._web3Wrapper.getContractDefaults(), to: self.address,
); ...txData,
if (txDataWithDefaults.from !== undefined) { data: encodedData,
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); },
} self._web3Wrapper.getContractDefaults(),
);
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); if (txDataWithDefaults.from !== undefined) {
return gas; txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas;
}, },
async callAsync( async callAsync(
coordinatorEndpoint: string, coordinatorEndpoint: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('coordinatorEndpoint', coordinatorEndpoint); assert.isString('coordinatorEndpoint', coordinatorEndpoint);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -121,8 +134,9 @@ export class CoordinatorRegistryContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -131,24 +145,24 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)'); const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<void>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<void
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(coordinatorEndpoint: string): string { getABIEncodedTransactionData(
coordinatorEndpoint: string,
): string {
assert.isString('coordinatorEndpoint', coordinatorEndpoint); assert.isString('coordinatorEndpoint', coordinatorEndpoint);
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [ const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
coordinatorEndpoint, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -157,7 +171,8 @@ export class CoordinatorRegistryContract extends BaseContract {
coordinatorOperator: string, coordinatorOperator: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.isString('coordinatorOperator', coordinatorOperator); assert.isString('coordinatorOperator', coordinatorOperator);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -167,10 +182,9 @@ export class CoordinatorRegistryContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [ const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [coordinatorOperator.toLowerCase()
coordinatorOperator.toLowerCase(), ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -179,32 +193,33 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)'); const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<string>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<string
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(coordinatorOperator: string): string { getABIEncodedTransactionData(
coordinatorOperator: string,
): string {
assert.isString('coordinatorOperator', coordinatorOperator); assert.isString('coordinatorOperator', coordinatorOperator);
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [coordinatorOperator.toLowerCase()
coordinatorOperator.toLowerCase(), ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
private readonly _subscriptionManager: SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>; private readonly _subscriptionManager: SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>;
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
artifactDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<CoordinatorRegistryContract> { ): Promise<CoordinatorRegistryContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -217,13 +232,15 @@ export class CoordinatorRegistryContract extends BaseContract {
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object; const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi; const abi = artifact.compilerOutput.abi;
return CoordinatorRegistryContract.deployAsync(bytecode, abi, provider, txDefaults); const abiDependencies = _.mapValues(artifactDependencies, (artifactDependency: ContractArtifact | SimpleContractArtifact) => {return artifactDependency.compilerOutput.abi});
return CoordinatorRegistryContract.deployAsync(bytecode, abi, provider, txDefaults, abiDependencies, );
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
abi: ContractAbi, abi: ContractAbi,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
abiDependencies: { [contractName: string]: ContractAbi },
): Promise<CoordinatorRegistryContract> { ): Promise<CoordinatorRegistryContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -233,13 +250,17 @@ export class CoordinatorRegistryContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -247,21 +268,18 @@ export class CoordinatorRegistryContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`CoordinatorRegistry successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`CoordinatorRegistry successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new CoordinatorRegistryContract( const contractInstance = new CoordinatorRegistryContract(txReceipt.contractAddress as string, provider, txDefaults, abiDependencies);
txReceipt.contractAddress as string,
provider,
txDefaults,
);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -270,12 +288,13 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
], ],
name: 'setCoordinatorEndpoint', name: 'setCoordinatorEndpoint',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -294,14 +313,16 @@ export class CoordinatorRegistryContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
inputs: [], inputs: [
outputs: [], ],
outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
}, },
{ {
anonymous: false, anonymous: false,
inputs: [ inputs: [
{ {
@ -316,7 +337,8 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
], ],
name: 'CoordinatorEndpointSet', name: 'CoordinatorEndpointSet',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -390,15 +412,15 @@ export class CoordinatorRegistryContract extends BaseContract {
); );
return logs; return logs;
} }
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) { constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
super('CoordinatorRegistry', CoordinatorRegistryContract.ABI(), address, supportedProvider, txDefaults); super('CoordinatorRegistry', CoordinatorRegistryContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>( this._subscriptionManager = new SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>(
CoordinatorRegistryContract.ABI(), CoordinatorRegistryContract.ABI(),
this._web3Wrapper, this._web3Wrapper,
); );
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -21,146 +21,94 @@ import { SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert'; import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
import * as _ from 'lodash';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
export class DutchAuctionContract extends BaseContract { export class DutchAuctionContract extends BaseContract {
public getAuctionDetails = { public getAuctionDetails = {
async sendTransactionAsync( async sendTransactionAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; txData?: Partial<TxData> | undefined,
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
const self = (this as any) as DutchAuctionContract;
const encodedData = self._strictEncodeArguments( const self = this as any as DutchAuctionContract;
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order
[order], ]);
); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( {
{ to: self.address,
to: self.address, ...txData,
...txData, data: encodedData,
data: encodedData, },
}, self._web3Wrapper.getContractDefaults(),
self._web3Wrapper.getContractDefaults(), self.getAuctionDetails.estimateGasAsync.bind(
self.getAuctionDetails.estimateGasAsync.bind(self, order), self,
); order
if (txDataWithDefaults.from !== undefined) { ),
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); );
} if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); }
return txHash;
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
txData?: Partial<TxData>, txData?: Partial<TxData>,
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
const self = (this as any) as DutchAuctionContract;
const txHashPromise = self.getAuctionDetails.sendTransactionAsync(order, txData); const self = this as any as DutchAuctionContract;
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( const txHashPromise = self.getAuctionDetails.sendTransactionAsync(order
txHashPromise, , txData);
(async (): Promise<TransactionReceiptWithDecodedLogs> => { return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
// When the transaction hash resolves, wait for it to be mined. txHashPromise,
return self._web3Wrapper.awaitTransactionSuccessAsync( (async (): Promise<TransactionReceiptWithDecodedLogs> => {
await txHashPromise, // When the transaction hash resolves, wait for it to be mined.
pollingIntervalMs, return self._web3Wrapper.awaitTransactionSuccessAsync(
timeoutMs, await txHashPromise,
); pollingIntervalMs,
})(), timeoutMs,
); );
})(),
);
}, },
async estimateGasAsync( async estimateGasAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
const self = (this as any) as DutchAuctionContract;
const encodedData = self._strictEncodeArguments( const self = this as any as DutchAuctionContract;
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order
[order], ]);
); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( {
{ to: self.address,
to: self.address, ...txData,
...txData, data: encodedData,
data: encodedData, },
}, self._web3Wrapper.getContractDefaults(),
self._web3Wrapper.getContractDefaults(), );
); if (txDataWithDefaults.from !== undefined) {
if (txDataWithDefaults.from !== undefined) { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); }
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas;
return gas;
}, },
async callAsync( async callAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<{ ): Promise<{beginTimeSeconds: BigNumber;endTimeSeconds: BigNumber;beginAmount: BigNumber;endAmount: BigNumber;currentAmount: BigNumber;currentTimeSeconds: BigNumber}
beginTimeSeconds: BigNumber; > {
endTimeSeconds: BigNumber;
beginAmount: BigNumber;
endAmount: BigNumber;
currentAmount: BigNumber;
currentTimeSeconds: BigNumber;
}> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -169,11 +117,9 @@ export class DutchAuctionContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as DutchAuctionContract; const self = this as any as DutchAuctionContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', ]);
[order],
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -182,266 +128,141 @@ export class DutchAuctionContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))');
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<{ const result = abiEncoder.strictDecodeReturnValue<{beginTimeSeconds: BigNumber;endTimeSeconds: BigNumber;beginAmount: BigNumber;endAmount: BigNumber;currentAmount: BigNumber;currentTimeSeconds: BigNumber}
beginTimeSeconds: BigNumber; >(rawCallResult);
endTimeSeconds: BigNumber;
beginAmount: BigNumber;
endAmount: BigNumber;
currentAmount: BigNumber;
currentTimeSeconds: BigNumber;
}>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(order: { getABIEncodedTransactionData(
makerAddress: string; order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string; const self = this as any as DutchAuctionContract;
makerAssetAmount: BigNumber; const abiEncodedTransactionData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order
takerAssetAmount: BigNumber; ]);
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}): string {
const self = (this as any) as DutchAuctionContract;
const abiEncodedTransactionData = self._strictEncodeArguments(
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))',
[order],
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public matchOrders = { public matchOrders = {
async sendTransactionAsync( async sendTransactionAsync(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string, buySignature: string,
sellSignature: string, sellSignature: string,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature);
const self = (this as any) as DutchAuctionContract; assert.isString('buySignature', buySignature);
const encodedData = self._strictEncodeArguments( assert.isString('sellSignature', sellSignature);
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', const self = this as any as DutchAuctionContract;
[buyOrder, sellOrder, buySignature, sellSignature], const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder,
); sellOrder,
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( buySignature,
{ sellSignature
to: self.address, ]);
...txData, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
data: encodedData, {
}, to: self.address,
self._web3Wrapper.getContractDefaults(), ...txData,
self.matchOrders.estimateGasAsync.bind(self, buyOrder, sellOrder, buySignature, sellSignature), data: encodedData,
); },
if (txDataWithDefaults.from !== undefined) { self._web3Wrapper.getContractDefaults(),
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); self.matchOrders.estimateGasAsync.bind(
} self,
buyOrder,
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); sellOrder,
return txHash; buySignature,
sellSignature
),
);
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string, buySignature: string,
sellSignature: string, sellSignature: string,
txData?: Partial<TxData>, txData?: Partial<TxData>,
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature);
const self = (this as any) as DutchAuctionContract; assert.isString('buySignature', buySignature);
const txHashPromise = self.matchOrders.sendTransactionAsync( assert.isString('sellSignature', sellSignature);
buyOrder, const self = this as any as DutchAuctionContract;
sellOrder, const txHashPromise = self.matchOrders.sendTransactionAsync(buyOrder,
buySignature, sellOrder,
sellSignature, buySignature,
txData, sellSignature
); , txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
// When the transaction hash resolves, wait for it to be mined. // When the transaction hash resolves, wait for it to be mined.
return self._web3Wrapper.awaitTransactionSuccessAsync( return self._web3Wrapper.awaitTransactionSuccessAsync(
await txHashPromise, await txHashPromise,
pollingIntervalMs, pollingIntervalMs,
timeoutMs, timeoutMs,
); );
})(), })(),
); );
}, },
async estimateGasAsync( async estimateGasAsync(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string, buySignature: string,
sellSignature: string, sellSignature: string,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature);
const self = (this as any) as DutchAuctionContract; assert.isString('buySignature', buySignature);
const encodedData = self._strictEncodeArguments( assert.isString('sellSignature', sellSignature);
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', const self = this as any as DutchAuctionContract;
[buyOrder, sellOrder, buySignature, sellSignature], const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder,
); sellOrder,
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( buySignature,
{ sellSignature
to: self.address, ]);
...txData, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
data: encodedData, {
}, to: self.address,
self._web3Wrapper.getContractDefaults(), ...txData,
); data: encodedData,
if (txDataWithDefaults.from !== undefined) { },
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); self._web3Wrapper.getContractDefaults(),
} );
if (txDataWithDefaults.from !== undefined) {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
return gas; }
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas;
}, },
async callAsync( async callAsync(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string, buySignature: string,
sellSignature: string, sellSignature: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<{ ): Promise<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber}
left: { > {
makerAssetFilledAmount: BigNumber;
takerAssetFilledAmount: BigNumber;
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
};
right: {
makerAssetFilledAmount: BigNumber;
takerAssetFilledAmount: BigNumber;
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
};
leftMakerAssetSpreadAmount: BigNumber;
}> {
assert.isString('buySignature', buySignature); assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature); assert.isString('sellSignature', sellSignature);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -452,11 +273,12 @@ export class DutchAuctionContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as DutchAuctionContract; const self = this as any as DutchAuctionContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder,
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', sellOrder,
[buyOrder, sellOrder, buySignature, sellSignature], buySignature,
); sellSignature
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -465,81 +287,42 @@ export class DutchAuctionContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)');
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<{ const result = abiEncoder.strictDecodeReturnValue<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber}
left: { >(rawCallResult);
makerAssetFilledAmount: BigNumber;
takerAssetFilledAmount: BigNumber;
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
};
right: {
makerAssetFilledAmount: BigNumber;
takerAssetFilledAmount: BigNumber;
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
};
leftMakerAssetSpreadAmount: BigNumber;
}>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string; buySignature: string,
feeRecipientAddress: string; sellSignature: string,
senderAddress: string; ): string {
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string,
sellSignature: string,
): string {
assert.isString('buySignature', buySignature); assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature); assert.isString('sellSignature', sellSignature);
const self = (this as any) as DutchAuctionContract; const self = this as any as DutchAuctionContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder,
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', sellOrder,
[buyOrder, sellOrder, buySignature, sellSignature], buySignature,
); sellSignature
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
_exchange: string, artifactDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
_exchange: string,
): Promise<DutchAuctionContract> { ): Promise<DutchAuctionContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -552,14 +335,17 @@ export class DutchAuctionContract extends BaseContract {
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object; const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi; const abi = artifact.compilerOutput.abi;
return DutchAuctionContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange); const abiDependencies = _.mapValues(artifactDependencies, (artifactDependency: ContractArtifact | SimpleContractArtifact) => {return artifactDependency.compilerOutput.abi});
return DutchAuctionContract.deployAsync(bytecode, abi, provider, txDefaults, abiDependencies, _exchange
);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
abi: ContractAbi, abi: ContractAbi,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
_exchange: string, abiDependencies: { [contractName: string]: ContractAbi },
_exchange: string,
): Promise<DutchAuctionContract> { ): Promise<DutchAuctionContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -569,17 +355,20 @@ export class DutchAuctionContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[_exchange] = BaseContract._formatABIDataItemList( [_exchange
] = BaseContract._formatABIDataItemList(
constructorAbi.inputs, constructorAbi.inputs,
[_exchange], [_exchange
],
BaseContract._bigNumberToString, BaseContract._bigNumberToString,
); );
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, [_exchange]); const txData = deployInfo.encode(bytecode, [_exchange
]);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -587,17 +376,19 @@ export class DutchAuctionContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`DutchAuction successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`DutchAuction successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new DutchAuctionContract(txReceipt.contractAddress as string, provider, txDefaults); const contractInstance = new DutchAuctionContract(txReceipt.contractAddress as string, provider, txDefaults, abiDependencies);
contractInstance.constructorArgs = [_exchange]; contractInstance.constructorArgs = [_exchange
];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -652,7 +443,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
], ],
name: 'getAuctionDetails', name: 'getAuctionDetails',
@ -685,14 +476,14 @@ export class DutchAuctionContract extends BaseContract {
name: 'currentTimeSeconds', name: 'currentTimeSeconds',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -747,7 +538,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'sellOrder', name: 'sellOrder',
@ -801,7 +592,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'buySignature', name: 'buySignature',
@ -838,7 +629,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerFeePaid', name: 'takerFeePaid',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
{ {
name: 'right', name: 'right',
@ -860,27 +651,28 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerFeePaid', name: 'takerFeePaid',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
{ {
name: 'leftMakerAssetSpreadAmount', name: 'leftMakerAssetSpreadAmount',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
inputs: [ inputs: [
{ {
name: '_exchange', name: '_exchange',
type: 'address', type: 'address',
}, },
], ],
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
@ -888,11 +680,11 @@ export class DutchAuctionContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) { constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
super('DutchAuction', DutchAuctionContract.ABI(), address, supportedProvider, txDefaults); super('DutchAuction', DutchAuctionContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,11 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { import { BaseContract,
BaseContract,
BlockRange, BlockRange,
EventCallback, EventCallback,
IndexedFilterValues, IndexedFilterValues,
SubscriptionManager, SubscriptionManager,PromiseWithTransactionHash } from '@0x/base-contract';
PromiseWithTransactionHash,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -29,9 +26,12 @@ import { SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert'; import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
import * as _ from 'lodash';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
export type ERC20TokenEventArgs = ERC20TokenTransferEventArgs | ERC20TokenApprovalEventArgs; export type ERC20TokenEventArgs =
| ERC20TokenTransferEventArgs
| ERC20TokenApprovalEventArgs;
export enum ERC20TokenEvents { export enum ERC20TokenEvents {
Transfer = 'Transfer', Transfer = 'Transfer',
@ -50,6 +50,7 @@ export interface ERC20TokenApprovalEventArgs extends DecodedLogArgs {
_value: BigNumber; _value: BigNumber;
} }
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
@ -58,30 +59,33 @@ export class ERC20TokenContract extends BaseContract {
async sendTransactionAsync( async sendTransactionAsync(
_spender: string, _spender: string,
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender.toLowerCase(),
_value
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
...txData,
data: encodedData,
},
self._web3Wrapper.getContractDefaults(),
self.approve.estimateGasAsync.bind(
self,
_spender.toLowerCase(), _spender.toLowerCase(),
_value, _value
]); ),
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( );
{ if (txDataWithDefaults.from !== undefined) {
to: self.address, txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
...txData, }
data: encodedData,
}, const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
self._web3Wrapper.getContractDefaults(), return txHash;
self.approve.estimateGasAsync.bind(self, _spender.toLowerCase(), _value),
);
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
_spender: string, _spender: string,
@ -90,55 +94,57 @@ export class ERC20TokenContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData); const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(),
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( _value
txHashPromise, , txData);
(async (): Promise<TransactionReceiptWithDecodedLogs> => { return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
// When the transaction hash resolves, wait for it to be mined. txHashPromise,
return self._web3Wrapper.awaitTransactionSuccessAsync( (async (): Promise<TransactionReceiptWithDecodedLogs> => {
await txHashPromise, // When the transaction hash resolves, wait for it to be mined.
pollingIntervalMs, return self._web3Wrapper.awaitTransactionSuccessAsync(
timeoutMs, await txHashPromise,
); pollingIntervalMs,
})(), timeoutMs,
); );
})(),
);
}, },
async estimateGasAsync( async estimateGasAsync(
_spender: string, _spender: string,
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender.toLowerCase(),
_spender.toLowerCase(), _value
_value, ]);
]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( {
{ to: self.address,
to: self.address, ...txData,
...txData, data: encodedData,
data: encodedData, },
}, self._web3Wrapper.getContractDefaults(),
self._web3Wrapper.getContractDefaults(), );
); if (txDataWithDefaults.from !== undefined) {
if (txDataWithDefaults.from !== undefined) { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); }
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas;
return gas;
}, },
async callAsync( async callAsync(
_spender: string, _spender: string,
_value: BigNumber, _value: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -149,11 +155,10 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender.toLowerCase(),
_spender.toLowerCase(), _value
_value, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -162,31 +167,36 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_spender: string, _value: BigNumber): string { getABIEncodedTransactionData(
_spender: string,
_value: BigNumber,
): string {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_spender.toLowerCase(),
_spender.toLowerCase(), _value
_value, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public totalSupply = { public totalSupply = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<BigNumber
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -195,7 +205,7 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('totalSupply()', []); const encodedData = self._strictEncodeArguments('totalSupply()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -205,20 +215,20 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('totalSupply()'); const abiEncoder = self._lookupAbiEncoder('totalSupply()');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(): string { getABIEncodedTransactionData(
const self = (this as any) as ERC20TokenContract; ): string {
const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []); const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -228,32 +238,36 @@ export class ERC20TokenContract extends BaseContract {
_from: string, _from: string,
_to: string, _to: string,
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_to.toLowerCase(),
_value
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
...txData,
data: encodedData,
},
self._web3Wrapper.getContractDefaults(),
self.transferFrom.estimateGasAsync.bind(
self,
_from.toLowerCase(), _from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_value, _value
]); ),
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( );
{ if (txDataWithDefaults.from !== undefined) {
to: self.address, txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
...txData, }
data: encodedData,
}, const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
self._web3Wrapper.getContractDefaults(), return txHash;
self.transferFrom.estimateGasAsync.bind(self, _from.toLowerCase(), _to.toLowerCase(), _value),
);
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
_from: string, _from: string,
@ -263,27 +277,25 @@ export class ERC20TokenContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const txHashPromise = self.transferFrom.sendTransactionAsync( const txHashPromise = self.transferFrom.sendTransactionAsync(_from.toLowerCase(),
_from.toLowerCase(), _to.toLowerCase(),
_to.toLowerCase(), _value
_value, , txData);
txData, return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
); txHashPromise,
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( (async (): Promise<TransactionReceiptWithDecodedLogs> => {
txHashPromise, // When the transaction hash resolves, wait for it to be mined.
(async (): Promise<TransactionReceiptWithDecodedLogs> => { return self._web3Wrapper.awaitTransactionSuccessAsync(
// When the transaction hash resolves, wait for it to be mined. await txHashPromise,
return self._web3Wrapper.awaitTransactionSuccessAsync( pollingIntervalMs,
await txHashPromise, timeoutMs,
pollingIntervalMs, );
timeoutMs, })(),
); );
})(),
);
}, },
async estimateGasAsync( async estimateGasAsync(
_from: string, _from: string,
@ -291,29 +303,28 @@ export class ERC20TokenContract extends BaseContract {
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(), _to.toLowerCase(),
_to.toLowerCase(), _value
_value, ]);
]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( {
{ to: self.address,
to: self.address, ...txData,
...txData, data: encodedData,
data: encodedData, },
}, self._web3Wrapper.getContractDefaults(),
self._web3Wrapper.getContractDefaults(), );
); if (txDataWithDefaults.from !== undefined) {
if (txDataWithDefaults.from !== undefined) { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); }
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas;
return gas;
}, },
async callAsync( async callAsync(
_from: string, _from: string,
@ -321,7 +332,8 @@ export class ERC20TokenContract extends BaseContract {
_value: BigNumber, _value: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
@ -333,12 +345,11 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(), _to.toLowerCase(),
_to.toLowerCase(), _value
_value, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -347,28 +358,30 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string { getABIEncodedTransactionData(
_from: string,
_to: string,
_value: BigNumber,
): string {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(), _to.toLowerCase(),
_to.toLowerCase(), _value
_value, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -377,7 +390,8 @@ export class ERC20TokenContract extends BaseContract {
_owner: string, _owner: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<BigNumber> { ): Promise<BigNumber
> {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -387,8 +401,9 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -397,22 +412,24 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_owner: string): string { getABIEncodedTransactionData(
_owner: string,
): string {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -420,27 +437,33 @@ export class ERC20TokenContract extends BaseContract {
async sendTransactionAsync( async sendTransactionAsync(
_to: string, _to: string,
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( _value
{ ]);
to: self.address, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
...txData, {
data: encodedData, to: self.address,
}, ...txData,
self._web3Wrapper.getContractDefaults(), data: encodedData,
self.transfer.estimateGasAsync.bind(self, _to.toLowerCase(), _value), },
); self._web3Wrapper.getContractDefaults(),
if (txDataWithDefaults.from !== undefined) { self.transfer.estimateGasAsync.bind(
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); self,
} _to.toLowerCase(),
_value
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); ),
return txHash; );
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
_to: string, _to: string,
@ -449,48 +472,57 @@ export class ERC20TokenContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData); const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(),
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( _value
txHashPromise, , txData);
(async (): Promise<TransactionReceiptWithDecodedLogs> => { return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
// When the transaction hash resolves, wait for it to be mined. txHashPromise,
return self._web3Wrapper.awaitTransactionSuccessAsync( (async (): Promise<TransactionReceiptWithDecodedLogs> => {
await txHashPromise, // When the transaction hash resolves, wait for it to be mined.
pollingIntervalMs, return self._web3Wrapper.awaitTransactionSuccessAsync(
timeoutMs, await txHashPromise,
); pollingIntervalMs,
})(), timeoutMs,
); );
})(),
);
}, },
async estimateGasAsync(_to: string, _value: BigNumber, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
assert.isString('_to', _to); _to: string,
assert.isBigNumber('_value', _value); _value: BigNumber,
const self = (this as any) as ERC20TokenContract; txData?: Partial<TxData> | undefined,
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); ): Promise<number> {
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( assert.isString('_to', _to);
{ assert.isBigNumber('_value', _value);
to: self.address, const self = this as any as ERC20TokenContract;
...txData, const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
data: encodedData, _value
}, ]);
self._web3Wrapper.getContractDefaults(), const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
); {
if (txDataWithDefaults.from !== undefined) { to: self.address,
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); ...txData,
} data: encodedData,
},
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); self._web3Wrapper.getContractDefaults(),
return gas; );
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas;
}, },
async callAsync( async callAsync(
_to: string, _to: string,
_value: BigNumber, _value: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -501,8 +533,10 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
_value
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -511,26 +545,27 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_to: string, _value: BigNumber): string { getABIEncodedTransactionData(
_to: string,
_value: BigNumber,
): string {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
_to.toLowerCase(), _value
_value, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -540,7 +575,8 @@ export class ERC20TokenContract extends BaseContract {
_spender: string, _spender: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<BigNumber> { ): Promise<BigNumber
> {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -551,11 +587,10 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('allowance(address,address)', [ const encodedData = self._strictEncodeArguments('allowance(address,address)', [_owner.toLowerCase(),
_owner.toLowerCase(), _spender.toLowerCase()
_spender.toLowerCase(), ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -564,34 +599,36 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_owner: string, _spender: string): string { getABIEncodedTransactionData(
_owner: string,
_spender: string,
): string {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [_owner.toLowerCase(),
_owner.toLowerCase(), _spender.toLowerCase()
_spender.toLowerCase(), ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
private readonly _subscriptionManager: SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>; private readonly _subscriptionManager: SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>;
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
artifactDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<ERC20TokenContract> { ): Promise<ERC20TokenContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -604,13 +641,15 @@ export class ERC20TokenContract extends BaseContract {
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object; const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi; const abi = artifact.compilerOutput.abi;
return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults); const abiDependencies = _.mapValues(artifactDependencies, (artifactDependency: ContractArtifact | SimpleContractArtifact) => {return artifactDependency.compilerOutput.abi});
return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, abiDependencies, );
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
abi: ContractAbi, abi: ContractAbi,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
abiDependencies: { [contractName: string]: ContractAbi },
): Promise<ERC20TokenContract> { ): Promise<ERC20TokenContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -620,13 +659,17 @@ export class ERC20TokenContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -634,17 +677,18 @@ export class ERC20TokenContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`ERC20Token successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`ERC20Token successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new ERC20TokenContract(txReceipt.contractAddress as string, provider, txDefaults); const contractInstance = new ERC20TokenContract(txReceipt.contractAddress as string, provider, txDefaults, abiDependencies);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -667,9 +711,10 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'totalSupply', name: 'totalSupply',
outputs: [ outputs: [
{ {
@ -681,7 +726,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -708,7 +753,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -727,7 +772,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -750,7 +795,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -773,7 +818,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
anonymous: false, anonymous: false,
inputs: [ inputs: [
{ {
@ -793,10 +838,11 @@ export class ERC20TokenContract extends BaseContract {
}, },
], ],
name: 'Transfer', name: 'Transfer',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
{ {
anonymous: false, anonymous: false,
inputs: [ inputs: [
{ {
@ -816,7 +862,8 @@ export class ERC20TokenContract extends BaseContract {
}, },
], ],
name: 'Approval', name: 'Approval',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -890,15 +937,15 @@ export class ERC20TokenContract extends BaseContract {
); );
return logs; return logs;
} }
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) { constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
super('ERC20Token', ERC20TokenContract.ABI(), address, supportedProvider, txDefaults); super('ERC20Token', ERC20TokenContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>( this._subscriptionManager = new SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>(
ERC20TokenContract.ABI(), ERC20TokenContract.ABI(),
this._web3Wrapper, this._web3Wrapper,
); );
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -21,8 +21,10 @@ import { SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert'; import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
import * as _ from 'lodash';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
@ -32,7 +34,8 @@ export class EthBalanceCheckerContract extends BaseContract {
addresses: string[], addresses: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<BigNumber[]> { ): Promise<BigNumber[]
> {
assert.isArray('addresses', addresses); assert.isArray('addresses', addresses);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -42,8 +45,9 @@ export class EthBalanceCheckerContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as EthBalanceCheckerContract; const self = this as any as EthBalanceCheckerContract;
const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -52,29 +56,32 @@ export class EthBalanceCheckerContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])'); const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<BigNumber[]>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<BigNumber[]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(addresses: string[]): string { getABIEncodedTransactionData(
addresses: string[],
): string {
assert.isArray('addresses', addresses); assert.isArray('addresses', addresses);
const self = (this as any) as EthBalanceCheckerContract; const self = this as any as EthBalanceCheckerContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
artifactDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<EthBalanceCheckerContract> { ): Promise<EthBalanceCheckerContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -87,13 +94,15 @@ export class EthBalanceCheckerContract extends BaseContract {
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object; const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi; const abi = artifact.compilerOutput.abi;
return EthBalanceCheckerContract.deployAsync(bytecode, abi, provider, txDefaults); const abiDependencies = _.mapValues(artifactDependencies, (artifactDependency: ContractArtifact | SimpleContractArtifact) => {return artifactDependency.compilerOutput.abi});
return EthBalanceCheckerContract.deployAsync(bytecode, abi, provider, txDefaults, abiDependencies, );
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
abi: ContractAbi, abi: ContractAbi,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
abiDependencies: { [contractName: string]: ContractAbi },
): Promise<EthBalanceCheckerContract> { ): Promise<EthBalanceCheckerContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -103,13 +112,17 @@ export class EthBalanceCheckerContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -117,21 +130,18 @@ export class EthBalanceCheckerContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`EthBalanceChecker successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`EthBalanceChecker successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new EthBalanceCheckerContract( const contractInstance = new EthBalanceCheckerContract(txReceipt.contractAddress as string, provider, txDefaults, abiDependencies);
txReceipt.contractAddress as string,
provider,
txDefaults,
);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -153,11 +163,11 @@ export class EthBalanceCheckerContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) { constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
super('EthBalanceChecker', EthBalanceCheckerContract.ABI(), address, supportedProvider, txDefaults); super('EthBalanceChecker', EthBalanceCheckerContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -21,8 +21,10 @@ import { SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert'; import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
import * as _ from 'lodash';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
@ -34,7 +36,8 @@ export class IValidatorContract extends BaseContract {
signature: string, signature: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('hash', hash); assert.isString('hash', hash);
assert.isString('signerAddress', signerAddress); assert.isString('signerAddress', signerAddress);
assert.isString('signature', signature); assert.isString('signature', signature);
@ -46,12 +49,11 @@ export class IValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IValidatorContract; const self = this as any as IValidatorContract;
const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [ const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [hash,
hash, signerAddress.toLowerCase(),
signerAddress.toLowerCase(), signature
signature, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -60,35 +62,38 @@ export class IValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)'); const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(hash: string, signerAddress: string, signature: string): string { getABIEncodedTransactionData(
hash: string,
signerAddress: string,
signature: string,
): string {
assert.isString('hash', hash); assert.isString('hash', hash);
assert.isString('signerAddress', signerAddress); assert.isString('signerAddress', signerAddress);
assert.isString('signature', signature); assert.isString('signature', signature);
const self = (this as any) as IValidatorContract; const self = this as any as IValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [ const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [hash,
hash, signerAddress.toLowerCase(),
signerAddress.toLowerCase(), signature
signature, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
artifactDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<IValidatorContract> { ): Promise<IValidatorContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -101,13 +106,15 @@ export class IValidatorContract extends BaseContract {
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object; const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi; const abi = artifact.compilerOutput.abi;
return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults); const abiDependencies = _.mapValues(artifactDependencies, (artifactDependency: ContractArtifact | SimpleContractArtifact) => {return artifactDependency.compilerOutput.abi});
return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, abiDependencies, );
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
abi: ContractAbi, abi: ContractAbi,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
abiDependencies: { [contractName: string]: ContractAbi },
): Promise<IValidatorContract> { ): Promise<IValidatorContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -117,13 +124,17 @@ export class IValidatorContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -131,17 +142,18 @@ export class IValidatorContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`IValidator successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`IValidator successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new IValidatorContract(txReceipt.contractAddress as string, provider, txDefaults); const contractInstance = new IValidatorContract(txReceipt.contractAddress as string, provider, txDefaults, abiDependencies);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -171,11 +183,11 @@ export class IValidatorContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) { constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
super('IValidator', IValidatorContract.ABI(), address, supportedProvider, txDefaults); super('IValidator', IValidatorContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -21,8 +21,10 @@ import { SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert'; import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
import * as _ from 'lodash';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
@ -33,7 +35,8 @@ export class IWalletContract extends BaseContract {
signature: string, signature: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('hash', hash); assert.isString('hash', hash);
assert.isString('signature', signature); assert.isString('signature', signature);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -44,8 +47,10 @@ export class IWalletContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IWalletContract; const self = this as any as IWalletContract;
const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash, signature]); const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash,
signature
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -54,33 +59,35 @@ export class IWalletContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)'); const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(hash: string, signature: string): string { getABIEncodedTransactionData(
hash: string,
signature: string,
): string {
assert.isString('hash', hash); assert.isString('hash', hash);
assert.isString('signature', signature); assert.isString('signature', signature);
const self = (this as any) as IWalletContract; const self = this as any as IWalletContract;
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [ const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash,
hash, signature
signature, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
artifactDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<IWalletContract> { ): Promise<IWalletContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -93,13 +100,15 @@ export class IWalletContract extends BaseContract {
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object; const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi; const abi = artifact.compilerOutput.abi;
return IWalletContract.deployAsync(bytecode, abi, provider, txDefaults); const abiDependencies = _.mapValues(artifactDependencies, (artifactDependency: ContractArtifact | SimpleContractArtifact) => {return artifactDependency.compilerOutput.abi});
return IWalletContract.deployAsync(bytecode, abi, provider, txDefaults, abiDependencies, );
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
abi: ContractAbi, abi: ContractAbi,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
abiDependencies: { [contractName: string]: ContractAbi },
): Promise<IWalletContract> { ): Promise<IWalletContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -109,13 +118,17 @@ export class IWalletContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -123,17 +136,18 @@ export class IWalletContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`IWallet successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`IWallet successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new IWalletContract(txReceipt.contractAddress as string, provider, txDefaults); const contractInstance = new IWalletContract(txReceipt.contractAddress as string, provider, txDefaults, abiDependencies);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -159,11 +173,11 @@ export class IWalletContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) { constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
super('IWallet', IWalletContract.ABI(), address, supportedProvider, txDefaults); super('IWallet', IWalletContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -21,46 +21,23 @@ import { SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert'; import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
import * as _ from 'lodash';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
export class OrderValidatorContract extends BaseContract { export class OrderValidatorContract extends BaseContract {
public getOrderAndTraderInfo = { public getOrderAndTraderInfo = {
async callAsync( async callAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string, takerAddress: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise< ): Promise<[{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}, {makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}]
[
{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber },
{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}
]
> { > {
assert.isString('takerAddress', takerAddress); assert.isString('takerAddress', takerAddress);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -70,11 +47,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order,
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', takerAddress.toLowerCase()
[order, takerAddress.toLowerCase()], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -83,57 +59,27 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)');
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue< const result = abiEncoder.strictDecodeReturnValue<[{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}, {makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}]
[ >(rawCallResult);
{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber },
{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}
]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; takerAddress: string,
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string,
): string {
assert.isString('takerAddress', takerAddress); assert.isString('takerAddress', takerAddress);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order,
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', takerAddress.toLowerCase()
[order, takerAddress.toLowerCase()], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -143,7 +89,8 @@ export class OrderValidatorContract extends BaseContract {
assetData: string, assetData: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<[BigNumber, BigNumber]> { ): Promise<[BigNumber, BigNumber]
> {
assert.isString('target', target); assert.isString('target', target);
assert.isString('assetData', assetData); assert.isString('assetData', assetData);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -154,11 +101,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [ const encodedData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [target.toLowerCase(),
target.toLowerCase(), assetData
assetData, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -167,62 +113,37 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)'); const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(target: string, assetData: string): string { getABIEncodedTransactionData(
target: string,
assetData: string,
): string {
assert.isString('target', target); assert.isString('target', target);
assert.isString('assetData', assetData); assert.isString('assetData', assetData);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [ const abiEncodedTransactionData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [target.toLowerCase(),
target.toLowerCase(), assetData
assetData, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getOrdersAndTradersInfo = { public getOrdersAndTradersInfo = {
async callAsync( async callAsync(
orders: Array<{ orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}>,
takerAddresses: string[], takerAddresses: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise< ): Promise<[Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}>, Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>]
[
Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>,
Array<{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
]
> { > {
assert.isArray('orders', orders); assert.isArray('orders', orders);
assert.isArray('takerAddresses', takerAddresses); assert.isArray('takerAddresses', takerAddresses);
@ -234,11 +155,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders,
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', takerAddresses
[orders, takerAddresses], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -247,91 +167,37 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])');
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue< const result = abiEncoder.strictDecodeReturnValue<[Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}>, Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>]
[ >(rawCallResult);
Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>,
Array<{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
orders: Array<{ orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
makerAddress: string; takerAddresses: string[],
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}>,
takerAddresses: string[],
): string {
assert.isArray('orders', orders); assert.isArray('orders', orders);
assert.isArray('takerAddresses', takerAddresses); assert.isArray('takerAddresses', takerAddresses);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders,
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', takerAddresses
[orders, takerAddresses], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getTradersInfo = { public getTradersInfo = {
async callAsync( async callAsync(
orders: Array<{ orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}>,
takerAddresses: string[], takerAddresses: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise< ): Promise<Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>
Array<{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
> { > {
assert.isArray('orders', orders); assert.isArray('orders', orders);
assert.isArray('takerAddresses', takerAddresses); assert.isArray('takerAddresses', takerAddresses);
@ -343,11 +209,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders,
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', takerAddresses
[orders, takerAddresses], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -356,55 +221,27 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])');
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue< const result = abiEncoder.strictDecodeReturnValue<Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>
Array<{ >(rawCallResult);
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
orders: Array<{ orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
makerAddress: string; takerAddresses: string[],
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}>,
takerAddresses: string[],
): string {
assert.isArray('orders', orders); assert.isArray('orders', orders);
assert.isArray('takerAddresses', takerAddresses); assert.isArray('takerAddresses', takerAddresses);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders,
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', takerAddresses
[orders, takerAddresses], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -414,7 +251,8 @@ export class OrderValidatorContract extends BaseContract {
tokenId: BigNumber, tokenId: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.isString('token', token); assert.isString('token', token);
assert.isBigNumber('tokenId', tokenId); assert.isBigNumber('tokenId', tokenId);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -425,11 +263,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [ const encodedData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [token.toLowerCase(),
token.toLowerCase(), tokenId
tokenId, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -438,26 +275,27 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<string>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<string
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(token: string, tokenId: BigNumber): string { getABIEncodedTransactionData(
token: string,
tokenId: BigNumber,
): string {
assert.isString('token', token); assert.isString('token', token);
assert.isBigNumber('tokenId', tokenId); assert.isBigNumber('tokenId', tokenId);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [token.toLowerCase(),
token.toLowerCase(), tokenId
tokenId, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -467,7 +305,8 @@ export class OrderValidatorContract extends BaseContract {
assetData: string[], assetData: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<[BigNumber[], BigNumber[]]> { ): Promise<[BigNumber[], BigNumber[]]
> {
assert.isString('target', target); assert.isString('target', target);
assert.isArray('assetData', assetData); assert.isArray('assetData', assetData);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -478,11 +317,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [ const encodedData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [target.toLowerCase(),
target.toLowerCase(), assetData
assetData, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -491,58 +329,39 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])'); const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(target: string, assetData: string[]): string { getABIEncodedTransactionData(
target: string,
assetData: string[],
): string {
assert.isString('target', target); assert.isString('target', target);
assert.isArray('assetData', assetData); assert.isArray('assetData', assetData);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [ const abiEncodedTransactionData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [target.toLowerCase(),
target.toLowerCase(), assetData
assetData, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getTraderInfo = { public getTraderInfo = {
async callAsync( async callAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string, takerAddress: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<{ ): Promise<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}
makerBalance: BigNumber; > {
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}> {
assert.isString('takerAddress', takerAddress); assert.isString('takerAddress', takerAddress);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -552,11 +371,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order,
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', takerAddress.toLowerCase()
[order, takerAddress.toLowerCase()], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -565,61 +383,37 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)');
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<{ const result = abiEncoder.strictDecodeReturnValue<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}
makerBalance: BigNumber; >(rawCallResult);
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; takerAddress: string,
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string,
): string {
assert.isString('takerAddress', takerAddress); assert.isString('takerAddress', takerAddress);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order,
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', takerAddress.toLowerCase()
[order, takerAddress.toLowerCase()], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
_exchange: string, artifactDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
_zrxAssetData: string, _exchange: string,
_zrxAssetData: string,
): Promise<OrderValidatorContract> { ): Promise<OrderValidatorContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -632,15 +426,19 @@ export class OrderValidatorContract extends BaseContract {
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object; const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi; const abi = artifact.compilerOutput.abi;
return OrderValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange, _zrxAssetData); const abiDependencies = _.mapValues(artifactDependencies, (artifactDependency: ContractArtifact | SimpleContractArtifact) => {return artifactDependency.compilerOutput.abi});
return OrderValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, abiDependencies, _exchange,
_zrxAssetData
);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
abi: ContractAbi, abi: ContractAbi,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
_exchange: string, abiDependencies: { [contractName: string]: ContractAbi },
_zrxAssetData: string, _exchange: string,
_zrxAssetData: string,
): Promise<OrderValidatorContract> { ): Promise<OrderValidatorContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -650,17 +448,23 @@ export class OrderValidatorContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[_exchange, _zrxAssetData] = BaseContract._formatABIDataItemList( [_exchange,
_zrxAssetData
] = BaseContract._formatABIDataItemList(
constructorAbi.inputs, constructorAbi.inputs,
[_exchange, _zrxAssetData], [_exchange,
_zrxAssetData
],
BaseContract._bigNumberToString, BaseContract._bigNumberToString,
); );
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, [_exchange, _zrxAssetData]); const txData = deployInfo.encode(bytecode, [_exchange,
_zrxAssetData
]);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -668,17 +472,20 @@ export class OrderValidatorContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`OrderValidator successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`OrderValidator successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new OrderValidatorContract(txReceipt.contractAddress as string, provider, txDefaults); const contractInstance = new OrderValidatorContract(txReceipt.contractAddress as string, provider, txDefaults, abiDependencies);
contractInstance.constructorArgs = [_exchange, _zrxAssetData]; contractInstance.constructorArgs = [_exchange,
_zrxAssetData
];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -733,7 +540,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddress', name: 'takerAddress',
@ -758,7 +565,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'orderTakerAssetFilledAmount', name: 'orderTakerAssetFilledAmount',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
{ {
name: 'traderInfo', name: 'traderInfo',
@ -796,14 +603,14 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -830,7 +637,7 @@ export class OrderValidatorContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -885,7 +692,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddresses', name: 'takerAddresses',
@ -910,7 +717,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'orderTakerAssetFilledAmount', name: 'orderTakerAssetFilledAmount',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
{ {
name: 'tradersInfo', name: 'tradersInfo',
@ -948,14 +755,14 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -1010,7 +817,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddresses', name: 'takerAddresses',
@ -1055,14 +862,14 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -1085,7 +892,7 @@ export class OrderValidatorContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -1112,7 +919,7 @@ export class OrderValidatorContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -1167,7 +974,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddress', name: 'takerAddress',
@ -1212,14 +1019,14 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
inputs: [ inputs: [
{ {
name: '_exchange', name: '_exchange',
@ -1230,7 +1037,8 @@ export class OrderValidatorContract extends BaseContract {
type: 'bytes', type: 'bytes',
}, },
], ],
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
@ -1238,11 +1046,11 @@ export class OrderValidatorContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) { constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
super('OrderValidator', OrderValidatorContract.ABI(), address, supportedProvider, txDefaults); super('OrderValidator', OrderValidatorContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,12 @@ describe('AbiGenDummy Contract', () => {
let abiGenDummy: AbiGenDummyContract; let abiGenDummy: AbiGenDummyContract;
before(async () => { before(async () => {
providerUtils.startProviderEngine(provider); providerUtils.startProviderEngine(provider);
abiGenDummy = await AbiGenDummyContract.deployFrom0xArtifactAsync(artifacts.AbiGenDummy, provider, txDefaults); abiGenDummy = await AbiGenDummyContract.deployFrom0xArtifactAsync(
artifacts.AbiGenDummy,
provider,
txDefaults,
artifacts,
);
await blockchainLifecycle.startAsync(); await blockchainLifecycle.startAsync();
}); });
after(async () => { after(async () => {
@ -146,7 +151,12 @@ describe('Lib dummy contract', () => {
await blockchainLifecycle.revertAsync(); await blockchainLifecycle.revertAsync();
}); });
before(async () => { before(async () => {
libDummy = await TestLibDummyContract.deployFrom0xArtifactAsync(artifacts.TestLibDummy, provider, txDefaults); libDummy = await TestLibDummyContract.deployFrom0xArtifactAsync(
artifacts.TestLibDummy,
provider,
txDefaults,
artifacts,
);
}); });
beforeEach(async () => { beforeEach(async () => {
await blockchainLifecycle.startAsync(); await blockchainLifecycle.startAsync();

View File

@ -212,8 +212,8 @@ export class BaseContract {
this._abiEncoderByFunctionSignature[functionSignature] = abiEncoder; this._abiEncoderByFunctionSignature[functionSignature] = abiEncoder;
this._web3Wrapper.abiDecoder.addABI(abi, contractName); this._web3Wrapper.abiDecoder.addABI(abi, contractName);
}); });
_.each(abiDependencies, (abi, name) => { _.each(abiDependencies, (abiDependency, contractDependencyName) => {
this._web3Wrapper.abiDecoder.addABI(abi, name); this._web3Wrapper.abiDecoder.addABI(abiDependency, contractDependencyName);
}); });
} }
} }

View File

@ -351,10 +351,12 @@ describe('ExchangeWrapper', () => {
}); });
}); });
it('should throw when the ERC20 token has transfer restrictions', async () => { it('should throw when the ERC20 token has transfer restrictions', async () => {
const artifactDependencies = {};
const untransferrableToken = await DummyERC20TokenContract.deployFrom0xArtifactAsync( const untransferrableToken = await DummyERC20TokenContract.deployFrom0xArtifactAsync(
UntransferrableDummyERC20Token, UntransferrableDummyERC20Token,
provider, provider,
{ from: userAddresses[0] }, { from: userAddresses[0] },
artifactDependencies,
'UntransferrableToken', 'UntransferrableToken',
'UTT', 'UTT',
new BigNumber(constants.ZRX_DECIMALS), new BigNumber(constants.ZRX_DECIMALS),

View File

@ -29,11 +29,13 @@ export async function runMigrationsAsync(
artifacts.ERC20Proxy, artifacts.ERC20Proxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
const erc721Proxy = await wrappers.ERC721ProxyContract.deployFrom0xArtifactAsync( const erc721Proxy = await wrappers.ERC721ProxyContract.deployFrom0xArtifactAsync(
artifacts.ERC721Proxy, artifacts.ERC721Proxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
// ZRX // ZRX
@ -41,10 +43,16 @@ export async function runMigrationsAsync(
artifacts.ZRXToken, artifacts.ZRXToken,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
// Ether token // Ether token
const etherToken = await wrappers.WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults); const etherToken = await wrappers.WETH9Contract.deployFrom0xArtifactAsync(
artifacts.WETH9,
provider,
txDefaults,
artifacts,
);
// Exchange // Exchange
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
@ -52,6 +60,7 @@ export async function runMigrationsAsync(
artifacts.Exchange, artifacts.Exchange,
provider, provider,
txDefaults, txDefaults,
artifacts,
zrxAssetData, zrxAssetData,
); );
@ -63,6 +72,7 @@ export async function runMigrationsAsync(
artifacts.DummyERC20Token, artifacts.DummyERC20Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
token.name, token.name,
token.symbol, token.symbol,
token.decimals, token.decimals,
@ -76,6 +86,7 @@ export async function runMigrationsAsync(
artifacts.DummyERC721Token, artifacts.DummyERC721Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
erc721TokenInfo[0].name, erc721TokenInfo[0].name,
erc721TokenInfo[0].symbol, erc721TokenInfo[0].symbol,
); );
@ -84,6 +95,7 @@ export async function runMigrationsAsync(
artifacts.MultiAssetProxy, artifacts.MultiAssetProxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.awaitTransactionSuccessAsync(
@ -126,6 +138,7 @@ export async function runMigrationsAsync(
artifacts.Forwarder, artifacts.Forwarder,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchange.address, exchange.address,
assetDataUtils.encodeERC20AssetData(zrxToken.address), assetDataUtils.encodeERC20AssetData(zrxToken.address),
assetDataUtils.encodeERC20AssetData(etherToken.address), assetDataUtils.encodeERC20AssetData(etherToken.address),
@ -136,6 +149,7 @@ export async function runMigrationsAsync(
artifacts.OrderValidator, artifacts.OrderValidator,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchange.address, exchange.address,
zrxAssetData, zrxAssetData,
); );
@ -145,6 +159,7 @@ export async function runMigrationsAsync(
artifacts.DutchAuction, artifacts.DutchAuction,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchange.address, exchange.address,
); );
@ -159,6 +174,7 @@ export async function runMigrationsAsync(
artifacts.AssetProxyOwner, artifacts.AssetProxyOwner,
provider, provider,
txDefaults, txDefaults,
artifacts,
owners, owners,
[erc20Proxy.address, erc721Proxy.address, multiAssetProxy.address], [erc20Proxy.address, erc721Proxy.address, multiAssetProxy.address],
confirmationsRequired, confirmationsRequired,
@ -188,6 +204,7 @@ export async function runMigrationsAsync(
artifacts.CoordinatorRegistry, artifacts.CoordinatorRegistry,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
// Coordinator // Coordinator
@ -195,6 +212,7 @@ export async function runMigrationsAsync(
artifacts.Coordinator, artifacts.Coordinator,
provider, provider,
txDefaults, txDefaults,
artifacts,
exchange.address, exchange.address,
); );

View File

@ -46,6 +46,7 @@ describe('ExchangeTransferSimulator', async () => {
artifacts.ERC20Proxy, artifacts.ERC20Proxy,
provider, provider,
txDefaults, txDefaults,
artifacts,
); );
erc20ProxyAddress = erc20Proxy.address; erc20ProxyAddress = erc20Proxy.address;
@ -58,6 +59,7 @@ describe('ExchangeTransferSimulator', async () => {
artifacts.DummyERC20Token, artifacts.DummyERC20Token,
provider, provider,
txDefaults, txDefaults,
artifacts,
name, name,
symbol, symbol,
decimals, decimals,