# 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. ## Constructors \+ **new ProfilerSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `isVerbose`: boolean): *[ProfilerSubprovider](#class-profilersubprovider)* *Overrides void* *Defined in [sol-profiler/src/profiler_subprovider.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/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`): *`Promise`* Defined in subproviders/lib/src/subproviders/subprovider.d.ts:25 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` | JSON RPC payload | **Returns:** *`Promise`* JSON RPC response payload ___ ### handleRequest ▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [NextCallback](#nextcallback), `_end`: [ErrorCallback](#errorcallback)): *`Promise`* *Overrides void* Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:42 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](#nextcallback) | Callback to call if this subprovider decides not to handle the request | `_end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | **Returns:** *`Promise`* ___ ### setEngine ▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* *Overrides void* Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:49 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* Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:29 Starts trace collection **Returns:** *void* ___ ### stop ▸ **stop**(): *void* Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:33 Stops trace collection **Returns:** *void* ___ ### writeProfilerOutputAsync ▸ **writeProfilerOutputAsync**(): *`Promise`* *Defined in [sol-profiler/src/profiler_subprovider.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-profiler/src/profiler_subprovider.ts#L104)* Write the test profiler results to a file in Istanbul format. **Returns:** *`Promise`*
# Class: AbstractArtifactAdapter ## Methods ### `Abstract` collectContractsDataAsync ▸ **collectContractsDataAsync**(): *`Promise`* *Defined in [sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts:4](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts#L4)* **Returns:** *`Promise`*
# Class: SolCompilerArtifactAdapter ## Constructors \+ **new SolCompilerArtifactAdapter**(`artifactsPath?`: undefined | string, `sourcesPath?`: undefined | string): *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* *Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L18)* Instantiates a SolCompilerArtifactAdapter **Parameters:** Name | Type | Description | ------ | ------ | ------ | `artifactsPath?` | undefined \| string | Path to your artifacts directory | `sourcesPath?` | undefined \| string | Path to your contract sources directory | **Returns:** *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* ## Methods ### collectContractsDataAsync ▸ **collectContractsDataAsync**(): *`Promise`* *Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* *Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L44)* **Returns:** *`Promise`*
# Class: TruffleArtifactAdapter ## Constructors \+ **new TruffleArtifactAdapter**(`projectRoot`: string, `solcVersion`: string): *[TruffleArtifactAdapter](#class-truffleartifactadapter)* *Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L29)* Instantiates a TruffleArtifactAdapter **Parameters:** Name | Type | Description | ------ | ------ | ------ | `projectRoot` | string | Path to the truffle project's root directory | `solcVersion` | string | Solidity version with which to compile all the contracts | **Returns:** *[TruffleArtifactAdapter](#class-truffleartifactadapter)* ## Methods ### collectContractsDataAsync ▸ **collectContractsDataAsync**(): *`Promise`* *Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* *Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L40)* **Returns:** *`Promise`*
# Interface: JSONRPCRequestPayload ## Properties ### id • **id**: *number* *Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ ### jsonrpc • **jsonrpc**: *string* *Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ ### method • **method**: *string* *Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ ### params • **params**: *any[]* *Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
# Interface: JSONRPCResponseError ## Properties ### code • **code**: *number* *Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ ### message • **message**: *string* *Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
# Interface: JSONRPCResponsePayload ## Properties ### `Optional` error • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* *Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ ### id • **id**: *number* *Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ ### jsonrpc • **jsonrpc**: *string* *Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ ### result • **result**: *any* *Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
# Interface: JSONRPCRequestPayloadWithMethod ## Properties ### id • **id**: *number* Defined in ethereum-types/lib/index.d.ts:267 ___ ### jsonrpc • **jsonrpc**: *string* Defined in ethereum-types/lib/index.d.ts:268 ___ ### method • **method**: *string* *Overrides void* *Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L136)* ___ ### params • **params**: *any[]* Defined in ethereum-types/lib/index.d.ts:265
## Type aliases ## Functions ### `Const` profilerHandler ▸ **profilerHandler**(`contractData`: `ContractData`, `subtrace`: [Subtrace](#subtrace), `pcToSourceRange`: object, `fileIndex`: number): *`Coverage`* *Defined in [sol-profiler/src/profiler_subprovider.ts:118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-profiler/src/profiler_subprovider.ts#L118)* Computed partial coverage for a single file & subtrace for the purposes of gas profiling. **Parameters:** Name | Type | Description | ------ | ------ | ------ | `contractData` | `ContractData` | Contract metadata (source, srcMap, bytecode) | `subtrace` | [Subtrace](#subtrace) | A subset of a transcation/call trace that was executed within that contract | `pcToSourceRange` | object | A mapping from program counters to source ranges | `fileIndex` | number | Index of a file to compute coverage for | **Returns:** *`Coverage`* Partial istanbul coverage for that file & subtrace



## Type aliases ## Type aliases ### Callback Ƭ **Callback**: *function* *Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L131)* #### Type declaration: ▸ (): *void* ___ ### ErrorCallback Ƭ **ErrorCallback**: *function* *Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L130)* #### Type declaration: ▸ (`err`: `Error` | null, `data?`: any): *void* **Parameters:** Name | Type | ------ | ------ | `err` | `Error` \| null | `data?` | any | ___ ### NextCallback Ƭ **NextCallback**: *function* *Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L133)* #### Type declaration: ▸ (`callback?`: [OnNextCompleted](#onnextcompleted)): *void* **Parameters:** Name | Type | ------ | ------ | `callback?` | [OnNextCompleted](#onnextcompleted) | ___ ### OnNextCompleted Ƭ **OnNextCompleted**: *function* *Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L132)* #### Type declaration: ▸ (`err`: `Error` | null, `result`: any, `cb`: [Callback](#callback)): *void* **Parameters:** Name | Type | ------ | ------ | `err` | `Error` \| null | `result` | any | `cb` | [Callback](#callback) |