From d72b7299c66ea6d63eb14595b06456c02b2ad99b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 27 Mar 2018 15:19:23 +0200 Subject: Move common types out of web3 types --- .../0x.js/src/contract_wrappers/contract_wrapper.ts | 18 +++++++++--------- .../0x.js/src/contract_wrappers/exchange_wrapper.ts | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'packages/0x.js/src/contract_wrappers') diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts index ad7727de5..6c96428ed 100644 --- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts @@ -1,4 +1,4 @@ -import { BlockParamLiteral, LogWithDecodedArgs, RawLog } from '@0xproject/types'; +import { BlockParamLiteral, ContractAbi, FilterObject, LogEntry, LogWithDecodedArgs, RawLog } from '@0xproject/types'; import { AbiDecoder, intervalUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Block, BlockAndLogStreamer } from 'ethereumjs-blockstream'; @@ -35,7 +35,7 @@ export class ContractWrapper { private _abiDecoder?: AbiDecoder; private _blockAndLogStreamerIfExists?: BlockAndLogStreamer; private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer; - private _filters: { [filterToken: string]: Web3.FilterObject }; + private _filters: { [filterToken: string]: FilterObject }; private _filterCallbacks: { [filterToken: string]: EventCallback; }; @@ -75,7 +75,7 @@ export class ContractWrapper { address: string, eventName: ContractEvents, indexFilterValues: IndexedFilterValues, - abi: Web3.ContractAbi, + abi: ContractAbi, callback: EventCallback, ): string { const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi); @@ -92,7 +92,7 @@ export class ContractWrapper { eventName: ContractEvents, blockRange: BlockRange, indexFilterValues: IndexedFilterValues, - abi: Web3.ContractAbi, + abi: ContractAbi, ): Promise>> { const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, blockRange); const logs = await this._web3Wrapper.getLogsAsync(filter); @@ -100,7 +100,7 @@ export class ContractWrapper { return logsWithDecodedArguments; } protected _tryToDecodeLogOrNoop( - log: Web3.LogEntry, + log: LogEntry, ): LogWithDecodedArgs | RawLog { if (_.isUndefined(this._abiDecoder)) { throw new Error(InternalZeroExError.NoAbiDecoder); @@ -111,7 +111,7 @@ export class ContractWrapper { protected async _getContractAbiAndAddressFromArtifactsAsync( artifact: Artifact, addressIfExists?: string, - ): Promise<[Web3.ContractAbi, string]> { + ): Promise<[ContractAbi, string]> { let contractAddress: string; if (_.isUndefined(addressIfExists)) { if (_.isUndefined(artifact.networks[this._networkId])) { @@ -125,7 +125,7 @@ export class ContractWrapper { if (!doesContractExist) { throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contract_name]); } - const abiAndAddress: [Web3.ContractAbi, string] = [artifact.abi, contractAddress]; + const abiAndAddress: [ContractAbi, string] = [artifact.abi, contractAddress]; return abiAndAddress; } protected _getContractAddress(artifact: Artifact, addressIfExists?: string): string { @@ -139,8 +139,8 @@ export class ContractWrapper { return addressIfExists; } } - private _onLogStateChanged(isRemoved: boolean, log: Web3.LogEntry): void { - _.forEach(this._filters, (filter: Web3.FilterObject, filterToken: string) => { + private _onLogStateChanged(isRemoved: boolean, log: LogEntry): void { + _.forEach(this._filters, (filter: FilterObject, filterToken: string) => { if (filterUtils.matchesFilter(log, filter)) { const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs; const logEvent = { diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 59bd4db6b..6b5a75a9a 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -3,6 +3,7 @@ import { BlockParamLiteral, DecodedLogArgs, ECSignature, + LogEntry, LogWithDecodedArgs, Order, SignedOrder, @@ -10,7 +11,6 @@ import { import { AbiDecoder, BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; -import * as Web3 from 'web3'; import { artifacts } from '../artifacts'; import { @@ -863,7 +863,7 @@ export class ExchangeWrapper extends ContractWrapper { * Checks if logs contain LogError, which is emitted by Exchange contract on transaction failure. * @param logs Transaction logs as returned by `zeroEx.awaitTransactionMinedAsync` */ - public throwLogErrorsAsErrors(logs: Array | Web3.LogEntry>): void { + public throwLogErrorsAsErrors(logs: Array | LogEntry>): void { const errLog = _.find(logs, { event: ExchangeEvents.LogError, }); -- cgit