getAllSingleTransactionPlans

function getAllSingleTransactionPlans(transactionPlan): Readonly<{
  kind: "single";
  message: Readonly<{
     instructions: readonly Instruction<string, readonly (
        | AccountLookupMeta<..., ...>
       | AccountMeta<...>)[]>[];
     version: TransactionVersion;
  }> & TransactionMessageWithFeePayer<string>;
}>[];

Retrieves all individual SingleTransactionPlan instances from a transaction plan tree.

This function recursively traverses any nested structure of transaction plans and extracts all the single transaction plans they contain. It's useful when you need to access all the actual transaction messages that will be executed, regardless of their organization in the plan tree (parallel or sequential).

Parameters

ParameterTypeDescription
transactionPlanTransactionPlanThe transaction plan to extract single plans from

Returns

Readonly<{ kind: "single"; message: Readonly<{ instructions: readonly Instruction<string, readonly (/api/functions/ | AccountLookupMeta<..., ...> | AccountMeta<...>)[]>[]; version: TransactionVersion; }> & TransactionMessageWithFeePayer<string>; }>[]

An array of all single transaction plans contained in the tree

Example

const plan = parallelTransactionPlan([
  sequentialTransactionPlan([messageA, messageB]),
  nonDivisibleSequentialTransactionPlan([messageC, messageD]),
  messageE,
]);
 
const singlePlans = getAllSingleTransactionPlans(plan);
// Array of `SingleTransactionPlan` containing:
// messageA, messageB, messageC and messageD.

On this page