MPP.Methods.Solana.Instructions (mpp v0.15.0)

Copy Markdown View Source

Parse and match Solana payment instructions for MPP.Methods.Solana.

Two input shapes are supported:

  • compiled legacy transactions (Cartouche.Solana.Transaction) for pull-mode pre-broadcast checks (instruction allow-list + payment legs)
  • jsonParsed getTransaction results for push-mode and post-confirm payment matching

Observed jsonParsed transfer shapes were captured from Solana devnet (getTransaction / getBlock on 2026-08-19) and are the authority for field names used here.

Summary

Functions

Classify compiled instructions on a legacy transaction.

Classify top-level jsonParsed instructions from a getTransaction result.

Return the payment legs implied by a charge (primary remainder + splits).

Validate split entries in method_config (shape only; amount vs charge is checked when the charge is available).

Enforce the pull-mode instruction allow-list, ATA policy, and compute-budget ceilings, then match payment legs against the challenge.

Match payment legs in a confirmed jsonParsed transaction against the charge.

Types

classified()

@type classified() ::
  {:sol_transfer, map()}
  | {:spl_transfer, map()}
  | {:ata_create, map()}
  | {:memo, binary()}
  | {:compute_budget, term()}
  | {:unknown, binary()}

Functions

classify_compiled(transaction)

@spec classify_compiled(Cartouche.Solana.Transaction.t()) ::
  {:ok, [classified()]} | {:error, String.t()}

Classify compiled instructions on a legacy transaction.

Returns {:ok, [classified]} or {:error, reason} when an account index is out of range.

classify_parsed(rpc_tx)

@spec classify_parsed(map()) :: {:ok, [classified()]} | {:error, String.t()}

Classify top-level jsonParsed instructions from a getTransaction result.

payment_legs(charge)

@spec payment_legs(MPP.Intents.Charge.t()) ::
  {:ok, [map()]} | {:error, MPP.Errors.t()}

Return the payment legs implied by a charge (primary remainder + splits).

validate_splits_config!(splits)

@spec validate_splits_config!([map()] | nil) :: :ok

Validate split entries in method_config (shape only; amount vs charge is checked when the charge is available).

verify_compiled(tx, charge, opts)

@spec verify_compiled(Cartouche.Solana.Transaction.t(), MPP.Intents.Charge.t(), map()) ::
  :ok | {:error, MPP.Errors.t()}

Enforce the pull-mode instruction allow-list, ATA policy, and compute-budget ceilings, then match payment legs against the challenge.

verify_parsed(rpc_tx, charge, opts)

@spec verify_parsed(map(), MPP.Intents.Charge.t(), map()) ::
  :ok | {:error, MPP.Errors.t()}

Match payment legs in a confirmed jsonParsed transaction against the charge.