Files
protocol/packages/website/mdx/tools/@0x/sol-profiler/v3.1.11/reference.mdx
2019-08-24 00:04:47 +02:00

151 lines
3.4 KiB
Plaintext

# Class: ProfilerSubprovider
This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface.
ProfilerSubprovider is used to profile Solidity code while running tests.
### Hierarchy
* `TraceInfoSubprovider`
* **ProfilerSubprovider**
### Constructors
## constructer
\+ **new ProfilerSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `isVerbose`: boolean): *[ProfilerSubprovider](#class-profilersubprovider)*
*Overrides void*
*Defined in [profiler_subprovider.ts:30](https://github.com/0xProject/0x-monorepo/blob/a6f43f536/packages/sol-profiler/src/profiler_subprovider.ts#L30)*
Instantiates a ProfilerSubprovider 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 |
`isVerbose` | boolean | true | If true, we will log any unknown transactions. Otherwise we will ignore them |
**Returns:** *[ProfilerSubprovider](#class-profilersubprovider)*
### 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*
___
## writeProfilerOutputAsync
▸ **writeProfilerOutputAsync**(): *`Promise<void>`*
*Defined in [profiler_subprovider.ts:104](https://github.com/0xProject/0x-monorepo/blob/a6f43f536/packages/sol-profiler/src/profiler_subprovider.ts#L104)*
Write the test profiler results to a file in Istanbul format.
**Returns:** *`Promise<void>`*
<hr />