import { Transaction as EthereumJsTransaction } from '@ethereumjs/tx'; import { PrefixedHexString } from 'ethereumjs-util'; import { AuditRequest, AuditResponse, ContractInteractor, LoggerInterface, VersionsManager } from '@opengsn/common'; import { BlockExplorerInterface } from './BlockExplorerInterface'; import { TransactionManager } from '../TransactionManager'; import { ServerConfigParams } from '../ServerConfigParams'; import { Web3MethodsBuilder } from '../Web3MethodsBuilder'; export interface PenalizerDependencies { transactionManager: TransactionManager; contractInteractor: ContractInteractor; web3MethodsBuilder: Web3MethodsBuilder; txByNonceService: BlockExplorerInterface; } /** * types of penalization supported by a penalizer * string values are for logging purposes only */ declare enum PenalizationTypes { ILLEGAL_TRANSACTION = "penalizeIllegalTransaction", REPEATED_NONCE = "penalizeRepeatedNonce" } interface DelayedPenalization { readyBlockNumber?: number; type: PenalizationTypes; commitHash: PrefixedHexString; methodArgs: PrefixedHexString[]; } export declare class PenalizerService { private workerTask?; /** Maps block where commitment becomes valid to penalization details */ scheduledPenalizations: DelayedPenalization[]; transactionManager: TransactionManager; contractInteractor: ContractInteractor; web3MethodsBuilder: Web3MethodsBuilder; txByNonceService: BlockExplorerInterface; versionManager: VersionsManager; logger: LoggerInterface; config: ServerConfigParams; initialized: boolean; managerAddress: string; constructor(params: PenalizerDependencies, logger: LoggerInterface, config: ServerConfigParams); init(startWorker?: boolean): Promise; stop(): void; penalizeRepeatedNonce(req: AuditRequest): Promise; calculateCommitHash(method: any): PrefixedHexString; intervalHandler(): Promise; executeReadyPenalizations(): Promise; /** * Note: this method modifies elements of {@link scheduledPenalizations} in-place */ queryReadyBlocksForMinedCommitments(): Promise; penalizeIllegalTransaction(req: AuditRequest): Promise; commitAndScheduleReveal(delayedPenalization: DelayedPenalization): Promise; executeDelayedPenalization(delayedPenalization: DelayedPenalization): Promise; broadcastTransaction(methodName: string, method: any): Promise; getPenalizeIllegalTransactionArguments(requestTx: EthereumJsTransaction, randomValue: string): PrefixedHexString[]; getPenalizeRepeatedNonceArguments(minedTx: EthereumJsTransaction, requestTx: EthereumJsTransaction, randomValue: string): PrefixedHexString[]; validateTransaction(requestTx: EthereumJsTransaction): Promise<{ valid: boolean; error?: string; }>; isTransactionMined(requestTx: EthereumJsTransaction): Promise; validatePenalization(method: any): Promise<{ valid: boolean; error?: string; }>; getMethod(penalizationTypes: PenalizationTypes, methodArgs: PrefixedHexString[]): any; } export {};