Skip to content

Data & Queries] Soroban: Read APIs for invoice payment status (Medium, 150 points) #22

@Cedarich

Description

@Cedarich

Description

Add view methods to the Soroban contract so clients can query payment information for a given invoice ID or list recent payments, complementing event-based indexing.

Requirements and Context

  • Events are great for streaming, but some clients need direct queries.
  • The current contract may only emit events without stored state.
  • Done means:
    • View functions exist to:
      • Get payment info by invoice_id.
      • Optionally list payments for a given payer or recent history.

Suggested Execution

  • Extend the Soroban contract:
    • Add storage mapping from invoice_id to a payment record.
    • Implement a view method like get_payment(invoice_id) returning a struct.
  • Ensure:
    • Reads are cheap and don’t mutate state.
    • The data model aligns with the backend’s expectations.

Test and Commit

  • After recording a payment:
    • Call get_payment(invoice_id) via the Soroban CLI.
    • Confirm the data returned matches what was recorded.
  • Include in your PR:
    • Command examples to query payment status.
    • Sample outputs for successful lookups and not-found cases.

Example Commit Message

  • feat(contracts): add soroban view apis for invoice payment status

Guidelines

  • Complexity: Medium (150 points) — adds state and read methods, but limited surface area.
  • Handle non-existent invoices gracefully (e.g. return null/empty or a descriptive error).
  • Keep the storage layout simple and well-documented.
  • Reference this issue in your PR description (Closes #<issue_id>).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions