assertIsSuccessfulTransactionPlanResult

function assertIsSuccessfulTransactionPlanResult<
    TContext,
    TTransactionMessage,
>(
    plan,
): asserts plan is SuccessfulTransactionPlanResult<
    TContext,
    TTransactionMessage
>;

Asserts that the given transaction plan result is a SuccessfulTransactionPlanResult.

This function verifies that the entire transaction plan result tree contains only successful single transaction results. It throws if any SingleTransactionPlanResult in the tree has a 'failed' or 'canceled' status.

Note: This is different from assertIsSuccessfulSingleTransactionPlanResult which asserts that a single result is successful. This function asserts that the entire plan result tree (including all nested parallel/sequential structures) contains only successful transactions.

Type Parameters

Parameters

ParameterTypeDescription
planTransactionPlanResult<TContext, TTransactionMessage>The transaction plan result to assert.

Returns

asserts plan is SuccessfulTransactionPlanResult<TContext, TTransactionMessage>

Throws

Throws a SolanaError with code SOLANA_ERROR__INSTRUCTION_PLANS__EXPECTED_SUCCESSFUL_TRANSACTION_PLAN_RESULT if any single transaction result in the tree is not successful.

Example

const result: TransactionPlanResult = parallelTransactionPlanResult([
  successfulSingleTransactionPlanResultFromTransaction(messageA, transactionA),
  successfulSingleTransactionPlanResultFromTransaction(messageB, transactionB),
]);
 
assertIsSuccessfulTransactionPlanResult(result);
// All transactions were successful.
result satisfies SuccessfulTransactionPlanResult;

See

On this page