import { PrefixedHexString } from 'ethereumjs-util'; import { Address, EventData, GsnTransactionDetails, JsonRpcPayload, JsonRpcResponse, LoggerInterface } from '@opengsn/common'; import { AccountKeypair } from './AccountManager'; import { GsnEvent } from './GsnEvents'; import { GSNUnresolvedConstructorInput, RelayClient, RelayingResult } from './RelayClient'; import { GSNConfig } from './GSNConfigurator'; import { JsonRpcProvider, TransactionReceipt } from '@ethersproject/providers'; export declare type JsonRpcCallback = (error: Error | null, result?: JsonRpcResponse) => void; /** * This data can later be used to optimize creation of Transaction Receipts */ interface SubmittedRelayRequestInfo { submissionBlock: number; validUntilTime: string; } export declare class RelayProvider { protected readonly origProvider: JsonRpcProvider; private readonly _origProviderSend; private asyncSignTypedData?; protected readonly submittedRelayRequests: Map; protected config: GSNConfig; readonly relayClient: RelayClient; logger: LoggerInterface; host: string; connected: boolean; static newProvider(input: GSNUnresolvedConstructorInput): RelayProvider; constructor(relayClient: RelayClient); origProviderSend(payload: JsonRpcPayload, callback: JsonRpcCallback): void; init(useTokenPaymaster?: boolean): Promise; registerEventListener(handler: (event: GsnEvent) => void): void; unregisterEventListener(handler: (event: GsnEvent) => void): void; _delegateEventsApi(): void; send(payload: JsonRpcPayload, callback: JsonRpcCallback): void; _ethGetTransactionReceiptWithTransactionHash(payload: JsonRpcPayload, callback: JsonRpcCallback): void; /** * pack promise call as a jsonrpc callback * @param promise the promise request. return value is "result" for the callback * @param payload original payload. used to copy rpc param (jsonrpc, id) * @param callback callback to call result or error (for exception) */ asCallback(promise: Promise, payload: JsonRpcPayload, callback: JsonRpcCallback): void; _getSubmissionDetailsForRelayRequestId(relayRequestID: PrefixedHexString): Promise; _ethGetTransactionByHash(payload: JsonRpcPayload, callback: JsonRpcCallback): Promise; /** * The ID can be either a RelayRequestID which requires event-based lookup or Transaction Hash that goes through * @param payload * @param callback */ _ethGetTransactionReceipt(payload: JsonRpcPayload, callback: JsonRpcCallback): Promise; _ethSendTransaction(payload: JsonRpcPayload, callback: JsonRpcCallback): Promise; _onRelayTransactionFulfilled(relayingResult: RelayingResult, payload: JsonRpcPayload, callback: JsonRpcCallback): void; _onRelayTransactionRejected(reason: any, callback: JsonRpcCallback): void; _convertRelayRequestIdToRpcSendResponse(relayRequestID: PrefixedHexString, request: JsonRpcPayload): JsonRpcResponse; /** * convert relayRequestId (which is a "synthethic" transaction ID) into the actual transaction Id. * This is done by parsing RelayHub event, and can only be done after mining. * @param relayRequestID * @param submissionDetails * @return transactionId or marker: * If the transaction is already mined, return a real transactionId * If the transaction is no longer valid, return TX_NOTFOUND * If the transaction can still be mined, returns TX_FUTURE */ _getTransactionIdFromRequestId(relayRequestID: string, submissionDetails: SubmittedRelayRequestInfo): Promise; /** * If the transaction is already mined, return a simulated successful transaction receipt * If the transaction is no longer valid, return a simulated reverted transaction receipt * If the transaction can still be mined, returns "null" like a regular RPC call would do */ _createTransactionReceiptForRelayRequestID(relayRequestID: string): Promise; _getTranslatedGsnResponseResult(respResult: TransactionReceipt, relayRequestID?: string): TransactionReceipt; _useGSN(payload: JsonRpcPayload): boolean; _fixGasFees(_txDetails: any): Promise; supportsSubscriptions(): boolean; disconnect(): boolean; newAccount(): AccountKeypair; calculateGasFees(): Promise<{ maxFeePerGas: PrefixedHexString; maxPriorityFeePerGas: PrefixedHexString; }>; addAccount(privateKey: PrefixedHexString): AccountKeypair; isEphemeralAccount(account: Address): boolean; _sign(payload: JsonRpcPayload, callback: JsonRpcCallback): void; _signTransaction(payload: JsonRpcPayload, callback: JsonRpcCallback): void; _signTypedData(payload: JsonRpcPayload, callback: JsonRpcCallback): void; _getAccounts(payload: JsonRpcPayload, callback: JsonRpcCallback): void; /** * In an edge case many events with the same ID may be mined. * If there is a successful {@link TransactionRelayed} event, it will be returned. * If all events are {@link TransactionRejectedByPaymaster}, return the last one. * If there is more than one successful {@link TransactionRelayed} throws as this is impossible for current Forwarder */ _pickSingleEvent(events: EventData[], relayRequestID: string): EventData; cacheSubmittedTransactionDetails(relayingResult: RelayingResult): void; _createTransactionRevertedReceipt(): TransactionReceipt; } export {};