commit c54c08d1a494d854f002c5abcee3d0e9cb5d1da1 parent c320c4585c270afc31c3c93d4f5606ca9e5565ea Author: triesap <tyson@radroots.org> Date: Sat, 11 Jul 2026 06:49:03 +0000 sdk: align event API names - update SDK Rust APIs, tests, examples, and wasm helpers to neutral event-envelope names - refresh generated TypeScript bindings and package metadata from xtask - preserve raw Nostr protocol event names only in Nostr signer and adapter surfaces - remove old core draft, signed-event, event-ref, and event-pointer names without aliases Validation: - cargo xtask generate ts - cargo xtask generate package-metadata - cargo fmt --all --check - cargo check --workspace --all-targets - cargo xtask check - cargo test -p radroots_sdk --all-features - git diff --check Diffstat:
40 files changed, 363 insertions(+), 369 deletions(-)
diff --git a/contracts/packages/go.toml b/contracts/packages/go.toml @@ -34,11 +34,11 @@ order = 3 [shared_types] "WireEventParts" = "WireEventParts" -"RadrootsFrozenEventDraft" = "RadrootsFrozenEventDraft" -"RadrootsSignedNostrEvent" = "RadrootsSignedNostrEvent" -"RadrootsNostrEvent" = "RadrootsNostrEvent" -"RadrootsNostrEventRef" = "RadrootsNostrEventRef" -"RadrootsNostrEventPtr" = "RadrootsNostrEventPtr" +"RadrootsEventDraft" = "RadrootsEventDraft" +"RadrootsSignedEvent" = "RadrootsSignedEvent" +"RadrootsEventEnvelope" = "RadrootsEventEnvelope" +"RadrootsEventRef" = "RadrootsEventRef" +"RadrootsEventPtr" = "RadrootsEventPtr" "RadrootsListingAddress" = "ListingAddress" "RadrootsProfile" = "RadrootsProfile" "RadrootsFarm" = "RadrootsFarm" diff --git a/contracts/packages/kotlin.toml b/contracts/packages/kotlin.toml @@ -34,11 +34,11 @@ order = 2 [shared_types] "WireEventParts" = "WireEventParts" -"RadrootsFrozenEventDraft" = "RadrootsFrozenEventDraft" -"RadrootsSignedNostrEvent" = "RadrootsSignedNostrEvent" -"RadrootsNostrEvent" = "RadrootsNostrEvent" -"RadrootsNostrEventRef" = "RadrootsNostrEventRef" -"RadrootsNostrEventPtr" = "RadrootsNostrEventPtr" +"RadrootsEventDraft" = "RadrootsEventDraft" +"RadrootsSignedEvent" = "RadrootsSignedEvent" +"RadrootsEventEnvelope" = "RadrootsEventEnvelope" +"RadrootsEventRef" = "RadrootsEventRef" +"RadrootsEventPtr" = "RadrootsEventPtr" "RadrootsListingAddress" = "ListingAddress" "RadrootsProfile" = "RadrootsProfile" "RadrootsFarm" = "RadrootsFarm" diff --git a/contracts/packages/py.toml b/contracts/packages/py.toml @@ -34,11 +34,11 @@ order = 3 [shared_types] "WireEventParts" = "WireEventParts" -"RadrootsFrozenEventDraft" = "RadrootsFrozenEventDraft" -"RadrootsSignedNostrEvent" = "RadrootsSignedNostrEvent" -"RadrootsNostrEvent" = "RadrootsNostrEvent" -"RadrootsNostrEventRef" = "RadrootsNostrEventRef" -"RadrootsNostrEventPtr" = "RadrootsNostrEventPtr" +"RadrootsEventDraft" = "RadrootsEventDraft" +"RadrootsSignedEvent" = "RadrootsSignedEvent" +"RadrootsEventEnvelope" = "RadrootsEventEnvelope" +"RadrootsEventRef" = "RadrootsEventRef" +"RadrootsEventPtr" = "RadrootsEventPtr" "RadrootsListingAddress" = "ListingAddress" "RadrootsProfile" = "RadrootsProfile" "RadrootsFarm" = "RadrootsFarm" diff --git a/contracts/packages/swift.toml b/contracts/packages/swift.toml @@ -34,11 +34,11 @@ order = 2 [shared_types] "WireEventParts" = "WireEventParts" -"RadrootsFrozenEventDraft" = "RadrootsFrozenEventDraft" -"RadrootsSignedNostrEvent" = "RadrootsSignedNostrEvent" -"RadrootsNostrEvent" = "RadrootsNostrEvent" -"RadrootsNostrEventRef" = "RadrootsNostrEventRef" -"RadrootsNostrEventPtr" = "RadrootsNostrEventPtr" +"RadrootsEventDraft" = "RadrootsEventDraft" +"RadrootsSignedEvent" = "RadrootsSignedEvent" +"RadrootsEventEnvelope" = "RadrootsEventEnvelope" +"RadrootsEventRef" = "RadrootsEventRef" +"RadrootsEventPtr" = "RadrootsEventPtr" "RadrootsListingAddress" = "ListingAddress" "RadrootsProfile" = "RadrootsProfile" "RadrootsFarm" = "RadrootsFarm" diff --git a/contracts/packages/ts.toml b/contracts/packages/ts.toml @@ -111,11 +111,11 @@ order = 1 [shared_types] "WireEventParts" = "WireEventParts" -"RadrootsFrozenEventDraft" = "RadrootsFrozenEventDraft" -"RadrootsSignedNostrEvent" = "RadrootsSignedNostrEvent" -"RadrootsNostrEvent" = "RadrootsNostrEvent" -"RadrootsNostrEventRef" = "RadrootsNostrEventRef" -"RadrootsNostrEventPtr" = "RadrootsNostrEventPtr" +"RadrootsEventDraft" = "RadrootsEventDraft" +"RadrootsSignedEvent" = "RadrootsSignedEvent" +"RadrootsEventEnvelope" = "RadrootsEventEnvelope" +"RadrootsEventRef" = "RadrootsEventRef" +"RadrootsEventPtr" = "RadrootsEventPtr" "RadrootsListingAddress" = "ListingAddress" "RadrootsProfile" = "RadrootsProfile" "RadrootsFarm" = "RadrootsFarm" diff --git a/crates/events_codec_wasm/src/lib.rs b/crates/events_codec_wasm/src/lib.rs @@ -132,7 +132,9 @@ fn tags_to_json(tags: Vec<Vec<String>>) -> Result<String, RadrootsJsValue> { serde_json::to_string(&tags).map_err(err_js) } -fn parse_event_json(input: &str) -> Result<radroots_events::RadrootsNostrEvent, RadrootsJsValue> { +fn parse_event_json( + input: &str, +) -> Result<radroots_events::RadrootsEventEnvelope, RadrootsJsValue> { serde_json::from_str(input).map_err(|_| error_json("invalid_json", Some("event_json"))) } @@ -164,7 +166,7 @@ where { event_type: &'static str, contract_id: &'static str, - event: &'a radroots_events::RadrootsNostrEvent, + event: &'a radroots_events::RadrootsEventEnvelope, payload: &'a T, } @@ -693,8 +695,8 @@ mod tests { } } - fn knowledge_event_ref(seed: char, kind: u32) -> radroots_events::RadrootsNostrEventRef { - radroots_events::RadrootsNostrEventRef { + fn knowledge_event_ref(seed: char, kind: u32) -> radroots_events::RadrootsEventRef { + radroots_events::RadrootsEventRef { id: synthetic_event_id(seed), author: synthetic_pubkey('a'), kind, @@ -888,7 +890,7 @@ mod tests { .custom_created_at(nostr::Timestamp::from_secs(1_800_000_000)) .sign_with_keys(&keys) .expect("signed event"); - serde_json::to_string(&radroots_events::RadrootsNostrEvent { + serde_json::to_string(&radroots_events::RadrootsEventEnvelope { id: event.id.to_hex(), author: event.pubkey.to_hex(), created_at: event.created_at.as_secs() as u32, diff --git a/crates/replica_sync_wasm/src/lib.rs b/crates/replica_sync_wasm/src/lib.rs @@ -4,7 +4,7 @@ use base64::Engine; #[cfg(target_arch = "wasm32")] use base64::engine::general_purpose::URL_SAFE_NO_PAD; -use radroots_events::RadrootsNostrEvent; +use radroots_events::RadrootsEventEnvelope; use radroots_replica_sync::RadrootsReplicaSyncRequest; #[cfg(target_arch = "wasm32")] use radroots_replica_sync::{ @@ -53,7 +53,7 @@ pub fn parse_request_model(request_json: &str) -> Result<RadrootsReplicaSyncRequ serde_json::from_str(request_json).map_err(|error| error.to_string()) } -pub fn parse_event_model(event_json: &str) -> Result<RadrootsNostrEvent, String> { +pub fn parse_event_model(event_json: &str) -> Result<RadrootsEventEnvelope, String> { let envelope: NostrEventEnvelope = serde_json::from_str(event_json).map_err(|error| error.to_string())?; let author = match (envelope.author, envelope.pubkey) { @@ -64,7 +64,7 @@ pub fn parse_event_model(event_json: &str) -> Result<RadrootsNostrEvent, String> (None, Some(pubkey)) => pubkey, (None, None) => return Err("missing author/pubkey".to_owned()), }; - Ok(RadrootsNostrEvent { + Ok(RadrootsEventEnvelope { id: envelope.id, author, created_at: envelope.created_at, diff --git a/crates/sdk/examples/sdk_v1_knowledge_prepare.rs b/crates/sdk/examples/sdk_v1_knowledge_prepare.rs @@ -33,7 +33,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { Ok(()) } -fn sign_parts(parts: WireEventParts) -> Result<RadrootsNostrEvent, Box<dyn std::error::Error>> { +fn sign_parts(parts: WireEventParts) -> Result<RadrootsEventEnvelope, Box<dyn std::error::Error>> { let tags = parts .tags .into_iter() @@ -44,7 +44,7 @@ fn sign_parts(parts: WireEventParts) -> Result<RadrootsNostrEvent, Box<dyn std:: .tags(tags) .custom_created_at(Timestamp::from_secs(u64::from(CREATED_AT))) .sign_with_keys(&keys)?; - Ok(RadrootsNostrEvent { + Ok(RadrootsEventEnvelope { id: event.id.to_hex(), author: event.pubkey.to_hex(), created_at: event.created_at.as_secs() as u32, @@ -71,8 +71,8 @@ fn hex_64(character: char) -> String { character.to_string().repeat(64) } -fn event_ref(character: char, kind: u32) -> RadrootsNostrEventRef { - RadrootsNostrEventRef { +fn event_ref(character: char, kind: u32) -> RadrootsEventRef { + RadrootsEventRef { id: hex_64(character), author: hex_64('a'), kind, diff --git a/crates/sdk/src/adapters/radrootsd.rs b/crates/sdk/src/adapters/radrootsd.rs @@ -1,7 +1,7 @@ use core::fmt; use core::time::Duration; -use radroots_events::draft::RadrootsSignedNostrEvent; +use radroots_events::draft::RadrootsSignedEvent; use radroots_transport_publish_protocol::{ METHOD_EVENT, SignedNostrEventWire, TransportPublishDeliveryPolicy, TransportPublishEventRequest, TransportPublishEventResponse, TransportPublishProtocolError, @@ -100,7 +100,7 @@ impl RadrootsdProxyPublishAdapter { #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsdProxyPublishRequest { - pub signed_event: RadrootsSignedNostrEvent, + pub signed_event: RadrootsSignedEvent, pub target_policy: TransportPublishTargetPolicy, pub delivery_policy: TransportPublishDeliveryPolicy, pub idempotency_key: Option<String>, @@ -299,7 +299,7 @@ where decode_jsonrpc_response(method, request_id, body.as_str()) } -fn signed_event_wire(event: &RadrootsSignedNostrEvent) -> SignedNostrEventWire { +fn signed_event_wire(event: &RadrootsSignedEvent) -> SignedNostrEventWire { SignedNostrEventWire { id: event.id.clone(), pubkey: event.pubkey.clone(), diff --git a/crates/sdk/src/dvm_runtime.rs b/crates/sdk/src/dvm_runtime.rs @@ -15,8 +15,8 @@ use radroots_authority::{RadrootsActorContext, RadrootsEventSigner, authorize_ac use radroots_event_store::RadrootsEventIngest; #[cfg(feature = "runtime")] use radroots_events::{ - RadrootsNostrEvent, - draft::RadrootsFrozenEventDraft, + RadrootsEventEnvelope, + draft::RadrootsEventDraft, ids::{RadrootsEventId, RadrootsListingAddress, RadrootsOrderId, RadrootsPublicKey}, kinds::KIND_TRADE_TRANSITION_PROOF_REQUEST, }; @@ -301,7 +301,7 @@ pub struct DvmTradeTransitionProofPlan { pub proof_mode: DvmProofMode, pub expected_receipt_proof_system: RadrootsValidationReceiptProofSystem, pub expected_event_id: RadrootsEventId, - pub frozen_draft: RadrootsFrozenEventDraft, + pub frozen_draft: RadrootsEventDraft, pub payload: DvmTradeTransitionProofRequestPayload, pub created_at: RadrootsSdkTimestamp, } @@ -329,7 +329,7 @@ pub struct DvmTradeTransitionProofReceipt { #[derive(Clone, Debug, serde::Serialize)] #[non_exhaustive] pub struct DvmValidationReceiptIngestRequest { - pub event: RadrootsNostrEvent, + pub event: RadrootsEventEnvelope, pub observed_at: Option<RadrootsSdkTimestamp>, pub expected_order_id: Option<RadrootsOrderId>, pub expected_listing_event_id: Option<RadrootsEventId>, @@ -340,7 +340,7 @@ pub struct DvmValidationReceiptIngestRequest { #[cfg(feature = "runtime")] impl DvmValidationReceiptIngestRequest { - pub fn new(event: RadrootsNostrEvent) -> Self { + pub fn new(event: RadrootsEventEnvelope) -> Self { Self { event, observed_at: None, diff --git a/crates/sdk/src/farms_runtime.rs b/crates/sdk/src/farms_runtime.rs @@ -16,7 +16,7 @@ use radroots_authority::{RadrootsActorContext, RadrootsEventSigner}; #[cfg(feature = "runtime")] use radroots_events::{ contract::RadrootsActorRole, - draft::RadrootsFrozenEventDraft, + draft::RadrootsEventDraft, farm::{RadrootsFarm, RadrootsFarmPublicLocation}, ids::{RadrootsAddressableCoordinate, RadrootsEventId}, kinds::KIND_FARM, @@ -127,7 +127,7 @@ impl FarmEnqueuePublishRequest { pub struct FarmPublishPlan { pub farm_addr: RadrootsAddressableCoordinate, pub expected_event_id: RadrootsEventId, - pub frozen_draft: RadrootsFrozenEventDraft, + pub frozen_draft: RadrootsEventDraft, pub created_at: RadrootsSdkTimestamp, } diff --git a/crates/sdk/src/knowledge.rs b/crates/sdk/src/knowledge.rs @@ -12,8 +12,8 @@ use std::{ use core::fmt; pub use radroots_events::{ - RadrootsNostrEvent, RadrootsNostrEventRef, - draft::{RadrootsDraftError, RadrootsFrozenEventDraft}, + RadrootsEventEnvelope, RadrootsEventRef, + draft::{RadrootsDraftError, RadrootsEventDraft}, kinds::{ KIND_FILE_METADATA, KIND_KNOWLEDGE_CLAIM, KIND_KNOWLEDGE_FIELD_REPORT, KIND_KNOWLEDGE_RELATION, KIND_KNOWLEDGE_REVIEW, KIND_KNOWLEDGE_SOURCE, KIND_WIKI_ARTICLE, @@ -211,7 +211,7 @@ pub struct RadrootsWikiArticleBuilder { content_djot: Option<String>, summary: Option<String>, topics: Vec<String>, - references: Vec<RadrootsNostrEventRef>, + references: Vec<RadrootsEventRef>, forked_from: Vec<RadrootsWikiArticleVersionRef>, deferred_to: Option<RadrootsWikiArticleVersionRef>, } @@ -244,7 +244,7 @@ impl RadrootsWikiArticleBuilder { self } - pub fn reference(mut self, reference: RadrootsNostrEventRef) -> Self { + pub fn reference(mut self, reference: RadrootsEventRef) -> Self { self.references.push(reference); self } @@ -281,7 +281,7 @@ impl RadrootsWikiArticleBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(prepare_wiki_article_draft( &self.build()?, expected_pubkey, @@ -325,7 +325,7 @@ impl RadrootsWikiRedirectBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(prepare_wiki_redirect_draft( &self.build()?, expected_pubkey, @@ -404,7 +404,7 @@ impl RadrootsWikiMergeRequestBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(prepare_wiki_merge_request_draft( &self.build()?, expected_pubkey, @@ -423,7 +423,7 @@ pub struct RadrootsKnowledgeSourceBuilder { publication_year: Option<u16>, edition: Option<String>, canonical_url: Option<String>, - artifact_refs: Vec<RadrootsNostrEventRef>, + artifact_refs: Vec<RadrootsEventRef>, author_asserted_rights: Option<RadrootsRightsAssertion>, topics: Vec<String>, summary: Option<String>, @@ -472,7 +472,7 @@ impl RadrootsKnowledgeSourceBuilder { self } - pub fn artifact_ref(mut self, artifact_ref: RadrootsNostrEventRef) -> Self { + pub fn artifact_ref(mut self, artifact_ref: RadrootsEventRef) -> Self { self.artifact_refs.push(artifact_ref); self } @@ -520,7 +520,7 @@ impl RadrootsKnowledgeSourceBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(prepare_knowledge_source_draft( &self.build()?, expected_pubkey, @@ -537,7 +537,7 @@ pub struct RadrootsKnowledgeClaimBuilder { topics: Vec<String>, applies_to: Vec<String>, author_asserted_confidence: Option<String>, - supersedes: Vec<RadrootsNostrEventRef>, + supersedes: Vec<RadrootsEventRef>, } impl RadrootsKnowledgeClaimBuilder { @@ -586,7 +586,7 @@ impl RadrootsKnowledgeClaimBuilder { self } - pub fn supersedes(mut self, supersedes: RadrootsNostrEventRef) -> Self { + pub fn supersedes(mut self, supersedes: RadrootsEventRef) -> Self { self.supersedes.push(supersedes); self } @@ -614,7 +614,7 @@ impl RadrootsKnowledgeClaimBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(prepare_knowledge_claim_draft( &self.build()?, expected_pubkey, @@ -628,9 +628,9 @@ pub struct RadrootsKnowledgeRelationBuilder { subject: Option<RadrootsKnowledgeNodeRef>, predicate: Option<String>, object: Option<RadrootsKnowledgeNodeRef>, - support_refs: Vec<RadrootsNostrEventRef>, + support_refs: Vec<RadrootsEventRef>, author_asserted_confidence: Option<String>, - supersedes: Vec<RadrootsNostrEventRef>, + supersedes: Vec<RadrootsEventRef>, } impl RadrootsKnowledgeRelationBuilder { @@ -660,7 +660,7 @@ impl RadrootsKnowledgeRelationBuilder { self } - pub fn support_ref(mut self, support_ref: RadrootsNostrEventRef) -> Self { + pub fn support_ref(mut self, support_ref: RadrootsEventRef) -> Self { self.support_refs.push(support_ref); self } @@ -673,7 +673,7 @@ impl RadrootsKnowledgeRelationBuilder { self } - pub fn supersedes(mut self, supersedes: RadrootsNostrEventRef) -> Self { + pub fn supersedes(mut self, supersedes: RadrootsEventRef) -> Self { self.supersedes.push(supersedes); self } @@ -700,7 +700,7 @@ impl RadrootsKnowledgeRelationBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(prepare_knowledge_relation_draft( &self.build()?, expected_pubkey, @@ -716,7 +716,7 @@ pub struct RadrootsKnowledgeReviewBuilder { verdict: Option<String>, scores: Vec<RadrootsKnowledgeReviewScore>, notes: Option<String>, - evidence_refs: Vec<RadrootsNostrEventRef>, + evidence_refs: Vec<RadrootsEventRef>, } impl RadrootsKnowledgeReviewBuilder { @@ -756,7 +756,7 @@ impl RadrootsKnowledgeReviewBuilder { self } - pub fn evidence_ref(mut self, evidence_ref: RadrootsNostrEventRef) -> Self { + pub fn evidence_ref(mut self, evidence_ref: RadrootsEventRef) -> Self { self.evidence_refs.push(evidence_ref); self } @@ -783,7 +783,7 @@ impl RadrootsKnowledgeReviewBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(prepare_knowledge_review_draft( &self.build()?, expected_pubkey, @@ -799,8 +799,8 @@ pub struct RadrootsKnowledgeFieldReportBuilder { summary: Option<String>, context: Option<RadrootsKnowledgeFieldContext>, observations: Vec<RadrootsKnowledgeObservation>, - artifact_refs: Vec<RadrootsNostrEventRef>, - related_refs: Vec<RadrootsNostrEventRef>, + artifact_refs: Vec<RadrootsEventRef>, + related_refs: Vec<RadrootsEventRef>, limitations: Vec<String>, } @@ -843,12 +843,12 @@ impl RadrootsKnowledgeFieldReportBuilder { self } - pub fn artifact_ref(mut self, artifact_ref: RadrootsNostrEventRef) -> Self { + pub fn artifact_ref(mut self, artifact_ref: RadrootsEventRef) -> Self { self.artifact_refs.push(artifact_ref); self } - pub fn related_ref(mut self, related_ref: RadrootsNostrEventRef) -> Self { + pub fn related_ref(mut self, related_ref: RadrootsEventRef) -> Self { self.related_refs.push(related_ref); self } @@ -882,7 +882,7 @@ impl RadrootsKnowledgeFieldReportBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(prepare_knowledge_field_report_draft( &self.build()?, expected_pubkey, @@ -981,56 +981,56 @@ impl KnowledgeDraftBuilder { pub fn wiki_article( &self, article: &RadrootsWikiArticle, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_article_draft(article, self.expected_pubkey(), self.created_at) } pub fn wiki_redirect( &self, redirect: &RadrootsWikiRedirect, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_redirect_draft(redirect, self.expected_pubkey(), self.created_at) } pub fn wiki_merge_request( &self, request: &RadrootsWikiMergeRequest, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_merge_request_draft(request, self.expected_pubkey(), self.created_at) } pub fn knowledge_source( &self, source: &RadrootsKnowledgeSource, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_source_draft(source, self.expected_pubkey(), self.created_at) } pub fn knowledge_claim( &self, claim: &RadrootsKnowledgeClaim, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_claim_draft(claim, self.expected_pubkey(), self.created_at) } pub fn knowledge_relation( &self, relation: &RadrootsKnowledgeRelation, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_relation_draft(relation, self.expected_pubkey(), self.created_at) } pub fn knowledge_review( &self, review: &RadrootsKnowledgeReview, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_review_draft(review, self.expected_pubkey(), self.created_at) } pub fn knowledge_field_report( &self, report: &RadrootsKnowledgeFieldReport, - ) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_field_report_draft(report, self.expected_pubkey(), self.created_at) } } @@ -1045,7 +1045,7 @@ impl KnowledgeCodec { pub fn verify_and_decode_radroots_event( &self, - event: RadrootsNostrEvent, + event: RadrootsEventEnvelope, ) -> Result<RadrootsDecodedEvent, RadrootsSdkKnowledgeError> { verify_and_decode_radroots_event(event) } @@ -1115,7 +1115,7 @@ pub fn prepare_wiki_article_draft( article: &RadrootsWikiArticle, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_wiki_article_event(article)?, WIKI_ARTICLE_CONTRACT_ID, @@ -1128,7 +1128,7 @@ pub fn prepare_wiki_redirect_draft( redirect: &RadrootsWikiRedirect, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_wiki_redirect_event(redirect)?, WIKI_REDIRECT_CONTRACT_ID, @@ -1141,7 +1141,7 @@ pub fn prepare_wiki_merge_request_draft( request: &RadrootsWikiMergeRequest, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_wiki_merge_request_event(request)?, WIKI_MERGE_REQUEST_CONTRACT_ID, @@ -1154,7 +1154,7 @@ pub fn prepare_knowledge_source_draft( source: &RadrootsKnowledgeSource, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_source_event(source)?, KNOWLEDGE_SOURCE_CONTRACT_ID, @@ -1167,7 +1167,7 @@ pub fn prepare_knowledge_claim_draft( claim: &RadrootsKnowledgeClaim, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_claim_event(claim)?, KNOWLEDGE_CLAIM_CONTRACT_ID, @@ -1180,7 +1180,7 @@ pub fn prepare_knowledge_relation_draft( relation: &RadrootsKnowledgeRelation, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_relation_event(relation)?, KNOWLEDGE_RELATION_CONTRACT_ID, @@ -1193,7 +1193,7 @@ pub fn prepare_knowledge_review_draft( review: &RadrootsKnowledgeReview, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_review_event(review)?, KNOWLEDGE_REVIEW_CONTRACT_ID, @@ -1206,7 +1206,7 @@ pub fn prepare_knowledge_field_report_draft( report: &RadrootsKnowledgeFieldReport, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_field_report_event(report)?, KNOWLEDGE_FIELD_REPORT_CONTRACT_ID, @@ -1216,7 +1216,7 @@ pub fn prepare_knowledge_field_report_draft( } pub fn verify_and_decode_radroots_event( - event: RadrootsNostrEvent, + event: RadrootsEventEnvelope, ) -> Result<RadrootsDecodedEvent, RadrootsSdkKnowledgeError> { Ok(codec_verify_and_decode(event)?) } @@ -1238,7 +1238,7 @@ fn prepare_draft( contract_id: &'static str, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsFrozenEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { Ok(to_frozen_draft( parts, contract_id, @@ -1328,20 +1328,20 @@ pub mod prelude { RADROOTS_KNOWLEDGE_REVIEW_SCHEMA, RADROOTS_KNOWLEDGE_SCHEMA_VERSION, RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, RADROOTS_WIKI_D_TAG_MAX_LEN, RadrootsAddressableRef, RadrootsContractValidatedEvent, RadrootsDecodeError, RadrootsDecodedEvent, - RadrootsDraftError, RadrootsEncodeError, RadrootsFrozenEventDraft, RadrootsIdVerifiedEvent, - RadrootsKnowledgeBuilderError, RadrootsKnowledgeChangeProposal, - RadrootsKnowledgeCitationSpan, RadrootsKnowledgeClaim, RadrootsKnowledgeClaimBuilder, - RadrootsKnowledgeContractManifest, RadrootsKnowledgeContractManifestEntry, - RadrootsKnowledgeFieldContext, RadrootsKnowledgeFieldReport, - RadrootsKnowledgeFieldReportBuilder, RadrootsKnowledgeLocation, - RadrootsKnowledgeLocationPrecision, RadrootsKnowledgeManifestCodecSupport, - RadrootsKnowledgeManifestDiscriminator, RadrootsKnowledgeManifestTagContract, - RadrootsKnowledgeNodeRef, RadrootsKnowledgeObservation, RadrootsKnowledgeObservationValue, - RadrootsKnowledgeRelation, RadrootsKnowledgeRelationBuilder, RadrootsKnowledgeReview, - RadrootsKnowledgeReviewBuilder, RadrootsKnowledgeReviewScope, RadrootsKnowledgeReviewScore, - RadrootsKnowledgeReviewTarget, RadrootsKnowledgeSource, RadrootsKnowledgeSourceBuilder, - RadrootsKnowledgeValidationError, RadrootsNip01VerificationError, RadrootsNostrEvent, - RadrootsNostrEventRef, RadrootsRightsAssertion, RadrootsSdkKnowledgeError, + RadrootsDraftError, RadrootsEncodeError, RadrootsEventDraft, RadrootsEventEnvelope, + RadrootsEventRef, RadrootsIdVerifiedEvent, RadrootsKnowledgeBuilderError, + RadrootsKnowledgeChangeProposal, RadrootsKnowledgeCitationSpan, RadrootsKnowledgeClaim, + RadrootsKnowledgeClaimBuilder, RadrootsKnowledgeContractManifest, + RadrootsKnowledgeContractManifestEntry, RadrootsKnowledgeFieldContext, + RadrootsKnowledgeFieldReport, RadrootsKnowledgeFieldReportBuilder, + RadrootsKnowledgeLocation, RadrootsKnowledgeLocationPrecision, + RadrootsKnowledgeManifestCodecSupport, RadrootsKnowledgeManifestDiscriminator, + RadrootsKnowledgeManifestTagContract, RadrootsKnowledgeNodeRef, + RadrootsKnowledgeObservation, RadrootsKnowledgeObservationValue, RadrootsKnowledgeRelation, + RadrootsKnowledgeRelationBuilder, RadrootsKnowledgeReview, RadrootsKnowledgeReviewBuilder, + RadrootsKnowledgeReviewScope, RadrootsKnowledgeReviewScore, RadrootsKnowledgeReviewTarget, + RadrootsKnowledgeSource, RadrootsKnowledgeSourceBuilder, RadrootsKnowledgeValidationError, + RadrootsNip01VerificationError, RadrootsRightsAssertion, RadrootsSdkKnowledgeError, RadrootsSignatureVerifiedEvent, RadrootsWikiArticle, RadrootsWikiArticleBuilder, RadrootsWikiArticleVersionRef, RadrootsWikiDTagError, RadrootsWikiMergeRequest, RadrootsWikiMergeRequestBuilder, RadrootsWikiRedirect, RadrootsWikiRedirectBuilder, diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs @@ -107,9 +107,9 @@ pub use crate::knowledge::{ RADROOTS_KNOWLEDGE_SCHEMA_VERSION, RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, RADROOTS_WIKI_D_TAG_MAX_LEN, RadrootsAddressableRef, RadrootsContractValidatedEvent, RadrootsDecodeError, RadrootsDecodedEvent, RadrootsDraftError, RadrootsEncodeError, - RadrootsFrozenEventDraft, RadrootsIdVerifiedEvent, RadrootsKnowledgeBuilderError, - RadrootsKnowledgeChangeProposal, RadrootsKnowledgeCitationSpan, RadrootsKnowledgeClaim, - RadrootsKnowledgeClaimBuilder, RadrootsKnowledgeContractManifest, + RadrootsEventDraft, RadrootsEventEnvelope, RadrootsEventRef, RadrootsIdVerifiedEvent, + RadrootsKnowledgeBuilderError, RadrootsKnowledgeChangeProposal, RadrootsKnowledgeCitationSpan, + RadrootsKnowledgeClaim, RadrootsKnowledgeClaimBuilder, RadrootsKnowledgeContractManifest, RadrootsKnowledgeContractManifestEntry, RadrootsKnowledgeFieldContext, RadrootsKnowledgeFieldReport, RadrootsKnowledgeFieldReportBuilder, RadrootsKnowledgeLocation, RadrootsKnowledgeLocationPrecision, RadrootsKnowledgeManifestCodecSupport, @@ -118,13 +118,12 @@ pub use crate::knowledge::{ RadrootsKnowledgeRelation, RadrootsKnowledgeRelationBuilder, RadrootsKnowledgeReview, RadrootsKnowledgeReviewBuilder, RadrootsKnowledgeReviewScope, RadrootsKnowledgeReviewScore, RadrootsKnowledgeReviewTarget, RadrootsKnowledgeSource, RadrootsKnowledgeSourceBuilder, - RadrootsNip01VerificationError, RadrootsNostrEvent, RadrootsNostrEventRef, - RadrootsRightsAssertion, RadrootsSdkKnowledgeError, RadrootsSignatureVerifiedEvent, - RadrootsWikiArticle, RadrootsWikiArticleBuilder, RadrootsWikiArticleVersionRef, - RadrootsWikiDTagError, RadrootsWikiMergeRequest, RadrootsWikiMergeRequestBuilder, - RadrootsWikiRedirect, RadrootsWikiRedirectBuilder, WIKI_ARTICLE_CONTRACT_ID, - WIKI_MERGE_REQUEST_CONTRACT_ID, WIKI_REDIRECT_CONTRACT_ID, WireEventParts, - build_knowledge_claim_event, build_knowledge_field_report_event, + RadrootsNip01VerificationError, RadrootsRightsAssertion, RadrootsSdkKnowledgeError, + RadrootsSignatureVerifiedEvent, RadrootsWikiArticle, RadrootsWikiArticleBuilder, + RadrootsWikiArticleVersionRef, RadrootsWikiDTagError, RadrootsWikiMergeRequest, + RadrootsWikiMergeRequestBuilder, RadrootsWikiRedirect, RadrootsWikiRedirectBuilder, + WIKI_ARTICLE_CONTRACT_ID, WIKI_MERGE_REQUEST_CONTRACT_ID, WIKI_REDIRECT_CONTRACT_ID, + WireEventParts, build_knowledge_claim_event, build_knowledge_field_report_event, build_knowledge_relation_event, build_knowledge_review_event, build_knowledge_source_event, build_wiki_article_event, build_wiki_merge_request_event, build_wiki_redirect_event, contract_manifest, contract_manifest_json, contract_manifest_sha256, normalize_wiki_d_tag, diff --git a/crates/sdk/src/listings_runtime.rs b/crates/sdk/src/listings_runtime.rs @@ -10,7 +10,7 @@ use crate::{ use radroots_authority::{RadrootsActorContext, RadrootsEventSigner}; #[cfg(feature = "runtime")] use radroots_events::{ - draft::RadrootsFrozenEventDraft, + draft::RadrootsEventDraft, ids::{RadrootsEventId, RadrootsListingAddress}, listing::RadrootsListing, }; @@ -139,7 +139,7 @@ pub struct ListingPublishPlan { pub public_listing_addr: RadrootsListingAddress, pub draft_listing_addr: RadrootsListingAddress, pub expected_event_id: RadrootsEventId, - pub frozen_draft: RadrootsFrozenEventDraft, + pub frozen_draft: RadrootsEventDraft, pub created_at: RadrootsSdkTimestamp, } diff --git a/crates/sdk/src/order.rs b/crates/sdk/src/order.rs @@ -3,9 +3,9 @@ pub use radroots_events::order::*; pub use radroots_events_codec::error::EventEncodeError; pub use radroots_events_codec::order::RadrootsOrderEnvelopeParseError; -use radroots_events::RadrootsNostrEvent; +use radroots_events::RadrootsEventEnvelope; #[cfg(any(feature = "signer-adapters", test))] -use radroots_events::{RadrootsNostrEventPtr, ids::RadrootsEventId, tags::TAG_E}; +use radroots_events::{RadrootsEventPtr, ids::RadrootsEventId, tags::TAG_E}; #[cfg(any(feature = "signer-adapters", test))] use radroots_events_codec::wire::WireEventParts; @@ -87,7 +87,7 @@ fn with_contract_root_event_tag( #[cfg(any(feature = "signer-adapters", test))] pub fn build_order_request_draft( - listing_event: &RadrootsNostrEventPtr, + listing_event: &RadrootsEventPtr, payload: &RadrootsOrderRequest, ) -> Result<RadrootsOrderRequestDraft, EventEncodeError> { Ok(RadrootsOrderRequestDraft { @@ -168,7 +168,7 @@ pub fn build_order_cancellation_draft( } pub fn parse_order_request( - event: &RadrootsNostrEvent, + event: &RadrootsEventEnvelope, ) -> Result<RadrootsOrderEnvelope<RadrootsOrderRequest>, RadrootsOrderEnvelopeParseError> { radroots_events_codec::order::order_request_from_event(event) } diff --git a/crates/sdk/src/orders_runtime.rs b/crates/sdk/src/orders_runtime.rs @@ -31,7 +31,7 @@ use radroots_event_store::RadrootsStoredEventTag; use radroots_event_store::{RadrootsEventIngest, RadrootsStoredEvent}; #[cfg(feature = "runtime")] use radroots_events::{ - RadrootsNostrEvent, + RadrootsEventEnvelope, contract::RadrootsActorRole, ids::RadrootsEventId, kinds::{ @@ -43,8 +43,8 @@ use radroots_events::{ }; #[cfg(any(feature = "signer-adapters", test))] use radroots_events::{ - RadrootsNostrEventPtr, - draft::RadrootsFrozenEventDraft, + RadrootsEventPtr, + draft::RadrootsEventDraft, ids::RadrootsOrderRevisionId, order::{ RadrootsOrderCancellation, RadrootsOrderDecision, RadrootsOrderDecisionOutcome, @@ -244,7 +244,7 @@ pub struct TradeWorkflowRetryAdvice { pub struct TradeSubmitPrepareRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub listing_event: RadrootsNostrEventPtr, + pub listing_event: RadrootsEventPtr, pub order: RadrootsOrderRequest, pub created_at: Option<RadrootsSdkTimestamp>, } @@ -254,7 +254,7 @@ pub struct TradeSubmitPrepareRequest { impl TradeSubmitPrepareRequest { pub fn new( actor: RadrootsActorContext, - listing_event: RadrootsNostrEventPtr, + listing_event: RadrootsEventPtr, order: RadrootsOrderRequest, ) -> Self { Self { @@ -278,7 +278,7 @@ impl TradeSubmitPrepareRequest { pub struct TradeSubmitEnqueueRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub listing_event: RadrootsNostrEventPtr, + pub listing_event: RadrootsEventPtr, pub order: RadrootsOrderRequest, pub target_policy: TargetPolicy, pub publish_mode: PublishMode, @@ -292,7 +292,7 @@ pub struct TradeSubmitEnqueueRequest { impl TradeSubmitEnqueueRequest { pub fn new( actor: RadrootsActorContext, - listing_event: RadrootsNostrEventPtr, + listing_event: RadrootsEventPtr, order: RadrootsOrderRequest, target_policy: TargetPolicy, publish_mode: PublishMode, @@ -352,7 +352,7 @@ pub struct TradeSubmitPlan { pub seller_pubkey: RadrootsPublicKey, pub listing_event_id: RadrootsEventId, pub expected_event_id: RadrootsEventId, - pub frozen_draft: RadrootsFrozenEventDraft, + pub frozen_draft: RadrootsEventDraft, pub created_at: RadrootsSdkTimestamp, } @@ -379,13 +379,13 @@ pub struct TradeSubmitReceipt { #[derive(Clone, Debug, serde::Serialize)] #[non_exhaustive] pub struct TradeRequestEvidenceIngestRequest { - pub event: RadrootsNostrEvent, + pub event: RadrootsEventEnvelope, pub observed_at: Option<RadrootsSdkTimestamp>, } #[cfg(feature = "runtime")] impl TradeRequestEvidenceIngestRequest { - pub fn new(event: RadrootsNostrEvent) -> Self { + pub fn new(event: RadrootsEventEnvelope) -> Self { Self { event, observed_at: None, @@ -414,13 +414,13 @@ pub struct TradeRequestEvidenceIngestReceipt { #[derive(Clone, Debug, serde::Serialize)] #[non_exhaustive] pub struct TradeEvidenceIngestRequest { - pub event: RadrootsNostrEvent, + pub event: RadrootsEventEnvelope, pub observed_at: Option<RadrootsSdkTimestamp>, } #[cfg(feature = "runtime")] impl TradeEvidenceIngestRequest { - pub fn new(event: RadrootsNostrEvent) -> Self { + pub fn new(event: RadrootsEventEnvelope) -> Self { Self { event, observed_at: None, @@ -450,7 +450,7 @@ pub struct TradeEvidenceIngestReceipt { pub struct TradeDecisionPrepareRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub request_event: RadrootsNostrEventPtr, + pub request_event: RadrootsEventPtr, pub decision: RadrootsOrderDecision, pub created_at: Option<RadrootsSdkTimestamp>, } @@ -460,7 +460,7 @@ pub struct TradeDecisionPrepareRequest { impl TradeDecisionPrepareRequest { pub fn new( actor: RadrootsActorContext, - request_event: RadrootsNostrEventPtr, + request_event: RadrootsEventPtr, decision: RadrootsOrderDecision, ) -> Self { Self { @@ -484,7 +484,7 @@ impl TradeDecisionPrepareRequest { pub struct TradeDecisionEnqueueRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub request_event: RadrootsNostrEventPtr, + pub request_event: RadrootsEventPtr, pub decision: RadrootsOrderDecision, pub target_policy: TargetPolicy, pub publish_mode: PublishMode, @@ -498,7 +498,7 @@ pub struct TradeDecisionEnqueueRequest { impl TradeDecisionEnqueueRequest { pub fn new( actor: RadrootsActorContext, - request_event: RadrootsNostrEventPtr, + request_event: RadrootsEventPtr, decision: RadrootsOrderDecision, target_policy: TargetPolicy, publish_mode: PublishMode, @@ -558,7 +558,7 @@ pub struct TradeDecisionPlan { pub seller_pubkey: RadrootsPublicKey, pub request_event_id: RadrootsEventId, pub expected_event_id: RadrootsEventId, - pub frozen_draft: RadrootsFrozenEventDraft, + pub frozen_draft: RadrootsEventDraft, pub created_at: RadrootsSdkTimestamp, } @@ -587,8 +587,8 @@ pub struct TradeDecisionReceipt { pub struct TradeRevisionProposalPrepareRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub root_event: RadrootsNostrEventPtr, - pub previous_event: RadrootsNostrEventPtr, + pub root_event: RadrootsEventPtr, + pub previous_event: RadrootsEventPtr, pub proposal: RadrootsOrderRevisionProposal, pub created_at: Option<RadrootsSdkTimestamp>, } @@ -598,8 +598,8 @@ pub struct TradeRevisionProposalPrepareRequest { impl TradeRevisionProposalPrepareRequest { pub fn new( actor: RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, proposal: RadrootsOrderRevisionProposal, ) -> Self { Self { @@ -624,8 +624,8 @@ impl TradeRevisionProposalPrepareRequest { pub struct TradeRevisionProposalEnqueueRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub root_event: RadrootsNostrEventPtr, - pub previous_event: RadrootsNostrEventPtr, + pub root_event: RadrootsEventPtr, + pub previous_event: RadrootsEventPtr, pub proposal: RadrootsOrderRevisionProposal, pub target_policy: TargetPolicy, pub publish_mode: PublishMode, @@ -639,8 +639,8 @@ pub struct TradeRevisionProposalEnqueueRequest { impl TradeRevisionProposalEnqueueRequest { pub fn new( actor: RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, proposal: RadrootsOrderRevisionProposal, target_policy: TargetPolicy, publish_mode: PublishMode, @@ -702,7 +702,7 @@ pub struct TradeRevisionProposalPlan { pub root_event_id: RadrootsEventId, pub previous_event_id: RadrootsEventId, pub expected_event_id: RadrootsEventId, - pub frozen_draft: RadrootsFrozenEventDraft, + pub frozen_draft: RadrootsEventDraft, pub created_at: RadrootsSdkTimestamp, } @@ -732,8 +732,8 @@ pub struct TradeRevisionProposalReceipt { pub struct TradeRevisionDecisionPrepareRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub root_event: RadrootsNostrEventPtr, - pub previous_event: RadrootsNostrEventPtr, + pub root_event: RadrootsEventPtr, + pub previous_event: RadrootsEventPtr, pub decision: RadrootsOrderRevisionDecision, pub created_at: Option<RadrootsSdkTimestamp>, } @@ -743,8 +743,8 @@ pub struct TradeRevisionDecisionPrepareRequest { impl TradeRevisionDecisionPrepareRequest { pub fn new( actor: RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, decision: RadrootsOrderRevisionDecision, ) -> Self { Self { @@ -769,8 +769,8 @@ impl TradeRevisionDecisionPrepareRequest { pub struct TradeRevisionDecisionEnqueueRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub root_event: RadrootsNostrEventPtr, - pub previous_event: RadrootsNostrEventPtr, + pub root_event: RadrootsEventPtr, + pub previous_event: RadrootsEventPtr, pub decision: RadrootsOrderRevisionDecision, pub target_policy: TargetPolicy, pub publish_mode: PublishMode, @@ -784,8 +784,8 @@ pub struct TradeRevisionDecisionEnqueueRequest { impl TradeRevisionDecisionEnqueueRequest { pub fn new( actor: RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, decision: RadrootsOrderRevisionDecision, target_policy: TargetPolicy, publish_mode: PublishMode, @@ -847,7 +847,7 @@ pub struct TradeRevisionDecisionPlan { pub root_event_id: RadrootsEventId, pub previous_event_id: RadrootsEventId, pub expected_event_id: RadrootsEventId, - pub frozen_draft: RadrootsFrozenEventDraft, + pub frozen_draft: RadrootsEventDraft, pub created_at: RadrootsSdkTimestamp, } @@ -877,8 +877,8 @@ pub struct TradeRevisionDecisionReceipt { pub struct TradeCancellationPrepareRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub root_event: RadrootsNostrEventPtr, - pub previous_event: RadrootsNostrEventPtr, + pub root_event: RadrootsEventPtr, + pub previous_event: RadrootsEventPtr, pub cancellation: RadrootsOrderCancellation, pub created_at: Option<RadrootsSdkTimestamp>, } @@ -888,8 +888,8 @@ pub struct TradeCancellationPrepareRequest { impl TradeCancellationPrepareRequest { pub fn new( actor: RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, cancellation: RadrootsOrderCancellation, ) -> Self { Self { @@ -914,8 +914,8 @@ impl TradeCancellationPrepareRequest { pub struct TradeCancellationEnqueueRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub root_event: RadrootsNostrEventPtr, - pub previous_event: RadrootsNostrEventPtr, + pub root_event: RadrootsEventPtr, + pub previous_event: RadrootsEventPtr, pub cancellation: RadrootsOrderCancellation, pub target_policy: TargetPolicy, pub publish_mode: PublishMode, @@ -929,8 +929,8 @@ pub struct TradeCancellationEnqueueRequest { impl TradeCancellationEnqueueRequest { pub fn new( actor: RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, cancellation: RadrootsOrderCancellation, target_policy: TargetPolicy, publish_mode: PublishMode, @@ -992,7 +992,7 @@ pub struct TradeCancellationPlan { pub root_event_id: RadrootsEventId, pub previous_event_id: RadrootsEventId, pub expected_event_id: RadrootsEventId, - pub frozen_draft: RadrootsFrozenEventDraft, + pub frozen_draft: RadrootsEventDraft, pub created_at: RadrootsSdkTimestamp, } @@ -1061,7 +1061,7 @@ impl TradeEvidenceMode { pub struct TradeProposeRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub listing_event: RadrootsNostrEventPtr, + pub listing_event: RadrootsEventPtr, pub order_id: RadrootsOrderId, pub listing_addr: RadrootsListingAddress, pub seller_pubkey: RadrootsPublicKey, @@ -1080,7 +1080,7 @@ pub struct TradeProposeRequest { impl TradeProposeRequest { pub fn new( actor: RadrootsActorContext, - listing_event: RadrootsNostrEventPtr, + listing_event: RadrootsEventPtr, order_id: RadrootsOrderId, listing_addr: RadrootsListingAddress, seller_pubkey: RadrootsPublicKey, @@ -1895,7 +1895,7 @@ pub struct TradeValidationReceiptInspectReceipt { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct TradeValidationReceiptEvent { - pub event: RadrootsNostrEvent, + pub event: RadrootsEventEnvelope, pub receipt: RadrootsTradeValidationReceipt, pub tags: TradeValidationReceiptTags, pub worker_evidence: TradeValidationReceiptWorkerEvidenceSelection, @@ -1904,7 +1904,7 @@ pub struct TradeValidationReceiptEvent { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct TradeValidationReceiptInvalidCandidate { - pub event: RadrootsNostrEvent, + pub event: RadrootsEventEnvelope, pub reason_code: String, pub reason: String, } @@ -4465,7 +4465,7 @@ async fn validation_receipt_events_from_fetch( sdk: &crate::RadrootsClient, events: &[TradeResyncEventImportReceipt], expected_kind: u32, -) -> Result<Vec<RadrootsNostrEvent>, RadrootsSdkError> { +) -> Result<Vec<RadrootsEventEnvelope>, RadrootsSdkError> { let mut event_ids = events .iter() .filter(|event| !event.malformed) @@ -4496,7 +4496,7 @@ async fn validation_receipt_events_from_fetch( #[cfg(all(feature = "runtime", feature = "transport-nostr-runtime"))] fn classify_validation_receipts( - events: Vec<RadrootsNostrEvent>, + events: Vec<RadrootsEventEnvelope>, expected_order_id: Option<&str>, ) -> Result< ( @@ -4570,7 +4570,7 @@ where fn worker_evidence_for_receipts( trusted_worker_pubkeys: &[RadrootsPublicKey], receipts: &[TradeValidationReceiptEvent], - events: Vec<RadrootsNostrEvent>, + events: Vec<RadrootsEventEnvelope>, ) -> Result<BTreeMap<String, TradeValidationReceiptWorkerEvidenceSelection>, RadrootsSdkError> { let trusted_pubkeys = trusted_worker_pubkeys .iter() @@ -4916,7 +4916,7 @@ async fn trade_status_validation_trust_decision( async fn validation_receipt_worker_result_events_for_receipt( sdk: &crate::RadrootsClient, receipt_event_id: &RadrootsEventId, -) -> Result<Vec<RadrootsNostrEvent>, RadrootsSdkError> { +) -> Result<Vec<RadrootsEventEnvelope>, RadrootsSdkError> { let events = sdk ._event_store .events_by_tag( @@ -5261,7 +5261,7 @@ impl From<RadrootsValidationReceiptTags> for TradeValidationReceiptTags { #[cfg(feature = "runtime")] fn stored_event_to_nostr_event( stored_event: &RadrootsStoredEvent, -) -> Result<RadrootsNostrEvent, RadrootsSdkError> { +) -> Result<RadrootsEventEnvelope, RadrootsSdkError> { let tags = serde_json::from_str(&stored_event.tags_json).map_err(|error| { RadrootsSdkError::EventStore { message: format!( @@ -5270,7 +5270,7 @@ fn stored_event_to_nostr_event( ), } })?; - Ok(RadrootsNostrEvent { + Ok(RadrootsEventEnvelope { id: stored_event.event_id.clone(), author: stored_event.pubkey.clone(), created_at: stored_event.created_at, @@ -5625,7 +5625,7 @@ impl<'sdk> TradeSellerClient<'sdk> { ), } })?; - let nostr_event = RadrootsNostrEvent { + let nostr_event = RadrootsEventEnvelope { id: event.event_id, author: event.pubkey, created_at: event.created_at, @@ -6185,8 +6185,8 @@ fn require_trade_mutation_online_evidence_clean( } #[cfg(feature = "signer-adapters")] -fn event_ptr(event_id: &RadrootsEventId) -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn event_ptr(event_id: &RadrootsEventId) -> RadrootsEventPtr { + RadrootsEventPtr { id: event_id.as_str().to_owned(), relays: None, } @@ -6385,7 +6385,7 @@ struct ParsedOrderEvidence { #[cfg(feature = "runtime")] #[inline(never)] fn parse_order_evidence( - event: &RadrootsNostrEvent, + event: &RadrootsEventEnvelope, ) -> Result<ParsedOrderEvidence, RadrootsSdkError> { let event_id = RadrootsEventId::parse(event.id.as_str()).map_err(|error| { RadrootsSdkError::InvalidRequest { @@ -6660,7 +6660,7 @@ impl TradeStatusNextActionKind { #[cfg(any(feature = "signer-adapters", test))] fn order_submit_plan( actor: &RadrootsActorContext, - listing_event: RadrootsNostrEventPtr, + listing_event: RadrootsEventPtr, order_request: RadrootsOrderRequest, created_at: RadrootsSdkTimestamp, ) -> Result<TradeSubmitPlan, RadrootsSdkError> { @@ -6709,7 +6709,7 @@ fn order_submit_plan( #[cfg(any(feature = "signer-adapters", test))] fn order_decision_plan( actor: &RadrootsActorContext, - request_event: RadrootsNostrEventPtr, + request_event: RadrootsEventPtr, decision: RadrootsOrderDecision, created_at: RadrootsSdkTimestamp, ) -> Result<TradeDecisionPlan, RadrootsSdkError> { @@ -6761,8 +6761,8 @@ fn order_decision_plan( #[cfg(any(feature = "signer-adapters", test))] fn order_revision_proposal_plan( actor: &RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, proposal: RadrootsOrderRevisionProposal, created_at: RadrootsSdkTimestamp, ) -> Result<TradeRevisionProposalPlan, RadrootsSdkError> { @@ -6819,8 +6819,8 @@ fn order_revision_proposal_plan( #[cfg(any(feature = "signer-adapters", test))] fn order_revision_decision_plan( actor: &RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, decision: RadrootsOrderRevisionDecision, created_at: RadrootsSdkTimestamp, ) -> Result<TradeRevisionDecisionPlan, RadrootsSdkError> { @@ -6877,8 +6877,8 @@ fn order_revision_decision_plan( #[cfg(any(feature = "signer-adapters", test))] fn order_cancellation_plan( actor: &RadrootsActorContext, - root_event: RadrootsNostrEventPtr, - previous_event: RadrootsNostrEventPtr, + root_event: RadrootsEventPtr, + previous_event: RadrootsEventPtr, cancellation: RadrootsOrderCancellation, created_at: RadrootsSdkTimestamp, ) -> Result<TradeCancellationPlan, RadrootsSdkError> { @@ -7143,7 +7143,7 @@ fn freeze_order_workflow_draft( expected_pubkey: &str, created_at: u32, _operation: &'static str, -) -> (RadrootsFrozenEventDraft, RadrootsEventId) { +) -> (RadrootsEventDraft, RadrootsEventId) { let frozen_draft = to_frozen_draft(parts, contract_id, expected_pubkey, created_at) .expect("validated order workflow draft freezes"); let expected_event_id = RadrootsEventId::parse(frozen_draft.expected_event_id.as_str()) @@ -7217,7 +7217,7 @@ struct TradeRequestEvidence { #[cfg(feature = "runtime")] fn parse_order_request_evidence( - event: &RadrootsNostrEvent, + event: &RadrootsEventEnvelope, ) -> Result<TradeRequestEvidence, RadrootsSdkError> { let request_event_id = RadrootsEventId::parse(event.id.as_str()).map_err(|error| { RadrootsSdkError::InvalidRequest { @@ -7628,9 +7628,7 @@ fn require_seller_actor( } #[cfg(any(feature = "signer-adapters", test))] -fn listing_event_id( - listing_event: &RadrootsNostrEventPtr, -) -> Result<RadrootsEventId, RadrootsSdkError> { +fn listing_event_id(listing_event: &RadrootsEventPtr) -> Result<RadrootsEventId, RadrootsSdkError> { RadrootsEventId::parse(listing_event.id.as_str()).map_err(|error| { RadrootsSdkError::InvalidRequest { message: format!("listing evidence event id is invalid: {error}"), @@ -7639,9 +7637,7 @@ fn listing_event_id( } #[cfg(any(feature = "signer-adapters", test))] -fn request_event_id( - request_event: &RadrootsNostrEventPtr, -) -> Result<RadrootsEventId, RadrootsSdkError> { +fn request_event_id(request_event: &RadrootsEventPtr) -> Result<RadrootsEventId, RadrootsSdkError> { RadrootsEventId::parse(request_event.id.as_str()).map_err(|error| { RadrootsSdkError::InvalidRequest { message: format!("order request evidence event id is invalid: {error}"), @@ -7651,7 +7647,7 @@ fn request_event_id( #[cfg(any(feature = "signer-adapters", test))] fn order_reference_event_id( - event: &RadrootsNostrEventPtr, + event: &RadrootsEventPtr, label: &'static str, ) -> Result<RadrootsEventId, RadrootsSdkError> { RadrootsEventId::parse(event.id.as_str()).map_err(|error| RadrootsSdkError::InvalidRequest { diff --git a/crates/sdk/src/signer_provider.rs b/crates/sdk/src/signer_provider.rs @@ -6,7 +6,7 @@ use radroots_authority::{ RadrootsActorContext, RadrootsEventSigner, RadrootsSignerError, authorize_actor_for_draft, authorize_signer_for_draft, sign_authorized_draft, validate_signed_event_matches_draft, }; -use radroots_events::draft::{RadrootsFrozenEventDraft, RadrootsSignedNostrEvent}; +use radroots_events::draft::{RadrootsEventDraft, RadrootsSignedEvent}; use radroots_events::ids::RadrootsPublicKey; use radroots_events::kinds::{ KIND_FARM, KIND_LISTING, KIND_ORDER_CANCELLATION, KIND_ORDER_DECISION, KIND_ORDER_REQUEST, @@ -120,7 +120,7 @@ where pub struct RadrootsSdkSignRequest<'a> { pub operation_kind: &'a str, pub actor: &'a RadrootsActorContext, - pub frozen_draft: &'a RadrootsFrozenEventDraft, + pub frozen_draft: &'a RadrootsEventDraft, progress_sink: Option<&'a mut dyn RadrootsSdkSignerProgressSink>, } @@ -128,7 +128,7 @@ impl<'a> RadrootsSdkSignRequest<'a> { pub fn new( operation_kind: &'a str, actor: &'a RadrootsActorContext, - frozen_draft: &'a RadrootsFrozenEventDraft, + frozen_draft: &'a RadrootsEventDraft, ) -> Self { Self { operation_kind, @@ -164,7 +164,7 @@ pub struct RadrootsSdkSignReceipt { pub signer_pubkey: String, pub remote_signer_pubkey: Option<String>, pub signed_event_id: String, - pub signed_event: RadrootsSignedNostrEvent, + pub signed_event: RadrootsSignedEvent, } #[derive(Clone)] @@ -518,8 +518,8 @@ impl RadrootsEventSigner for RadrootsSdkSignerIdentityOnly { fn sign_frozen_draft( &self, - _draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + _draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { Err(RadrootsSignerError::Unavailable) } } @@ -544,7 +544,7 @@ impl RadrootsNostrConnectClientTransport for RadrootsSdkNip46TransportAdapter<'_ } fn sign_event_request_from_frozen_draft( - draft: &RadrootsFrozenEventDraft, + draft: &RadrootsEventDraft, ) -> Result<RadrootsNostrConnectRequest, RadrootsSdkError> { let public_key = nip46_unsigned_event_pubkey(draft)?; let kind = nip46_unsigned_event_kind(draft)?; @@ -560,9 +560,7 @@ fn sign_event_request_from_frozen_draft( Ok(RadrootsNostrConnectRequest::SignEvent(unsigned_event)) } -fn nip46_unsigned_event_pubkey( - draft: &RadrootsFrozenEventDraft, -) -> Result<PublicKey, RadrootsSdkError> { +fn nip46_unsigned_event_pubkey(draft: &RadrootsEventDraft) -> Result<PublicKey, RadrootsSdkError> { PublicKey::parse(draft.expected_pubkey.as_str()).map_err(|error| { nip46_sign_event_protocol_error(format!( "failed to parse frozen draft pubkey for NIP-46 unsigned event: {error}" @@ -570,7 +568,7 @@ fn nip46_unsigned_event_pubkey( }) } -fn nip46_unsigned_event_kind(draft: &RadrootsFrozenEventDraft) -> Result<Kind, RadrootsSdkError> { +fn nip46_unsigned_event_kind(draft: &RadrootsEventDraft) -> Result<Kind, RadrootsSdkError> { let kind = u16::try_from(draft.kind).map_err(|error| { nip46_sign_event_protocol_error(format!( "failed to convert frozen draft kind to NIP-46 unsigned event: {error}" @@ -579,9 +577,7 @@ fn nip46_unsigned_event_kind(draft: &RadrootsFrozenEventDraft) -> Result<Kind, R Ok(Kind::from_u16(kind)) } -fn nip46_unsigned_event_tags( - draft: &RadrootsFrozenEventDraft, -) -> Result<Vec<Tag>, RadrootsSdkError> { +fn nip46_unsigned_event_tags(draft: &RadrootsEventDraft) -> Result<Vec<Tag>, RadrootsSdkError> { let mut tags = Vec::with_capacity(draft.tags.len()); for raw_tag in &draft.tags { let tag = Tag::parse(raw_tag.clone()).map_err(|error| { @@ -604,15 +600,16 @@ fn nip46_sign_event_protocol_error(reason: String) -> RadrootsSdkError { fn signed_event_from_nip46_response( operation_kind: &str, response: RadrootsNostrConnectResponse, -) -> Result<RadrootsSignedNostrEvent, RadrootsSdkError> { +) -> Result<RadrootsSignedEvent, RadrootsSdkError> { match response { RadrootsNostrConnectResponse::SignedEvent(event) => { let raw_json = event.as_json(); - RadrootsSignedNostrEvent::from_event(radroots_event_from_nostr(&event), raw_json) - .map_err(|error| RadrootsSdkError::SignerProtocol { + RadrootsSignedEvent::from_event(radroots_event_from_nostr(&event), raw_json).map_err( + |error| RadrootsSdkError::SignerProtocol { mode: RadrootsSdkSignerMode::MycNip46.as_str().to_owned(), reason: format!("remote signed event is invalid: {error}"), - }) + }, + ) } RadrootsNostrConnectResponse::Error { error, .. } => { Err(RadrootsSdkError::SignerRequestRejected { @@ -665,7 +662,7 @@ fn sign_receipt( mode: RadrootsSdkSignerMode, signer_pubkey: String, remote_signer_pubkey: Option<String>, - signed_event: RadrootsSignedNostrEvent, + signed_event: RadrootsSignedEvent, ) -> RadrootsSdkSignReceipt { RadrootsSdkSignReceipt { operation_kind: operation_kind.to_owned(), diff --git a/crates/sdk/src/sync_runtime.rs b/crates/sdk/src/sync_runtime.rs @@ -1662,7 +1662,7 @@ fn proxy_error_message(error: &RadrootsdError) -> String { #[cfg(all(feature = "runtime", feature = "radrootsd-proxy"))] fn proxy_transport_error_receipt( claimed: &RadrootsOutboxClaimedEvent, - event: &radroots_events::draft::RadrootsSignedNostrEvent, + event: &radroots_events::draft::RadrootsSignedEvent, delivery_policy: &TransportPublishDeliveryPolicy, message: String, ) -> Result<PushOutboxEventReceipt, RadrootsSdkError> { diff --git a/crates/sdk/src/workflow_runtime.rs b/crates/sdk/src/workflow_runtime.rs @@ -9,8 +9,8 @@ use radroots_event_store::{ RadrootsEventIngest, RadrootsTransportObservation, RadrootsTransportObservationType, }; use radroots_events::{ - RadrootsNostrEvent, - draft::{RadrootsFrozenEventDraft, RadrootsSignedNostrEvent}, + RadrootsEventEnvelope, + draft::{RadrootsEventDraft, RadrootsSignedEvent}, ids::RadrootsEventId, }; use radroots_outbox::{ @@ -26,7 +26,7 @@ const SDK_LOCAL_EVENT_ENDPOINT_URI: &str = "local:sdk"; pub(crate) struct SdkWorkflowEnqueueRequest<'a> { pub(crate) operation_kind: &'static str, pub(crate) actor: &'a RadrootsActorContext, - pub(crate) frozen_draft: &'a RadrootsFrozenEventDraft, + pub(crate) frozen_draft: &'a RadrootsEventDraft, pub(crate) target_policy: TargetPolicy, pub(crate) satisfaction_policy: SatisfactionPolicy, pub(crate) idempotency_key: Option<SdkIdempotencyKey>, @@ -73,7 +73,7 @@ pub(crate) async fn enqueue_configured_signed_workflow( async fn enqueue_signed_workflow_event( sdk: &RadrootsClient, request: SdkWorkflowEnqueueRequest<'_>, - signed_event: RadrootsSignedNostrEvent, + signed_event: RadrootsSignedEvent, delivery_plan: SdkResolvedDeliveryPlan, ) -> Result<SdkWorkflowEnqueueReceipt, RadrootsSdkError> { let idempotency_key = match request.idempotency_key { @@ -303,8 +303,8 @@ fn parse_event_id(value: &str, field: &str) -> Result<RadrootsEventId, RadrootsS fn signed_outbox_input( operation_kind: &'static str, - frozen_draft: &RadrootsFrozenEventDraft, - signed_event: RadrootsSignedNostrEvent, + frozen_draft: &RadrootsEventDraft, + signed_event: RadrootsSignedEvent, delivery_plan: RadrootsOutboxDeliveryPlanInput, idempotency_key: SdkIdempotencyKey, event_store_inserted: bool, @@ -322,8 +322,8 @@ fn signed_outbox_input( .with_idempotency_key(idempotency_key.into_string()) } -fn event_from_signed(signed_event: &RadrootsSignedNostrEvent) -> RadrootsNostrEvent { - RadrootsNostrEvent { +fn event_from_signed(signed_event: &RadrootsSignedEvent) -> RadrootsEventEnvelope { + RadrootsEventEnvelope { id: signed_event.id.clone(), author: signed_event.pubkey.clone(), created_at: signed_event.created_at, diff --git a/crates/sdk/tests/dvm_runtime.rs b/crates/sdk/tests/dvm_runtime.rs @@ -8,9 +8,9 @@ use radroots_core::{ }; use radroots_event_store::{RadrootsEventIngest, RadrootsEventStore}; use radroots_events::{ - RadrootsNostrEvent, RadrootsNostrEventPtr, + RadrootsEventEnvelope, RadrootsEventPtr, contract::RadrootsActorRole, - draft::{RadrootsFrozenEventDraft, RadrootsSignedNostrEvent}, + draft::{RadrootsEventDraft, RadrootsSignedEvent}, ids::{ RadrootsEventId, RadrootsInventoryBinId, RadrootsListingAddress, RadrootsOrderId, RadrootsPublicKey, @@ -81,8 +81,8 @@ impl RadrootsEventSigner for FixtureSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { radroots_nostr_sign_frozen_draft(&self.keys, draft).map_err(|error| { RadrootsSignerError::SigningFailed { message: error.to_string(), @@ -696,8 +696,8 @@ fn listing_address() -> RadrootsListingAddress { .expect("listing address") } -fn listing_event_ptr() -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn listing_event_ptr() -> RadrootsEventPtr { + RadrootsEventPtr { id: deterministic_event_id("listing-event").into_string(), relays: Some(RELAY.to_owned()), } @@ -782,7 +782,7 @@ fn order_decision(raw_order_id: &str) -> RadrootsOrderDecision { } } -fn signed_order_request_event(raw_order_id: &str, created_at: u32) -> RadrootsNostrEvent { +fn signed_order_request_event(raw_order_id: &str, created_at: u32) -> RadrootsEventEnvelope { let draft = radroots_events_codec::order::order_request_event_build( &listing_event_ptr(), &order_request(raw_order_id), @@ -795,7 +795,7 @@ fn signed_order_decision_event( raw_order_id: &str, root_event_id: &RadrootsEventId, created_at: u32, -) -> RadrootsNostrEvent { +) -> RadrootsEventEnvelope { let draft = radroots_events_codec::order::order_decision_event_build( root_event_id, root_event_id, @@ -811,7 +811,7 @@ fn signed_validation_receipt_event( root_event_id: &RadrootsEventId, target_event_id: &RadrootsEventId, created_at: u32, -) -> RadrootsNostrEvent { +) -> RadrootsEventEnvelope { let receipt = RadrootsTradeValidationReceipt { changed_records_root: hash32('6'), domain: "radroots.receipt".to_owned(), @@ -846,7 +846,7 @@ fn signed_event( secret_key_hex: &str, created_at: u32, parts: radroots_events_codec::wire::WireEventParts, -) -> RadrootsNostrEvent { +) -> RadrootsEventEnvelope { let secret_key = RadrootsNostrSecretKey::from_hex(secret_key_hex).expect("secret key"); let keys = RadrootsNostrKeys::new(secret_key); let event = radroots_nostr_build_event(parts.kind, parts.content, parts.tags) diff --git a/crates/sdk/tests/farms_runtime.rs b/crates/sdk/tests/farms_runtime.rs @@ -6,7 +6,7 @@ use radroots_authority::{ use radroots_event_store::RadrootsEventStore; use radroots_events::{ contract::RadrootsActorRole, - draft::{RadrootsFrozenEventDraft, RadrootsSignedNostrEvent, RadrootsSignedNostrEventParts}, + draft::{RadrootsEventDraft, RadrootsSignedEvent, RadrootsSignedEventParts}, farm::RadrootsFarm, ids::RadrootsAddressableCoordinate, kinds::{KIND_FARM, KIND_PROFILE}, @@ -66,8 +66,8 @@ impl RadrootsEventSigner for FixtureSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { if self.pubkey().as_str() != draft.expected_pubkey.as_str() { return Err(RadrootsSignerError::SigningFailed { message: "wrong fixture signer".to_owned(), @@ -84,7 +84,7 @@ impl RadrootsEventSigner for FixtureSigner { "sig": sig, }) .to_string(); - RadrootsSignedNostrEvent::new(RadrootsSignedNostrEventParts { + RadrootsSignedEvent::new(RadrootsSignedEventParts { id: draft.expected_event_id.clone(), pubkey: self.pubkey().as_str().to_owned(), created_at: draft.created_at, diff --git a/crates/sdk/tests/knowledge_public_api.rs b/crates/sdk/tests/knowledge_public_api.rs @@ -394,7 +394,7 @@ fn knowledge_errors_expose_stable_codes() { assert_eq!(error.inner_code(), "invalid_field"); assert!(!error.to_string().contains(article.content_djot.as_str())); - let draft_error: RadrootsSdkKnowledgeError = RadrootsFrozenEventDraft::new( + let draft_error: RadrootsSdkKnowledgeError = RadrootsEventDraft::new( KNOWLEDGE_CLAIM_CONTRACT_ID, KIND_KNOWLEDGE_CLAIM, CREATED_AT, @@ -408,7 +408,7 @@ fn knowledge_errors_expose_stable_codes() { assert_eq!(draft_error.inner_code(), "missing_tag"); } -fn sign_parts(parts: WireEventParts) -> RadrootsNostrEvent { +fn sign_parts(parts: WireEventParts) -> RadrootsEventEnvelope { let tags = parts .tags .into_iter() @@ -421,7 +421,7 @@ fn sign_parts(parts: WireEventParts) -> RadrootsNostrEvent { .custom_created_at(Timestamp::from_secs(u64::from(CREATED_AT))) .sign_with_keys(&keys) .expect("signed event"); - RadrootsNostrEvent { + RadrootsEventEnvelope { id: event.id.to_hex(), author: event.pubkey.to_hex(), created_at: event.created_at.as_secs() as u32, @@ -448,8 +448,8 @@ fn hex_64(character: char) -> String { character.to_string().repeat(64) } -fn event_ref(character: char, kind: u32) -> RadrootsNostrEventRef { - RadrootsNostrEventRef { +fn event_ref(character: char, kind: u32) -> RadrootsEventRef { + RadrootsEventRef { id: hex_64(character), author: hex_64('a'), kind, @@ -458,7 +458,7 @@ fn event_ref(character: char, kind: u32) -> RadrootsNostrEventRef { } } -fn malformed_event_ref(kind: u32) -> RadrootsNostrEventRef { +fn malformed_event_ref(kind: u32) -> RadrootsEventRef { let mut reference = event_ref('f', kind); reference.id = "bad".to_owned(); reference diff --git a/crates/sdk/tests/listings_runtime.rs b/crates/sdk/tests/listings_runtime.rs @@ -10,7 +10,7 @@ use radroots_core::{ use radroots_event_store::RadrootsEventStore; use radroots_events::{ contract::RadrootsActorRole, - draft::{RadrootsFrozenEventDraft, RadrootsSignedNostrEvent, RadrootsSignedNostrEventParts}, + draft::{RadrootsEventDraft, RadrootsSignedEvent, RadrootsSignedEventParts}, farm::RadrootsFarmRef, ids::{RadrootsDTag, RadrootsInventoryBinId}, kinds::KIND_LISTING, @@ -72,8 +72,8 @@ impl RadrootsEventSigner for FixtureSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { if self.pubkey().as_str() != draft.expected_pubkey.as_str() { return Err(RadrootsSignerError::SigningFailed { message: "wrong fixture signer".to_owned(), @@ -90,7 +90,7 @@ impl RadrootsEventSigner for FixtureSigner { "sig": sig, }) .to_string(); - RadrootsSignedNostrEvent::new(RadrootsSignedNostrEventParts { + RadrootsSignedEvent::new(RadrootsSignedEventParts { id: draft.expected_event_id.clone(), pubkey: self.pubkey().as_str().to_owned(), created_at: draft.created_at, diff --git a/crates/sdk/tests/market_runtime.rs b/crates/sdk/tests/market_runtime.rs @@ -9,7 +9,7 @@ use radroots_core::{ }; use radroots_events::{ contract::RadrootsActorRole, - draft::{RadrootsFrozenEventDraft, RadrootsSignedNostrEvent}, + draft::{RadrootsEventDraft, RadrootsSignedEvent}, farm::RadrootsFarmRef, ids::{RadrootsDTag, RadrootsInventoryBinId}, listing::{ @@ -60,8 +60,8 @@ impl RadrootsEventSigner for FixtureSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { radroots_nostr_sign_frozen_draft(&self.keys, draft).map_err(|error| { RadrootsSignerError::SigningFailed { message: error.to_string(), diff --git a/crates/sdk/tests/orders_runtime.rs b/crates/sdk/tests/orders_runtime.rs @@ -18,7 +18,7 @@ use radroots_event_store::{RadrootsEventIngest, RadrootsEventStore}; #[cfg(feature = "transport-nostr-runtime")] use radroots_events::ids::RadrootsPublicKey; use radroots_events::{ - RadrootsNostrEvent, RadrootsNostrEventPtr, + RadrootsEventEnvelope, RadrootsEventPtr, contract::RadrootsActorRole, ids::{RadrootsEventId, RadrootsListingAddress, RadrootsOrderId, RadrootsOrderRevisionId}, kinds::{ @@ -434,11 +434,9 @@ impl radroots_authority::RadrootsEventSigner for FixtureSigner { fn sign_frozen_draft( &self, - draft: &radroots_events::draft::RadrootsFrozenEventDraft, - ) -> Result< - radroots_events::draft::RadrootsSignedNostrEvent, - radroots_authority::RadrootsSignerError, - > { + draft: &radroots_events::draft::RadrootsEventDraft, + ) -> Result<radroots_events::draft::RadrootsSignedEvent, radroots_authority::RadrootsSignerError> + { radroots_nostr::prelude::radroots_nostr_sign_frozen_draft(&self.keys, draft).map_err( |error| radroots_authority::RadrootsSignerError::SigningFailed { message: error.to_string(), @@ -555,8 +553,8 @@ fn listing_address() -> RadrootsListingAddress { .expect("listing address") } -fn listing_event_ptr() -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn listing_event_ptr() -> RadrootsEventPtr { + RadrootsEventPtr { id: deterministic_event_id("listing-event").into_string(), relays: Some(RELAY.to_owned()), } @@ -665,8 +663,8 @@ fn trade_propose_request( } #[cfg(any())] -fn invalid_listing_event_ptr() -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn invalid_listing_event_ptr() -> RadrootsEventPtr { + RadrootsEventPtr { id: String::new(), relays: Some(RELAY.to_owned()), } @@ -2649,7 +2647,7 @@ async fn relay_event_item_from_store( async fn event_from_store( source: &RadrootsEventStore, event_id: &RadrootsEventId, -) -> RadrootsNostrEvent { +) -> RadrootsEventEnvelope { let stored = source .get_event(event_id.as_str()) .await @@ -4098,7 +4096,7 @@ async fn insert_perf_non_trade_events(store: &RadrootsEventStore, base: i64, cou let batch = (count - inserted).min(1_000); sqlx::query( "WITH RECURSIVE seq(n) AS (SELECT 0 UNION ALL SELECT n + 1 FROM seq WHERE n + 1 < ?) - INSERT INTO nostr_events(event_id, pubkey, created_at, kind, tags_json, content, sig, raw_json, verification_status, contract_status, contract_id, event_class, projection_eligible, inserted_at_ms, updated_at_ms) + INSERT INTO event_envelopes(event_id, pubkey, created_at, kind, tags_json, content, sig, raw_json, verification_status, contract_status, contract_id, event_class, projection_eligible, inserted_at_ms, updated_at_ms) SELECT lower(printf('%064x', ? + n)), ?, 1700000000 + n, 1, json_array(), '{}', ?, '{}', 'verified', 'unsupported_kind', NULL, NULL, 0, 1700000000000 + n, 1700000000000 + n FROM seq", ) .bind(batch) @@ -4118,7 +4116,7 @@ async fn insert_perf_trade_background_events(store: &RadrootsEventStore, base: i let batch = (count - inserted).min(1_000); sqlx::query( "WITH RECURSIVE seq(n) AS (SELECT 0 UNION ALL SELECT n + 1 FROM seq WHERE n + 1 < ?) - INSERT INTO nostr_events(event_id, pubkey, created_at, kind, tags_json, content, sig, raw_json, verification_status, contract_status, contract_id, event_class, projection_eligible, inserted_at_ms, updated_at_ms) + INSERT INTO event_envelopes(event_id, pubkey, created_at, kind, tags_json, content, sig, raw_json, verification_status, contract_status, contract_id, event_class, projection_eligible, inserted_at_ms, updated_at_ms) SELECT lower(printf('%064x', ? + n)), ?, 1700000000 + n, ?, json_array(json_array('d', 'perf-bg-' || printf('%06d', ? + n))), '{}', ?, '{}', 'verified', 'supported', 'radroots.order.request.v1', 'regular', 1, 1700000000000 + n, 1700000000000 + n FROM seq", ) .bind(batch) @@ -4132,7 +4130,7 @@ async fn insert_perf_trade_background_events(store: &RadrootsEventStore, base: i .expect("trade perf event seed"); sqlx::query( "WITH RECURSIVE seq(n) AS (SELECT 0 UNION ALL SELECT n + 1 FROM seq WHERE n + 1 < ?) - INSERT INTO nostr_event_tags(event_id, tag_index, tag_name, tag_value, tag_json, contract_semantic, contract_value_type, relay_indexed) + INSERT INTO event_envelope_tags(event_id, tag_index, tag_name, tag_value, tag_json, contract_semantic, contract_value_type, relay_indexed) SELECT lower(printf('%064x', ? + n)), 0, 'd', 'perf-bg-' || printf('%06d', ? + n), json_array('d', 'perf-bg-' || printf('%06d', ? + n)), NULL, NULL, 0 FROM seq", ) .bind(batch) @@ -4185,7 +4183,7 @@ fn signed_event( secret_key_hex: &str, created_at: u32, parts: WireEventParts, -) -> RadrootsNostrEvent { +) -> RadrootsEventEnvelope { let event = signed_raw_event(secret_key_hex, created_at, parts); radroots_event_from_nostr(&event) } @@ -4200,7 +4198,7 @@ fn signed_raw_event(secret_key_hex: &str, created_at: u32, parts: WireEventParts .expect("signed event") } -fn signed_order_request_event(raw_order_id: &str, created_at: u32) -> RadrootsNostrEvent { +fn signed_order_request_event(raw_order_id: &str, created_at: u32) -> RadrootsEventEnvelope { let draft = radroots_events_codec::order::order_request_event_build( &listing_event_ptr(), &order_request(raw_order_id), @@ -4220,16 +4218,16 @@ fn signed_raw_order_request_event(raw_order_id: &str, created_at: u32) -> nostr: } #[cfg(any())] -fn request_event_ptr(event: &RadrootsNostrEvent) -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn request_event_ptr(event: &RadrootsEventEnvelope) -> RadrootsEventPtr { + RadrootsEventPtr { id: event.id.clone(), relays: Some(RELAY.to_owned()), } } #[cfg(any())] -fn order_event_ptr(event_id: &RadrootsEventId) -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn order_event_ptr(event_id: &RadrootsEventId) -> RadrootsEventPtr { + RadrootsEventPtr { id: event_id.as_str().to_owned(), relays: Some(RELAY.to_owned()), } @@ -4253,7 +4251,7 @@ fn signed_order_decision_event( raw_order_id: &str, root_event_id: &RadrootsEventId, created_at: u32, -) -> RadrootsNostrEvent { +) -> RadrootsEventEnvelope { let draft = radroots_events_codec::order::order_decision_event_build( root_event_id, root_event_id, @@ -4263,7 +4261,7 @@ fn signed_order_decision_event( signed_event(SELLER_SECRET_KEY_HEX, created_at, draft) } -fn signed_status_noise_post_event(index: i64, created_at: u32) -> RadrootsNostrEvent { +fn signed_status_noise_post_event(index: i64, created_at: u32) -> RadrootsEventEnvelope { signed_event( SELLER_SECRET_KEY_HEX, created_at, @@ -4275,7 +4273,7 @@ fn signed_status_noise_post_event(index: i64, created_at: u32) -> RadrootsNostrE ) } -fn signed_non_order_event(created_at: u32) -> RadrootsNostrEvent { +fn signed_non_order_event(created_at: u32) -> RadrootsEventEnvelope { signed_event( SELLER_SECRET_KEY_HEX, created_at, @@ -4462,7 +4460,7 @@ async fn order_request_evidence_ingest_rejects_non_request_events() { async fn order_decision_prepare_accept_and_decline_are_side_effect_free() { let (_tempdir, sdk, store) = directory_sdk_and_store().await; let request_event_id = deterministic_event_id("order-decision-prepare-request"); - let request_event = RadrootsNostrEventPtr { + let request_event = RadrootsEventPtr { id: request_event_id.as_str().to_owned(), relays: Some(RELAY.to_owned()), }; @@ -4530,7 +4528,7 @@ async fn order_decision_prepare_accept_and_decline_are_side_effect_free() { #[tokio::test] async fn order_decision_prepare_rejects_invalid_actor_evidence_and_payload() { let (_tempdir, sdk, _store) = directory_sdk_and_store().await; - let request_event = RadrootsNostrEventPtr { + let request_event = RadrootsEventPtr { id: deterministic_event_id("order-decision-invalid-request") .as_str() .to_owned(), @@ -4567,7 +4565,7 @@ async fn order_decision_prepare_rejects_invalid_actor_evidence_and_payload() { .trades() .prepare_decision(TradeDecisionPrepareRequest::new( seller_actor(), - RadrootsNostrEventPtr { + RadrootsEventPtr { id: String::new(), relays: Some(RELAY.to_owned()), }, @@ -4622,7 +4620,7 @@ async fn order_decision_runtime_dtos_serialize_deterministically() { let prepare_event_id = deterministic_event_id("order-decision-serialized-request"); let prepare_request = TradeDecisionPrepareRequest::new( seller_actor(), - RadrootsNostrEventPtr { + RadrootsEventPtr { id: prepare_event_id.as_str().to_owned(), relays: Some(RELAY.to_owned()), }, @@ -5238,7 +5236,7 @@ async fn order_decision_enqueue_decline_stores_event_and_status_sees_declined() #[tokio::test] async fn order_decision_enqueue_rejects_missing_request_evidence_before_mutation() { let (_tempdir, sdk, store) = directory_sdk_and_store().await; - let missing_request = RadrootsNostrEventPtr { + let missing_request = RadrootsEventPtr { id: deterministic_event_id("missing-order-request") .as_str() .to_owned(), @@ -6889,7 +6887,7 @@ async fn order_status_maps_malformed_local_data_to_sanitized_error() { .ingest_event(RadrootsEventIngest::new(request_event.clone(), 3_000)) .await .expect("ingest"); - sqlx::query("UPDATE nostr_events SET tags_json = '[' WHERE event_id = ?") + sqlx::query("UPDATE event_envelopes SET tags_json = '[' WHERE event_id = ?") .bind(request_event.id.as_str()) .execute(store.pool()) .await diff --git a/crates/sdk/tests/replica_ingest.rs b/crates/sdk/tests/replica_ingest.rs @@ -1,4 +1,4 @@ -use radroots_events::{RadrootsNostrEvent, farm::RadrootsFarm}; +use radroots_events::{RadrootsEventEnvelope, farm::RadrootsFarm}; use radroots_replica_db::ReplicaSql; use radroots_replica_db_schema::farm::IFarmFindMany; use radroots_replica_sync::{RadrootsReplicaIngestOutcome, radroots_replica_ingest_event}; @@ -16,8 +16,8 @@ fn sdk_event( kind: u32, content: String, tags: Vec<Vec<String>>, -) -> RadrootsNostrEvent { - RadrootsNostrEvent { +) -> RadrootsEventEnvelope { + RadrootsEventEnvelope { id: format!("{id:064x}"), author: author.to_owned(), created_at, @@ -53,7 +53,7 @@ fn open_replica() -> (TempDir, ReplicaSql<SqliteExecutor>) { (dir, replica) } -fn ingest_farm(replica: &ReplicaSql<SqliteExecutor>) -> RadrootsNostrEvent { +fn ingest_farm(replica: &ReplicaSql<SqliteExecutor>) -> RadrootsEventEnvelope { let farm_value = sample_farm(); let author = seller_pubkey(); let parts = diff --git a/crates/sdk/tests/runtime_foundation.rs b/crates/sdk/tests/runtime_foundation.rs @@ -174,8 +174,12 @@ async fn sdk_directory_storage_creates_deterministic_sqlite_files() { assert!(paths.outbox_path.exists()); assert!(paths.private_store_path.exists()); let event_tables = sqlite_table_names(&paths.event_store_path).await; - assert!(event_tables.iter().any(|name| name == "nostr_events")); - assert!(event_tables.iter().any(|name| name == "nostr_event_tags")); + assert!(event_tables.iter().any(|name| name == "event_envelopes")); + assert!( + event_tables + .iter() + .any(|name| name == "event_envelope_tags") + ); assert!(event_tables.iter().any(|name| name == "listing_projection")); assert!(event_tables.iter().any(|name| name == "trade_projection")); assert!(event_tables.iter().any(|name| name == "listing_search_fts")); diff --git a/crates/sdk/tests/support/fixture_signer.rs b/crates/sdk/tests/support/fixture_signer.rs @@ -1,7 +1,5 @@ use radroots_authority::{RadrootsEventSigner, RadrootsSignerError, RadrootsSignerIdentity}; -use radroots_events::draft::{ - RadrootsFrozenEventDraft, RadrootsSignedNostrEvent, RadrootsSignedNostrEventParts, -}; +use radroots_events::draft::{RadrootsEventDraft, RadrootsSignedEvent, RadrootsSignedEventParts}; #[derive(Clone)] pub struct FixtureSigner { @@ -23,8 +21,8 @@ impl RadrootsEventSigner for FixtureSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { if self.pubkey().as_str() != draft.expected_pubkey.as_str() { return Err(RadrootsSignerError::SigningFailed { message: "wrong fixture signer".to_owned(), @@ -41,7 +39,7 @@ impl RadrootsEventSigner for FixtureSigner { "sig": sig, }) .to_string(); - RadrootsSignedNostrEvent::new(RadrootsSignedNostrEventParts { + RadrootsSignedEvent::new(RadrootsSignedEventParts { id: draft.expected_event_id.clone(), pubkey: self.pubkey().as_str().to_owned(), created_at: draft.created_at, diff --git a/crates/sdk/tests/sync_runtime.rs b/crates/sdk/tests/sync_runtime.rs @@ -11,7 +11,7 @@ use radroots_core::{ use radroots_event_store::{RadrootsEventStore, RadrootsTransportObservationType}; use radroots_events::{ contract::RadrootsActorRole, - draft::{RadrootsFrozenEventDraft, RadrootsSignedNostrEvent, RadrootsSignedNostrEventParts}, + draft::{RadrootsEventDraft, RadrootsSignedEvent, RadrootsSignedEventParts}, farm::RadrootsFarmRef, ids::{RadrootsDTag, RadrootsEventId, RadrootsInventoryBinId}, listing::{RadrootsListing, RadrootsListingBin, RadrootsListingProduct}, @@ -380,8 +380,8 @@ impl RadrootsEventSigner for FixtureSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { if self.pubkey().as_str() != draft.expected_pubkey.as_str() { return Err(RadrootsSignerError::SigningFailed { message: "wrong fixture signer".to_owned(), @@ -398,7 +398,7 @@ impl RadrootsEventSigner for FixtureSigner { "sig": sig, }) .to_string(); - RadrootsSignedNostrEvent::new(RadrootsSignedNostrEventParts { + RadrootsSignedEvent::new(RadrootsSignedEventParts { id: draft.expected_event_id.clone(), pubkey: self.pubkey().as_str().to_owned(), created_at: draft.created_at, diff --git a/crates/sdk/tests/trade_product_publish_runtime.rs b/crates/sdk/tests/trade_product_publish_runtime.rs @@ -10,7 +10,7 @@ use radroots_core::{ RadrootsCoreCurrency, RadrootsCoreDecimal, RadrootsCoreMoney, RadrootsCoreUnit, }; use radroots_events::{ - RadrootsNostrEventPtr, + RadrootsEventPtr, contract::RadrootsActorRole, ids::RadrootsListingAddress, kinds::KIND_LISTING, @@ -151,8 +151,8 @@ fn listing_address() -> RadrootsListingAddress { .expect("listing address") } -fn listing_event_ptr() -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn listing_event_ptr() -> RadrootsEventPtr { + RadrootsEventPtr { id: "6ccf12d1e56c21065d239bc3d46c0000cd000095d20000d9000073cd00009600".to_owned(), relays: Some(RELAY.to_owned()), } diff --git a/crates/sdk/tests/unit/adapters_radrootsd_tests.rs b/crates/sdk/tests/unit/adapters_radrootsd_tests.rs @@ -85,8 +85,8 @@ fn spawn_http_server( (endpoint, handle) } -fn signed_event() -> RadrootsSignedNostrEvent { - RadrootsSignedNostrEvent { +fn signed_event() -> RadrootsSignedEvent { + RadrootsSignedEvent { id: "a".repeat(64), pubkey: "b".repeat(64), created_at: 1_700_000_000, diff --git a/crates/sdk/tests/unit/dvm_runtime_tests.rs b/crates/sdk/tests/unit/dvm_runtime_tests.rs @@ -9,7 +9,7 @@ use crate::{ }; use radroots_authority::RadrootsActorContext; use radroots_events::{ - RadrootsNostrEvent, + RadrootsEventEnvelope, contract::RadrootsActorRole, ids::{RadrootsEventId, RadrootsInventoryBinId, RadrootsListingAddress, RadrootsPublicKey}, kinds::KIND_TRADE_TRANSITION_PROOF_REQUEST, @@ -371,8 +371,8 @@ fn hash32(ch: char) -> String { format!("0x{}", ch.to_string().repeat(64)) } -fn dummy_event() -> RadrootsNostrEvent { - RadrootsNostrEvent { +fn dummy_event() -> RadrootsEventEnvelope { + RadrootsEventEnvelope { id: event_id('9').into_string(), author: event_id('a').into_string(), created_at: 1, diff --git a/crates/sdk/tests/unit/orders_runtime_tests.rs b/crates/sdk/tests/unit/orders_runtime_tests.rs @@ -6,7 +6,7 @@ use radroots_core::{ }; use radroots_event_store::RadrootsEventStoreError; use radroots_events::{ - draft::RadrootsSignedNostrEvent, + draft::RadrootsSignedEvent, kinds::KIND_LISTING, order::{ RadrootsOrderDecisionOutcome, RadrootsOrderEconomicItem, RadrootsOrderEconomicLine, @@ -115,12 +115,12 @@ fn refs<'a>( } } -fn ptr(id: String) -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { id, relays: None } +fn ptr(id: String) -> RadrootsEventPtr { + RadrootsEventPtr { id, relays: None } } -fn nostr_event(id: String, kind: u32) -> RadrootsNostrEvent { - RadrootsNostrEvent { +fn nostr_event(id: String, kind: u32) -> RadrootsEventEnvelope { + RadrootsEventEnvelope { id, author: hex_64('c'), created_at: 1_700_000_000, @@ -289,8 +289,8 @@ impl RadrootsEventSigner for OrderFixtureSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { radroots_nostr_sign_frozen_draft(&self.keys, draft).map_err(|error| { RadrootsSignerError::SigningFailed { message: error.to_string(), @@ -314,15 +314,15 @@ fn fixture_listing_addr() -> RadrootsListingAddress { .expect("listing address") } -fn fixture_event_ptr(character: char) -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn fixture_event_ptr(character: char) -> RadrootsEventPtr { + RadrootsEventPtr { id: hex_64(character), relays: Some(RELAY.to_owned()), } } -fn fixture_order_event_ptr(event_id: &RadrootsEventId) -> RadrootsNostrEventPtr { - RadrootsNostrEventPtr { +fn fixture_order_event_ptr(event_id: &RadrootsEventId) -> RadrootsEventPtr { + RadrootsEventPtr { id: event_id.as_str().to_owned(), relays: Some(RELAY.to_owned()), } @@ -597,10 +597,10 @@ fn event_from_parts( parts: WireEventParts, contract_id: &str, expected_pubkey: &RadrootsPublicKey, -) -> RadrootsNostrEvent { +) -> RadrootsEventEnvelope { let frozen = to_frozen_draft(parts, contract_id, expected_pubkey.as_str(), 1_700_000_000) .expect("frozen draft"); - RadrootsNostrEvent { + RadrootsEventEnvelope { id: frozen.expected_event_id, author: expected_pubkey.as_str().to_owned(), created_at: frozen.created_at, @@ -611,7 +611,7 @@ fn event_from_parts( } } -fn request_event() -> RadrootsNostrEvent { +fn request_event() -> RadrootsEventEnvelope { let listing_event = ptr(event_id('a').as_str().to_owned()); let request = order_request_payload(); event_from_parts( diff --git a/crates/sdk/tests/unit/runtime_tests.rs b/crates/sdk/tests/unit/runtime_tests.rs @@ -666,10 +666,10 @@ async fn storage_status_integrity_and_backup_map_closed_pool_errors() { ); let event_store_summary_error = RadrootsClient::builder().build().await.expect("sdk"); - sqlx::query("DROP TABLE nostr_events") + sqlx::query("DROP TABLE event_envelopes") .execute(event_store_summary_error._event_store.pool()) .await - .expect("drop nostr events"); + .expect("drop event envelopes"); assert!(matches!( event_store_summary_error .storage_status(StorageStatusRequest::new()) @@ -1607,7 +1607,7 @@ async fn restore_archive_private_failures_cover_staging_and_verification_edges() populated_sdk ._event_store .ingest_event(radroots_event_store::RadrootsEventIngest::new( - radroots_events::RadrootsNostrEvent { + radroots_events::RadrootsEventEnvelope { id: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".to_owned(), author: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" .to_owned(), diff --git a/crates/sdk/tests/unit/signer_provider_tests.rs b/crates/sdk/tests/unit/signer_provider_tests.rs @@ -45,7 +45,7 @@ fn actor() -> RadrootsActorContext { RadrootsActorContext::test(USER_PUBLIC_KEY_HEX, [RadrootsActorRole::Farmer]).expect("actor") } -fn frozen_draft() -> RadrootsFrozenEventDraft { +fn frozen_draft() -> RadrootsEventDraft { frozen_draft_with( "radroots.farm.profile.v1", USER_PUBLIC_KEY_HEX, @@ -63,7 +63,7 @@ fn frozen_draft_with( created_at: u32, tags: Vec<Vec<String>>, content: &str, -) -> RadrootsFrozenEventDraft { +) -> RadrootsEventDraft { to_frozen_draft( WireEventParts { kind, @@ -77,7 +77,7 @@ fn frozen_draft_with( .expect("frozen draft") } -fn sign_event(keys: &RadrootsNostrKeys, draft: &RadrootsFrozenEventDraft) -> RadrootsNostrEvent { +fn sign_event(keys: &RadrootsNostrKeys, draft: &RadrootsEventDraft) -> RadrootsNostrEvent { let signed = radroots_nostr::prelude::radroots_nostr_sign_frozen_draft(keys, draft).expect("signed"); RadrootsNostrEvent::from_json(signed.raw_json.as_str()).expect("event") diff --git a/crates/sdk/tests/unit/sync_runtime_tests.rs b/crates/sdk/tests/unit/sync_runtime_tests.rs @@ -26,7 +26,7 @@ use radroots_event_store::RadrootsEventStoreStatusSummary; #[cfg(feature = "radrootsd-proxy")] use radroots_events::contract::RadrootsActorRole; #[cfg(feature = "radrootsd-proxy")] -use radroots_events::draft::{RadrootsFrozenEventDraft, RadrootsSignedNostrEvent}; +use radroots_events::draft::{RadrootsEventDraft, RadrootsSignedEvent}; use radroots_events::ids::RadrootsEventId; #[cfg(feature = "radrootsd-proxy")] use radroots_events::kinds::KIND_FARM; @@ -106,8 +106,8 @@ impl RadrootsEventSigner for ProxyFixtureSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { radroots_nostr_sign_frozen_draft(&self.keys, draft).map_err(|error| { RadrootsSignerError::SigningFailed { message: error.to_string(), @@ -133,7 +133,7 @@ fn proxy_actor() -> RadrootsActorContext { } #[cfg(feature = "radrootsd-proxy")] -fn proxy_frozen_draft(d_tag: &str) -> RadrootsFrozenEventDraft { +fn proxy_frozen_draft(d_tag: &str) -> RadrootsEventDraft { to_frozen_draft( WireEventParts { kind: KIND_FARM, @@ -1111,7 +1111,7 @@ async fn proxy_push_reports_missing_signed_claim_before_daemon_publish() { state: RadrootsOutboxEventState::Signed, claim_token: "claim-token".to_owned(), active_delivery_plan_id: Some(1), - draft: RadrootsFrozenEventDraft { + draft: RadrootsEventDraft { contract_id: "radroots.test".to_owned(), contract_registry_version: 1, kind: 1, diff --git a/crates/sdk/tests/unit/workflow_runtime_tests.rs b/crates/sdk/tests/unit/workflow_runtime_tests.rs @@ -3,7 +3,7 @@ use super::*; use crate::{RadrootsSdkLocalKeySigner, RadrootsSdkSignerProvider}; use radroots_authority::{RadrootsSignerError, RadrootsSignerIdentity}; use radroots_events::contract::RadrootsActorRole; -use radroots_events::draft::RadrootsSignedNostrEvent; +use radroots_events::draft::RadrootsSignedEvent; use radroots_events::kinds::KIND_FARM; use radroots_events_codec::wire::{WireEventParts, to_frozen_draft}; use radroots_nostr::prelude::{ @@ -39,8 +39,8 @@ impl RadrootsEventSigner for WorkflowSigner { fn sign_frozen_draft( &self, - draft: &RadrootsFrozenEventDraft, - ) -> Result<RadrootsSignedNostrEvent, RadrootsSignerError> { + draft: &RadrootsEventDraft, + ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { radroots_nostr_sign_frozen_draft(&self.keys, draft).map_err(|error| { RadrootsSignerError::SigningFailed { message: error.to_string(), @@ -49,11 +49,11 @@ impl RadrootsEventSigner for WorkflowSigner { } } -fn frozen_draft_for(pubkey: &str) -> RadrootsFrozenEventDraft { +fn frozen_draft_for(pubkey: &str) -> RadrootsEventDraft { frozen_draft_for_d_tag(pubkey, "test") } -fn frozen_draft_for_d_tag(pubkey: &str, d_tag: &str) -> RadrootsFrozenEventDraft { +fn frozen_draft_for_d_tag(pubkey: &str, d_tag: &str) -> RadrootsEventDraft { to_frozen_draft( WireEventParts { kind: KIND_FARM, @@ -67,12 +67,12 @@ fn frozen_draft_for_d_tag(pubkey: &str, d_tag: &str) -> RadrootsFrozenEventDraft .expect("frozen draft") } -fn frozen_draft() -> RadrootsFrozenEventDraft { +fn frozen_draft() -> RadrootsEventDraft { frozen_draft_for("a".repeat(64).as_str()) } -fn signed_event() -> RadrootsSignedNostrEvent { - RadrootsSignedNostrEvent { +fn signed_event() -> RadrootsSignedEvent { + RadrootsSignedEvent { id: "b".repeat(64), pubkey: "a".repeat(64), created_at: 1_700_000_000, diff --git a/packages/events-bindings/src/generated/types.ts b/packages/events-bindings/src/generated/types.ts @@ -18,7 +18,7 @@ export type RadrootsComment = { root: RadrootsSocialTarget, parent: RadrootsSoci export type RadrootsCommercialDomain = "trade:listing"; -export type RadrootsContributionAttestation = { schema: string, schema_version: number, contributor_pubkey: string, contribution_type: string, subject_refs: Array<RadrootsNostrEventRef>, summary: string, evidence_refs: Array<RadrootsNostrEventRef>, }; +export type RadrootsContributionAttestation = { schema: string, schema_version: number, contributor_pubkey: string, contribution_type: string, subject_refs: Array<RadrootsEventRef>, summary: string, evidence_refs: Array<RadrootsEventRef>, }; export type RadrootsCoop = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsCoopLocation | null, tags?: Array<string> | null, }; @@ -30,7 +30,13 @@ export type RadrootsDocument = { d_tag: string, doc_type: string, title: string, export type RadrootsDocumentSubject = { pubkey: string, address?: string | null, }; -export type RadrootsEvidenceBounty = { schema: string, schema_version: number, d_tag: string, title: string, summary?: string | null, topics: Array<string>, target_refs: Array<RadrootsNostrEventRef>, reward_note?: string | null, closes_at?: string | null, }; +export type RadrootsEventEnvelope = { id: string, author: string, created_at: number, kind: number, tags: Array<Array<string>>, content: string, sig: string, }; + +export type RadrootsEventPtr = { id: string, relays?: string | null, }; + +export type RadrootsEventRef = { id: string, author: string, kind: number, d_tag?: string | null, relays?: Array<string> | null, }; + +export type RadrootsEvidenceBounty = { schema: string, schema_version: number, d_tag: string, title: string, summary?: string | null, topics: Array<string>, target_refs: Array<RadrootsEventRef>, reward_note?: string | null, closes_at?: string | null, }; export type RadrootsFarm = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsFarmPublicLocation | null, tags?: Array<string> | null, }; @@ -54,7 +60,7 @@ export type RadrootsGiftWrap = { recipient: RadrootsGiftWrapRecipient, content: export type RadrootsGiftWrapRecipient = { public_key: string, relay_url?: string | null, }; -export type RadrootsJobFeedback = { kind: number, status: JobFeedbackStatus, extra_info?: string | null, request_event: RadrootsNostrEventPtr, customer_pubkey?: string | null, payment?: JobPaymentRequest | null, content?: string | null, encrypted: boolean, }; +export type RadrootsJobFeedback = { kind: number, status: JobFeedbackStatus, extra_info?: string | null, request_event: RadrootsEventPtr, customer_pubkey?: string | null, payment?: JobPaymentRequest | null, content?: string | null, encrypted: boolean, }; export type RadrootsJobInput = { data: string, input_type: JobInputType, relay?: string | null, marker?: string | null, }; @@ -62,31 +68,31 @@ export type RadrootsJobParam = { key: string, value: string, }; export type RadrootsJobRequest = { kind: number, inputs: Array<RadrootsJobInput>, output?: string | null, params: Array<RadrootsJobParam>, bid_sat?: number | null, relays: Array<string>, providers: Array<string>, topics: Array<string>, encrypted: boolean, }; -export type RadrootsJobResult = { kind: number, request_event: RadrootsNostrEventPtr, request_json?: string | null, inputs: Array<RadrootsJobInput>, customer_pubkey?: string | null, payment?: JobPaymentRequest | null, content?: string | null, encrypted: boolean, }; +export type RadrootsJobResult = { kind: number, request_event: RadrootsEventPtr, request_json?: string | null, inputs: Array<RadrootsJobInput>, customer_pubkey?: string | null, payment?: JobPaymentRequest | null, content?: string | null, encrypted: boolean, }; -export type RadrootsKnowledgeChangeProposal = { schema: string, schema_version: number, target: RadrootsNostrEventRef, proposal_type: string, summary: string, rationale?: string | null, evidence_refs: Array<RadrootsNostrEventRef>, supersedes: Array<RadrootsNostrEventRef>, }; +export type RadrootsKnowledgeChangeProposal = { schema: string, schema_version: number, target: RadrootsEventRef, proposal_type: string, summary: string, rationale?: string | null, evidence_refs: Array<RadrootsEventRef>, supersedes: Array<RadrootsEventRef>, }; -export type RadrootsKnowledgeCitationSpan = { source_ref: RadrootsNostrEventRef, artifact_ref?: RadrootsNostrEventRef | null, page_start?: number | null, page_end?: number | null, section_path: Array<string>, quote_hash?: string | null, chunk_id?: string | null, }; +export type RadrootsKnowledgeCitationSpan = { source_ref: RadrootsEventRef, artifact_ref?: RadrootsEventRef | null, page_start?: number | null, page_end?: number | null, section_path: Array<string>, quote_hash?: string | null, chunk_id?: string | null, }; -export type RadrootsKnowledgeClaim = { schema: string, schema_version: number, claim_type: string, text: string, citation_spans: Array<RadrootsKnowledgeCitationSpan>, topics: Array<string>, applies_to: Array<string>, author_asserted_confidence?: string | null, supersedes: Array<RadrootsNostrEventRef>, }; +export type RadrootsKnowledgeClaim = { schema: string, schema_version: number, claim_type: string, text: string, citation_spans: Array<RadrootsKnowledgeCitationSpan>, topics: Array<string>, applies_to: Array<string>, author_asserted_confidence?: string | null, supersedes: Array<RadrootsEventRef>, }; -export type RadrootsKnowledgeFieldContext = { location_precision: RadrootsKnowledgeLocationPrecision, public_location?: RadrootsKnowledgeLocation | null, private_location_ref?: RadrootsNostrEventRef | null, topics: Array<string>, context_tags: Array<string>, }; +export type RadrootsKnowledgeFieldContext = { location_precision: RadrootsKnowledgeLocationPrecision, public_location?: RadrootsKnowledgeLocation | null, private_location_ref?: RadrootsEventRef | null, topics: Array<string>, context_tags: Array<string>, }; -export type RadrootsKnowledgeFieldReport = { schema: string, schema_version: number, report_type: string, title: string, summary?: string | null, context: RadrootsKnowledgeFieldContext, observations: Array<RadrootsKnowledgeObservation>, artifact_refs: Array<RadrootsNostrEventRef>, related_refs: Array<RadrootsNostrEventRef>, limitations: Array<string>, }; +export type RadrootsKnowledgeFieldReport = { schema: string, schema_version: number, report_type: string, title: string, summary?: string | null, context: RadrootsKnowledgeFieldContext, observations: Array<RadrootsKnowledgeObservation>, artifact_refs: Array<RadrootsEventRef>, related_refs: Array<RadrootsEventRef>, limitations: Array<string>, }; export type RadrootsKnowledgeLocation = { label?: string | null, region?: string | null, locality?: string | null, geohash?: string | null, }; export type RadrootsKnowledgeLocationPrecision = "none" | "region" | "locality" | "coarse_geohash" | "exact_public" | "exact_private_reference"; -export type RadrootsKnowledgeNodeRef = { node_type: string, event_ref?: RadrootsNostrEventRef | null, address_ref?: RadrootsAddressableRef | null, external_id?: string | null, label?: string | null, }; +export type RadrootsKnowledgeNodeRef = { node_type: string, event_ref?: RadrootsEventRef | null, address_ref?: RadrootsAddressableRef | null, external_id?: string | null, label?: string | null, }; export type RadrootsKnowledgeObservation = { observation_type: string, text: string, observed_at?: string | null, values: Array<RadrootsKnowledgeObservationValue>, }; export type RadrootsKnowledgeObservationValue = { key: string, value: string, unit?: string | null, }; -export type RadrootsKnowledgeRelation = { schema: string, schema_version: number, subject: RadrootsKnowledgeNodeRef, predicate: string, object: RadrootsKnowledgeNodeRef, support_refs: Array<RadrootsNostrEventRef>, author_asserted_confidence?: string | null, supersedes: Array<RadrootsNostrEventRef>, }; +export type RadrootsKnowledgeRelation = { schema: string, schema_version: number, subject: RadrootsKnowledgeNodeRef, predicate: string, object: RadrootsKnowledgeNodeRef, support_refs: Array<RadrootsEventRef>, author_asserted_confidence?: string | null, supersedes: Array<RadrootsEventRef>, }; -export type RadrootsKnowledgeReview = { schema: string, schema_version: number, target: RadrootsKnowledgeReviewTarget, reviewer_role: string, verdict: string, scores: Array<RadrootsKnowledgeReviewScore>, notes?: string | null, evidence_refs: Array<RadrootsNostrEventRef>, }; +export type RadrootsKnowledgeReview = { schema: string, schema_version: number, target: RadrootsKnowledgeReviewTarget, reviewer_role: string, verdict: string, scores: Array<RadrootsKnowledgeReviewScore>, notes?: string | null, evidence_refs: Array<RadrootsEventRef>, }; export type RadrootsKnowledgeReviewScope = "specific_version" | "addressable_coordinate_at_published_at" | "policy_latest"; @@ -94,7 +100,7 @@ export type RadrootsKnowledgeReviewScore = { dimension: string, value: string, n export type RadrootsKnowledgeReviewTarget = { event_id: string, author_pubkey: string, kind: number, address?: string | null, relays: Array<string>, review_scope: RadrootsKnowledgeReviewScope, }; -export type RadrootsKnowledgeSource = { schema: string, schema_version: number, d_tag: string, title: string, source_type: string, authors: Array<string>, publisher?: string | null, publication_year?: number | null, edition?: string | null, canonical_url?: string | null, artifact_refs: Array<RadrootsNostrEventRef>, author_asserted_rights?: RadrootsRightsAssertion | null, topics: Array<string>, summary?: string | null, }; +export type RadrootsKnowledgeSource = { schema: string, schema_version: number, d_tag: string, title: string, source_type: string, authors: Array<string>, publisher?: string | null, publication_year?: number | null, edition?: string | null, canonical_url?: string | null, artifact_refs: Array<RadrootsEventRef>, author_asserted_rights?: RadrootsRightsAssertion | null, topics: Array<string>, summary?: string | null, }; export type RadrootsList = { content: string, entries: Array<RadrootsListEntry>, }; @@ -124,20 +130,14 @@ export type RadrootsListingPublicLocation = { primary: string, city?: string | n export type RadrootsListingStatus = { kind: "active", } | { kind: "sold", } | { kind: "other", amount: { value: string, }, }; -export type RadrootsMessage = { recipients: Array<RadrootsMessageRecipient>, content: string, reply_to?: RadrootsNostrEventPtr | null, subject?: string | null, }; +export type RadrootsMessage = { recipients: Array<RadrootsMessageRecipient>, content: string, reply_to?: RadrootsEventPtr | null, subject?: string | null, }; -export type RadrootsMessageFile = { recipients: Array<RadrootsMessageRecipient>, file_url: string, reply_to?: RadrootsNostrEventPtr | null, subject?: string | null, file_type: string, encryption_algorithm: string, decryption_key: string, decryption_nonce: string, encrypted_hash: string, original_hash?: string | null, size?: string | null, dimensions?: RadrootsMessageFileDimensions | null, blurhash?: string | null, thumb?: string | null, fallbacks: Array<string>, }; +export type RadrootsMessageFile = { recipients: Array<RadrootsMessageRecipient>, file_url: string, reply_to?: RadrootsEventPtr | null, subject?: string | null, file_type: string, encryption_algorithm: string, decryption_key: string, decryption_nonce: string, encrypted_hash: string, original_hash?: string | null, size?: string | null, dimensions?: RadrootsMessageFileDimensions | null, blurhash?: string | null, thumb?: string | null, fallbacks: Array<string>, }; export type RadrootsMessageFileDimensions = { w: number, h: number, }; export type RadrootsMessageRecipient = { public_key: string, relay_url?: string | null, }; -export type RadrootsNostrEvent = { id: string, author: string, created_at: number, kind: number, tags: Array<Array<string>>, content: string, sig: string, }; - -export type RadrootsNostrEventPtr = { id: string, relays?: string | null, }; - -export type RadrootsNostrEventRef = { id: string, author: string, kind: number, d_tag?: string | null, relays?: Array<string> | null, }; - export type RadrootsOrderCancellation = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, reason: string, }; export type RadrootsOrderDecision = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, decision: RadrootsOrderDecisionOutcome, }; @@ -216,13 +216,13 @@ export type RadrootsSocialMediaThumbnail = { url: string, dimensions?: RadrootsS export type RadrootsSocialTarget = { kind: "event", id: string, author?: string | null, event_kind?: number | null, relays?: Array<string> | null, } | { kind: "address", address: string, author?: string | null, event_kind?: number | null, relays?: Array<string> | null, } | { kind: "external", id: string, external_kind: string, hint?: string | null, }; -export type RadrootsTradeListingValidateRequest = { listing_event?: RadrootsNostrEventPtr | null, }; +export type RadrootsTradeListingValidateRequest = { listing_event?: RadrootsEventPtr | null, }; export type RadrootsTradeListingValidateResult = { valid: boolean, errors: Array<RadrootsTradeValidationListingError>, }; export type RadrootsTradeValidationListingError = { kind: "invalid_kind", amount: { kind: number, }, } | { kind: "missing_listing_id", } | { kind: "listing_event_not_found", amount: { listing_addr: string, }, } | { kind: "listing_event_fetch_failed", amount: { listing_addr: string, }, } | { kind: "parse_error", amount: { error: RadrootsListingParseError, }, } | { kind: "invalid_seller", } | { kind: "missing_farm_profile", } | { kind: "missing_farm_record", } | { kind: "missing_title", } | { kind: "missing_description", } | { kind: "missing_product_type", } | { kind: "missing_bins", } | { kind: "missing_primary_bin", } | { kind: "invalid_bin", } | { kind: "missing_price", } | { kind: "invalid_price", } | { kind: "missing_inventory", } | { kind: "invalid_inventory", } | { kind: "missing_availability", } | { kind: "missing_location", } | { kind: "missing_location_locality", } | { kind: "missing_location_geohash", } | { kind: "invalid_location_geohash", } | { kind: "missing_delivery_method", }; -export type RadrootsWikiArticle = { d_tag: string, title?: string | null, content_djot: string, summary?: string | null, topics: Array<string>, references: Array<RadrootsNostrEventRef>, forked_from: Array<RadrootsWikiArticleVersionRef>, deferred_to?: RadrootsWikiArticleVersionRef | null, }; +export type RadrootsWikiArticle = { d_tag: string, title?: string | null, content_djot: string, summary?: string | null, topics: Array<string>, references: Array<RadrootsEventRef>, forked_from: Array<RadrootsWikiArticleVersionRef>, deferred_to?: RadrootsWikiArticleVersionRef | null, }; export type RadrootsWikiArticleVersionRef = { event_id: string, address_ref: RadrootsAddressableRef, }; diff --git a/tools/xtask/src/dto_roots.rs b/tools/xtask/src/dto_roots.rs @@ -156,7 +156,7 @@ const TRADE_EXTERNAL_OVERRIDES: &[DtoExternalOverride] = &[ events_override("RadrootsListingProduct"), events_override("RadrootsListingPublicLocation"), events_override("RadrootsListingStatus"), - events_override("RadrootsNostrEventPtr"), + events_override("RadrootsEventPtr"), events_override("RadrootsPlotRef"), events_override("RadrootsResourceAreaRef"), events_override("RadrootsOrderEconomicActor"), @@ -651,9 +651,9 @@ mod tests { "RadrootsMessageFile", "RadrootsMessageFileDimensions", "RadrootsMessageRecipient", - "RadrootsNostrEvent", - "RadrootsNostrEventPtr", - "RadrootsNostrEventRef", + "RadrootsEventEnvelope", + "RadrootsEventPtr", + "RadrootsEventRef", "RadrootsOrderCancellation", "RadrootsOrderDecision", "RadrootsOrderDecisionOutcome", diff --git a/tools/xtask/src/smoke.rs b/tools/xtask/src/smoke.rs @@ -141,7 +141,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { Ok(()) } -fn sign_parts(parts: WireEventParts) -> Result<RadrootsNostrEvent, Box<dyn std::error::Error>> { +fn sign_parts(parts: WireEventParts) -> Result<RadrootsEventEnvelope, Box<dyn std::error::Error>> { let tags = parts .tags .into_iter() @@ -152,7 +152,7 @@ fn sign_parts(parts: WireEventParts) -> Result<RadrootsNostrEvent, Box<dyn std:: .tags(tags) .custom_created_at(Timestamp::from_secs(u64::from(CREATED_AT))) .sign_with_keys(&keys)?; - Ok(RadrootsNostrEvent { + Ok(RadrootsEventEnvelope { id: event.id.to_hex(), author: event.pubkey.to_hex(), created_at: event.created_at.as_secs() as u32, @@ -179,8 +179,8 @@ fn hex_64(character: char) -> String { character.to_string().repeat(64) } -fn event_ref(character: char, kind: u32) -> RadrootsNostrEventRef { - RadrootsNostrEventRef { +fn event_ref(character: char, kind: u32) -> RadrootsEventRef { + RadrootsEventRef { id: hex_64(character), author: hex_64('a'), kind,