everyTransactionPlan

function everyTransactionPlan(transactionPlan, predicate): boolean;

Checks if every transaction plan in the tree satisfies the given predicate.

This function performs a depth-first traversal through the transaction plan tree, returning true only if the predicate returns true for every plan in the tree (including the root plan and all nested plans).

Parameters

ParameterTypeDescription
transactionPlanTransactionPlanThe transaction plan tree to check.
predicate(plan) => booleanA function that returns true if the plan satisfies the condition.

Returns

boolean

true if every plan in the tree satisfies the predicate, false otherwise.

Examples

Checking if all plans are divisible.

const plan = sequentialTransactionPlan([
  parallelTransactionPlan([messageA, messageB]),
  sequentialTransactionPlan([messageC, messageD]),
]);
 
const allDivisible = everyTransactionPlan(
  plan,
  (p) => p.kind !== 'sequential' || p.divisible,
);
// Returns true because all sequential plans are divisible.

Checking if all single plans have a specific fee payer.

const plan = parallelTransactionPlan([messageA, messageB, messageC]);
 
const allUseSameFeePayer = everyTransactionPlan(
  plan,
  (p) => p.kind !== 'single' || p.message.feePayer.address === myFeePayer,
);

See

On this page