Skip to content

BE — Add explainers for all remaining Stellar operation types #176

@Tinna23

Description

@Tinna23

Description

The backend currently only explains payment operations. All other operation types fall into Operation::Other and return no explanation. Stellar has ~20 operation types — this issue implements explainers for the most important remaining ones, following the exact same pattern as the existing payment.rs explainer.

Operation Types to Implement

Each operation needs:

  • A struct in src/models/operation.rs
  • A From<HorizonOperation> mapping
  • An explainer in src/explain/operation/
  • Unit tests

Required operations (in priority order):

Operation Why it matters
create_account Most common after payment — activates new wallets
change_trust How accounts opt in to hold assets (USDC etc.)
set_options Configures signers, flags, home domain, thresholds
path_payment_strict_send Cross-asset payment — sends one asset, receiver gets another
path_payment_strict_receive Cross-asset payment — receiver specifies exact amount
manage_sell_offer DEX order placement / update / cancel
manage_buy_offer DEX buy order
create_passive_sell_offer DEX passive order (doesn't consume existing offers)
clawback Regulated asset recovery by issuer
clawback_claimable_balance Clawback on claimable balances
account_merge Merges account into another, transfers all XLM

Requirements

  • Follow the exact pattern established in src/explain/operation/payment.rs
  • Each explainer must be pure, deterministic, and side-effect free
  • Each new variant must be added to the Operation enum in src/models/operation.rs
  • Each must have a From<HorizonOperation> mapping
  • Register each new module in src/explain/operation/mod.rs
  • Plain-English explanations — no jargon
  • Example output for create_account: "GABC… funded and activated a new Stellar account GDEST… with a starting balance of 1.5 XLM"
  • Example output for change_trust (add): "GABC… opted in to hold up to 10,000 USDC issued by GBBB…"
  • Example output for change_trust (remove): "GABC… removed their trust line for USDC"
  • Example output for account_merge: "GABC… merged their account into GDEST…, transferring all remaining XLM"
  • DEX offers: offer_id = 0 = new offer, offer_id > 0 = update, amount = 0 = cancel

Key Files

  • packages/core/src/models/operation.rs
  • packages/core/src/explain/operation/ (create new files here)
  • packages/core/src/explain/operation/mod.rs
  • packages/core/src/services/horizon.rs (add any missing HorizonOperation fields)

Acceptance Criteria

  • All 11 operation types listed above have a working explainer
  • Each explainer has unit tests covering standard and edge cases
  • Fetching a create_account transaction returns a human-readable explanation
  • Fetching a change_trust transaction correctly identifies add vs remove
  • DEX offers correctly identify new offer vs update vs cancel
  • cargo test passes with no regressions
  • No operation type returns an empty or missing explanation

Stage: S3 — Operation Coverage

Metadata

Metadata

Assignees

No one assigned

    Labels

    RustA language empowering everyone to build reliable and efficient software.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions