UNPKG

@hyperlane-xyz/sdk

Version:

The official SDK for the Hyperlane Network

48 lines 1.66 kB
import { rootLogger } from '@hyperlane-xyz/utils'; /** * Builds a TxSubmitterBuilder for batch transaction submission. * * Example use-cases: * const eV5builder = new TxSubmitterBuilder<EV5Transaction, EV5TransactionReceipt>(); * let txReceipts = eV5builder.for( * new EV5GnosisSafeTxSubmitter(chainA) * ).submit( * txs * ); * txReceipts = eV5builder.for( * new EV5ImpersonatedAccountTxSubmitter(chainA) * ).submit(txs); * txReceipts = eV5builder.for( * new EV5JsonRpcTxSubmitter(chainC) * ).submit(txs); */ export class TxSubmitterBuilder { currentSubmitter; txSubmitterType; logger = rootLogger.child({ module: 'submitter-builder', }); constructor(currentSubmitter) { this.currentSubmitter = currentSubmitter; this.txSubmitterType = this.currentSubmitter.txSubmitterType; } /** * Sets the current submitter for the builder. * @param txSubmitterOrType The submitter to add to the builder */ for(txSubmitter) { this.currentSubmitter = txSubmitter; return this; } /** * Submits a set of transactions to the builder. * @param txs The transactions to submit */ async submit(...txs) { this.logger.debug(`Submitting ${txs.length} transactions to the ${this.currentSubmitter.txSubmitterType} submitter...`); const txReceipts = await this.currentSubmitter.submit(...txs); this.logger.debug(`✅ Successfully submitted ${txs.length} transactions to the ${this.currentSubmitter.txSubmitterType} submitter.`); return txReceipts; } } //# sourceMappingURL=TxSubmitterBuilder.js.map