Skip to content

[CT-31] Implement real POST /submit handler in the Rust verifier #936

Description

@mftee

Overview

submit_document() in lib.rs validates the hash format but then unconditionally returns 400 with the message "submit endpoint not yet implemented" (see the comment: "Endpoint behavior not yet implemented; preserve previous BAD_REQUEST semantics."). The handler doesn't even take State<AppState>, so it has no access to the Stellar client, cache, or metrics.

File

contract/src/lib.rs (submit_document)

Acceptance Criteria

  • Add State<AppState> to submit_document's signature
  • Implement real submission: anchor document_hash to Stellar (reuse/extend StellarClient, similar to anchor_transfer's intended behavior once CT-35 lands), returning transaction_id and anchored_at on success
  • Cache the submission result the same way verify_document does
  • Increment metrics.increment_request_count() / increment_error_count() appropriately
  • Return 200/201 with SubmitResponse{ success: true, transaction_id, anchored_at, error: None } on success, and a meaningful error body (not just BAD_REQUEST) on real failure
  • Add integration tests covering success and a simulated Stellar failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions