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

Constructors

  • Provides a simple framework for receiving payloads to be processed.

    Parameters

    • aptosConfig: AptosConfig

      a config object

    • account: Account
    • maxWaitTime: number = 30

      the max wait time to wait before resyncing the sequence number to the current on-chain state, default to 30

    • maximumInFlight: number = 100

      submit up to maximumInFlight transactions per account. Mempool limits the number of transactions per account to 100, hence why we default to 100.

    • sleepTime: number = 10

      If maximumInFlight are in flight, wait sleepTime seconds before re-evaluating, default to 10

    Returns TransactionWorker

Properties

account: Account
accountSequnceNumber: AccountSequenceNumber
aptosConfig: AptosConfig
executedTransactions: [string, bigint, any][] = []

transactions that have been committed to chain

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

signed transactions waiting to be submitted

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

transactions that have been submitted to chain

started: boolean
taskQueue: AsyncQueue<(() => Promise<void>)> = ...

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

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

transactions payloads waiting to be generated and signed

TODO support entry function payload from ABI builder

prefixed: string | boolean

Methods

  • Type Parameters

    Parameters

    Returns this

  • Once transaction has been sent to chain, we check for its execution status.

    Parameters

    • sentTransaction: PromiseFulfilledResult<PendingTransactionResponse>

      transactions that were sent to chain and are now waiting to be executed

    • sequenceNumber: bigint

      the account's sequence number that was sent with the transaction

    Returns Promise<void>

  • Calls each of the listeners registered for a given event.

    Type Parameters

    Parameters

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (keyof TransactionWorkerEvents)[]

  • Return the number of listeners listening to a given event.

    Parameters

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Type Parameters

    Parameters

    Returns this

  • Add a listener for a given event.

    Type Parameters

    Parameters

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    Parameters

    Returns this

  • Reads the outstanding transaction queue and submits the transaction to chain.

    If the transaction has fulfilled, it pushes the transaction to the processed transactions queue and fires a transactionsFulfilled event.

    If the transaction has failed, it pushes the transaction to the processed transactions queue with the failure reason and fires a transactionsFailed event.

    Returns Promise<void>

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

    Parameters

    • Optional event: keyof TransactionWorkerEvents

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    Parameters

    Returns this

  • Gets the current account sequence number, generates the transaction with the account sequence number, adds the transaction to the outstanding transaction queue to be processed later.

    Returns Promise<void>

Generated using TypeDoc