aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/contract-wrappers/package.json10
-rw-r--r--packages/contract-wrappers/src/artifacts.ts27
-rw-r--r--packages/contract-wrappers/src/contract_wrappers.ts5
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts9
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts21
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts9
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts21
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts31
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts21
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts11
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts9
-rw-r--r--packages/contract-wrappers/src/index.ts54
-rw-r--r--packages/contract-wrappers/src/types.ts18
-rw-r--r--packages/contract-wrappers/src/utils/transaction_encoder.ts10
-rw-r--r--packages/contract-wrappers/test/utils/token_utils.ts8
-rw-r--r--packages/contracts/generated-wrappers/erc20_token.ts556
-rw-r--r--packages/contracts/generated-wrappers/erc721_token.ts893
-rw-r--r--packages/contracts/package.json10
-rw-r--r--packages/contracts/src/index.ts5
-rw-r--r--packages/contracts/src/wrappers/index.ts2
20 files changed, 1569 insertions, 161 deletions
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json
index 35f27d77c..70efccec6 100644
--- a/packages/contract-wrappers/package.json
+++ b/packages/contract-wrappers/package.json
@@ -11,24 +11,19 @@
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
- "build": "yarn pre_build && tsc -b",
+ "build": "tsc -b",
"build:ci": "yarn build",
- "pre_build": "run-s update_artifacts generate_contract_wrappers copy_artifacts",
- "generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token|ZRXToken|ERC20Token|ERC721Token|WETH9|ERC20Proxy|ERC721Proxy|Forwarder|OrderValidator).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers",
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*",
"test:circleci": "run-s test:coverage",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
- "update_artifacts": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-trimmed/$i.json src/artifacts; done;",
- "copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
- "clean": "shx rm -rf _bundles lib test_temp test/artifacts src/contract_wrappers/generated src/artifacts generated_docs",
+ "clean": "shx rm -rf _bundles lib test_temp generated_docs",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
- "contracts_v2": "AssetProxyOwner Exchange ERC20Proxy ERC20Token ERC721Proxy ERC721Token WETH9 ZRXToken Forwarder OrderValidator DummyERC20Token DummyERC721Token",
"postpublish": {
"assets": []
}
@@ -72,6 +67,7 @@
"web3-provider-engine": "14.0.6"
},
"dependencies": {
+ "@0xproject/contracts": "^2.0.0",
"@0xproject/assert": "^1.0.13",
"@0xproject/base-contract": "^3.0.1",
"@0xproject/fill-scenarios": "^1.0.7",
diff --git a/packages/contract-wrappers/src/artifacts.ts b/packages/contract-wrappers/src/artifacts.ts
deleted file mode 100644
index 925f34162..000000000
--- a/packages/contract-wrappers/src/artifacts.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { ContractArtifact } from 'ethereum-types';
-
-import * as DummyERC20Token from './artifacts/DummyERC20Token.json';
-import * as DummyERC721Token from './artifacts/DummyERC721Token.json';
-import * as ERC20Proxy from './artifacts/ERC20Proxy.json';
-import * as ERC20Token from './artifacts/ERC20Token.json';
-import * as ERC721Proxy from './artifacts/ERC721Proxy.json';
-import * as ERC721Token from './artifacts/ERC721Token.json';
-import * as Exchange from './artifacts/Exchange.json';
-import * as Forwarder from './artifacts/Forwarder.json';
-import * as OrderValidator from './artifacts/OrderValidator.json';
-import * as EtherToken from './artifacts/WETH9.json';
-import * as ZRXToken from './artifacts/ZRXToken.json';
-
-export const artifacts = {
- ZRXToken: (ZRXToken as any) as ContractArtifact,
- DummyERC20Token: (DummyERC20Token as any) as ContractArtifact,
- DummyERC721Token: (DummyERC721Token as any) as ContractArtifact,
- ERC20Token: (ERC20Token as any) as ContractArtifact,
- ERC721Token: (ERC721Token as any) as ContractArtifact,
- Exchange: (Exchange as any) as ContractArtifact,
- EtherToken: (EtherToken as any) as ContractArtifact,
- ERC20Proxy: (ERC20Proxy as any) as ContractArtifact,
- ERC721Proxy: (ERC721Proxy as any) as ContractArtifact,
- Forwarder: (Forwarder as any) as ContractArtifact,
- OrderValidator: (OrderValidator as any) as ContractArtifact,
-};
diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts
index 89402029b..b272fabda 100644
--- a/packages/contract-wrappers/src/contract_wrappers.ts
+++ b/packages/contract-wrappers/src/contract_wrappers.ts
@@ -1,10 +1,8 @@
+import { artifacts } from '@0xproject/contracts';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
-import { constants } from './utils/constants';
-
-import { artifacts } from './artifacts';
import { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
import { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
import { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper';
@@ -18,6 +16,7 @@ import { contractWrappersPrivateNetworkConfigSchema } from './schemas/contract_w
import { contractWrappersPublicNetworkConfigSchema } from './schemas/contract_wrappers_public_network_config_schema';
import { ContractWrappersConfig } from './types';
import { assert } from './utils/assert';
+import { constants } from './utils/constants';
/**
* The ContractWrappers class contains smart contract wrappers helpful when building on 0x protocol.
*/
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
index ff027d78a..5900f0502 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
@@ -1,20 +1,19 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { AssetProxyId } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from '../artifacts';
import { assert } from '../utils/assert';
import { ContractWrapper } from './contract_wrapper';
-import { ERC20ProxyContract } from './generated/erc20_proxy';
/**
* This class includes the functionality related to interacting with the ERC20Proxy contract.
*/
export class ERC20ProxyWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
- private _erc20ProxyContractIfExists?: ERC20ProxyContract;
+ private _erc20ProxyContractIfExists?: wrappers.ERC20ProxyContract;
private _contractAddressIfExists?: string;
/**
* Instantiate ERC20ProxyWrapper
@@ -72,7 +71,7 @@ export class ERC20ProxyWrapper extends ContractWrapper {
private _invalidateContractInstance(): void {
delete this._erc20ProxyContractIfExists;
}
- private async _getERC20ProxyContractAsync(): Promise<ERC20ProxyContract> {
+ private async _getERC20ProxyContractAsync(): Promise<wrappers.ERC20ProxyContract> {
if (!_.isUndefined(this._erc20ProxyContractIfExists)) {
return this._erc20ProxyContractIfExists;
}
@@ -80,7 +79,7 @@ export class ERC20ProxyWrapper extends ContractWrapper {
artifacts.ERC20Proxy,
this._contractAddressIfExists,
);
- const contractInstance = new ERC20ProxyContract(
+ const contractInstance = new wrappers.ERC20ProxyContract(
abi,
address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
index 4625cef6a..3be5bcaee 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
@@ -1,10 +1,10 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { schemas } from '@0xproject/json-schemas';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from '../artifacts';
import { methodOptsSchema } from '../schemas/method_opts_schema';
import { txOptsSchema } from '../schemas/tx_opts_schema';
import {
@@ -20,7 +20,6 @@ import { constants } from '../utils/constants';
import { ContractWrapper } from './contract_wrapper';
import { ERC20ProxyWrapper } from './erc20_proxy_wrapper';
-import { ERC20TokenContract, ERC20TokenEventArgs, ERC20TokenEvents } from './generated/erc20_token';
const removeUndefinedProperties = _.pickBy;
@@ -32,7 +31,7 @@ const removeUndefinedProperties = _.pickBy;
export class ERC20TokenWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.ERC20Token.compilerOutput.abi;
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- private _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
+ private _tokenContractsByAddress: { [address: string]: wrappers.ERC20TokenContract };
private _erc20ProxyWrapper: ERC20ProxyWrapper;
/**
* Instantiate ERC20TokenWrapper
@@ -357,15 +356,15 @@ export class ERC20TokenWrapper extends ContractWrapper {
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
* @return Subscription token used later to unsubscribe
*/
- public subscribe<ArgsType extends ERC20TokenEventArgs>(
+ public subscribe<ArgsType extends wrappers.ERC20TokenEventArgs>(
tokenAddress: string,
- eventName: ERC20TokenEvents,
+ eventName: wrappers.ERC20TokenEvents,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
): string {
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, wrappers.ERC20TokenEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const normalizedTokenAddress = tokenAddress.toLowerCase();
@@ -402,14 +401,14 @@ export class ERC20TokenWrapper extends ContractWrapper {
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
- public async getLogsAsync<ArgsType extends ERC20TokenEventArgs>(
+ public async getLogsAsync<ArgsType extends wrappers.ERC20TokenEventArgs>(
tokenAddress: string,
- eventName: ERC20TokenEvents,
+ eventName: wrappers.ERC20TokenEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, wrappers.ERC20TokenEvents);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const normalizedTokenAddress = tokenAddress.toLowerCase();
@@ -429,7 +428,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
this.unsubscribeAll();
this._tokenContractsByAddress = {};
}
- private async _getTokenContractAsync(tokenAddress: string): Promise<ERC20TokenContract> {
+ private async _getTokenContractAsync(tokenAddress: string): Promise<wrappers.ERC20TokenContract> {
const normalizedTokenAddress = tokenAddress.toLowerCase();
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
if (!_.isUndefined(tokenContract)) {
@@ -439,7 +438,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
artifacts.ERC20Token,
normalizedTokenAddress,
);
- const contractInstance = new ERC20TokenContract(
+ const contractInstance = new wrappers.ERC20TokenContract(
abi,
address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts
index 933c1dc27..6ba162213 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts
@@ -1,20 +1,19 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { AssetProxyId } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from '../artifacts';
import { assert } from '../utils/assert';
import { ContractWrapper } from './contract_wrapper';
-import { ERC721ProxyContract } from './generated/erc721_proxy';
/**
* This class includes the functionality related to interacting with the ERC721Proxy contract.
*/
export class ERC721ProxyWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
- private _erc721ProxyContractIfExists?: ERC721ProxyContract;
+ private _erc721ProxyContractIfExists?: wrappers.ERC721ProxyContract;
private _contractAddressIfExists?: string;
/**
* Instantiate ERC721ProxyWrapper
@@ -72,7 +71,7 @@ export class ERC721ProxyWrapper extends ContractWrapper {
private _invalidateContractInstance(): void {
delete this._erc721ProxyContractIfExists;
}
- private async _getERC721ProxyContractAsync(): Promise<ERC721ProxyContract> {
+ private async _getERC721ProxyContractAsync(): Promise<wrappers.ERC721ProxyContract> {
if (!_.isUndefined(this._erc721ProxyContractIfExists)) {
return this._erc721ProxyContractIfExists;
}
@@ -80,7 +79,7 @@ export class ERC721ProxyWrapper extends ContractWrapper {
artifacts.ERC721Proxy,
this._contractAddressIfExists,
);
- const contractInstance = new ERC721ProxyContract(
+ const contractInstance = new wrappers.ERC721ProxyContract(
abi,
address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
index 590dbbf74..23b335710 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
@@ -1,10 +1,10 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { schemas } from '@0xproject/json-schemas';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from '../artifacts';
import { methodOptsSchema } from '../schemas/method_opts_schema';
import { txOptsSchema } from '../schemas/tx_opts_schema';
import {
@@ -20,7 +20,6 @@ import { constants } from '../utils/constants';
import { ContractWrapper } from './contract_wrapper';
import { ERC721ProxyWrapper } from './erc721_proxy_wrapper';
-import { ERC721TokenContract, ERC721TokenEventArgs, ERC721TokenEvents } from './generated/erc721_token';
const removeUndefinedProperties = _.pickBy;
@@ -31,7 +30,7 @@ const removeUndefinedProperties = _.pickBy;
*/
export class ERC721TokenWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.ERC721Token.compilerOutput.abi;
- private _tokenContractsByAddress: { [address: string]: ERC721TokenContract };
+ private _tokenContractsByAddress: { [address: string]: wrappers.ERC721TokenContract };
private _erc721ProxyWrapper: ERC721ProxyWrapper;
/**
* Instantiate ERC721TokenWrapper
@@ -384,15 +383,15 @@ export class ERC721TokenWrapper extends ContractWrapper {
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
* @return Subscription token used later to unsubscribe
*/
- public subscribe<ArgsType extends ERC721TokenEventArgs>(
+ public subscribe<ArgsType extends wrappers.ERC721TokenEventArgs>(
tokenAddress: string,
- eventName: ERC721TokenEvents,
+ eventName: wrappers.ERC721TokenEvents,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
): string {
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, wrappers.ERC721TokenEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const normalizedTokenAddress = tokenAddress.toLowerCase();
@@ -429,14 +428,14 @@ export class ERC721TokenWrapper extends ContractWrapper {
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
- public async getLogsAsync<ArgsType extends ERC721TokenEventArgs>(
+ public async getLogsAsync<ArgsType extends wrappers.ERC721TokenEventArgs>(
tokenAddress: string,
- eventName: ERC721TokenEvents,
+ eventName: wrappers.ERC721TokenEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, wrappers.ERC721TokenEvents);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const normalizedTokenAddress = tokenAddress.toLowerCase();
@@ -456,7 +455,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
this.unsubscribeAll();
this._tokenContractsByAddress = {};
}
- private async _getTokenContractAsync(tokenAddress: string): Promise<ERC721TokenContract> {
+ private async _getTokenContractAsync(tokenAddress: string): Promise<wrappers.ERC721TokenContract> {
const normalizedTokenAddress = tokenAddress.toLowerCase();
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
if (!_.isUndefined(tokenContract)) {
@@ -466,7 +465,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
artifacts.ERC721Token,
normalizedTokenAddress,
);
- const contractInstance = new ERC721TokenContract(
+ const contractInstance = new wrappers.ERC721TokenContract(
abi,
address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
index 1ac01812e..30653adf2 100644
--- a/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
@@ -1,16 +1,15 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { schemas } from '@0xproject/json-schemas';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from '../artifacts';
import { BlockRange, ContractWrappersError, EventCallback, IndexedFilterValues, TransactionOpts } from '../types';
import { assert } from '../utils/assert';
import { ContractWrapper } from './contract_wrapper';
import { ERC20TokenWrapper } from './erc20_token_wrapper';
-import { WETH9Contract, WETH9EventArgs, WETH9Events } from './generated/weth9';
const removeUndefinedProperties = _.pickBy;
@@ -19,9 +18,9 @@ const removeUndefinedProperties = _.pickBy;
* The caller can convert ETH into the equivalent number of wrapped ETH ERC20 tokens and back.
*/
export class EtherTokenWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.EtherToken.compilerOutput.abi;
+ public abi: ContractAbi = artifacts.WETH9.compilerOutput.abi;
private _etherTokenContractsByAddress: {
- [address: string]: WETH9Contract;
+ [address: string]: wrappers.WETH9Contract;
} = {};
private _erc20TokenWrapper: ERC20TokenWrapper;
/**
@@ -126,15 +125,15 @@ export class EtherTokenWrapper extends ContractWrapper {
* the value is the value you are interested in. E.g `{_owner: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
- public async getLogsAsync<ArgsType extends WETH9EventArgs>(
+ public async getLogsAsync<ArgsType extends wrappers.WETH9EventArgs>(
etherTokenAddress: string,
- eventName: WETH9Events,
+ eventName: wrappers.WETH9Events,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.isETHAddressHex('etherTokenAddress', etherTokenAddress);
const normalizedEtherTokenAddress = etherTokenAddress.toLowerCase();
- assert.doesBelongToStringEnum('eventName', eventName, WETH9Events);
+ assert.doesBelongToStringEnum('eventName', eventName, wrappers.WETH9Events);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const logs = await this._getLogsAsync<ArgsType>(
@@ -142,7 +141,7 @@ export class EtherTokenWrapper extends ContractWrapper {
eventName,
blockRange,
indexFilterValues,
- artifacts.EtherToken.compilerOutput.abi,
+ artifacts.WETH9.compilerOutput.abi,
);
return logs;
}
@@ -156,23 +155,23 @@ export class EtherTokenWrapper extends ContractWrapper {
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
* @return Subscription token used later to unsubscribe
*/
- public subscribe<ArgsType extends WETH9EventArgs>(
+ public subscribe<ArgsType extends wrappers.WETH9EventArgs>(
etherTokenAddress: string,
- eventName: WETH9Events,
+ eventName: wrappers.WETH9Events,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
): string {
assert.isETHAddressHex('etherTokenAddress', etherTokenAddress);
const normalizedEtherTokenAddress = etherTokenAddress.toLowerCase();
- assert.doesBelongToStringEnum('eventName', eventName, WETH9Events);
+ assert.doesBelongToStringEnum('eventName', eventName, wrappers.WETH9Events);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const subscriptionToken = this._subscribe<ArgsType>(
normalizedEtherTokenAddress,
eventName,
indexFilterValues,
- artifacts.EtherToken.compilerOutput.abi,
+ artifacts.WETH9.compilerOutput.abi,
callback,
isVerbose,
);
@@ -199,7 +198,7 @@ export class EtherTokenWrapper extends ContractWrapper {
* @returns The Ethereum address of the EtherToken contract or undefined.
*/
public getContractAddressIfExists(): string | undefined {
- const networkSpecificArtifact = artifacts.EtherToken.networks[this._networkId];
+ const networkSpecificArtifact = artifacts.WETH9.networks[this._networkId];
const contractAddressIfExists = _.isUndefined(networkSpecificArtifact)
? undefined
: networkSpecificArtifact.address;
@@ -210,16 +209,16 @@ export class EtherTokenWrapper extends ContractWrapper {
this.unsubscribeAll();
this._etherTokenContractsByAddress = {};
}
- private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<WETH9Contract> {
+ private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<wrappers.WETH9Contract> {
let etherTokenContract = this._etherTokenContractsByAddress[etherTokenAddress];
if (!_.isUndefined(etherTokenContract)) {
return etherTokenContract;
}
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
- artifacts.EtherToken,
+ artifacts.WETH9,
etherTokenAddress,
);
- const contractInstance = new WETH9Contract(
+ const contractInstance = new wrappers.WETH9Contract(
abi,
address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts
index dc9ffcbf7..613747720 100644
--- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts
@@ -1,3 +1,4 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { schemas } from '@0xproject/json-schemas';
import {
assetDataUtils,
@@ -11,7 +12,6 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { BlockParamLiteral, ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from '../artifacts';
import { AssetBalanceAndProxyAllowanceFetcher } from '../fetchers/asset_balance_and_proxy_allowance_fetcher';
import { OrderFilledCancelledFetcher } from '../fetchers/order_filled_cancelled_fetcher';
import { methodOptsSchema } from '../schemas/method_opts_schema';
@@ -35,7 +35,6 @@ import { TransactionEncoder } from '../utils/transaction_encoder';
import { ContractWrapper } from './contract_wrapper';
import { ERC20TokenWrapper } from './erc20_token_wrapper';
import { ERC721TokenWrapper } from './erc721_token_wrapper';
-import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from './generated/exchange';
/**
* This class includes all the functionality related to calling methods, sending transactions and subscribing to
@@ -43,7 +42,7 @@ import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from './generated
*/
export class ExchangeWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.Exchange.compilerOutput.abi;
- private _exchangeContractIfExists?: ExchangeContract;
+ private _exchangeContractIfExists?: wrappers.ExchangeContract;
private _erc721TokenWrapper: ERC721TokenWrapper;
private _erc20TokenWrapper: ERC20TokenWrapper;
private _contractAddressIfExists?: string;
@@ -1042,13 +1041,13 @@ export class ExchangeWrapper extends ContractWrapper {
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
* @return Subscription token used later to unsubscribe
*/
- public subscribe<ArgsType extends ExchangeEventArgs>(
- eventName: ExchangeEvents,
+ public subscribe<ArgsType extends wrappers.ExchangeEventArgs>(
+ eventName: wrappers.ExchangeEvents,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
): string {
- assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, wrappers.ExchangeEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const exchangeContractAddress = this.getContractAddress();
@@ -1083,12 +1082,12 @@ export class ExchangeWrapper extends ContractWrapper {
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
- public async getLogsAsync<ArgsType extends ExchangeEventArgs>(
- eventName: ExchangeEvents,
+ public async getLogsAsync<ArgsType extends wrappers.ExchangeEventArgs>(
+ eventName: wrappers.ExchangeEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
- assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, wrappers.ExchangeEvents);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const exchangeContractAddress = this.getContractAddress();
@@ -1201,7 +1200,7 @@ export class ExchangeWrapper extends ContractWrapper {
delete this._exchangeContractIfExists;
}
// tslint:enable:no-unused-variable
- private async _getExchangeContractAsync(): Promise<ExchangeContract> {
+ private async _getExchangeContractAsync(): Promise<wrappers.ExchangeContract> {
if (!_.isUndefined(this._exchangeContractIfExists)) {
return this._exchangeContractIfExists;
}
@@ -1209,7 +1208,7 @@ export class ExchangeWrapper extends ContractWrapper {
artifacts.Exchange,
this._contractAddressIfExists,
);
- const contractInstance = new ExchangeContract(
+ const contractInstance = new wrappers.ExchangeContract(
abi,
address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
index c19edf188..854a8381b 100644
--- a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
@@ -1,3 +1,4 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { schemas } from '@0xproject/json-schemas';
import { AssetProxyId, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
@@ -5,7 +6,6 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from '../artifacts';
import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema';
import { txOptsSchema } from '../schemas/tx_opts_schema';
import { OrderTransactionOpts } from '../types';
@@ -16,14 +16,13 @@ import { decorators } from '../utils/decorators';
import { utils } from '../utils/utils';
import { ContractWrapper } from './contract_wrapper';
-import { ForwarderContract } from './generated/forwarder';
/**
* This class includes the functionality related to interacting with the Forwarder contract.
*/
export class ForwarderWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.Forwarder.compilerOutput.abi;
- private _forwarderContractIfExists?: ForwarderContract;
+ private _forwarderContractIfExists?: wrappers.ForwarderContract;
private _contractAddressIfExists?: string;
private _zrxContractAddressIfExists?: string;
constructor(
@@ -242,7 +241,7 @@ export class ForwarderWrapper extends ContractWrapper {
* @return Address of Ether token
*/
public getEtherTokenAddress(): string {
- const contractAddress = this._getContractAddress(artifacts.EtherToken);
+ const contractAddress = this._getContractAddress(artifacts.WETH9);
return contractAddress;
}
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
@@ -251,7 +250,7 @@ export class ForwarderWrapper extends ContractWrapper {
private _invalidateContractInstance(): void {
delete this._forwarderContractIfExists;
}
- private async _getForwarderContractAsync(): Promise<ForwarderContract> {
+ private async _getForwarderContractAsync(): Promise<wrappers.ForwarderContract> {
if (!_.isUndefined(this._forwarderContractIfExists)) {
return this._forwarderContractIfExists;
}
@@ -259,7 +258,7 @@ export class ForwarderWrapper extends ContractWrapper {
artifacts.Forwarder,
this._contractAddressIfExists,
);
- const contractInstance = new ForwarderContract(
+ const contractInstance = new wrappers.ForwarderContract(
abi,
address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
index 1da88f624..02f9dd4de 100644
--- a/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
@@ -1,3 +1,4 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { schemas } from '@0xproject/json-schemas';
import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
@@ -5,19 +6,17 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from '../artifacts';
import { BalanceAndAllowance, OrderAndTraderInfo, TraderInfo } from '../types';
import { assert } from '../utils/assert';
import { ContractWrapper } from './contract_wrapper';
-import { OrderValidatorContract } from './generated/order_validator';
/**
* This class includes the functionality related to interacting with the OrderValidator contract.
*/
export class OrderValidatorWrapper extends ContractWrapper {
public abi: ContractAbi = artifacts.OrderValidator.compilerOutput.abi;
- private _orderValidatorContractIfExists?: OrderValidatorContract;
+ private _orderValidatorContractIfExists?: wrappers.OrderValidatorContract;
/**
* Instantiate OrderValidatorWrapper
* @param web3Wrapper Web3Wrapper instance to use
@@ -170,12 +169,12 @@ export class OrderValidatorWrapper extends ContractWrapper {
private _invalidateContractInstance(): void {
delete this._orderValidatorContractIfExists;
}
- private async _getOrderValidatorContractAsync(): Promise<OrderValidatorContract> {
+ private async _getOrderValidatorContractAsync(): Promise<wrappers.OrderValidatorContract> {
if (!_.isUndefined(this._orderValidatorContractIfExists)) {
return this._orderValidatorContractIfExists;
}
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(artifacts.OrderValidator);
- const contractInstance = new OrderValidatorContract(
+ const contractInstance = new wrappers.OrderValidatorContract(
abi,
address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts
index e8a53170e..659394eb6 100644
--- a/packages/contract-wrappers/src/index.ts
+++ b/packages/contract-wrappers/src/index.ts
@@ -1,3 +1,5 @@
+import { wrappers } from '@0xproject/contracts';
+
export { ContractWrappers } from './contract_wrappers';
export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
export { ERC721TokenWrapper } from './contract_wrappers/erc721_token_wrapper';
@@ -54,39 +56,31 @@ export {
StateMutability,
} from 'ethereum-types';
-export {
- WETH9Events,
- WETH9WithdrawalEventArgs,
- WETH9ApprovalEventArgs,
- WETH9EventArgs,
- WETH9DepositEventArgs,
- WETH9TransferEventArgs,
-} from './contract_wrappers/generated/weth9';
+export const WETH9Events = wrappers.WETH9Events;
+export type WETH9WithdrawalEventArgs = wrappers.WETH9WithdrawalEventArgs;
+export type WETH9ApprovalEventArgs = wrappers.WETH9ApprovalEventArgs;
+export type WETH9EventArgs = wrappers.WETH9EventArgs;
+export type WETH9DepositEventArgs = wrappers.WETH9DepositEventArgs;
+export type WETH9TransferEventArgs = wrappers.WETH9TransferEventArgs;
-export {
- ERC20TokenTransferEventArgs,
- ERC20TokenApprovalEventArgs,
- ERC20TokenEvents,
- ERC20TokenEventArgs,
-} from './contract_wrappers/generated/erc20_token';
+export type ERC20TokenTransferEventArgs = wrappers.ERC20TokenTransferEventArgs;
+export type ERC20TokenApprovalEventArgs = wrappers.ERC20TokenApprovalEventArgs;
+export const ERC20TokenEvents = wrappers.ERC20TokenEvents;
+export type ERC20TokenEventArgs = wrappers.ERC20TokenEventArgs;
-export {
- ERC721TokenApprovalEventArgs,
- ERC721TokenApprovalForAllEventArgs,
- ERC721TokenTransferEventArgs,
- ERC721TokenEvents,
- ERC721TokenEventArgs,
-} from './contract_wrappers/generated/erc721_token';
+export type ERC721TokenApprovalEventArgs = wrappers.ERC721TokenApprovalEventArgs;
+export type ERC721TokenApprovalForAllEventArgs = wrappers.ERC721TokenApprovalForAllEventArgs;
+export type ERC721TokenTransferEventArgs = wrappers.ERC721TokenTransferEventArgs;
+export const ERC721TokenEvents = wrappers.ERC721TokenEvents;
+export type ERC721TokenEventArgs = wrappers.ERC721TokenEventArgs;
-export {
- ExchangeCancelUpToEventArgs,
- ExchangeAssetProxyRegisteredEventArgs,
- ExchangeSignatureValidatorApprovalEventArgs,
- ExchangeFillEventArgs,
- ExchangeCancelEventArgs,
- ExchangeEventArgs,
- ExchangeEvents,
-} from './contract_wrappers/generated/exchange';
+export type ExchangeCancelUpToEventArgs = wrappers.ExchangeCancelUpToEventArgs;
+export type ExchangeAssetProxyRegisteredEventArgs = wrappers.ExchangeAssetProxyRegisteredEventArgs;
+export type ExchangeSignatureValidatorApprovalEventArgs = wrappers.ExchangeSignatureValidatorApprovalEventArgs;
+export type ExchangeFillEventArgs = wrappers.ExchangeFillEventArgs;
+export type ExchangeCancelEventArgs = wrappers.ExchangeCancelEventArgs;
+export type ExchangeEventArgs = wrappers.ExchangeEventArgs;
+export const ExchangeEvents = wrappers.ExchangeEvents;
export { AbstractBalanceAndProxyAllowanceFetcher, AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils';
diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts
index e0b12b7c9..0ac5f05e4 100644
--- a/packages/contract-wrappers/src/types.ts
+++ b/packages/contract-wrappers/src/types.ts
@@ -1,13 +1,9 @@
+import { wrappers } from '@0xproject/contracts';
import { BigNumber } from '@0xproject/utils';
import { OrderState, SignedOrder } from '@0xproject/types';
import { BlockParam, ContractEventArg, DecodedLogArgs, LogEntryEvent, LogWithDecodedArgs } from 'ethereum-types';
-import { ERC20TokenEventArgs, ERC20TokenEvents } from './contract_wrappers/generated/erc20_token';
-import { ERC721TokenEventArgs, ERC721TokenEvents } from './contract_wrappers/generated/erc721_token';
-import { ExchangeEventArgs, ExchangeEvents } from './contract_wrappers/generated/exchange';
-import { WETH9EventArgs, WETH9Events } from './contract_wrappers/generated/weth9';
-
export enum ExchangeWrapperError {
AssetDataMismatch = 'ASSET_DATA_MISMATCH',
}
@@ -60,7 +56,11 @@ export interface ContractEvent {
args: ContractEventArgs;
}
-export type ContractEventArgs = ExchangeEventArgs | ERC20TokenEventArgs | ERC721TokenEventArgs | WETH9EventArgs;
+export type ContractEventArgs =
+ | wrappers.ExchangeEventArgs
+ | wrappers.ERC20TokenEventArgs
+ | wrappers.ERC721TokenEventArgs
+ | wrappers.WETH9EventArgs;
// [address, name, symbol, decimals, ipfsHash, swarmHash]
export type TokenMetadata = [string, string, string, number, string, string];
@@ -83,7 +83,11 @@ export interface TokenAddressBySymbol {
[symbol: string]: string;
}
-export type ContractEvents = ERC20TokenEvents | ERC721TokenEvents | ExchangeEvents | WETH9Events;
+export type ContractEvents =
+ | wrappers.ERC20TokenEvents
+ | wrappers.ERC721TokenEvents
+ | wrappers.ExchangeEvents
+ | wrappers.WETH9Events;
export interface IndexedFilterValues {
[index: string]: ContractEventArg;
diff --git a/packages/contract-wrappers/src/utils/transaction_encoder.ts b/packages/contract-wrappers/src/utils/transaction_encoder.ts
index 33086944b..f4c6de97f 100644
--- a/packages/contract-wrappers/src/utils/transaction_encoder.ts
+++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts
@@ -1,11 +1,11 @@
+import { wrappers } from '@0xproject/contracts';
+
import { schemas } from '@0xproject/json-schemas';
import { eip712Utils } from '@0xproject/order-utils';
import { Order, SignedOrder } from '@0xproject/types';
import { BigNumber, signTypedDataUtils } from '@0xproject/utils';
import _ = require('lodash');
-import { ExchangeContract } from '../contract_wrappers/generated/exchange';
-
import { assert } from './assert';
/**
@@ -14,8 +14,8 @@ import { assert } from './assert';
* can submit this to the blockchain. The Exchange context executes as if UserA had directly submitted this transaction.
*/
export class TransactionEncoder {
- private readonly _exchangeInstance: ExchangeContract;
- constructor(exchangeInstance: ExchangeContract) {
+ private readonly _exchangeInstance: wrappers.ExchangeContract;
+ constructor(exchangeInstance: wrappers.ExchangeContract) {
this._exchangeInstance = exchangeInstance;
}
/**
@@ -275,7 +275,7 @@ export class TransactionEncoder {
);
return abiEncodedData;
}
- private _getExchangeContract(): ExchangeContract {
+ private _getExchangeContract(): wrappers.ExchangeContract {
return this._exchangeInstance;
}
}
diff --git a/packages/contract-wrappers/test/utils/token_utils.ts b/packages/contract-wrappers/test/utils/token_utils.ts
index 06a82ff6e..0a35b4107 100644
--- a/packages/contract-wrappers/test/utils/token_utils.ts
+++ b/packages/contract-wrappers/test/utils/token_utils.ts
@@ -1,9 +1,7 @@
+import { artifacts, wrappers } from '@0xproject/contracts';
import { generatePseudoRandomSalt } from '@0xproject/order-utils';
import { BigNumber } from '@0xproject/utils';
-import { artifacts } from '../../src/artifacts';
-import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/dummy_erc721_token';
-
import { constants } from './constants';
import { provider, txDefaults, web3Wrapper } from './web3_wrapper';
@@ -24,7 +22,7 @@ export const tokenUtils = {
return artifacts.ZRXToken.networks[constants.TESTRPC_NETWORK_ID].address;
},
getWethTokenAddress(): string {
- return artifacts.EtherToken.networks[constants.TESTRPC_NETWORK_ID].address;
+ return artifacts.WETH9.networks[constants.TESTRPC_NETWORK_ID].address;
},
getDummyERC20TokenAddresses(): string[] {
return DUMMY_ERC_20_ADRESSES;
@@ -33,7 +31,7 @@ export const tokenUtils = {
return DUMMY_ERC_721_ADRESSES;
},
async mintDummyERC721Async(address: string, tokenOwner: string): Promise<BigNumber> {
- const erc721 = new DummyERC721TokenContract(
+ const erc721 = new wrappers.DummyERC721TokenContract(
artifacts.DummyERC721Token.compilerOutput.abi,
address,
provider,
diff --git a/packages/contracts/generated-wrappers/erc20_token.ts b/packages/contracts/generated-wrappers/erc20_token.ts
new file mode 100644
index 000000000..3f8f9cd92
--- /dev/null
+++ b/packages/contracts/generated-wrappers/erc20_token.ts
@@ -0,0 +1,556 @@
+// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
+// tslint:disable:no-unused-variable
+// tslint:disable:no-unbound-method
+import { BaseContract } from '@0xproject/base-contract';
+import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
+import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import * as ethers from 'ethers';
+import * as _ from 'lodash';
+// tslint:enable:no-unused-variable
+
+export type ERC20TokenEventArgs =
+ | ERC20TokenTransferEventArgs
+ | ERC20TokenApprovalEventArgs;
+
+export enum ERC20TokenEvents {
+ Transfer = 'Transfer',
+ Approval = 'Approval',
+}
+
+export interface ERC20TokenTransferEventArgs extends DecodedLogArgs {
+ _from: string;
+ _to: string;
+ _value: BigNumber;
+}
+
+export interface ERC20TokenApprovalEventArgs extends DecodedLogArgs {
+ _owner: string;
+ _spender: string;
+ _value: BigNumber;
+}
+
+
+/* istanbul ignore next */
+// tslint:disable:no-parameter-reassignment
+// tslint:disable-next-line:class-name
+export class ERC20TokenContract extends BaseContract {
+ public approve = {
+ async sendTransactionAsync(
+ _spender: string,
+ _value: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<string> {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
+ [_spender,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
+ _value
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender,
+ _value
+ ]);
+ const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
+ _value
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ self.approve.estimateGasAsync.bind(
+ self,
+ _spender,
+ _value
+ ),
+ );
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ return txHash;
+ },
+ async estimateGasAsync(
+ _spender: string,
+ _value: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<number> {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
+ [_spender,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
+ _value
+ ], BaseContract._bigNumberToString);
+ const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
+ _value
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ _spender: string,
+ _value: BigNumber,
+ ): string {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
+ [_spender,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
+ _value
+ ], BaseContract._bigNumberToString);
+ const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
+ _value
+ ]);
+ return abiEncodedTransactionData;
+ },
+ async callAsync(
+ _spender: string,
+ _value: BigNumber,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<boolean
+ > {
+ const self = this as any as ERC20TokenContract;
+ const functionSignature = 'approve(address,uint256)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_spender,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
+ _value
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender,
+ _value
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve;
+ const encodedData = ethersFunction.encode([_spender,
+ _value
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public totalSupply = {
+ async callAsync(
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<BigNumber
+ > {
+ const self = this as any as ERC20TokenContract;
+ const functionSignature = 'totalSupply()';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, []);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.totalSupply;
+ const encodedData = ethersFunction.encode([]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'totalSupply'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public transferFrom = {
+ async sendTransactionAsync(
+ _from: string,
+ _to: string,
+ _value: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<string> {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _value
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
+ _to,
+ _value
+ ]);
+ const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
+ _to,
+ _value
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ self.transferFrom.estimateGasAsync.bind(
+ self,
+ _from,
+ _to,
+ _value
+ ),
+ );
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ return txHash;
+ },
+ async estimateGasAsync(
+ _from: string,
+ _to: string,
+ _value: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<number> {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _value
+ ], BaseContract._bigNumberToString);
+ const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
+ _to,
+ _value
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ _from: string,
+ _to: string,
+ _value: BigNumber,
+ ): string {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _value
+ ], BaseContract._bigNumberToString);
+ const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
+ _to,
+ _value
+ ]);
+ return abiEncodedTransactionData;
+ },
+ async callAsync(
+ _from: string,
+ _to: string,
+ _value: BigNumber,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<boolean
+ > {
+ const self = this as any as ERC20TokenContract;
+ const functionSignature = 'transferFrom(address,address,uint256)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_from,
+ _to,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _value
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
+ _to,
+ _value
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom;
+ const encodedData = ethersFunction.encode([_from,
+ _to,
+ _value
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public balanceOf = {
+ async callAsync(
+ _owner: string,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<BigNumber
+ > {
+ const self = this as any as ERC20TokenContract;
+ const functionSignature = 'balanceOf(address)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_owner
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_owner
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf;
+ const encodedData = ethersFunction.encode([_owner
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public transfer = {
+ async sendTransactionAsync(
+ _to: string,
+ _value: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<string> {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
+ [_to,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_to,
+ _value
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_to,
+ _value
+ ]);
+ const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
+ _value
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ self.transfer.estimateGasAsync.bind(
+ self,
+ _to,
+ _value
+ ),
+ );
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ return txHash;
+ },
+ async estimateGasAsync(
+ _to: string,
+ _value: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<number> {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
+ [_to,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_to,
+ _value
+ ], BaseContract._bigNumberToString);
+ const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
+ _value
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ _to: string,
+ _value: BigNumber,
+ ): string {
+ const self = this as any as ERC20TokenContract;
+ const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
+ [_to,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_to,
+ _value
+ ], BaseContract._bigNumberToString);
+ const abiEncodedTransactionData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
+ _value
+ ]);
+ return abiEncodedTransactionData;
+ },
+ async callAsync(
+ _to: string,
+ _value: BigNumber,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<boolean
+ > {
+ const self = this as any as ERC20TokenContract;
+ const functionSignature = 'transfer(address,uint256)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_to,
+ _value
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_to,
+ _value
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_to,
+ _value
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transfer;
+ const encodedData = ethersFunction.encode([_to,
+ _value
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'transfer'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public allowance = {
+ async callAsync(
+ _owner: string,
+ _spender: string,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<BigNumber
+ > {
+ const self = this as any as ERC20TokenContract;
+ const functionSignature = 'allowance(address,address)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_owner,
+ _spender
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_owner,
+ _spender
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner,
+ _spender
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowance;
+ const encodedData = ethersFunction.encode([_owner,
+ _spender
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'allowance'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public static async deployFrom0xArtifactAsync(
+ artifact: ContractArtifact,
+ provider: Provider,
+ txDefaults: Partial<TxData>,
+ ): Promise<ERC20TokenContract> {
+ if (_.isUndefined(artifact.compilerOutput)) {
+ throw new Error('Compiler output not found in the artifact file');
+ }
+ const bytecode = artifact.compilerOutput.evm.bytecode.object;
+ const abi = artifact.compilerOutput.abi;
+ return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
+ }
+ public static async deployAsync(
+ bytecode: string,
+ abi: ContractAbi,
+ provider: Provider,
+ txDefaults: Partial<TxData>,
+ ): Promise<ERC20TokenContract> {
+ const constructorAbi = BaseContract._lookupConstructorAbi(abi);
+ [] = BaseContract._formatABIDataItemList(
+ constructorAbi.inputs,
+ [],
+ BaseContract._bigNumberToString,
+ );
+ const iface = new ethers.Interface(abi);
+ const deployInfo = iface.deployFunction;
+ const txData = deployInfo.encode(bytecode, []);
+ const web3Wrapper = new Web3Wrapper(provider);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {data: txData},
+ txDefaults,
+ web3Wrapper.estimateGasAsync.bind(web3Wrapper),
+ );
+ const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ logUtils.log(`transactionHash: ${txHash}`);
+ const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
+ logUtils.log(`ERC20Token successfully deployed at ${txReceipt.contractAddress}`);
+ const contractInstance = new ERC20TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
+ contractInstance.constructorArgs = [];
+ return contractInstance;
+ }
+ constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
+ super('ERC20Token', abi, address, provider, txDefaults);
+ classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
+ }
+} // tslint:disable:max-file-line-count
+// tslint:enable:no-unbound-method
diff --git a/packages/contracts/generated-wrappers/erc721_token.ts b/packages/contracts/generated-wrappers/erc721_token.ts
new file mode 100644
index 000000000..6c4aa644b
--- /dev/null
+++ b/packages/contracts/generated-wrappers/erc721_token.ts
@@ -0,0 +1,893 @@
+// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
+// tslint:disable:no-unused-variable
+// tslint:disable:no-unbound-method
+import { BaseContract } from '@0xproject/base-contract';
+import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
+import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import * as ethers from 'ethers';
+import * as _ from 'lodash';
+// tslint:enable:no-unused-variable
+
+export type ERC721TokenEventArgs =
+ | ERC721TokenTransferEventArgs
+ | ERC721TokenApprovalEventArgs
+ | ERC721TokenApprovalForAllEventArgs;
+
+export enum ERC721TokenEvents {
+ Transfer = 'Transfer',
+ Approval = 'Approval',
+ ApprovalForAll = 'ApprovalForAll',
+}
+
+export interface ERC721TokenTransferEventArgs extends DecodedLogArgs {
+ _from: string;
+ _to: string;
+ _tokenId: BigNumber;
+}
+
+export interface ERC721TokenApprovalEventArgs extends DecodedLogArgs {
+ _owner: string;
+ _approved: string;
+ _tokenId: BigNumber;
+}
+
+export interface ERC721TokenApprovalForAllEventArgs extends DecodedLogArgs {
+ _owner: string;
+ _operator: string;
+ _approved: boolean;
+}
+
+
+/* istanbul ignore next */
+// tslint:disable:no-parameter-reassignment
+// tslint:disable-next-line:class-name
+export class ERC721TokenContract extends BaseContract {
+ public getApproved = {
+ async callAsync(
+ _tokenId: BigNumber,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<string
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'getApproved(uint256)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_tokenId
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_tokenId
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getApproved;
+ const encodedData = ethersFunction.encode([_tokenId
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'getApproved'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public approve = {
+ async sendTransactionAsync(
+ _approved: string,
+ _tokenId: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<string> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
+ [_approved,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_approved,
+ _tokenId
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_approved,
+ _tokenId
+ ]);
+ const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved,
+ _tokenId
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ self.approve.estimateGasAsync.bind(
+ self,
+ _approved,
+ _tokenId
+ ),
+ );
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ return txHash;
+ },
+ async estimateGasAsync(
+ _approved: string,
+ _tokenId: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<number> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
+ [_approved,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_approved,
+ _tokenId
+ ], BaseContract._bigNumberToString);
+ const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved,
+ _tokenId
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ _approved: string,
+ _tokenId: BigNumber,
+ ): string {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
+ [_approved,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_approved,
+ _tokenId
+ ], BaseContract._bigNumberToString);
+ const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved,
+ _tokenId
+ ]);
+ return abiEncodedTransactionData;
+ },
+ async callAsync(
+ _approved: string,
+ _tokenId: BigNumber,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<void
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'approve(address,uint256)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_approved,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_approved,
+ _tokenId
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_approved,
+ _tokenId
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve;
+ const encodedData = ethersFunction.encode([_approved,
+ _tokenId
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray;
+ },
+ };
+ public transferFrom = {
+ async sendTransactionAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<string> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
+ _to,
+ _tokenId
+ ]);
+ const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
+ _to,
+ _tokenId
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ self.transferFrom.estimateGasAsync.bind(
+ self,
+ _from,
+ _to,
+ _tokenId
+ ),
+ );
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ return txHash;
+ },
+ async estimateGasAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<number> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId
+ ], BaseContract._bigNumberToString);
+ const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
+ _to,
+ _tokenId
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ ): string {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId
+ ], BaseContract._bigNumberToString);
+ const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
+ _to,
+ _tokenId
+ ]);
+ return abiEncodedTransactionData;
+ },
+ async callAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<void
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'transferFrom(address,address,uint256)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_from,
+ _to,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
+ _to,
+ _tokenId
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom;
+ const encodedData = ethersFunction.encode([_from,
+ _to,
+ _tokenId
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray;
+ },
+ };
+ public safeTransferFrom1 = {
+ async sendTransactionAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<string> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
+ _to,
+ _tokenId
+ ]);
+ const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from,
+ _to,
+ _tokenId
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ self.safeTransferFrom1.estimateGasAsync.bind(
+ self,
+ _from,
+ _to,
+ _tokenId
+ ),
+ );
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ return txHash;
+ },
+ async estimateGasAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ txData: Partial<TxData> = {},
+ ): Promise<number> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId
+ ], BaseContract._bigNumberToString);
+ const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from,
+ _to,
+ _tokenId
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ ): string {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs;
+ [_from,
+ _to,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId
+ ], BaseContract._bigNumberToString);
+ const abiEncodedTransactionData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from,
+ _to,
+ _tokenId
+ ]);
+ return abiEncodedTransactionData;
+ },
+ async callAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<void
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'safeTransferFrom(address,address,uint256)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_from,
+ _to,
+ _tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
+ _to,
+ _tokenId
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.safeTransferFrom;
+ const encodedData = ethersFunction.encode([_from,
+ _to,
+ _tokenId
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'safeTransferFrom'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray;
+ },
+ };
+ public ownerOf = {
+ async callAsync(
+ _tokenId: BigNumber,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<string
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'ownerOf(uint256)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_tokenId
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_tokenId
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_tokenId
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.ownerOf;
+ const encodedData = ethersFunction.encode([_tokenId
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'ownerOf'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public balanceOf = {
+ async callAsync(
+ _owner: string,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<BigNumber
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'balanceOf(address)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_owner
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_owner
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf;
+ const encodedData = ethersFunction.encode([_owner
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public setApprovalForAll = {
+ async sendTransactionAsync(
+ _operator: string,
+ _approved: boolean,
+ txData: Partial<TxData> = {},
+ ): Promise<string> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs;
+ [_operator,
+ _approved
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_operator,
+ _approved
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_operator,
+ _approved
+ ]);
+ const encodedData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator,
+ _approved
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ self.setApprovalForAll.estimateGasAsync.bind(
+ self,
+ _operator,
+ _approved
+ ),
+ );
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ return txHash;
+ },
+ async estimateGasAsync(
+ _operator: string,
+ _approved: boolean,
+ txData: Partial<TxData> = {},
+ ): Promise<number> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs;
+ [_operator,
+ _approved
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_operator,
+ _approved
+ ], BaseContract._bigNumberToString);
+ const encodedData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator,
+ _approved
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ _operator: string,
+ _approved: boolean,
+ ): string {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs;
+ [_operator,
+ _approved
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_operator,
+ _approved
+ ], BaseContract._bigNumberToString);
+ const abiEncodedTransactionData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator,
+ _approved
+ ]);
+ return abiEncodedTransactionData;
+ },
+ async callAsync(
+ _operator: string,
+ _approved: boolean,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<void
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'setApprovalForAll(address,bool)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_operator,
+ _approved
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_operator,
+ _approved
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_operator,
+ _approved
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.setApprovalForAll;
+ const encodedData = ethersFunction.encode([_operator,
+ _approved
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'setApprovalForAll'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray;
+ },
+ };
+ public safeTransferFrom2 = {
+ async sendTransactionAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ _data: string,
+ txData: Partial<TxData> = {},
+ ): Promise<string> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs;
+ [_from,
+ _to,
+ _tokenId,
+ _data
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId,
+ _data
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
+ _to,
+ _tokenId,
+ _data
+ ]);
+ const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from,
+ _to,
+ _tokenId,
+ _data
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ self.safeTransferFrom2.estimateGasAsync.bind(
+ self,
+ _from,
+ _to,
+ _tokenId,
+ _data
+ ),
+ );
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ return txHash;
+ },
+ async estimateGasAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ _data: string,
+ txData: Partial<TxData> = {},
+ ): Promise<number> {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs;
+ [_from,
+ _to,
+ _tokenId,
+ _data
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId,
+ _data
+ ], BaseContract._bigNumberToString);
+ const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from,
+ _to,
+ _tokenId,
+ _data
+ ]);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...txData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ _data: string,
+ ): string {
+ const self = this as any as ERC721TokenContract;
+ const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs;
+ [_from,
+ _to,
+ _tokenId,
+ _data
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId,
+ _data
+ ], BaseContract._bigNumberToString);
+ const abiEncodedTransactionData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from,
+ _to,
+ _tokenId,
+ _data
+ ]);
+ return abiEncodedTransactionData;
+ },
+ async callAsync(
+ _from: string,
+ _to: string,
+ _tokenId: BigNumber,
+ _data: string,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<void
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'safeTransferFrom(address,address,uint256,bytes)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_from,
+ _to,
+ _tokenId,
+ _data
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_from,
+ _to,
+ _tokenId,
+ _data
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
+ _to,
+ _tokenId,
+ _data
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.safeTransferFrom;
+ const encodedData = ethersFunction.encode([_from,
+ _to,
+ _tokenId,
+ _data
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'safeTransferFrom'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray;
+ },
+ };
+ public isApprovedForAll = {
+ async callAsync(
+ _owner: string,
+ _operator: string,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
+ ): Promise<boolean
+ > {
+ const self = this as any as ERC721TokenContract;
+ const functionSignature = 'isApprovedForAll(address,address)';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
+ [_owner,
+ _operator
+ ] = BaseContract._formatABIDataItemList(inputAbi, [_owner,
+ _operator
+ ], BaseContract._bigNumberToString.bind(self));
+ BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner,
+ _operator
+ ]);
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isApprovedForAll;
+ const encodedData = ethersFunction.encode([_owner,
+ _operator
+ ]);
+ const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {
+ to: self.address,
+ ...callData,
+ data: encodedData,
+ },
+ self._web3Wrapper.getContractDefaults(),
+ );
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
+ const outputAbi = (_.find(self.abi, {name: 'isApprovedForAll'}) as MethodAbi).outputs;
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
+ resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
+ return resultArray[0];
+ },
+ };
+ public static async deployFrom0xArtifactAsync(
+ artifact: ContractArtifact,
+ provider: Provider,
+ txDefaults: Partial<TxData>,
+ ): Promise<ERC721TokenContract> {
+ if (_.isUndefined(artifact.compilerOutput)) {
+ throw new Error('Compiler output not found in the artifact file');
+ }
+ const bytecode = artifact.compilerOutput.evm.bytecode.object;
+ const abi = artifact.compilerOutput.abi;
+ return ERC721TokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
+ }
+ public static async deployAsync(
+ bytecode: string,
+ abi: ContractAbi,
+ provider: Provider,
+ txDefaults: Partial<TxData>,
+ ): Promise<ERC721TokenContract> {
+ const constructorAbi = BaseContract._lookupConstructorAbi(abi);
+ [] = BaseContract._formatABIDataItemList(
+ constructorAbi.inputs,
+ [],
+ BaseContract._bigNumberToString,
+ );
+ const iface = new ethers.Interface(abi);
+ const deployInfo = iface.deployFunction;
+ const txData = deployInfo.encode(bytecode, []);
+ const web3Wrapper = new Web3Wrapper(provider);
+ const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
+ {data: txData},
+ txDefaults,
+ web3Wrapper.estimateGasAsync.bind(web3Wrapper),
+ );
+ const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ logUtils.log(`transactionHash: ${txHash}`);
+ const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
+ logUtils.log(`ERC721Token successfully deployed at ${txReceipt.contractAddress}`);
+ const contractInstance = new ERC721TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
+ contractInstance.constructorArgs = [];
+ return contractInstance;
+ }
+ constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
+ super('ERC721Token', abi, address, provider, txDefaults);
+ classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
+ }
+} // tslint:disable:max-file-line-count
+// tslint:enable:no-unbound-method
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index b147e8827..087e35a41 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -1,7 +1,6 @@
{
- "private": true,
- "name": "contracts",
- "version": "2.1.49",
+ "name": "@0xproject/contracts",
+ "version": "2.0.0",
"engines": {
"node": ">=6.12"
},
@@ -32,7 +31,7 @@
"lint-contracts": "solhint contracts/**/**/**/**/*.sol"
},
"config": {
- "abis": "generated-artifacts/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Proxy|ERC721Proxy|Forwarder|Exchange|ExchangeWrapper|IAssetData|IAssetProxy|InvalidERC721Receiver|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|OrderValidator|ReentrantERC20Token|TestAssetProxyOwner|TestAssetProxyDispatcher|TestConstants|TestExchangeInternals|TestLibBytes|TestLibs|TestSignatureValidator|TestStaticCallReceiver|Validator|Wallet|Whitelist|WETH9|ZRXToken).json"
+ "abis": "generated-artifacts/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|ERC20Proxy|ERC721Token|ERC721Proxy|Forwarder|Exchange|ExchangeWrapper|IAssetData|IAssetProxy|InvalidERC721Receiver|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|OrderValidator|ReentrantERC20Token|TestAssetProxyOwner|TestAssetProxyDispatcher|TestConstants|TestExchangeInternals|TestLibBytes|TestLibs|TestSignatureValidator|TestStaticCallReceiver|Validator|Wallet|Whitelist|WETH9|ZRXToken).json"
},
"repository": {
"type": "git",
@@ -86,5 +85,8 @@
"ethers": "~4.0.4",
"js-combinatorics": "^0.5.3",
"lodash": "^4.17.5"
+ },
+ "publishConfig": {
+ "access": "public"
}
}
diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts
index 714259158..72f75c594 100644
--- a/packages/contracts/src/index.ts
+++ b/packages/contracts/src/index.ts
@@ -1,4 +1,3 @@
-import * as artifacts from './artifacts';
+export * from './artifacts';
import * as wrappers from './wrappers';
-
-export { wrappers, artifacts };
+export { wrappers };
diff --git a/packages/contracts/src/wrappers/index.ts b/packages/contracts/src/wrappers/index.ts
index 89c398424..64f1dc6a3 100644
--- a/packages/contracts/src/wrappers/index.ts
+++ b/packages/contracts/src/wrappers/index.ts
@@ -7,6 +7,8 @@ export * from '../../generated-wrappers/dummy_multiple_return_erc20_token';
export * from '../../generated-wrappers/dummy_no_return_erc20_token';
export * from '../../generated-wrappers/erc20_proxy';
export * from '../../generated-wrappers/erc721_proxy';
+export * from '../../generated-wrappers/erc20_token';
+export * from '../../generated-wrappers/erc721_token';
export * from '../../generated-wrappers/exchange';
export * from '../../generated-wrappers/exchange_wrapper';
export * from '../../generated-wrappers/forwarder';