sdk

Radroots SDK and bindings
git clone https://radroots.dev/git/sdk.git
Log | Files | Refs | README

commit 36509e62546b07c2aa2f62cd6ad07b4f39d2abff
parent 026dbe08a91c97f1a555d0507f3c43e10768eb91
Author: triesap <tyson@radroots.org>
Date:   Mon,  6 Jul 2026 06:45:18 +0000

knowledge: surface draft contract error codes

- map contract-shape draft failures to their underlying contract validation code
- prove SDK knowledge errors expose stable draft inner codes
- keep SDK builders routed through the core frozen draft constructor
- avoid adding SDK-local duplicate contract validation

Diffstat:
Mcrates/sdk/src/knowledge.rs | 1+
Mcrates/sdk/tests/knowledge_public_api.rs | 13+++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/crates/sdk/src/knowledge.rs b/crates/sdk/src/knowledge.rs @@ -1251,6 +1251,7 @@ fn draft_error_code(error: &RadrootsDraftError) -> &'static str { match error { RadrootsDraftError::UnknownContract(_) => "unknown_contract", RadrootsDraftError::ContractKindMismatch { .. } => "contract_kind_mismatch", + RadrootsDraftError::ContractShape { error, .. } => error.code(), RadrootsDraftError::SignedEventPubkeyMismatch { .. } => "signed_event_pubkey_mismatch", RadrootsDraftError::SignedEventIdMismatch { .. } => "signed_event_id_mismatch", RadrootsDraftError::SignedEventCreatedAtMismatch { .. } => { diff --git a/crates/sdk/tests/knowledge_public_api.rs b/crates/sdk/tests/knowledge_public_api.rs @@ -393,6 +393,19 @@ fn knowledge_errors_expose_stable_codes() { assert_eq!(error.code(), "knowledge_encode"); assert_eq!(error.inner_code(), "invalid_field"); assert!(!error.to_string().contains(article.content_djot.as_str())); + + let draft_error: RadrootsSdkKnowledgeError = RadrootsFrozenEventDraft::new( + KNOWLEDGE_CLAIM_CONTRACT_ID, + KIND_KNOWLEDGE_CLAIM, + CREATED_AT, + Vec::new(), + r#"{"schema":"radroots.knowledge.claim.v1","schema_version":1}"#, + public_key_hex(), + ) + .expect_err("contract shape") + .into(); + assert_eq!(draft_error.code(), "knowledge_draft"); + assert_eq!(draft_error.inner_code(), "missing_tag"); } fn sign_parts(parts: WireEventParts) -> RadrootsNostrEvent {