@aptos-labs/ts-sdk - v7.4.0
    Preparing search index...

    Class TransactionWorker

    TransactionWorker provides a simple framework for receiving payloads to be processed.

    Once one start() the process and pushes a new transaction, the worker acquires the current account's next sequence number (by using the AccountSequenceNumber class), generates a signed transaction and pushes an async submission process into the outstandingTransactions queue. At the same time, the worker processes transactions by reading the outstandingTransactions queue and submits the next transaction to chain, it

    1. waits for resolution of the submission process or get pre-execution validation error and 2) waits for the resolution of the execution process or get an execution error. The worker fires events for any submission and/or execution success and/or failure.

    Hierarchy (View Summary)

    Index
    • Initializes a new instance of the class, providing a framework for receiving payloads to be processed.

      Parameters

      • aptosConfig: AptosConfig

        A configuration object for Aptos.

      • account: Account

        The account that will be used for sending transactions.

      • maxWaitTime: number = 30

        The maximum wait time to wait before re-syncing the sequence number to the current on-chain state, default is 30 seconds.

      • maximumInFlight: number = 100

        The maximum number of transactions that can be submitted per account, default is 100.

      • sleepTime: number = 10

        The time to wait in seconds before re-evaluating if the maximum number of transactions are in flight, default is 10 seconds.

      Returns TransactionWorker

    executedTransactions: [string, bigint, any][] = []

    transactions that have been committed to chain. Limited to MAX_TRANSACTION_HISTORY_SIZE entries to prevent unbounded memory growth.

    outstandingTransactions: AsyncQueue<
        [Promise<PendingTransactionResponse>, bigint],
    > = ...

    signed transactions waiting to be submitted

    sentTransactions: [string, bigint, any][] = []

    transactions that have been submitted to chain. Limited to MAX_TRANSACTION_HISTORY_SIZE entries to prevent unbounded memory growth.

    transactionsQueue: AsyncQueue<
        [
            InputGenerateTransactionPayloadData,
            InputGenerateTransactionOptions
            | undefined,
        ],
    > = ...

    transactions payloads waiting to be generated and signed

    TODO support entry function payload from ABI builder

    • Reads the outstanding transaction queue and checks each successfully submitted transaction's execution status.

      Returns Promise<void>

      Throws an error if the process execution fails. TransactionWorkerEventsEnum.TransactionExecuted - Emitted when a transaction executes successfully. TransactionWorkerEventsEnum.TransactionExecutionFailed - Emitted when a transaction fails during execution. TransactionWorkerEventsEnum.ExecutionFinish - Emitted when the execution of transactions is complete.

    • Submits the next transaction for the account by generating it with the current sequence number and adding it to the outstanding transaction queue for processing. This function continues to submit transactions until there are no more to process.

      Returns Promise<void>

      Throws an error if the transaction submission fails. TransactionWorkerEventsEnum.TransactionSent - Emitted when a transaction is sent to the chain. TransactionWorkerEventsEnum.TransactionSendFailed - Emitted when a transaction fails to send.

    • Reads the outstanding transaction queue and checks each successfully submitted transaction's execution status.

      Returns Promise<void>

      Throws an error if the process execution fails. TransactionWorkerEventsEnum.TransactionExecuted - Emitted when a transaction executes successfully. TransactionWorkerEventsEnum.TransactionExecutionFailed - Emitted when a transaction fails during execution. TransactionWorkerEventsEnum.ExecutionFinish - Emitted when the execution of transactions is complete.

    • Submits the next transaction for the account by generating it with the current sequence number and adding it to the outstanding transaction queue for processing. This function continues to submit transactions until there are no more to process.

      Returns Promise<void>

      Throws an error if the transaction submission fails. TransactionWorkerEventsEnum.TransactionSent - Emitted when a transaction is sent to the chain. TransactionWorkerEventsEnum.TransactionSendFailed - Emitted when a transaction fails to send.

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: keyof TransactionWorkerEvents

      Returns this

    account: Account
    accountSequnceNumber: AccountSequenceNumber
    aptosConfig: AptosConfig
    started: boolean
    taskQueue: AsyncQueue<() => Promise<void>> = ...
    prefixed: string | boolean