From 2bd7b0f66bd28792281ba025cf005c666e7f767e Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 4 Oct 2018 14:40:58 -0700 Subject: update contract_wrappers to use new artifacts and abi-gen wrappers packages --- .../src/contract_wrappers/ether_token_wrapper.ts | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts') 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( + public async getLogsAsync( etherTokenAddress: string, - eventName: wrappers.WETH9Events, + eventName: WETH9Events, blockRange: BlockRange, indexFilterValues: IndexedFilterValues, ): Promise>> { 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( @@ -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( + public subscribe( etherTokenAddress: string, - eventName: wrappers.WETH9Events, + eventName: WETH9Events, indexFilterValues: IndexedFilterValues, callback: EventCallback, 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( 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 { + private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise { 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(), -- cgit v1.2.3