diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-10-02 09:22:42 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-10-16 04:36:09 +0800 |
commit | 026ad1f9a10359723eed54f37c067ee2a61d8fcd (patch) | |
tree | c14d09b25ae07473e9d5b516b21331a8ad5c3621 /packages/contract-wrappers/src/contract_wrappers | |
parent | 81c48872415998e53ad653aabf183e18257ec327 (diff) | |
download | dexon-0x-contracts-026ad1f9a10359723eed54f37c067ee2a61d8fcd.tar.gz dexon-0x-contracts-026ad1f9a10359723eed54f37c067ee2a61d8fcd.tar.zst dexon-0x-contracts-026ad1f9a10359723eed54f37c067ee2a61d8fcd.zip |
Update contract-wrappers package to use new contracts package for generated files
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers')
8 files changed, 62 insertions, 70 deletions
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(), |