/// /// import { EventEmitter } from 'events'; import { PrefixedHexString, BN } from 'ethereumjs-util'; import { Block } from '@ethersproject/providers'; import { IRelayHubInstance } from '@opengsn/contracts/types/truffle-contracts'; import { Address, AmountRequired, ContractInteractor, Environment, EventData, IntString, LoggerInterface, ObjectMap, PingResponse, ReadinessInfo, RelayRequest, RelayRequestLimits, RelayTransactionRequest, StatsResponse, TransactionType } from '@opengsn/common'; import { GasPriceFetcher } from './GasPriceFetcher'; import { PaymasterGasAndDataLimits } from '@opengsn/common/dist/Utils'; import { RegistrationManager } from './RegistrationManager'; import { ReputationManager } from './ReputationManager'; import { BoostingResult, TransactionManager } from './TransactionManager'; import { ShortBlockInfo } from './StoredTransaction'; import { TxStoreManager } from './TxStoreManager'; import { ServerConfigParams, ServerDependencies } from './ServerConfigParams'; import { Web3MethodsBuilder } from './Web3MethodsBuilder'; export declare class RelayServer extends EventEmitter { readonly logger: LoggerInterface; lastScannedBlock: number; lastRefreshBlock: number; ready: boolean; readonly managerAddress: PrefixedHexString; readonly workerAddress: PrefixedHexString; minMaxPriorityFeePerGas: number; minMaxFeePerGas: number; running: boolean; alerted: boolean; alertedByTransactionBlockTimestamp: number; initialized: boolean; shouldRefreshBalances: boolean; readonly contractInteractor: ContractInteractor; readonly web3MethodsBuilder: Web3MethodsBuilder; readonly gasPriceFetcher: GasPriceFetcher; private readonly versionManager; config: ServerConfigParams; transactionManager: TransactionManager; txStoreManager: TxStoreManager; readinessInfo: ReadinessInfo; maxGasLimit: number; transactionType: TransactionType; reputationManager: ReputationManager; registrationManager: RegistrationManager; chainId: number; networkId: number; relayHubContract: IRelayHubInstance; trustedPaymastersGasAndDataLimits: Map; workerBalanceRequired: AmountRequired; environment: Environment; constructor(config: Partial, transactionManager: TransactionManager, dependencies: ServerDependencies); printServerAddresses(): void; getMinMaxPriorityFeePerGas(): number; pingHandler(paymaster?: string): Promise; statsHandler(): StatsResponse; validateRequestTxType(req: RelayTransactionRequest): void; validateInput(req: RelayTransactionRequest): void; validateWhitelistsAndBlacklists(relayRequest: RelayRequest): void; validateGasFees(relayRequest: RelayRequest): void; validateMaxNonce(relayMaxNonce: number): Promise; validatePaymasterReputation(paymaster: Address, currentBlockNumber: number): Promise; calculateAndValidatePaymasterGasAndDataLimits(relayTransactionRequest: RelayTransactionRequest): Promise; validatePaymasterGasAndDataLimits(relayTransactionRequest: RelayTransactionRequest, relayRequestLimits: RelayRequestLimits): Promise; verifyTransactionCalldataGasUsed(req: RelayTransactionRequest, transactionCalldataGasUsed: number): void; verifyEffectiveAcceptanceBudget(paymasterAcceptanceBudget: number, effectiveAcceptanceBudget: number, requestMaxAcceptanceBudget: number, paymaster: string): void; verifyMaxPossibleGas(maxPossibleGasFactorReserve: number): void; verifyPaymasterBalance(maxPossibleCharge: BN, maxPossibleGasFactorReserve: number, paymaster: string): Promise; validateViewCallSucceeds(req: RelayTransactionRequest, maxAcceptanceBudget: number, maxPossibleGas: number): Promise; createRelayTransaction(req: RelayTransactionRequest): Promise<{ signedTx: PrefixedHexString; nonceGapFilled: ObjectMap; }>; start(): void; stop(): void; fatal(message: string): void; /*** * initialize data from trusted paymasters. * "Trusted" paymasters means that: * - we trust their code not to alter the gas limits (getGasAndDataLimits returns constants) * - we trust preRelayedCall to be consistent: off-chain call and on-chain calls should either both succeed * or both revert. * - given that, we agree to give the requested acceptanceBudget (since breaking one of the above two "invariants" * is the only cases where the relayer will have to pay for this budget) * * @param paymasters list of trusted paymaster addresses */ _initTrustedPaymasters(paymasters?: string[]): Promise; _getPaymasterMaxAcceptanceBudget(paymaster?: string): IntString; init(): Promise; _replenishWorker(workerReplenishAmount: BN, currentBlockNumber: number, currentBlockHash: string, currentBlockTimestamp: number): Promise; _withdrawHubDeposit(managerHubBalance: BN, currentBlockNumber: number, currentBlockHash: string, currentBlockTimestamp: number): Promise; replenishServer(workerIndex: number, currentBlockNumber: number, currentBlockHash: string, currentBlockTimestamp: number): Promise; intervalHandler(): Promise; _worker(block: Block): Promise; _refreshAndCheckBalances(): Promise; _refreshGasFees(): Promise; _handleChanges(currentBlock: Block): Promise; getManagerBalance(): Promise; getWorkerBalance(workerIndex: number): Promise; _shouldRegisterAgain(currentBlockNumber: number, currentBlockTimestamp: number): Promise; _shouldRefreshState(currentBlock: Block): boolean; handlePastHubEvents(currentBlock: Block, hubEventsSinceLastScan: EventData[]): Promise; getAllHubEventsSinceLastScan(): Promise; _handleTransactionRelayedEvent(paymaster: Address, eventBlockNumber: number): Promise; _handleTransactionRejectedByPaymasterEvent(paymaster: Address, eventBlockNumber: number): Promise; withdrawToOwnerIfNeeded(currentBlockNumber: number, currentBlockHash: string, currentBlockTimestamp: number): Promise; /** * Resend all outgoing pending transactions with insufficient gas price by all signers (manager, workers) * @return the mapping of the previous transaction hash to details of a new boosted transaction */ _boostStuckPendingTransactions(currentBlockInfo: ShortBlockInfo): Promise; _boostStuckTransactionsForManager(currentBlockInfo: ShortBlockInfo): Promise; _boostStuckTransactionsForWorker(currentBlockInfo: ShortBlockInfo, workerIndex: number): Promise; _isTrustedPaymaster(paymaster: string): boolean; _isBlacklistedPaymaster(paymaster: string): boolean; _isBlacklistedRecipient(recipient: string): boolean; _isWhitelistedPaymaster(paymaster: string): boolean; _isWhitelistedRecipient(recipient: string): boolean; isReady(): boolean; setReadyState(isReady: boolean): void; }