180 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			180 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
# Class: CoverageSubprovider
 | 
						|
 | 
						|
This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface.
 | 
						|
It's used to compute your code coverage while running solidity tests.
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* `TraceInfoSubprovider`
 | 
						|
 | 
						|
  * **CoverageSubprovider**
 | 
						|
 | 
						|
 | 
						|
### Constructors
 | 
						|
 | 
						|
##  constructer
 | 
						|
 | 
						|
\+ **new CoverageSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `partialConfig`: [CoverageSubproviderPartialConfig](#coveragesubproviderpartialconfig)): *[CoverageSubprovider](#class-coveragesubprovider)*
 | 
						|
 | 
						|
*Overrides void*
 | 
						|
 | 
						|
*Defined in [coverage_subprovider.ts:44](https://github.com/0xProject/0x-monorepo/blob/a6f43f536/packages/sol-coverage/src/coverage_subprovider.ts#L44)*
 | 
						|
 | 
						|
Instantiates a CoverageSubprovider instance
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Default | Description |
 | 
						|
------ | ------ | ------ | ------ |
 | 
						|
`artifactAdapter` | `AbstractArtifactAdapter` | - | Adapter for used artifacts format (0x, truffle, giveth, etc.) |
 | 
						|
`defaultFromAddress` | string | - | default from address to use when sending transactions |
 | 
						|
`partialConfig` | [CoverageSubproviderPartialConfig](#coveragesubproviderpartialconfig) |  {} | Partial configuration object  |
 | 
						|
 | 
						|
**Returns:** *[CoverageSubprovider](#class-coveragesubprovider)*
 | 
						|
 | 
						|
### Methods
 | 
						|
 | 
						|
##  emitPayloadAsync
 | 
						|
 | 
						|
▸ **emitPayloadAsync**(`payload`: `Partial<JSONRPCRequestPayloadWithMethod>`): *`Promise<JSONRPCResponsePayload>`*
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
Emits a JSON RPC payload that will then be handled by the ProviderEngine instance
 | 
						|
this subprovider is a part of. The payload will cascade down the subprovider middleware
 | 
						|
stack until finding the responsible entity for handling the request.
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`payload` | `Partial<JSONRPCRequestPayloadWithMethod>` | JSON RPC payload |
 | 
						|
 | 
						|
**Returns:** *`Promise<JSONRPCResponsePayload>`*
 | 
						|
 | 
						|
JSON RPC response payload
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  handleRequest
 | 
						|
 | 
						|
▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: `NextCallback`, `_end`: `ErrorCallback`): *`Promise<void>`*
 | 
						|
 | 
						|
 | 
						|
 | 
						|
*Overrides void*
 | 
						|
 | 
						|
 | 
						|
 | 
						|
This method conforms to the web3-provider-engine interface.
 | 
						|
It is called internally by the ProviderEngine when it is this subproviders
 | 
						|
turn to handle a JSON RPC request.
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`payload` | `JSONRPCRequestPayload` | JSON RPC payload |
 | 
						|
`next` | `NextCallback` | Callback to call if this subprovider decides not to handle the request |
 | 
						|
`_end` | `ErrorCallback` | Callback to call if subprovider handled the request and wants to pass back the request.  |
 | 
						|
 | 
						|
**Returns:** *`Promise<void>`*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  setEngine
 | 
						|
 | 
						|
▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void*
 | 
						|
 | 
						|
 | 
						|
 | 
						|
*Overrides void*
 | 
						|
 | 
						|
 | 
						|
 | 
						|
Set's the subprovider's engine to the ProviderEngine it is added to.
 | 
						|
This is only called within the ProviderEngine source code, do not call
 | 
						|
directly.
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to  |
 | 
						|
 | 
						|
**Returns:** *void*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  start
 | 
						|
 | 
						|
▸ **start**(): *void*
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
Starts trace collection
 | 
						|
 | 
						|
**Returns:** *void*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  stop
 | 
						|
 | 
						|
▸ **stop**(): *void*
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
Stops trace collection
 | 
						|
 | 
						|
**Returns:** *void*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  writeCoverageAsync
 | 
						|
 | 
						|
▸ **writeCoverageAsync**(): *`Promise<void>`*
 | 
						|
 | 
						|
*Defined in [coverage_subprovider.ts:78](https://github.com/0xProject/0x-monorepo/blob/a6f43f536/packages/sol-coverage/src/coverage_subprovider.ts#L78)*
 | 
						|
 | 
						|
Write the test coverage results to a file in Istanbul format.
 | 
						|
 | 
						|
**Returns:** *`Promise<void>`*
 | 
						|
 | 
						|
<hr />
 | 
						|
 | 
						|
# Interface: CoverageSubproviderConfig
 | 
						|
 | 
						|
This type defines the schema of the config object that could be passed to CoverageSubprovider
 | 
						|
isVerbose: If true - will log any unknown transactions. Defaults to true.
 | 
						|
ignoreFilesGlobs: The list of globs matching the file names of the files we want to ignore coverage for. Defaults to [].
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* **CoverageSubproviderConfig**
 | 
						|
 | 
						|
 | 
						|
### Properties
 | 
						|
 | 
						|
##  ignoreFilesGlobs
 | 
						|
 | 
						|
• **ignoreFilesGlobs**: *string[]*
 | 
						|
 | 
						|
*Defined in [coverage_subprovider.ts:28](https://github.com/0xProject/0x-monorepo/blob/a6f43f536/packages/sol-coverage/src/coverage_subprovider.ts#L28)*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  isVerbose
 | 
						|
 | 
						|
• **isVerbose**: *boolean*
 | 
						|
 | 
						|
*Defined in [coverage_subprovider.ts:27](https://github.com/0xProject/0x-monorepo/blob/a6f43f536/packages/sol-coverage/src/coverage_subprovider.ts#L27)*
 | 
						|
 | 
						|
<hr />
 | 
						|
 |