feat(contract): implement POST /submit — anchor document hash to Stellar [CT-01]#957
Merged
Merged
Conversation
Contributor
|
@kike-alt is attempting to deploy a commit to the Mftee's projects Team on Vercel. A member of the Team first needs to authorize it. |
…lar [CT-01]
Implements the previously stubbed submit_document handler in
contract/src/lib.rs and adds anchor_hash() to StellarClient in
contract/src/stellar.rs.
Changes:
- contract/src/stellar.rs:
- Added AnchorResult struct (tx_hash, ledger, anchored_at)
- Implemented StellarClient::anchor_hash() using stellar-base:
- Fetches account sequence number from Horizon
- Builds a ManageData operation with key 'doc_' + hash[:58]
(matches NestJS buildDataKey() exactly)
- Signs the transaction with the service's STELLAR_SECRET_KEY
- Submits to Horizon via application/x-www-form-urlencoded
- Returns AnchorResult on success; propagates Horizon error detail on failure
- Added build_data_key() and build_revocation_key() helpers
- Added stellar-base = "0.5" dependency for XDR/transaction building
- contract/src/lib.rs:
- submit_document() now takes State<AppState> and calls stellar.anchor_hash()
- Idempotency: checks Redis cache (stellar:verify:{hash}) before submitting;
returns existing result with 200 if already anchored
- On success: caches result with 1-year TTL, returns SubmitResponse
- On Horizon failure: returns 502 with error detail
- Returns 400 for missing/malformed hash (unchanged)
- Added Deserialize to SubmitResponse to support cache round-trip
Closes CodeGirlsInc#854
kike-alt
force-pushed
the
feature/implement-post-submit
branch
from
July 21, 2026 13:10
14bed41 to
740959b
Compare
added 2 commits
July 21, 2026 15:30
Contracts (Rust): - Run cargo fmt --all to fix formatting in contract/src/lib.rs and contract/src/stellar.rs; long lines in info!/warn! macros and method chains were not wrapped to rustfmt's column limit Frontend (Next.js): - Move misplaced pages from app/(protected)/ to app/[locale]/(protected)/ so they are covered by the root layout at app/[locale]/layout.tsx. Affected pages: admin/providers, profile, reports, settings/api-keys. Without a root layout Next.js 15 refuses to build the page.
…bility stellar-base 0.5.0 calls sodiumoxide::crypto::sign::Signature::from_slice() which does not exist in newer sodiumoxide versions. Pinning to =0.2.6 (the version stellar-base 0.5 was built against) resolves the compile error: error[E0599]: no associated function or constant named 'from_slice' found for struct 'sodiumoxide::crypto::sign::Signature'
mftee
approved these changes
Jul 21, 2026
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
POST /submitendpoint in the Rust verifier microservice, which was previously returning400 Bad Requestwith"submit endpoint not yet implemented".Changes
contract/src/stellar.rsAnchorResultstruct (tx_hash,ledger,anchored_at)StellarClient::anchor_hash(hash, public_key, secret_key):ManageDatatransaction usingstellar-base:"doc_" + &hash[..58]— matches NestJSbuildDataKey()exactlySTELLAR_SECRET_KEYPOST /transactionsAnchorResulton success; propagates Horizon error detail on failurebuild_data_key()andbuild_revocation_key()helper functionscontract/src/lib.rssubmit_document()now takesState<AppState>and callsstellar.anchor_hash()stellar:verify:{hash}) before submitting — duplicate submissions return the cached result with200{ success, transaction_id, anchored_at }502with error detail from Horizon400for missing/malformed hash (unchanged)DeserializetoSubmitResponseto support cache round-tripcontract/Cargo.tomlstellar-base = "0.5"for XDR transaction buildingTesting
cargo build— clean ✓verify_documentandrecord_transferhandlersCloses #854