UNPKG

trezor-web3-subprovider

Version:
53 lines (52 loc) 2.91 kB
import Web3ProviderEngine from 'web3-provider-engine'; import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; import { Callback, ErrorCallback, PartialTxParams, JSONRPCRequestPayloadWithMethod } from './types'; /** * A altered version of the base class Subprovider found in [web3-provider-engine](https://github.com/MetaMask/provider-engine). * This one has an async/await `emitPayloadAsync` and also defined types. */ export declare abstract class Subprovider { private engine; protected static _createFinalPayload(payload: Partial<JSONRPCRequestPayloadWithMethod>): Partial<JSONRPCRequestPayloadWithMethod>; private static _getRandomId; /** * @param payload JSON RPC request payload * @param next A callback to pass the request to the next subprovider in the stack * @param end A callback called once the subprovider is done handling the request */ abstract handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback): Promise<void>; /** * 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. * @param payload JSON RPC payload * @returns JSON RPC response payload */ emitPayloadAsync(payload: Partial<JSONRPCRequestPayloadWithMethod>): Promise<JSONRPCResponsePayload>; /** * 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. * @param engine The ProviderEngine this subprovider is added to */ setEngine(engine: Web3ProviderEngine): void; } export declare abstract class BaseWalletSubprovider extends Subprovider { protected static _validateTxParams(txParams: PartialTxParams): void; private static _validateSender; abstract getAccountsAsync(): Promise<string[]>; abstract signTransactionAsync(txParams: PartialTxParams): Promise<string>; abstract signPersonalMessageAsync(data: string, address: string): Promise<string>; abstract signTypedDataAsync(address: string, typedData: any): Promise<string>; /** * 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. * @param payload JSON RPC payload * @param next Callback to call if this subprovider decides not to handle the request * @param end Callback to call if subprovider handled the request and wants to pass back the request. */ handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback): Promise<void>; private _emitSendTransactionAsync; private _populateMissingTxParamsAsync; }