aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-10-05 05:40:58 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-10-16 04:36:59 +0800
commit2bd7b0f66bd28792281ba025cf005c666e7f767e (patch)
tree228f2797a772a4ba828d6b71e5c85c78a708ed21
parent8f0ceaf1d8261e9779213276372f4690cdf3426c (diff)
downloaddexon-sol-tools-2bd7b0f66bd28792281ba025cf005c666e7f767e.tar
dexon-sol-tools-2bd7b0f66bd28792281ba025cf005c666e7f767e.tar.gz
dexon-sol-tools-2bd7b0f66bd28792281ba025cf005c666e7f767e.tar.bz2
dexon-sol-tools-2bd7b0f66bd28792281ba025cf005c666e7f767e.tar.lz
dexon-sol-tools-2bd7b0f66bd28792281ba025cf005c666e7f767e.tar.xz
dexon-sol-tools-2bd7b0f66bd28792281ba025cf005c666e7f767e.tar.zst
dexon-sol-tools-2bd7b0f66bd28792281ba025cf005c666e7f767e.zip
update contract_wrappers to use new artifacts and abi-gen wrappers packages
-rw-r--r--packages/contract-wrappers/package.json3
-rw-r--r--packages/contract-wrappers/src/contract_wrappers.ts28
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts11
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts27
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts11
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts27
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts27
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts27
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts11
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts11
-rw-r--r--packages/contract-wrappers/src/globals.d.ts6
-rw-r--r--packages/contract-wrappers/src/index.ts51
-rw-r--r--packages/contract-wrappers/src/types.ts23
-rw-r--r--packages/contract-wrappers/src/utils/transaction_encoder.ts8
-rw-r--r--packages/contract-wrappers/test/utils/token_utils.ts10
15 files changed, 147 insertions, 134 deletions
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json
index a75da5faf..e96b57df1 100644
--- a/packages/contract-wrappers/package.json
+++ b/packages/contract-wrappers/package.json
@@ -67,9 +67,10 @@
"web3-provider-engine": "14.0.6"
},
"dependencies": {
- "@0xproject/contracts": "^2.1.48",
+ "@0xproject/abi-gen-wrappers": "^1.0.0",
"@0xproject/assert": "^1.0.13",
"@0xproject/base-contract": "^3.0.1",
+ "@0xproject/contract-artifacts": "^1.0.0",
"@0xproject/fill-scenarios": "^1.0.7",
"@0xproject/json-schemas": "^1.0.7",
"@0xproject/order-utils": "^1.0.7",
diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts
index 8e4693da6..359307da4 100644
--- a/packages/contract-wrappers/src/contract_wrappers.ts
+++ b/packages/contract-wrappers/src/contract_wrappers.ts
@@ -1,4 +1,13 @@
-import { artifacts } from '@0xproject/contracts';
+import {
+ ERC20Proxy,
+ ERC20Token,
+ ERC721Proxy,
+ ERC721Token,
+ Exchange,
+ Forwarder,
+ OrderValidator,
+ WETH9,
+} from '@0xproject/contract-artifacts';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
@@ -71,14 +80,22 @@ export class ContractWrappers {
contractWrappersPrivateNetworkConfigSchema,
contractWrappersPublicNetworkConfigSchema,
]);
- const artifactJSONs = _.values(artifacts);
- const abiArrays = _.map(artifactJSONs, artifact => artifact.compilerOutput.abi);
const txDefaults = {
gasPrice: config.gasPrice,
};
this._web3Wrapper = new Web3Wrapper(provider, txDefaults);
- _.forEach(abiArrays, abi => {
- this._web3Wrapper.abiDecoder.addABI(abi);
+ const artifactsArray = [
+ ERC20Proxy,
+ ERC20Token,
+ ERC721Proxy,
+ ERC721Token,
+ Exchange,
+ Forwarder,
+ OrderValidator,
+ WETH9,
+ ];
+ _.forEach(artifactsArray, artifact => {
+ this._web3Wrapper.abiDecoder.addABI(artifact.compilerOutput.abi);
});
const blockPollingIntervalMs = _.isUndefined(config.blockPollingIntervalMs)
? constants.DEFAULT_BLOCK_POLLING_INTERVAL
@@ -114,7 +131,6 @@ export class ContractWrappers {
* @param networkId The id of the network your provider is connected to
*/
public setProvider(provider: Provider): void {
- // TODO(albrow): Make sure all contract wrappers are called below.
this._web3Wrapper.setProvider(provider);
(this.exchange as any)._invalidateContractInstances();
(this.erc20Token as any)._invalidateContractInstances();
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 31b3b6755..205a5ed10 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { ERC20ProxyContract } from '@0xproject/abi-gen-wrappers';
+import { ERC20Proxy } from '@0xproject/contract-artifacts';
import { AssetProxyId } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
@@ -12,9 +13,9 @@ import { ContractWrapper } from './contract_wrapper';
* This class includes the functionality related to interacting with the ERC20Proxy contract.
*/
export class ERC20ProxyWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
+ public abi: ContractAbi = ERC20Proxy.compilerOutput.abi;
public address: string;
- private _erc20ProxyContractIfExists?: wrappers.ERC20ProxyContract;
+ private _erc20ProxyContractIfExists?: ERC20ProxyContract;
/**
* Instantiate ERC20ProxyWrapper
* @param web3Wrapper Web3Wrapper instance to use
@@ -62,11 +63,11 @@ export class ERC20ProxyWrapper extends ContractWrapper {
private _invalidateContractInstance(): void {
delete this._erc20ProxyContractIfExists;
}
- private _getERC20ProxyContract(): wrappers.ERC20ProxyContract {
+ private _getERC20ProxyContract(): ERC20ProxyContract {
if (!_.isUndefined(this._erc20ProxyContractIfExists)) {
return this._erc20ProxyContractIfExists;
}
- const contractInstance = new wrappers.ERC20ProxyContract(
+ const contractInstance = new ERC20ProxyContract(
this.abi,
this.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 53cda5d08..68928e71f 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { ERC20TokenContract, ERC20TokenEventArgs, ERC20TokenEvents } from '@0xproject/abi-gen-wrappers';
+import { ERC20Token } from '@0xproject/contract-artifacts';
import { schemas } from '@0xproject/json-schemas';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -29,9 +30,9 @@ const removeUndefinedProperties = _.pickBy;
* to the 0x ERC20 Proxy smart contract.
*/
export class ERC20TokenWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.ERC20Token.compilerOutput.abi;
+ public abi: ContractAbi = ERC20Token.compilerOutput.abi;
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- private _tokenContractsByAddress: { [address: string]: wrappers.ERC20TokenContract };
+ private _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
private _erc20ProxyWrapper: ERC20ProxyWrapper;
/**
* Instantiate ERC20TokenWrapper
@@ -350,15 +351,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 wrappers.ERC20TokenEventArgs>(
+ public subscribe<ArgsType extends ERC20TokenEventArgs>(
tokenAddress: string,
- eventName: wrappers.ERC20TokenEvents,
+ eventName: ERC20TokenEvents,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
): string {
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.doesBelongToStringEnum('eventName', eventName, wrappers.ERC20TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const normalizedTokenAddress = tokenAddress.toLowerCase();
@@ -366,7 +367,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
normalizedTokenAddress,
eventName,
indexFilterValues,
- artifacts.ERC20Token.compilerOutput.abi,
+ ERC20Token.compilerOutput.abi,
callback,
isVerbose,
);
@@ -395,14 +396,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 wrappers.ERC20TokenEventArgs>(
+ public async getLogsAsync<ArgsType extends ERC20TokenEventArgs>(
tokenAddress: string,
- eventName: wrappers.ERC20TokenEvents,
+ eventName: ERC20TokenEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.doesBelongToStringEnum('eventName', eventName, wrappers.ERC20TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const normalizedTokenAddress = tokenAddress.toLowerCase();
@@ -411,7 +412,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
eventName,
blockRange,
indexFilterValues,
- artifacts.ERC20Token.compilerOutput.abi,
+ ERC20Token.compilerOutput.abi,
);
return logs;
}
@@ -422,7 +423,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
this.unsubscribeAll();
this._tokenContractsByAddress = {};
}
- private async _getTokenContractAsync(tokenAddress: string): Promise<wrappers.ERC20TokenContract> {
+ private async _getTokenContractAsync(tokenAddress: string): Promise<ERC20TokenContract> {
const normalizedTokenAddress = tokenAddress.toLowerCase();
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
if (!_.isUndefined(tokenContract)) {
@@ -434,7 +435,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
if (!doesContractExist) {
throw new Error(ContractWrappersError.ERC20TokenContractDoesNotExist);
}
- const contractInstance = new wrappers.ERC20TokenContract(
+ const contractInstance = new ERC20TokenContract(
this.abi,
normalizedTokenAddress,
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 2472d512b..963d5b40f 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { ERC721ProxyContract } from '@0xproject/abi-gen-wrappers';
+import { ERC721Proxy } from '@0xproject/contract-artifacts';
import { AssetProxyId } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
@@ -12,9 +13,9 @@ import { ContractWrapper } from './contract_wrapper';
* This class includes the functionality related to interacting with the ERC721Proxy contract.
*/
export class ERC721ProxyWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
+ public abi: ContractAbi = ERC721Proxy.compilerOutput.abi;
public address: string;
- private _erc721ProxyContractIfExists?: wrappers.ERC721ProxyContract;
+ private _erc721ProxyContractIfExists?: ERC721ProxyContract;
/**
* Instantiate ERC721ProxyWrapper
* @param web3Wrapper Web3Wrapper instance to use
@@ -62,11 +63,11 @@ export class ERC721ProxyWrapper extends ContractWrapper {
private _invalidateContractInstance(): void {
delete this._erc721ProxyContractIfExists;
}
- private _getERC721ProxyContract(): wrappers.ERC721ProxyContract {
+ private _getERC721ProxyContract(): ERC721ProxyContract {
if (!_.isUndefined(this._erc721ProxyContractIfExists)) {
return this._erc721ProxyContractIfExists;
}
- const contractInstance = new wrappers.ERC721ProxyContract(
+ const contractInstance = new ERC721ProxyContract(
this.abi,
this.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 7fcd74eaf..3d58908d8 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { ERC721TokenContract, ERC721TokenEventArgs, ERC721TokenEvents } from '@0xproject/abi-gen-wrappers';
+import { ERC721Token } from '@0xproject/contract-artifacts';
import { schemas } from '@0xproject/json-schemas';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -29,8 +30,8 @@ const removeUndefinedProperties = _.pickBy;
* to the 0x ERC721 Proxy smart contract.
*/
export class ERC721TokenWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.ERC721Token.compilerOutput.abi;
- private _tokenContractsByAddress: { [address: string]: wrappers.ERC721TokenContract };
+ public abi: ContractAbi = ERC721Token.compilerOutput.abi;
+ private _tokenContractsByAddress: { [address: string]: ERC721TokenContract };
private _erc721ProxyWrapper: ERC721ProxyWrapper;
/**
* Instantiate ERC721TokenWrapper
@@ -377,15 +378,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 wrappers.ERC721TokenEventArgs>(
+ public subscribe<ArgsType extends ERC721TokenEventArgs>(
tokenAddress: string,
- eventName: wrappers.ERC721TokenEvents,
+ eventName: ERC721TokenEvents,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
): string {
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.doesBelongToStringEnum('eventName', eventName, wrappers.ERC721TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const normalizedTokenAddress = tokenAddress.toLowerCase();
@@ -393,7 +394,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
normalizedTokenAddress,
eventName,
indexFilterValues,
- artifacts.ERC721Token.compilerOutput.abi,
+ ERC721Token.compilerOutput.abi,
callback,
isVerbose,
);
@@ -422,14 +423,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 wrappers.ERC721TokenEventArgs>(
+ public async getLogsAsync<ArgsType extends ERC721TokenEventArgs>(
tokenAddress: string,
- eventName: wrappers.ERC721TokenEvents,
+ eventName: ERC721TokenEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.doesBelongToStringEnum('eventName', eventName, wrappers.ERC721TokenEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const normalizedTokenAddress = tokenAddress.toLowerCase();
@@ -438,7 +439,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
eventName,
blockRange,
indexFilterValues,
- artifacts.ERC721Token.compilerOutput.abi,
+ ERC721Token.compilerOutput.abi,
);
return logs;
}
@@ -449,7 +450,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
this.unsubscribeAll();
this._tokenContractsByAddress = {};
}
- private async _getTokenContractAsync(tokenAddress: string): Promise<wrappers.ERC721TokenContract> {
+ private async _getTokenContractAsync(tokenAddress: string): Promise<ERC721TokenContract> {
const normalizedTokenAddress = tokenAddress.toLowerCase();
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
if (!_.isUndefined(tokenContract)) {
@@ -461,7 +462,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
if (!doesContractExist) {
throw new Error(ContractWrappersError.ERC721TokenContractDoesNotExist);
}
- const contractInstance = new wrappers.ERC721TokenContract(
+ const contractInstance = new ERC721TokenContract(
this.abi,
normalizedTokenAddress,
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 526324abd..a6f2fd81e 100644
--- a/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { WETH9Contract, WETH9EventArgs, WETH9Events } from '@0xproject/abi-gen-wrappers';
+import { WETH9 } from '@0xproject/contract-artifacts';
import { schemas } from '@0xproject/json-schemas';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -18,9 +19,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.WETH9.compilerOutput.abi;
+ public abi: ContractAbi = WETH9.compilerOutput.abi;
private _etherTokenContractsByAddress: {
- [address: string]: wrappers.WETH9Contract;
+ [address: string]: WETH9Contract;
} = {};
private _erc20TokenWrapper: ERC20TokenWrapper;
/**
@@ -120,15 +121,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 wrappers.WETH9EventArgs>(
+ public async getLogsAsync<ArgsType extends WETH9EventArgs>(
etherTokenAddress: string,
- eventName: wrappers.WETH9Events,
+ eventName: WETH9Events,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.isETHAddressHex('etherTokenAddress', etherTokenAddress);
const normalizedEtherTokenAddress = etherTokenAddress.toLowerCase();
- assert.doesBelongToStringEnum('eventName', eventName, wrappers.WETH9Events);
+ assert.doesBelongToStringEnum('eventName', eventName, WETH9Events);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const logs = await this._getLogsAsync<ArgsType>(
@@ -136,7 +137,7 @@ export class EtherTokenWrapper extends ContractWrapper {
eventName,
blockRange,
indexFilterValues,
- artifacts.WETH9.compilerOutput.abi,
+ WETH9.compilerOutput.abi,
);
return logs;
}
@@ -150,23 +151,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 wrappers.WETH9EventArgs>(
+ public subscribe<ArgsType extends WETH9EventArgs>(
etherTokenAddress: string,
- eventName: wrappers.WETH9Events,
+ eventName: WETH9Events,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
): string {
assert.isETHAddressHex('etherTokenAddress', etherTokenAddress);
const normalizedEtherTokenAddress = etherTokenAddress.toLowerCase();
- assert.doesBelongToStringEnum('eventName', eventName, wrappers.WETH9Events);
+ assert.doesBelongToStringEnum('eventName', eventName, WETH9Events);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const subscriptionToken = this._subscribe<ArgsType>(
normalizedEtherTokenAddress,
eventName,
indexFilterValues,
- artifacts.WETH9.compilerOutput.abi,
+ WETH9.compilerOutput.abi,
callback,
isVerbose,
);
@@ -191,7 +192,7 @@ export class EtherTokenWrapper extends ContractWrapper {
this.unsubscribeAll();
this._etherTokenContractsByAddress = {};
}
- private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<wrappers.WETH9Contract> {
+ private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<WETH9Contract> {
let etherTokenContract = this._etherTokenContractsByAddress[etherTokenAddress];
if (!_.isUndefined(etherTokenContract)) {
return etherTokenContract;
@@ -203,7 +204,7 @@ export class EtherTokenWrapper extends ContractWrapper {
if (!doesContractExist) {
throw new Error(ContractWrappersError.EtherTokenContractDoesNotExist);
}
- const contractInstance = new wrappers.WETH9Contract(
+ const contractInstance = new WETH9Contract(
this.abi,
etherTokenAddress,
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 b65baee55..6b3694bc5 100644
--- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from '@0xproject/abi-gen-wrappers';
+import { Exchange } from '@0xproject/contract-artifacts';
import { schemas } from '@0xproject/json-schemas';
import {
assetDataUtils,
@@ -40,10 +41,10 @@ import { ERC721TokenWrapper } from './erc721_token_wrapper';
* events of the 0x V2 Exchange smart contract.
*/
export class ExchangeWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.Exchange.compilerOutput.abi;
+ public abi: ContractAbi = Exchange.compilerOutput.abi;
public address: string;
public zrxTokenAddress: string;
- private _exchangeContractIfExists?: wrappers.ExchangeContract;
+ private _exchangeContractIfExists?: ExchangeContract;
private _erc721TokenWrapper: ERC721TokenWrapper;
private _erc20TokenWrapper: ERC20TokenWrapper;
/**
@@ -1039,20 +1040,20 @@ 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 wrappers.ExchangeEventArgs>(
- eventName: wrappers.ExchangeEvents,
+ public subscribe<ArgsType extends ExchangeEventArgs>(
+ eventName: ExchangeEvents,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
): string {
- assert.doesBelongToStringEnum('eventName', eventName, wrappers.ExchangeEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const subscriptionToken = this._subscribe<ArgsType>(
this.address,
eventName,
indexFilterValues,
- artifacts.Exchange.compilerOutput.abi,
+ Exchange.compilerOutput.abi,
callback,
isVerbose,
);
@@ -1079,12 +1080,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 wrappers.ExchangeEventArgs>(
- eventName: wrappers.ExchangeEvents,
+ public async getLogsAsync<ArgsType extends ExchangeEventArgs>(
+ eventName: ExchangeEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
- assert.doesBelongToStringEnum('eventName', eventName, wrappers.ExchangeEvents);
+ assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const logs = await this._getLogsAsync<ArgsType>(
@@ -1092,7 +1093,7 @@ export class ExchangeWrapper extends ContractWrapper {
eventName,
blockRange,
indexFilterValues,
- artifacts.Exchange.compilerOutput.abi,
+ Exchange.compilerOutput.abi,
);
return logs;
}
@@ -1178,11 +1179,11 @@ export class ExchangeWrapper extends ContractWrapper {
delete this._exchangeContractIfExists;
}
// tslint:enable:no-unused-variable
- private async _getExchangeContractAsync(): Promise<wrappers.ExchangeContract> {
+ private async _getExchangeContractAsync(): Promise<ExchangeContract> {
if (!_.isUndefined(this._exchangeContractIfExists)) {
return this._exchangeContractIfExists;
}
- const contractInstance = new wrappers.ExchangeContract(
+ const contractInstance = new ExchangeContract(
this.abi,
this.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 cd8f9ece9..22fc916e2 100644
--- a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { ForwarderContract } from '@0xproject/abi-gen-wrappers';
+import { Forwarder } from '@0xproject/contract-artifacts';
import { schemas } from '@0xproject/json-schemas';
import { AssetProxyId, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
@@ -21,11 +22,11 @@ import { ContractWrapper } from './contract_wrapper';
* This class includes the functionality related to interacting with the Forwarder contract.
*/
export class ForwarderWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.Forwarder.compilerOutput.abi;
+ public abi: ContractAbi = Forwarder.compilerOutput.abi;
public address: string;
public zrxTokenAddress: string;
public etherTokenAddress: string;
- private _forwarderContractIfExists?: wrappers.ForwarderContract;
+ private _forwarderContractIfExists?: ForwarderContract;
// TODO(albrow): Make addresses optional?
constructor(web3Wrapper: Web3Wrapper, address: string, zrxTokenAddress: string, etherTokenAddress: string) {
super(web3Wrapper);
@@ -215,11 +216,11 @@ export class ForwarderWrapper extends ContractWrapper {
private _invalidateContractInstance(): void {
delete this._forwarderContractIfExists;
}
- private async _getForwarderContractAsync(): Promise<wrappers.ForwarderContract> {
+ private async _getForwarderContractAsync(): Promise<ForwarderContract> {
if (!_.isUndefined(this._forwarderContractIfExists)) {
return this._forwarderContractIfExists;
}
- const contractInstance = new wrappers.ForwarderContract(
+ const contractInstance = new ForwarderContract(
this.abi,
this.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 23e0d42c1..cb67d57f7 100644
--- a/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { OrderValidatorContract } from '@0xproject/abi-gen-wrappers';
+import { OrderValidator } from '@0xproject/contract-artifacts';
import { schemas } from '@0xproject/json-schemas';
import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
@@ -15,9 +16,9 @@ import { ContractWrapper } from './contract_wrapper';
* This class includes the functionality related to interacting with the OrderValidator contract.
*/
export class OrderValidatorWrapper extends ContractWrapper {
- public abi: ContractAbi = artifacts.OrderValidator.compilerOutput.abi;
+ public abi: ContractAbi = OrderValidator.compilerOutput.abi;
public address: string;
- private _orderValidatorContractIfExists?: wrappers.OrderValidatorContract;
+ private _orderValidatorContractIfExists?: OrderValidatorContract;
/**
* Instantiate OrderValidatorWrapper
* @param web3Wrapper Web3Wrapper instance to use.
@@ -172,11 +173,11 @@ export class OrderValidatorWrapper extends ContractWrapper {
private _invalidateContractInstance(): void {
delete this._orderValidatorContractIfExists;
}
- private async _getOrderValidatorContractAsync(): Promise<wrappers.OrderValidatorContract> {
+ private async _getOrderValidatorContractAsync(): Promise<OrderValidatorContract> {
if (!_.isUndefined(this._orderValidatorContractIfExists)) {
return this._orderValidatorContractIfExists;
}
- const contractInstance = new wrappers.OrderValidatorContract(
+ const contractInstance = new OrderValidatorContract(
this.abi,
this.address,
this._web3Wrapper.getProvider(),
diff --git a/packages/contract-wrappers/src/globals.d.ts b/packages/contract-wrappers/src/globals.d.ts
deleted file mode 100644
index 94e63a32d..000000000
--- a/packages/contract-wrappers/src/globals.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare module '*.json' {
- const json: any;
- /* tslint:disable */
- export default json;
- /* tslint:enable */
-}
diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts
index 659394eb6..50dfe88be 100644
--- a/packages/contract-wrappers/src/index.ts
+++ b/packages/contract-wrappers/src/index.ts
@@ -1,4 +1,27 @@
-import { wrappers } from '@0xproject/contracts';
+export {
+ WETH9Events,
+ WETH9WithdrawalEventArgs,
+ WETH9ApprovalEventArgs,
+ WETH9EventArgs,
+ WETH9DepositEventArgs,
+ WETH9TransferEventArgs,
+ ERC20TokenTransferEventArgs,
+ ERC20TokenApprovalEventArgs,
+ ERC20TokenEvents,
+ ERC20TokenEventArgs,
+ ERC721TokenApprovalEventArgs,
+ ERC721TokenApprovalForAllEventArgs,
+ ERC721TokenTransferEventArgs,
+ ERC721TokenEvents,
+ ERC721TokenEventArgs,
+ ExchangeCancelUpToEventArgs,
+ ExchangeAssetProxyRegisteredEventArgs,
+ ExchangeSignatureValidatorApprovalEventArgs,
+ ExchangeFillEventArgs,
+ ExchangeCancelEventArgs,
+ ExchangeEventArgs,
+ ExchangeEvents,
+} from '@0xproject/abi-gen-wrappers';
export { ContractWrappers } from './contract_wrappers';
export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
@@ -56,32 +79,6 @@ export {
StateMutability,
} from 'ethereum-types';
-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 type ERC20TokenTransferEventArgs = wrappers.ERC20TokenTransferEventArgs;
-export type ERC20TokenApprovalEventArgs = wrappers.ERC20TokenApprovalEventArgs;
-export const ERC20TokenEvents = wrappers.ERC20TokenEvents;
-export type ERC20TokenEventArgs = wrappers.ERC20TokenEventArgs;
-
-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 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';
export { AssetBalanceAndProxyAllowanceFetcher } from './fetchers/asset_balance_and_proxy_allowance_fetcher';
diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts
index f882cc188..b06a6b914 100644
--- a/packages/contract-wrappers/src/types.ts
+++ b/packages/contract-wrappers/src/types.ts
@@ -1,4 +1,13 @@
-import { wrappers } from '@0xproject/contracts';
+import {
+ ERC20TokenEventArgs,
+ ERC20TokenEvents,
+ ERC721TokenEventArgs,
+ ERC721TokenEvents,
+ ExchangeEventArgs,
+ ExchangeEvents,
+ WETH9EventArgs,
+ WETH9Events,
+} from '@0xproject/abi-gen-wrappers';
import { ContractAddresses, OrderState, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
@@ -56,11 +65,7 @@ export interface ContractEvent {
args: ContractEventArgs;
}
-export type ContractEventArgs =
- | wrappers.ExchangeEventArgs
- | wrappers.ERC20TokenEventArgs
- | wrappers.ERC721TokenEventArgs
- | wrappers.WETH9EventArgs;
+export type ContractEventArgs = ExchangeEventArgs | ERC20TokenEventArgs | ERC721TokenEventArgs | WETH9EventArgs;
// [address, name, symbol, decimals, ipfsHash, swarmHash]
export type TokenMetadata = [string, string, string, number, string, string];
@@ -83,11 +88,7 @@ export interface TokenAddressBySymbol {
[symbol: string]: string;
}
-export type ContractEvents =
- | wrappers.ERC20TokenEvents
- | wrappers.ERC721TokenEvents
- | wrappers.ExchangeEvents
- | wrappers.WETH9Events;
+export type ContractEvents = ERC20TokenEvents | ERC721TokenEvents | ExchangeEvents | 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 f4c6de97f..d179fa07e 100644
--- a/packages/contract-wrappers/src/utils/transaction_encoder.ts
+++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts
@@ -1,4 +1,4 @@
-import { wrappers } from '@0xproject/contracts';
+import { ExchangeContract } from '@0xproject/abi-gen-wrappers';
import { schemas } from '@0xproject/json-schemas';
import { eip712Utils } from '@0xproject/order-utils';
@@ -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: wrappers.ExchangeContract;
- constructor(exchangeInstance: wrappers.ExchangeContract) {
+ private readonly _exchangeInstance: ExchangeContract;
+ constructor(exchangeInstance: ExchangeContract) {
this._exchangeInstance = exchangeInstance;
}
/**
@@ -275,7 +275,7 @@ export class TransactionEncoder {
);
return abiEncodedData;
}
- private _getExchangeContract(): wrappers.ExchangeContract {
+ private _getExchangeContract(): 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 e9ca9533f..c9e1e7434 100644
--- a/packages/contract-wrappers/test/utils/token_utils.ts
+++ b/packages/contract-wrappers/test/utils/token_utils.ts
@@ -1,4 +1,5 @@
-import { artifacts, wrappers } from '@0xproject/contracts';
+import { DummyERC721TokenContract } from '@0xproject/abi-gen-wrappers';
+import { DummyERC721Token } from '@0xproject/contract-artifacts';
import { generatePseudoRandomSalt } from '@0xproject/order-utils';
import { BigNumber } from '@0xproject/utils';
@@ -25,12 +26,7 @@ export const tokenUtils = {
return DUMMY_ERC_721_ADRESSES;
},
async mintDummyERC721Async(address: string, tokenOwner: string): Promise<BigNumber> {
- const erc721 = new wrappers.DummyERC721TokenContract(
- artifacts.DummyERC721Token.compilerOutput.abi,
- address,
- provider,
- txDefaults,
- );
+ const erc721 = new DummyERC721TokenContract(DummyERC721Token.compilerOutput.abi, address, provider, txDefaults);
const tokenId = generatePseudoRandomSalt();
const txHash = await erc721.mint.sendTransactionAsync(tokenOwner, tokenId);
web3Wrapper.awaitTransactionSuccessAsync(txHash);