sdk

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

commit a10f2f320c3b54effbe8c48f3cf5129093ab3dda
parent 39b12eaa8b2b9c6246246200b888e7ce70f12f08
Author: triesap <tyson@radroots.org>
Date:   Wed, 29 Jul 2026 08:19:58 +0000

event: migrate bindings beyond superseded surface

- migrate Rust SDK consumers to canonical event names and module paths
- preserve language predecessors until the generated-surface cutover
- resolve event and schema name collisions with explicit aliases
- verify bindings SDK examples tests architecture and tooling

Diffstat:
Mcrates/event_codec_wasm/src/lib.rs | 562+++++++++++++++++++++++++++++++++++++------------------------------------------
Mcrates/replica_sync_wasm/src/lib.rs | 6+++---
Mcrates/sdk/examples/runtime_local.rs | 35+++++++++++++++++------------------
Mcrates/sdk/examples/sdk_v1_knowledge_prepare.rs | 14+++++++-------
Mcrates/sdk/examples/sdk_v1_listing_prepare.rs | 35+++++++++++++++++------------------
Mcrates/sdk/examples/sdk_v1_local_enqueue_and_mock_sync.rs | 35+++++++++++++++++------------------
Mcrates/sdk/src/adapters/radrootsd.rs | 6+++---
Mcrates/sdk/src/error.rs | 66++++++++++++++++++++++++++++--------------------------------------
Mcrates/sdk/src/farm.rs | 4++--
Mcrates/sdk/src/farms_runtime.rs | 74+++++++++++++++++++++++++++++++++++---------------------------------------
Mcrates/sdk/src/idempotency.rs | 4++--
Mcrates/sdk/src/knowledge.rs | 421++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mcrates/sdk/src/lib.rs | 45++++++++++++++++++++++-----------------------
Mcrates/sdk/src/listings_runtime.rs | 38+++++++++++++++++++-------------------
Mcrates/sdk/src/private_store.rs | 18+++++++++---------
Mcrates/sdk/src/signer_provider.rs | 33++++++++++++++-------------------
Mcrates/sdk/src/sync_runtime.rs | 10+++++-----
Mcrates/sdk/src/trade_runtime.rs | 193+++++++++++++++++++++++++++++++++++++------------------------------------------
Mcrates/sdk/src/transport.rs | 4++--
Mcrates/sdk/src/workflow_runtime.rs | 42++++++++++++++++++++----------------------
Mcrates/sdk/tests/farms_runtime.rs | 12++++++------
Mcrates/sdk/tests/knowledge_public_api.rs | 116++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mcrates/sdk/tests/listings_runtime.rs | 35+++++++++++++++++------------------
Mcrates/sdk/tests/replica_ingest.rs | 14+++++++-------
Mcrates/sdk/tests/support/fixture_signer.rs | 7++-----
Mcrates/sdk/tests/sync_runtime.rs | 37++++++++++++++++++-------------------
Mcrates/sdk/tests/unit/adapters_radrootsd_tests.rs | 8++++----
Mcrates/sdk/tests/unit/error_tests.rs | 2+-
Mcrates/sdk/tests/unit/farms_runtime_tests.rs | 18++++++++----------
Mcrates/sdk/tests/unit/idempotency_tests.rs | 4++--
Mcrates/sdk/tests/unit/listings_runtime_tests.rs | 45++++++++++++++++++++++-----------------------
Mcrates/sdk/tests/unit/private_store_tests.rs | 8++++----
Mcrates/sdk/tests/unit/runtime_tests.rs | 4++--
Mcrates/sdk/tests/unit/signer_provider_tests.rs | 10+++++-----
Mcrates/sdk/tests/unit/sync_runtime_tests.rs | 19++++++++-----------
Mcrates/sdk/tests/unit/trade_runtime_tests.rs | 84++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mcrates/sdk/tests/unit/workflow_runtime_tests.rs | 39+++++++++++++++------------------------
Mtools/xtask/src/smoke.rs | 14+++++++-------
38 files changed, 1007 insertions(+), 1114 deletions(-)

diff --git a/crates/event_codec_wasm/src/lib.rs b/crates/event_codec_wasm/src/lib.rs @@ -1,55 +1,51 @@ #![forbid(unsafe_code)] use radroots_blossom::{BlobDescriptor, BlobUrl, Error, MediaType, Sha256}; -use radroots_event::envelope::{ - RadrootsEventEnvelope, RadrootsEventEnvelopeError, RadrootsEventEnvelopeParts, -}; -use radroots_event::farm::RadrootsFarm; -use radroots_event::farm::coop::RadrootsCoop; -use radroots_event::farm::crdt::RadrootsFarmCrdtChange; -use radroots_event::farm::file::RadrootsFarmFileMetadata; -use radroots_event::farm::plot::RadrootsPlot; -use radroots_event::farm::workspace::RadrootsFarmWorkspaceManifest; +use radroots_event::envelope::{EventEnvelope, EventEnvelopeError, EventEnvelopeParts}; +use radroots_event::farm::Farm; +use radroots_event::farm::coop::Coop; +use radroots_event::farm::crdt::FarmCrdtChange; +use radroots_event::farm::file::FarmFileMetadata; +use radroots_event::farm::plot::Plot; +use radroots_event::farm::workspace::FarmWorkspaceManifest; use radroots_event::knowledge::{ - RadrootsKnowledgeClaim, RadrootsKnowledgeFieldReport, RadrootsKnowledgeRelation, - RadrootsKnowledgeReview, RadrootsKnowledgeSource, RadrootsWikiArticle, - RadrootsWikiMergeRequest, RadrootsWikiRedirect, + KnowledgeClaim, KnowledgeFieldReport, KnowledgeRelation, KnowledgeReview, KnowledgeSource, + WikiArticle, WikiMergeRequest, WikiRedirect, }; -use radroots_event::listing::operational::RadrootsOperationalListing; -use radroots_event::media::file_metadata::RadrootsFileMetadata; -use radroots_event::media::{RadrootsAuthoredImage, RadrootsAuthoredImageError}; -use radroots_event::post::article::RadrootsArticle; +use radroots_event::listing::operational::OperationalListing; +use radroots_event::media::file_metadata::FileMetadata; +use radroots_event::media::{AuthoredImage, AuthoredImageError}; +use radroots_event::post::article::Article; use radroots_event::post::comment::{ - RadrootsAuthoredNip22Comment, RadrootsNip22AddressRootReference, RadrootsNip22CommentError, - RadrootsNip22CommentParentReference, RadrootsNip22CommentRoot, RadrootsNip22EventRootReference, + AuthoredNip22Comment, Nip22AddressRootReference, Nip22CommentError, + Nip22CommentParentReference, Nip22CommentRoot, Nip22EventRootReference, }; -use radroots_event::post::document::RadrootsDocument; -use radroots_event::post::reaction::RadrootsReaction; -use radroots_event::post::report::RadrootsReport; -use radroots_event::post::repost::{RadrootsGenericRepost, RadrootsRepost}; +use radroots_event::post::document::Document; +use radroots_event::post::reaction::Reaction; +use radroots_event::post::report::Report; +use radroots_event::post::repost::{GenericRepost, Repost}; use radroots_event::post::{ - RadrootsAuthoredAsk, RadrootsAuthoredPhotoUpdate, RadrootsAuthoredPostError, - RadrootsAuthoredPostImage, RadrootsAuthoredUpdate, RadrootsPostImageDimensions, + AuthoredAsk, AuthoredPhotoUpdate, AuthoredPostError, AuthoredPostImage, AuthoredUpdate, + PostImageDimensions, }; -use radroots_event::social::follow::RadrootsFollow; -use radroots_event::social::gift_wrap::RadrootsGiftWrap; +use radroots_event::social::follow::Follow; +use radroots_event::social::gift_wrap::GiftWrap; use radroots_event::social::group::{ - RadrootsGroupAdmins, RadrootsGroupCreateGroup, RadrootsGroupCreateInvite, - RadrootsGroupDeleteEvent, RadrootsGroupDeleteGroup, RadrootsGroupEditMetadata, - RadrootsGroupJoinRequest, RadrootsGroupLeaveRequest, RadrootsGroupMembers, - RadrootsGroupMetadata, RadrootsGroupPutUser, RadrootsGroupRemoveUser, RadrootsGroupRoles, + GroupAdmins, GroupCreateGroup, GroupCreateInvite, GroupDeleteEvent, GroupDeleteGroup, + GroupEditMetadata, GroupJoinRequest, GroupLeaveRequest, GroupMembers, GroupMetadata, + GroupPutUser, GroupRemoveUser, GroupRoles, }; -use radroots_event::social::http_auth::RadrootsHttpAuth; -use radroots_event::social::job_feedback::RadrootsJobFeedback; -use radroots_event::social::job_request::RadrootsJobRequest; -use radroots_event::social::job_result::RadrootsJobResult; -use radroots_event::social::list::RadrootsList; -use radroots_event::social::list_set::RadrootsListSet; -use radroots_event::social::message::RadrootsMessage; -use radroots_event::social::message_file::RadrootsMessageFile; -use radroots_event::social::relay_auth::RadrootsRelayAuth; -use radroots_event::social::seal::RadrootsSeal; -use radroots_event::wire::RadrootsNip01EventWireParts; +use radroots_event::social::http_auth::HttpAuth; +use radroots_event::social::job_feedback::JobFeedback; +use radroots_event::social::job_request::JobRequest; +use radroots_event::social::job_result::JobResult; +use radroots_event::social::list::List; +use radroots_event::social::list_set::ListSet; +use radroots_event::social::message::Message; +use radroots_event::social::message_file::MessageFile; +use radroots_event::social::relay_auth::RelayAuth; +use radroots_event::social::seal::Seal; +use radroots_event::wire::Nip01EventWireParts; use radroots_event_codec::article::encode::article_build_tags; use radroots_event_codec::comment::authored::authored_nip22_comment_to_wire_parts; use radroots_event_codec::coop::encode::coop_build_tags; @@ -147,19 +143,19 @@ fn blossom_authored_error(error: Error) -> RadrootsJsValue { authored_error(error.code()) } -fn post_authored_error(error: RadrootsAuthoredPostError) -> RadrootsJsValue { +fn post_authored_error(error: AuthoredPostError) -> RadrootsJsValue { authored_error(error.code()) } -fn image_authored_error(error: RadrootsAuthoredImageError) -> RadrootsJsValue { +fn image_authored_error(error: AuthoredImageError) -> RadrootsJsValue { authored_error(error.code()) } -fn comment_authored_error(error: RadrootsNip22CommentError) -> RadrootsJsValue { +fn comment_authored_error(error: Nip22CommentError) -> RadrootsJsValue { authored_error(error.code()) } -fn wire_parts_to_json(parts: &RadrootsNip01EventWireParts) -> Result<String, RadrootsJsValue> { +fn wire_parts_to_json(parts: &Nip01EventWireParts) -> Result<String, RadrootsJsValue> { serde_json::to_string(parts) .map_err(|_| error_json("internal_error", Some("wire_parts_serialization"))) } @@ -180,29 +176,29 @@ struct EventEnvelopeInput { sig: String, } -fn envelope_error_code(error: &RadrootsEventEnvelopeError) -> &'static str { +fn envelope_error_code(error: &EventEnvelopeError) -> &'static str { match error { - RadrootsEventEnvelopeError::InvalidId(_) => "id_invalid", - RadrootsEventEnvelopeError::InvalidAuthor(_) => "author_invalid", - RadrootsEventEnvelopeError::InvalidSignature(_) => "signature_invalid", - RadrootsEventEnvelopeError::NonCanonicalId => "id_non_canonical", - RadrootsEventEnvelopeError::NonCanonicalAuthor => "author_non_canonical", - RadrootsEventEnvelopeError::NonCanonicalSignature => "signature_non_canonical", - RadrootsEventEnvelopeError::EmptyTag { .. } => "tag_empty", - RadrootsEventEnvelopeError::EmptyTagKey { .. } => "tag_key_empty", - RadrootsEventEnvelopeError::ControlCharacterTagKey { .. } => "tag_key_control_character", - RadrootsEventEnvelopeError::ContentTooLarge { .. } => "content_too_large", - RadrootsEventEnvelopeError::TooManyTags { .. } => "too_many_tags", - RadrootsEventEnvelopeError::TooManyTagElements { .. } => "too_many_tag_elements", - RadrootsEventEnvelopeError::TagElementTooLarge { .. } => "tag_element_too_large", - RadrootsEventEnvelopeError::TagsTooLarge { .. } => "tags_too_large", - } -} - -fn parse_event_json(input: &str) -> Result<RadrootsEventEnvelope, RadrootsJsValue> { + EventEnvelopeError::InvalidId(_) => "id_invalid", + EventEnvelopeError::InvalidAuthor(_) => "author_invalid", + EventEnvelopeError::InvalidSignature(_) => "signature_invalid", + EventEnvelopeError::NonCanonicalId => "id_non_canonical", + EventEnvelopeError::NonCanonicalAuthor => "author_non_canonical", + EventEnvelopeError::NonCanonicalSignature => "signature_non_canonical", + EventEnvelopeError::EmptyTag { .. } => "tag_empty", + EventEnvelopeError::EmptyTagKey { .. } => "tag_key_empty", + EventEnvelopeError::ControlCharacterTagKey { .. } => "tag_key_control_character", + EventEnvelopeError::ContentTooLarge { .. } => "content_too_large", + EventEnvelopeError::TooManyTags { .. } => "too_many_tags", + EventEnvelopeError::TooManyTagElements { .. } => "too_many_tag_elements", + EventEnvelopeError::TagElementTooLarge { .. } => "tag_element_too_large", + EventEnvelopeError::TagsTooLarge { .. } => "tags_too_large", + } +} + +fn parse_event_json(input: &str) -> Result<EventEnvelope, RadrootsJsValue> { let envelope: EventEnvelopeInput = serde_json::from_str(input).map_err(|_| error_json("invalid_json", Some("event_json")))?; - RadrootsEventEnvelope::new(RadrootsEventEnvelopeParts { + EventEnvelope::new(EventEnvelopeParts { id: envelope.id, author: envelope.author, created_at: envelope.created_at, @@ -242,7 +238,7 @@ where { event_type: &'static str, contract_id: &'static str, - event: &'a radroots_event::envelope::RadrootsEventEnvelope, + event: &'a radroots_event::envelope::EventEnvelope, payload: &'a T, } @@ -325,7 +321,7 @@ fn decode_error_json(error: RadrootsDecodeError) -> RadrootsJsValue { #[derive(serde::Deserialize)] struct FarmCrdtTagsInput { - change: RadrootsFarmCrdtChange, + change: FarmCrdtChange, author_pubkey: String, } @@ -403,13 +399,11 @@ struct AuthoredCommentParentInput { fn authored_post_images( inputs: Vec<AuthoredImageInput>, -) -> Result<Vec<RadrootsAuthoredPostImage>, RadrootsJsValue> { +) -> Result<Vec<AuthoredPostImage>, RadrootsJsValue> { inputs.into_iter().map(authored_post_image).collect() } -fn authored_post_image( - input: AuthoredImageInput, -) -> Result<RadrootsAuthoredPostImage, RadrootsJsValue> { +fn authored_post_image(input: AuthoredImageInput) -> Result<AuthoredPostImage, RadrootsJsValue> { let media_type = MediaType::parse(&input.media_type).map_err(blossom_authored_error)?; let sha256 = Sha256::digest(&input.bytes); let size = u64::try_from(input.bytes.len()) @@ -426,12 +420,12 @@ fn authored_post_image( .map_err(blossom_authored_error)? .verify_bytes(&input.bytes, &media_type) .map_err(blossom_authored_error)?; - let image = RadrootsAuthoredImage::try_from_verified_descriptor(descriptor) - .map_err(image_authored_error)?; + let image = + AuthoredImage::try_from_verified_descriptor(descriptor).map_err(image_authored_error)?; let dimensions = - RadrootsPostImageDimensions::new(input.width, input.height).map_err(post_authored_error)?; - let mut authored = RadrootsAuthoredPostImage::new(image, dimensions, input.alt) - .map_err(post_authored_error)?; + PostImageDimensions::new(input.width, input.height).map_err(post_authored_error)?; + let mut authored = + AuthoredPostImage::new(image, dimensions, input.alt).map_err(post_authored_error)?; for fallback in input.fallbacks { let fallback = BlobUrl::parse(&fallback) .map_err(blossom_authored_error)? @@ -446,15 +440,15 @@ fn authored_post_image( fn authored_comment_from_input( input: AuthoredCommentInput, -) -> Result<RadrootsAuthoredNip22Comment, RadrootsJsValue> { +) -> Result<AuthoredNip22Comment, RadrootsJsValue> { let root = match input.root { AuthoredCommentRootInput::Event { event_id, author, kind, relay, - } => RadrootsNip22CommentRoot::Event( - RadrootsNip22EventRootReference::parse(event_id, author, kind, relay.as_deref()) + } => Nip22CommentRoot::Event( + Nip22EventRootReference::parse(event_id, author, kind, relay.as_deref()) .map_err(comment_authored_error)?, ), AuthoredCommentRootInput::Address { @@ -463,7 +457,7 @@ fn authored_comment_from_input( kind, relay, } => { - let root = RadrootsNip22AddressRootReference::parse(coordinate, relay.as_deref()) + let root = Nip22AddressRootReference::parse(coordinate, relay.as_deref()) .map_err(comment_authored_error)?; if root.author().to_hex() != author { return Err(authored_error("comment_root_author_mismatch")); @@ -471,32 +465,28 @@ fn authored_comment_from_input( if root.kind().as_u32() != kind { return Err(authored_error("comment_root_kind_mismatch")); } - RadrootsNip22CommentRoot::Address(root) + Nip22CommentRoot::Address(root) } }; match (root, input.position) { - (RadrootsNip22CommentRoot::Event(root), AuthoredCommentPositionInput::TopEvent) => { - RadrootsAuthoredNip22Comment::top_level_event(input.content, root) + (Nip22CommentRoot::Event(root), AuthoredCommentPositionInput::TopEvent) => { + AuthoredNip22Comment::top_level_event(input.content, root) .map_err(comment_authored_error) } ( - RadrootsNip22CommentRoot::Address(root), + Nip22CommentRoot::Address(root), AuthoredCommentPositionInput::TopAddress { current_revision }, - ) => RadrootsAuthoredNip22Comment::parse_top_level_address( - input.content, - root, - current_revision, - ) - .map_err(comment_authored_error), + ) => AuthoredNip22Comment::parse_top_level_address(input.content, root, current_revision) + .map_err(comment_authored_error), (root, AuthoredCommentPositionInput::Nested { parent }) => { - let parent = RadrootsNip22CommentParentReference::parse( + let parent = Nip22CommentParentReference::parse( parent.event_id, parent.author, parent.relay.as_deref(), ) .map_err(comment_authored_error)?; - RadrootsAuthoredNip22Comment::nested(input.content, root, parent) + AuthoredNip22Comment::nested(input.content, root, parent) .map_err(comment_authored_error) } _ => Err(authored_error("comment_root_position_incompatible")), @@ -510,7 +500,7 @@ fn authored_comment_from_input( )] pub fn social_update_build_authored_draft(input_json: &str) -> Result<String, RadrootsJsValue> { let input = parse_authored_json::<AuthoredUpdateInput>(input_json)?; - let update = RadrootsAuthoredUpdate::new(input.content).map_err(post_authored_error)?; + let update = AuthoredUpdate::new(input.content).map_err(post_authored_error)?; wire_parts_to_json(&authored_update_to_wire_parts(&update)) } @@ -524,8 +514,7 @@ pub fn social_photo_update_build_authored_draft( ) -> Result<String, RadrootsJsValue> { let input = parse_authored_json::<AuthoredMediaPostInput>(input_json)?; let images = authored_post_images(input.images)?; - let photo = - RadrootsAuthoredPhotoUpdate::new(input.content, images).map_err(post_authored_error)?; + let photo = AuthoredPhotoUpdate::new(input.content, images).map_err(post_authored_error)?; wire_parts_to_json(&authored_photo_update_to_wire_parts(&photo)) } @@ -537,7 +526,7 @@ pub fn social_photo_update_build_authored_draft( pub fn social_ask_build_authored_draft(input_json: &str) -> Result<String, RadrootsJsValue> { let input = parse_authored_json::<AuthoredMediaPostInput>(input_json)?; let images = authored_post_images(input.images)?; - let ask = RadrootsAuthoredAsk::new(input.content, images).map_err(post_authored_error)?; + let ask = AuthoredAsk::new(input.content, images).map_err(post_authored_error)?; wire_parts_to_json(&authored_ask_to_wire_parts(&ask)) } @@ -557,7 +546,7 @@ pub fn social_comment_build_authored_draft(input_json: &str) -> Result<String, R wasm_bindgen(js_name = operational_listing_tags) )] pub fn operational_listing_tags(listing_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsOperationalListing, _, _>(listing_json, operational_listing_tags_impl) + build_tags_json::<OperationalListing, _, _>(listing_json, operational_listing_tags_impl) } #[cfg_attr( @@ -565,58 +554,52 @@ pub fn operational_listing_tags(listing_json: &str) -> Result<String, RadrootsJs wasm_bindgen(js_name = operational_listing_tags_full) )] pub fn operational_listing_tags_full(listing_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsOperationalListing, _, _>( - listing_json, - operational_listing_tags_full_impl, - ) + build_tags_json::<OperationalListing, _, _>(listing_json, operational_listing_tags_full_impl) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = article_tags))] pub fn article_tags(article_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsArticle, _, _>(article_json, article_build_tags) + build_tags_json::<Article, _, _>(article_json, article_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = wiki_article_tags))] pub fn wiki_article_tags(article_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsWikiArticle, _, _>(article_json, wiki_article_build_tags) + build_tags_json::<WikiArticle, _, _>(article_json, wiki_article_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = wiki_redirect_tags))] pub fn wiki_redirect_tags(redirect_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsWikiRedirect, _, _>(redirect_json, wiki_redirect_build_tags) + build_tags_json::<WikiRedirect, _, _>(redirect_json, wiki_redirect_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = wiki_merge_request_tags))] pub fn wiki_merge_request_tags(request_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsWikiMergeRequest, _, _>(request_json, wiki_merge_request_build_tags) + build_tags_json::<WikiMergeRequest, _, _>(request_json, wiki_merge_request_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = knowledge_source_tags))] pub fn knowledge_source_tags(source_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsKnowledgeSource, _, _>(source_json, knowledge_source_build_tags) + build_tags_json::<KnowledgeSource, _, _>(source_json, knowledge_source_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = knowledge_claim_tags))] pub fn knowledge_claim_tags(claim_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsKnowledgeClaim, _, _>(claim_json, knowledge_claim_build_tags) + build_tags_json::<KnowledgeClaim, _, _>(claim_json, knowledge_claim_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = knowledge_relation_tags))] pub fn knowledge_relation_tags(relation_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsKnowledgeRelation, _, _>(relation_json, knowledge_relation_build_tags) + build_tags_json::<KnowledgeRelation, _, _>(relation_json, knowledge_relation_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = knowledge_review_tags))] pub fn knowledge_review_tags(review_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsKnowledgeReview, _, _>(review_json, knowledge_review_build_tags) + build_tags_json::<KnowledgeReview, _, _>(review_json, knowledge_review_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = knowledge_field_report_tags))] pub fn knowledge_field_report_tags(report_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsKnowledgeFieldReport, _, _>( - report_json, - knowledge_field_report_build_tags, - ) + build_tags_json::<KnowledgeFieldReport, _, _>(report_json, knowledge_field_report_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = verify_and_decode_event_json))] @@ -634,97 +617,97 @@ pub fn contract_manifest_json() -> Result<String, RadrootsJsValue> { #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = file_metadata_tags))] pub fn file_metadata_tags(metadata_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsFileMetadata, _, _>(metadata_json, file_metadata_build_tags) + build_tags_json::<FileMetadata, _, _>(metadata_json, file_metadata_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = repost_tags))] pub fn repost_tags(repost_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsRepost, _, _>(repost_json, repost_build_tags) + build_tags_json::<Repost, _, _>(repost_json, repost_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = generic_repost_tags))] pub fn generic_repost_tags(repost_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGenericRepost, _, _>(repost_json, generic_repost_build_tags) + build_tags_json::<GenericRepost, _, _>(repost_json, generic_repost_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = report_tags))] pub fn report_tags(report_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsReport, _, _>(report_json, report_build_tags) + build_tags_json::<Report, _, _>(report_json, report_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = follow_tags))] pub fn follow_tags(follow_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsFollow, _, _>(follow_json, follow_build_tags) + build_tags_json::<Follow, _, _>(follow_json, follow_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = document_tags))] pub fn document_tags(document_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsDocument, _, _>(document_json, document_build_tags) + build_tags_json::<Document, _, _>(document_json, document_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = coop_tags))] pub fn coop_tags(coop_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsCoop, _, _>(coop_json, coop_build_tags) + build_tags_json::<Coop, _, _>(coop_json, coop_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = farm_tags))] pub fn farm_tags(farm_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsFarm, _, _>(farm_json, farm_build_tags) + build_tags_json::<Farm, _, _>(farm_json, farm_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = list_tags))] pub fn list_tags(list_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsList, _, _>(list_json, list_build_tags) + build_tags_json::<List, _, _>(list_json, list_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = list_set_tags))] pub fn list_set_tags(list_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsListSet, _, _>(list_json, list_set_build_tags) + build_tags_json::<ListSet, _, _>(list_json, list_set_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = plot_tags))] pub fn plot_tags(plot_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsPlot, _, _>(plot_json, plot_build_tags) + build_tags_json::<Plot, _, _>(plot_json, plot_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = job_request_tags))] pub fn job_request_tags(job_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json_infallible::<RadrootsJobRequest, _>(job_json, job_request_build_tags) + build_tags_json_infallible::<JobRequest, _>(job_json, job_request_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = job_result_tags))] pub fn job_result_tags(job_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json_infallible::<RadrootsJobResult, _>(job_json, job_result_build_tags) + build_tags_json_infallible::<JobResult, _>(job_json, job_result_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = job_feedback_tags))] pub fn job_feedback_tags(job_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json_infallible::<RadrootsJobFeedback, _>(job_json, job_feedback_build_tags) + build_tags_json_infallible::<JobFeedback, _>(job_json, job_feedback_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = reaction_tags))] pub fn reaction_tags(reaction_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsReaction, _, _>(reaction_json, reaction_build_tags) + build_tags_json::<Reaction, _, _>(reaction_json, reaction_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = message_tags))] pub fn message_tags(message_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsMessage, _, _>(message_json, message_build_tags) + build_tags_json::<Message, _, _>(message_json, message_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = message_file_tags))] pub fn message_file_tags(message_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsMessageFile, _, _>(message_json, message_file_build_tags) + build_tags_json::<MessageFile, _, _>(message_json, message_file_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = seal_tags))] pub fn seal_tags(seal_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsSeal, _, _>(seal_json, seal_build_tags) + build_tags_json::<Seal, _, _>(seal_json, seal_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = gift_wrap_tags))] pub fn gift_wrap_tags(gift_wrap_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGiftWrap, _, _>(gift_wrap_json, gift_wrap_build_tags) + build_tags_json::<GiftWrap, _, _>(gift_wrap_json, gift_wrap_build_tags) } #[cfg_attr( @@ -732,10 +715,7 @@ pub fn gift_wrap_tags(gift_wrap_json: &str) -> Result<String, RadrootsJsValue> { wasm_bindgen(js_name = farm_workspace_manifest_tags) )] pub fn farm_workspace_manifest_tags(workspace_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsFarmWorkspaceManifest, _, _>( - workspace_json, - farm_workspace_build_tags, - ) + build_tags_json::<FarmWorkspaceManifest, _, _>(workspace_json, farm_workspace_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = farm_crdt_change_tags))] @@ -748,82 +728,82 @@ pub fn farm_crdt_change_tags(input_json: &str) -> Result<String, RadrootsJsValue #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = farm_file_metadata_tags))] pub fn farm_file_metadata_tags(file_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsFarmFileMetadata, _, _>(file_json, farm_file_metadata_build_tags) + build_tags_json::<FarmFileMetadata, _, _>(file_json, farm_file_metadata_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = relay_auth_tags))] pub fn relay_auth_tags(auth_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsRelayAuth, _, _>(auth_json, relay_auth_build_tags) + build_tags_json::<RelayAuth, _, _>(auth_json, relay_auth_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = http_auth_tags))] pub fn http_auth_tags(auth_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsHttpAuth, _, _>(auth_json, http_auth_build_tags) + build_tags_json::<HttpAuth, _, _>(auth_json, http_auth_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_put_user_tags))] pub fn group_put_user_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupPutUser, _, _>(group_json, group_put_user_build_tags) + build_tags_json::<GroupPutUser, _, _>(group_json, group_put_user_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_remove_user_tags))] pub fn group_remove_user_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupRemoveUser, _, _>(group_json, group_remove_user_build_tags) + build_tags_json::<GroupRemoveUser, _, _>(group_json, group_remove_user_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_create_group_tags))] pub fn group_create_group_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupCreateGroup, _, _>(group_json, group_create_group_build_tags) + build_tags_json::<GroupCreateGroup, _, _>(group_json, group_create_group_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_edit_metadata_tags))] pub fn group_edit_metadata_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupEditMetadata, _, _>(group_json, group_edit_metadata_build_tags) + build_tags_json::<GroupEditMetadata, _, _>(group_json, group_edit_metadata_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_delete_group_tags))] pub fn group_delete_group_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupDeleteGroup, _, _>(group_json, group_delete_group_build_tags) + build_tags_json::<GroupDeleteGroup, _, _>(group_json, group_delete_group_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_delete_event_tags))] pub fn group_delete_event_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupDeleteEvent, _, _>(group_json, group_delete_event_build_tags) + build_tags_json::<GroupDeleteEvent, _, _>(group_json, group_delete_event_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_create_invite_tags))] pub fn group_create_invite_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupCreateInvite, _, _>(group_json, group_create_invite_build_tags) + build_tags_json::<GroupCreateInvite, _, _>(group_json, group_create_invite_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_join_request_tags))] pub fn group_join_request_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupJoinRequest, _, _>(group_json, group_join_request_build_tags) + build_tags_json::<GroupJoinRequest, _, _>(group_json, group_join_request_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_leave_request_tags))] pub fn group_leave_request_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupLeaveRequest, _, _>(group_json, group_leave_request_build_tags) + build_tags_json::<GroupLeaveRequest, _, _>(group_json, group_leave_request_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_metadata_tags))] pub fn group_metadata_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupMetadata, _, _>(group_json, group_metadata_build_tags) + build_tags_json::<GroupMetadata, _, _>(group_json, group_metadata_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_admins_tags))] pub fn group_admins_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupAdmins, _, _>(group_json, group_admins_build_tags) + build_tags_json::<GroupAdmins, _, _>(group_json, group_admins_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_members_tags))] pub fn group_members_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupMembers, _, _>(group_json, group_members_build_tags) + build_tags_json::<GroupMembers, _, _>(group_json, group_members_build_tags) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = group_roles_tags))] pub fn group_roles_tags(group_json: &str) -> Result<String, RadrootsJsValue> { - build_tags_json::<RadrootsGroupRoles, _, _>(group_json, group_roles_build_tags) + build_tags_json::<GroupRoles, _, _>(group_json, group_roles_build_tags) } #[cfg(test)] @@ -834,52 +814,43 @@ mod tests { KIND_FARM_FILE_METADATA, KIND_FILE_METADATA, KIND_KNOWLEDGE_CLAIM, KIND_KNOWLEDGE_SOURCE, KIND_WIKI_ARTICLE, }; - use radroots_event::envelope::{ - RadrootsEventEnvelope, RadrootsEventEnvelopeLimits, RadrootsEventEnvelopeParts, - }; - use radroots_event::farm::RadrootsFarmRef; + use radroots_event::envelope::{EventEnvelope, EventEnvelopeLimits, EventEnvelopeParts}; + use radroots_event::farm::FarmRef; use radroots_event::farm::crdt::{ - RADROOTS_FARM_CRDT_CHANGE_SCHEMA, RadrootsCrdtBackend, RadrootsFarmCrdtDocumentKind, - RadrootsFarmSemanticKind, - }; - use radroots_event::farm::file::{ - RadrootsFarmFileDimensions, RadrootsFarmFileMetadata, RadrootsFarmFileSource, + CrdtBackend, FarmCrdtDocumentKind, FarmSemanticKind, RADROOTS_FARM_CRDT_CHANGE_SCHEMA, }; + use radroots_event::farm::file::{FarmFileDimensions, FarmFileMetadata, FarmFileSource}; use radroots_event::farm::workspace::{ - RADROOTS_FARM_WORKSPACE_PROTOCOL_VERSION, RADROOTS_FARM_WORKSPACE_SCHEMA, - RadrootsFarmWorkspaceManifest, RadrootsFarmWorkspaceMediaServer, RadrootsFarmWorkspaceRef, - RadrootsFarmWorkspaceRelay, RadrootsFarmWorkspaceRelayMode, + FarmWorkspaceManifest, FarmWorkspaceMediaServer, FarmWorkspaceRef, FarmWorkspaceRelay, + FarmWorkspaceRelayMode, RADROOTS_FARM_WORKSPACE_PROTOCOL_VERSION, + RADROOTS_FARM_WORKSPACE_SCHEMA, }; use radroots_event::knowledge::{ - RADROOTS_KNOWLEDGE_CLAIM_SCHEMA, RADROOTS_KNOWLEDGE_FIELD_REPORT_SCHEMA, - RADROOTS_KNOWLEDGE_RELATION_SCHEMA, RADROOTS_KNOWLEDGE_REVIEW_SCHEMA, - RADROOTS_KNOWLEDGE_SCHEMA_VERSION, RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, - RadrootsAddressableRef, RadrootsKnowledgeCitationSpan, RadrootsKnowledgeFieldContext, - RadrootsKnowledgeLocation, RadrootsKnowledgeLocationPrecision, RadrootsKnowledgeNodeRef, - RadrootsKnowledgeObservation, RadrootsKnowledgeObservationValue, - RadrootsKnowledgeReviewScope, RadrootsKnowledgeReviewScore, RadrootsKnowledgeReviewTarget, - RadrootsWikiArticleVersionRef, - }; - use radroots_event::listing::operational::{ - RadrootsOperationalListingBin, RadrootsOperationalListingProduct, + AddressableRef, KnowledgeCitationSpan, KnowledgeFieldContext, KnowledgeLocation, + KnowledgeLocationPrecision, KnowledgeNodeRef, KnowledgeObservation, + KnowledgeObservationValue, KnowledgeReviewScope, KnowledgeReviewScore, + KnowledgeReviewTarget, RADROOTS_KNOWLEDGE_CLAIM_SCHEMA, + RADROOTS_KNOWLEDGE_FIELD_REPORT_SCHEMA, RADROOTS_KNOWLEDGE_RELATION_SCHEMA, + RADROOTS_KNOWLEDGE_REVIEW_SCHEMA, RADROOTS_KNOWLEDGE_SCHEMA_VERSION, + RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, WikiArticleVersionRef, }; + use radroots_event::listing::operational::{OperationalListingBin, OperationalListingProduct}; use radroots_event::social::group::{ - RadrootsGroupAdmins, RadrootsGroupCreateGroup, RadrootsGroupCreateInvite, - RadrootsGroupDeleteEvent, RadrootsGroupDeleteGroup, RadrootsGroupEditMetadata, - RadrootsGroupEditableMetadata, RadrootsGroupJoinRequest, RadrootsGroupLeaveRequest, - RadrootsGroupMembers, RadrootsGroupMetadata, RadrootsGroupPutUser, RadrootsGroupRemoveUser, - RadrootsGroupRole, RadrootsGroupRoles, RadrootsGroupUserRef, + GroupAdmins, GroupCreateGroup, GroupCreateInvite, GroupDeleteEvent, GroupDeleteGroup, + GroupEditMetadata, GroupEditableMetadata, GroupJoinRequest, GroupLeaveRequest, + GroupMembers, GroupMetadata, GroupPutUser, GroupRemoveUser, GroupRole, GroupRoles, + GroupUserRef, }; - use radroots_event::social::http_auth::RadrootsHttpAuth; + use radroots_event::social::http_auth::HttpAuth; use radroots_event::social::job::JobInputType; - use radroots_event::social::job_request::{RadrootsJobInput, RadrootsJobParam}; - use radroots_event::social::relay_auth::RadrootsRelayAuth; + use radroots_event::social::job_request::{JobInput, JobParam}; + use radroots_event::social::relay_auth::RelayAuth; use radroots_event::social::{ - RadrootsReportFileTarget, RadrootsReportType, RadrootsSocialFarmAnchor, - RadrootsSocialLocation, RadrootsSocialMediaDimensions, RadrootsSocialTarget, + ReportFileTarget, ReportType, SocialFarmAnchor, SocialLocation, SocialMediaDimensions, + SocialTarget, }; - fn sample_listing() -> RadrootsOperationalListing { + fn sample_listing() -> OperationalListing { let quantity = Quantity::try_new(Decimal::from(1u32), Unit::Each).expect("positive fixture quantity"); let price = QuantityPrice::try_new( @@ -889,14 +860,14 @@ mod tests { ) .expect("non-zero fixture pricing quantity"); - RadrootsOperationalListing { + OperationalListing { d_tag: "AAAAAAAAAAAAAAAAAAAAAg".parse().expect("listing d tag"), published_at: None, - farm: RadrootsFarmRef { + farm: FarmRef { pubkey: "farm_pubkey".to_string(), d_tag: "AAAAAAAAAAAAAAAAAAAAAA".to_string(), }, - product: RadrootsOperationalListingProduct { + product: OperationalListingProduct { key: "sku".to_string(), title: "widget".to_string(), category: "tools".to_string(), @@ -908,7 +879,7 @@ mod tests { year: None, }, primary_bin_id: "bin-1".parse().expect("primary bin id"), - bins: vec![RadrootsOperationalListingBin { + bins: vec![OperationalListingBin { bin_id: "bin-1".parse().expect("bin id"), quantity, price_per_canonical_unit: price, @@ -937,9 +908,9 @@ mod tests { seed.to_string().repeat(64) } - fn social_farm_anchor() -> RadrootsSocialFarmAnchor { - RadrootsSocialFarmAnchor { - farm: RadrootsFarmRef { + fn social_farm_anchor() -> SocialFarmAnchor { + SocialFarmAnchor { + farm: FarmRef { pubkey: synthetic_pubkey('a'), d_tag: "AAAAAAAAAAAAAAAAAAAAAA".to_string(), }, @@ -947,8 +918,8 @@ mod tests { } } - fn event_target(kind: u32, seed: char) -> RadrootsSocialTarget { - RadrootsSocialTarget::Event { + fn event_target(kind: u32, seed: char) -> SocialTarget { + SocialTarget::Event { id: synthetic_event_id(seed), author: Some(synthetic_pubkey('b')), event_kind: Some(kind), @@ -956,9 +927,9 @@ mod tests { } } - fn address_target(kind: u32, d_tag: &str) -> RadrootsSocialTarget { + fn address_target(kind: u32, d_tag: &str) -> SocialTarget { let author = synthetic_pubkey('c'); - RadrootsSocialTarget::Address { + SocialTarget::Address { address: format!("{kind}:{author}:{d_tag}"), author: Some(author), event_kind: Some(kind), @@ -966,8 +937,8 @@ mod tests { } } - fn knowledge_event_ref(seed: char, kind: u32) -> radroots_event::tag::RadrootsEventRef { - radroots_event::tag::RadrootsEventRef { + fn knowledge_event_ref(seed: char, kind: u32) -> radroots_event::tag::EventRef { + radroots_event::tag::EventRef { id: synthetic_event_id(seed), author: radroots_identity::PublicKey::from_hex(&synthetic_pubkey('a')) .expect("fixture public key"), @@ -977,8 +948,8 @@ mod tests { } } - fn knowledge_address_ref() -> RadrootsAddressableRef { - RadrootsAddressableRef { + fn knowledge_address_ref() -> AddressableRef { + AddressableRef { kind: KIND_WIKI_ARTICLE, pubkey: synthetic_pubkey('a'), d_tag: "soil-health".to_string(), @@ -986,15 +957,15 @@ mod tests { } } - fn sample_wiki_article() -> RadrootsWikiArticle { - RadrootsWikiArticle { + fn sample_wiki_article() -> WikiArticle { + WikiArticle { d_tag: "soil-health".to_string(), title: Some("Soil health".to_string()), content_djot: "# Soil health".to_string(), summary: Some("Living soil basics".to_string()), topics: vec!["soil".to_string()], references: vec![knowledge_event_ref('1', KIND_KNOWLEDGE_SOURCE)], - forked_from: vec![RadrootsWikiArticleVersionRef { + forked_from: vec![WikiArticleVersionRef { event_id: synthetic_event_id('b'), address_ref: knowledge_address_ref(), }], @@ -1002,15 +973,15 @@ mod tests { } } - fn sample_wiki_redirect() -> RadrootsWikiRedirect { - RadrootsWikiRedirect { + fn sample_wiki_redirect() -> WikiRedirect { + WikiRedirect { d_tag: "soil".to_string(), target: knowledge_address_ref(), } } - fn sample_wiki_merge_request() -> RadrootsWikiMergeRequest { - RadrootsWikiMergeRequest { + fn sample_wiki_merge_request() -> WikiMergeRequest { + WikiMergeRequest { target_article: knowledge_address_ref(), destination_pubkey: synthetic_pubkey('a'), base_version_event_id: Some(synthetic_event_id('e')), @@ -1019,8 +990,8 @@ mod tests { } } - fn sample_knowledge_source() -> RadrootsKnowledgeSource { - RadrootsKnowledgeSource { + fn sample_knowledge_source() -> KnowledgeSource { + KnowledgeSource { schema: RADROOTS_KNOWLEDGE_SOURCE_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, d_tag: "soil-source".to_string(), @@ -1038,13 +1009,13 @@ mod tests { } } - fn sample_knowledge_claim() -> RadrootsKnowledgeClaim { - RadrootsKnowledgeClaim { + fn sample_knowledge_claim() -> KnowledgeClaim { + KnowledgeClaim { schema: RADROOTS_KNOWLEDGE_CLAIM_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, claim_type: "practice_effect".to_string(), text: "Cover crops improve soil structure.".to_string(), - citation_spans: vec![RadrootsKnowledgeCitationSpan { + citation_spans: vec![KnowledgeCitationSpan { source_ref: knowledge_event_ref('4', KIND_KNOWLEDGE_SOURCE), artifact_ref: None, page_start: Some(12), @@ -1060,8 +1031,8 @@ mod tests { } } - fn sample_knowledge_node_ref(label: &str) -> RadrootsKnowledgeNodeRef { - RadrootsKnowledgeNodeRef { + fn sample_knowledge_node_ref(label: &str) -> KnowledgeNodeRef { + KnowledgeNodeRef { node_type: "event".to_string(), event_ref: Some(knowledge_event_ref('6', KIND_KNOWLEDGE_CLAIM)), address_ref: None, @@ -1070,8 +1041,8 @@ mod tests { } } - fn sample_knowledge_relation() -> RadrootsKnowledgeRelation { - RadrootsKnowledgeRelation { + fn sample_knowledge_relation() -> KnowledgeRelation { + KnowledgeRelation { schema: RADROOTS_KNOWLEDGE_RELATION_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, subject: sample_knowledge_node_ref("cover crops"), @@ -1083,21 +1054,21 @@ mod tests { } } - fn sample_knowledge_review() -> RadrootsKnowledgeReview { - RadrootsKnowledgeReview { + fn sample_knowledge_review() -> KnowledgeReview { + KnowledgeReview { schema: RADROOTS_KNOWLEDGE_REVIEW_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, - target: RadrootsKnowledgeReviewTarget { + target: KnowledgeReviewTarget { event_id: synthetic_event_id('8'), author_pubkey: synthetic_pubkey('a'), kind: KIND_KNOWLEDGE_CLAIM, address: None, relays: vec!["wss://relay.example.test".to_string()], - review_scope: RadrootsKnowledgeReviewScope::SpecificVersion, + review_scope: KnowledgeReviewScope::SpecificVersion, }, reviewer_role: "peer".to_string(), verdict: "needs_more_evidence".to_string(), - scores: vec![RadrootsKnowledgeReviewScore { + scores: vec![KnowledgeReviewScore { dimension: "evidence".to_string(), value: "partial".to_string(), note: None, @@ -1107,16 +1078,16 @@ mod tests { } } - fn sample_knowledge_field_report() -> RadrootsKnowledgeFieldReport { - RadrootsKnowledgeFieldReport { + fn sample_knowledge_field_report() -> KnowledgeFieldReport { + KnowledgeFieldReport { schema: RADROOTS_KNOWLEDGE_FIELD_REPORT_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, report_type: "observation".to_string(), title: "Field observation".to_string(), summary: Some("Observed cover crop residue.".to_string()), - context: RadrootsKnowledgeFieldContext { - location_precision: RadrootsKnowledgeLocationPrecision::CoarseGeohash, - public_location: Some(RadrootsKnowledgeLocation { + context: KnowledgeFieldContext { + location_precision: KnowledgeLocationPrecision::CoarseGeohash, + public_location: Some(KnowledgeLocation { label: Some("watershed".to_string()), region: Some("synthetic-region".to_string()), locality: None, @@ -1126,11 +1097,11 @@ mod tests { topics: vec!["field".to_string()], context_tags: vec!["observation".to_string()], }, - observations: vec![RadrootsKnowledgeObservation { + observations: vec![KnowledgeObservation { observation_type: "residue".to_string(), text: "Residue was visible across beds.".to_string(), observed_at: Some("2026-07-05".to_string()), - values: vec![RadrootsKnowledgeObservationValue { + values: vec![KnowledgeObservationValue { key: "coverage".to_string(), value: "medium".to_string(), unit: None, @@ -1160,7 +1131,7 @@ mod tests { .custom_created_at(nostr::Timestamp::from_secs(1_800_000_000)) .sign_with_keys(&keys) .expect("signed event"); - let envelope = RadrootsEventEnvelope::new(RadrootsEventEnvelopeParts { + let envelope = EventEnvelope::new(EventEnvelopeParts { id: event.id.to_hex(), author: event.pubkey.to_hex(), created_at: event.created_at.as_secs(), @@ -1178,15 +1149,15 @@ mod tests { serde_json::to_string(&envelope).expect("event json") } - fn social_location() -> RadrootsSocialLocation { - RadrootsSocialLocation { + fn social_location() -> SocialLocation { + SocialLocation { name: Some("field edge".to_string()), geohash: Some("c23nb62w20st".to_string()), } } - fn sample_article() -> RadrootsArticle { - RadrootsArticle { + fn sample_article() -> Article { + Article { d_tag: "AAAAAAAAAAAAAAAAAAAAAg".to_string(), title: "soil notes".to_string(), content: "# soil notes".to_string(), @@ -1199,8 +1170,8 @@ mod tests { } } - fn sample_public_file_metadata() -> RadrootsFileMetadata { - RadrootsFileMetadata { + fn sample_public_file_metadata() -> FileMetadata { + FileMetadata { url: "https://media.example.test/public.jpg".to_string(), mime_type: "image/jpeg".to_string(), sha256: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".to_string(), @@ -1208,7 +1179,7 @@ mod tests { "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789".to_string(), ), size: Some(4096), - dimensions: Some(RadrootsSocialMediaDimensions { + dimensions: Some(SocialMediaDimensions { width: 1200, height: 800, }), @@ -1224,34 +1195,34 @@ mod tests { } } - fn sample_reaction() -> RadrootsReaction { - RadrootsReaction { + fn sample_reaction() -> Reaction { + Reaction { target: address_target(30023, "AAAAAAAAAAAAAAAAAAAAAg"), content: String::new(), } } - fn sample_repost() -> RadrootsRepost { - RadrootsRepost { + fn sample_repost() -> Repost { + Repost { target: event_target(1, 'b'), content: Some("field update".to_string()), } } - fn sample_generic_repost() -> RadrootsGenericRepost { - RadrootsGenericRepost { + fn sample_generic_repost() -> GenericRepost { + GenericRepost { target: address_target(30023, "AAAAAAAAAAAAAAAAAAAAAg"), target_kind: 30023, content: Some("article share".to_string()), } } - fn sample_report() -> RadrootsReport { - RadrootsReport { + fn sample_report() -> Report { + Report { reported_pubkey: synthetic_pubkey('b'), - report_type: RadrootsReportType::Spam, + report_type: ReportType::Spam, event: Some(event_target(1, 'c')), - file: Some(RadrootsReportFileTarget { + file: Some(ReportFileTarget { sha256: Some( "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".to_string(), ), @@ -1262,17 +1233,17 @@ mod tests { } } - fn sample_job_request() -> RadrootsJobRequest { - RadrootsJobRequest { + fn sample_job_request() -> JobRequest { + JobRequest { kind: 5100, - inputs: vec![RadrootsJobInput { + inputs: vec![JobInput { data: "alpha".to_string(), input_type: JobInputType::Text, relay: None, marker: None, }], output: None, - params: vec![RadrootsJobParam { + params: vec![JobParam { key: "mode".to_string(), value: "fast".to_string(), }], @@ -1284,22 +1255,22 @@ mod tests { } } - fn sample_workspace_manifest() -> RadrootsFarmWorkspaceManifest { - RadrootsFarmWorkspaceManifest { + fn sample_workspace_manifest() -> FarmWorkspaceManifest { + FarmWorkspaceManifest { d_tag: "AAAAAAAAAAAAAAAAAAAAAA".to_string(), schema: RADROOTS_FARM_WORKSPACE_SCHEMA.to_string(), farm_group_id: "field-group".to_string(), name: "Small Regen Farm".to_string(), owner_pubkey: "workspace_owner_pubkey".to_string(), - farm: Some(RadrootsFarmRef { + farm: Some(FarmRef { pubkey: "farm_pubkey".to_string(), d_tag: "AAAAAAAAAAAAAAAAAAAAAQ".to_string(), }), - relays: vec![RadrootsFarmWorkspaceRelay { + relays: vec![FarmWorkspaceRelay { url: "wss://relay.example.invalid/farm/field-group".to_string(), - mode: RadrootsFarmWorkspaceRelayMode::ReadWrite, + mode: FarmWorkspaceRelayMode::ReadWrite, }], - media_servers: vec![RadrootsFarmWorkspaceMediaServer { + media_servers: vec![FarmWorkspaceMediaServer { url: "https://media.example.invalid/farm/field-group".to_string(), service: "RadrootsPrivateMedia".to_string(), }], @@ -1310,51 +1281,51 @@ mod tests { } } - fn sample_crdt_change() -> RadrootsFarmCrdtChange { - RadrootsFarmCrdtChange { + fn sample_crdt_change() -> FarmCrdtChange { + FarmCrdtChange { schema: RADROOTS_FARM_CRDT_CHANGE_SCHEMA.to_string(), - workspace: RadrootsFarmWorkspaceRef { + workspace: FarmWorkspaceRef { pubkey: "workspace_pubkey".to_string(), d_tag: "AAAAAAAAAAAAAAAAAAAAAA".to_string(), }, farm_group_id: "field-group".to_string(), document_id: "AAAAAAAAAAAAAAAAAAAAAg".to_string(), - document_kind: RadrootsFarmCrdtDocumentKind::FarmTask, - crdt_backend: RadrootsCrdtBackend::Automerge, + document_kind: FarmCrdtDocumentKind::FarmTask, + crdt_backend: CrdtBackend::Automerge, crdt_backend_version: Some("0.x".to_string()), actor_id: "actor_abc".to_string(), change_hash: "crdt_hash_abc".to_string(), dependencies: Vec::new(), encoded_change: "abc-DEF_012".to_string(), - semantic_kind: RadrootsFarmSemanticKind::FarmTaskCreate, + semantic_kind: FarmSemanticKind::FarmTaskCreate, business_time_ms: 1_780_000_000_000, author_member_id: Some("member_abc".to_string()), app_version: Some("0.1.0".to_string()), } } - fn sample_file_metadata() -> RadrootsFarmFileMetadata { - RadrootsFarmFileMetadata { + fn sample_file_metadata() -> FarmFileMetadata { + FarmFileMetadata { d_tag: "AAAAAAAAAAAAAAAAAAAAAQ".to_string(), - workspace: RadrootsFarmWorkspaceRef { + workspace: FarmWorkspaceRef { pubkey: "workspace_pubkey".to_string(), d_tag: "AAAAAAAAAAAAAAAAAAAAAA".to_string(), }, farm_group_id: "field-group".to_string(), owner_document_id: "AAAAAAAAAAAAAAAAAAAAAg".to_string(), - owner_document_kind: RadrootsFarmCrdtDocumentKind::FarmTask, + owner_document_kind: FarmCrdtDocumentKind::FarmTask, caption: Some("Tomatoes harvested from Patch Y.".to_string()), url: "https://media.example.invalid/blob/sha256".to_string(), mime_type: "image/jpeg".to_string(), sha256: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".to_string(), original_sha256: None, size_bytes: Some(123_456), - dimensions: Some(RadrootsFarmFileDimensions { w: 1600, h: 1200 }), + dimensions: Some(FarmFileDimensions { w: 1600, h: 1200 }), blurhash: None, - thumb: Some(RadrootsFarmFileSource { + thumb: Some(FarmFileSource { url: "https://media.example.invalid/thumb/sha256".to_string(), mime_type: Some("image/jpeg".to_string()), - dimensions: Some(RadrootsFarmFileDimensions { w: 320, h: 240 }), + dimensions: Some(FarmFileDimensions { w: 320, h: 240 }), }), image: None, alt: Some("Harvested tomatoes in a crate".to_string()), @@ -1362,8 +1333,8 @@ mod tests { } } - fn sample_group_metadata() -> RadrootsGroupEditableMetadata { - RadrootsGroupEditableMetadata { + fn sample_group_metadata() -> GroupEditableMetadata { + GroupEditableMetadata { name: Some("Small Regen Farm".to_string()), about: Some("Field app group".to_string()), picture: Some("https://media.example.invalid/group.png".to_string()), @@ -1375,15 +1346,15 @@ mod tests { } } - fn sample_group_user(role: &str) -> RadrootsGroupUserRef { - RadrootsGroupUserRef { + fn sample_group_user(role: &str) -> GroupUserRef { + GroupUserRef { pubkey: format!("{role}_pubkey"), roles: vec![role.to_string()], } } - fn sample_group_role() -> RadrootsGroupRole { - RadrootsGroupRole { + fn sample_group_role() -> GroupRole { + GroupRole { name: "member".to_string(), description: Some("can read and write group events".to_string()), permissions: vec!["read".to_string(), "write".to_string()], @@ -1626,8 +1597,7 @@ mod tests { &serde_json::to_string(&input).expect("media request"), ) .expect("byte-verified PhotoUpdate"); - let encoded: RadrootsNip01EventWireParts = - serde_json::from_str(&encoded).expect("wire parts"); + let encoded: Nip01EventWireParts = serde_json::from_str(&encoded).expect("wire parts"); assert_eq!(encoded.tags.len(), 1); assert!(encoded.tags[0].contains(&format!("x {hash}"))); assert!(encoded.tags[0].contains(&"size 4".to_owned())); @@ -1674,7 +1644,7 @@ mod tests { fn ask_allows_zero_media_while_photo_update_requires_media() { let ask = social_ask_build_authored_draft(r#"{"content":"When is harvest?","images":[]}"#) .expect("Ask without media"); - let ask: RadrootsNip01EventWireParts = serde_json::from_str(&ask).expect("Ask wire parts"); + let ask: Nip01EventWireParts = serde_json::from_str(&ask).expect("Ask wire parts"); assert_eq!( ask.tags, vec![vec!["t".to_owned(), "radroots-ask".to_owned()]] @@ -1731,7 +1701,7 @@ mod tests { assert!(article_tags(&serde_json::to_string(&article).expect("article json")).is_err()); let mut reaction = sample_reaction(); - reaction.target = RadrootsSocialTarget::External { + reaction.target = SocialTarget::External { id: "https://example.test/object".to_string(), external_kind: "web".to_string(), hint: None, @@ -1919,7 +1889,7 @@ mod tests { let mut oversized: serde_json::Value = serde_json::from_str(&signed_claim_event_json()).expect("event json"); oversized["content"] = serde_json::Value::String( - "x".repeat(RadrootsEventEnvelopeLimits::default().max_content_bytes + 1), + "x".repeat(EventEnvelopeLimits::default().max_content_bytes + 1), ); let oversized_error = verify_and_decode_event_json(&oversized.to_string()).expect_err("oversized content"); @@ -1965,14 +1935,14 @@ mod tests { let file_json = serde_json::to_string(&sample_file_metadata()).expect("file json"); assert_tags_json(farm_file_metadata_tags(&file_json)); - let relay_auth_json = serde_json::to_string(&RadrootsRelayAuth { + let relay_auth_json = serde_json::to_string(&RelayAuth { relay: "wss://relay.example.invalid/farm/field-group".to_string(), challenge: "relay-provided-challenge".to_string(), }) .expect("relay auth json"); assert_tags_json(relay_auth_tags(&relay_auth_json)); - let http_auth_json = serde_json::to_string(&RadrootsHttpAuth { + let http_auth_json = serde_json::to_string(&HttpAuth { url: "https://media.example.invalid/upload".to_string(), method: "POST".to_string(), payload_sha256: Some( @@ -1998,7 +1968,7 @@ mod tests { fn group_bindings_encode_to_json_when_input_is_valid() { let metadata = sample_group_metadata(); assert_tags_json(group_put_user_tags( - &serde_json::to_string(&RadrootsGroupPutUser { + &serde_json::to_string(&GroupPutUser { group_id: "field-group".to_string(), message: Some("add member".to_string()), pubkey: "member_pubkey".to_string(), @@ -2007,7 +1977,7 @@ mod tests { .expect("put user json"), )); assert_tags_json(group_remove_user_tags( - &serde_json::to_string(&RadrootsGroupRemoveUser { + &serde_json::to_string(&GroupRemoveUser { group_id: "field-group".to_string(), message: Some("remove member".to_string()), pubkey: "member_pubkey".to_string(), @@ -2015,7 +1985,7 @@ mod tests { .expect("remove user json"), )); assert_tags_json(group_create_group_tags( - &serde_json::to_string(&RadrootsGroupCreateGroup { + &serde_json::to_string(&GroupCreateGroup { group_id: "field-group".to_string(), message: Some("create group".to_string()), metadata: metadata.clone(), @@ -2023,7 +1993,7 @@ mod tests { .expect("create group json"), )); assert_tags_json(group_edit_metadata_tags( - &serde_json::to_string(&RadrootsGroupEditMetadata { + &serde_json::to_string(&GroupEditMetadata { group_id: "field-group".to_string(), message: Some("edit metadata".to_string()), metadata: metadata.clone(), @@ -2031,14 +2001,14 @@ mod tests { .expect("edit metadata json"), )); assert_tags_json(group_delete_group_tags( - &serde_json::to_string(&RadrootsGroupDeleteGroup { + &serde_json::to_string(&GroupDeleteGroup { group_id: "field-group".to_string(), message: Some("delete group".to_string()), }) .expect("delete group json"), )); assert_tags_json(group_delete_event_tags( - &serde_json::to_string(&RadrootsGroupDeleteEvent { + &serde_json::to_string(&GroupDeleteEvent { group_id: "field-group".to_string(), message: Some("delete event".to_string()), event_id: "event_id".to_string(), @@ -2046,7 +2016,7 @@ mod tests { .expect("delete event json"), )); let invite_tags = tags_json(group_create_invite_tags( - &serde_json::to_string(&RadrootsGroupCreateInvite { + &serde_json::to_string(&GroupCreateInvite { group_id: "field-group".to_string(), message: Some("join the field group".to_string()), code: "invite-code".to_string(), @@ -2055,7 +2025,7 @@ mod tests { )); assert!(invite_tags.contains(&vec!["code".to_string(), "invite-code".to_string()])); assert_tags_json(group_join_request_tags( - &serde_json::to_string(&RadrootsGroupJoinRequest { + &serde_json::to_string(&GroupJoinRequest { group_id: "field-group".to_string(), message: Some("requesting access".to_string()), code: Some("invite-code".to_string()), @@ -2063,14 +2033,14 @@ mod tests { .expect("join json"), )); assert_tags_json(group_leave_request_tags( - &serde_json::to_string(&RadrootsGroupLeaveRequest { + &serde_json::to_string(&GroupLeaveRequest { group_id: "field-group".to_string(), message: Some("leaving".to_string()), }) .expect("leave json"), )); let metadata_tags = tags_json(group_metadata_tags( - &serde_json::to_string(&RadrootsGroupMetadata { + &serde_json::to_string(&GroupMetadata { d_tag: "field-group".to_string(), metadata, }) @@ -2084,7 +2054,7 @@ mod tests { KIND_FARM_FILE_METADATA.to_string() ])); assert_tags_json(group_admins_tags( - &serde_json::to_string(&RadrootsGroupAdmins { + &serde_json::to_string(&GroupAdmins { d_tag: "field-group".to_string(), description: Some("group admins".to_string()), admins: vec![sample_group_user("admin")], @@ -2092,7 +2062,7 @@ mod tests { .expect("admins json"), )); assert_tags_json(group_members_tags( - &serde_json::to_string(&RadrootsGroupMembers { + &serde_json::to_string(&GroupMembers { d_tag: "field-group".to_string(), description: Some("group members".to_string()), members: vec![sample_group_user("member")], @@ -2100,7 +2070,7 @@ mod tests { .expect("members json"), )); assert_tags_json(group_roles_tags( - &serde_json::to_string(&RadrootsGroupRoles { + &serde_json::to_string(&GroupRoles { d_tag: "field-group".to_string(), description: Some("group roles".to_string()), roles: vec![sample_group_role()], 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_event::envelope::{RadrootsEventEnvelope, RadrootsEventEnvelopeParts}; +use radroots_event::envelope::{EventEnvelope, EventEnvelopeParts}; #[cfg(any(target_arch = "wasm32", test))] use radroots_replica_sync::RadrootsReplicaIngestOutcome; use radroots_replica_sync::RadrootsReplicaSyncRequest; @@ -52,10 +52,10 @@ 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<RadrootsEventEnvelope, String> { +pub fn parse_event_model(event_json: &str) -> Result<EventEnvelope, String> { let envelope: EventEnvelopeInput = serde_json::from_str(event_json).map_err(|error| error.to_string())?; - RadrootsEventEnvelope::new(RadrootsEventEnvelopeParts { + EventEnvelope::new(EventEnvelopeParts { id: envelope.id, author: envelope.author, created_at: envelope.created_at, diff --git a/crates/sdk/examples/runtime_local.rs b/crates/sdk/examples/runtime_local.rs @@ -1,13 +1,12 @@ use radroots_authority::{RadrootsActorContext, RadrootsLocalEventSigner}; use radroots_core::{Currency, Decimal, Money, Quantity, QuantityPrice, Unit}; use radroots_event::contract::AuthorRole; -use radroots_event::farm::RadrootsFarmRef; -use radroots_event::id::{RadrootsDTag, RadrootsInventoryBinId}; +use radroots_event::farm::FarmRef; +use radroots_event::id::{DTag, InventoryBinId}; use radroots_event::listing::operational::{ - RadrootsOperationalListing, RadrootsOperationalListingAvailability, - RadrootsOperationalListingBin, RadrootsOperationalListingDeliveryMethod, - RadrootsOperationalListingProduct, RadrootsOperationalListingPublicLocation, - RadrootsOperationalListingStatus, + OperationalListing, OperationalListingAvailability, OperationalListingBin, + OperationalListingDeliveryMethod, OperationalListingProduct, OperationalListingPublicLocation, + OperationalListingStatus, }; use radroots_nostr::prelude::RadrootsNostrKeys; use radroots_sdk::{ @@ -66,15 +65,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { Ok(()) } -fn sample_listing(seller: &str) -> RadrootsOperationalListing { - RadrootsOperationalListing { - d_tag: RadrootsDTag::parse("AAAAAAAAAAAAAAAAAAAAAQ").expect("d tag"), +fn sample_listing(seller: &str) -> OperationalListing { + OperationalListing { + d_tag: DTag::parse("AAAAAAAAAAAAAAAAAAAAAQ").expect("d tag"), published_at: None, - farm: RadrootsFarmRef { + farm: FarmRef { pubkey: seller.to_owned(), d_tag: "AAAAAAAAAAAAAAAAAAAAAA".to_owned(), }, - product: RadrootsOperationalListingProduct { + product: OperationalListingProduct { key: "coffee".to_owned(), title: "Coffee".to_owned(), category: "coffee".to_owned(), @@ -85,9 +84,9 @@ fn sample_listing(seller: &str) -> RadrootsOperationalListing { profile: None, year: None, }, - primary_bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), - bins: vec![RadrootsOperationalListingBin { - bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), + primary_bin_id: InventoryBinId::parse("bin-1").expect("bin id"), + bins: vec![OperationalListingBin { + bin_id: InventoryBinId::parse("bin-1").expect("bin id"), quantity: Quantity::try_new(Decimal::from(1000u32), Unit::MassG) .expect("positive example quantity"), price_per_canonical_unit: QuantityPrice::try_new( @@ -107,11 +106,11 @@ fn sample_listing(seller: &str) -> RadrootsOperationalListing { plot: None, discounts: None, inventory_available: Some(Decimal::from(5u32)), - availability: Some(RadrootsOperationalListingAvailability::Status { - status: RadrootsOperationalListingStatus::Active, + availability: Some(OperationalListingAvailability::Status { + status: OperationalListingStatus::Active, }), - delivery_method: Some(RadrootsOperationalListingDeliveryMethod::Pickup), - location: Some(RadrootsOperationalListingPublicLocation { + delivery_method: Some(OperationalListingDeliveryMethod::Pickup), + location: Some(OperationalListingPublicLocation { primary: "Victoria".to_owned(), city: Some("Victoria".to_owned()), region: Some("British Columbia".to_owned()), diff --git a/crates/sdk/examples/sdk_v1_knowledge_prepare.rs b/crates/sdk/examples/sdk_v1_knowledge_prepare.rs @@ -1,5 +1,5 @@ use nostr::{EventBuilder, Keys, Kind, Tag, Timestamp}; -use radroots_event::envelope::RadrootsEventEnvelopeParts; +use radroots_event::envelope::EventEnvelopeParts; use radroots_identity::PublicKey; use radroots_sdk::knowledge::prelude::*; @@ -36,9 +36,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { } fn sign_parts( - parts: RadrootsNip01EventWireParts, + parts: Nip01EventWireParts, keys: &Keys, -) -> Result<RadrootsEventEnvelope, Box<dyn std::error::Error>> { +) -> Result<EventEnvelope, Box<dyn std::error::Error>> { let tags = parts .tags .into_iter() @@ -48,7 +48,7 @@ fn sign_parts( .tags(tags) .custom_created_at(Timestamp::from_secs(u64::from(CREATED_AT))) .sign_with_keys(keys)?; - Ok(RadrootsEventEnvelope::new(RadrootsEventEnvelopeParts { + Ok(EventEnvelope::new(EventEnvelopeParts { id: event.id.to_hex(), author: event.pubkey.to_hex(), created_at: event.created_at.as_secs(), @@ -68,8 +68,8 @@ fn hex_64(character: char) -> String { character.to_string().repeat(64) } -fn event_ref(character: char, kind: u32) -> RadrootsEventRef { - RadrootsEventRef { +fn event_ref(character: char, kind: u32) -> EventRef { + EventRef { id: hex_64(character), author: PublicKey::from_hex( "585591529da0bab31b3b1b1f986611cf5f435dca84f978c89ee8a40cca7103df", @@ -85,7 +85,7 @@ fn claim_builder() -> RadrootsKnowledgeClaimBuilder { RadrootsKnowledgeClaimBuilder::new() .claim_type("practice_effect") .text("Cover crops improve soil structure.") - .citation_span(RadrootsKnowledgeCitationSpan { + .citation_span(KnowledgeCitationSpan { source_ref: event_ref('4', KIND_KNOWLEDGE_SOURCE), artifact_ref: None, page_start: Some(12), diff --git a/crates/sdk/examples/sdk_v1_listing_prepare.rs b/crates/sdk/examples/sdk_v1_listing_prepare.rs @@ -1,13 +1,12 @@ use radroots_authority::RadrootsActorContext; use radroots_core::{Currency, Decimal, Money, Quantity, QuantityPrice, Unit}; use radroots_event::contract::AuthorRole; -use radroots_event::farm::RadrootsFarmRef; -use radroots_event::id::{RadrootsDTag, RadrootsInventoryBinId}; +use radroots_event::farm::FarmRef; +use radroots_event::id::{DTag, InventoryBinId}; use radroots_event::listing::operational::{ - RadrootsOperationalListing, RadrootsOperationalListingAvailability, - RadrootsOperationalListingBin, RadrootsOperationalListingDeliveryMethod, - RadrootsOperationalListingProduct, RadrootsOperationalListingPublicLocation, - RadrootsOperationalListingStatus, + OperationalListing, OperationalListingAvailability, OperationalListingBin, + OperationalListingDeliveryMethod, OperationalListingProduct, OperationalListingPublicLocation, + OperationalListingStatus, }; use radroots_sdk::{ListingPreparePublishRequest, RadrootsClient, RadrootsSdkTimestamp}; @@ -29,15 +28,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { Ok(()) } -fn sample_listing(seller: &str) -> RadrootsOperationalListing { - RadrootsOperationalListing { - d_tag: RadrootsDTag::parse("AAAAAAAAAAAAAAAAAAAAAQ").expect("d tag"), +fn sample_listing(seller: &str) -> OperationalListing { + OperationalListing { + d_tag: DTag::parse("AAAAAAAAAAAAAAAAAAAAAQ").expect("d tag"), published_at: None, - farm: RadrootsFarmRef { + farm: FarmRef { pubkey: seller.to_owned(), d_tag: "AAAAAAAAAAAAAAAAAAAAAA".to_owned(), }, - product: RadrootsOperationalListingProduct { + product: OperationalListingProduct { key: "coffee".to_owned(), title: "Coffee".to_owned(), category: "coffee".to_owned(), @@ -48,9 +47,9 @@ fn sample_listing(seller: &str) -> RadrootsOperationalListing { profile: None, year: None, }, - primary_bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), - bins: vec![RadrootsOperationalListingBin { - bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), + primary_bin_id: InventoryBinId::parse("bin-1").expect("bin id"), + bins: vec![OperationalListingBin { + bin_id: InventoryBinId::parse("bin-1").expect("bin id"), quantity: Quantity::try_new(Decimal::from(1000u32), Unit::MassG) .expect("positive example quantity"), price_per_canonical_unit: QuantityPrice::try_new( @@ -70,11 +69,11 @@ fn sample_listing(seller: &str) -> RadrootsOperationalListing { plot: None, discounts: None, inventory_available: Some(Decimal::from(5u32)), - availability: Some(RadrootsOperationalListingAvailability::Status { - status: RadrootsOperationalListingStatus::Active, + availability: Some(OperationalListingAvailability::Status { + status: OperationalListingStatus::Active, }), - delivery_method: Some(RadrootsOperationalListingDeliveryMethod::Pickup), - location: Some(RadrootsOperationalListingPublicLocation { + delivery_method: Some(OperationalListingDeliveryMethod::Pickup), + location: Some(OperationalListingPublicLocation { primary: "Victoria".to_owned(), city: Some("Victoria".to_owned()), region: Some("British Columbia".to_owned()), diff --git a/crates/sdk/examples/sdk_v1_local_enqueue_and_mock_sync.rs b/crates/sdk/examples/sdk_v1_local_enqueue_and_mock_sync.rs @@ -1,13 +1,12 @@ use radroots_authority::{RadrootsActorContext, RadrootsLocalEventSigner}; use radroots_core::{Currency, Decimal, Money, Quantity, QuantityPrice, Unit}; use radroots_event::contract::AuthorRole; -use radroots_event::farm::RadrootsFarmRef; -use radroots_event::id::{RadrootsDTag, RadrootsInventoryBinId}; +use radroots_event::farm::FarmRef; +use radroots_event::id::{DTag, InventoryBinId}; use radroots_event::listing::operational::{ - RadrootsOperationalListing, RadrootsOperationalListingAvailability, - RadrootsOperationalListingBin, RadrootsOperationalListingDeliveryMethod, - RadrootsOperationalListingProduct, RadrootsOperationalListingPublicLocation, - RadrootsOperationalListingStatus, + OperationalListing, OperationalListingAvailability, OperationalListingBin, + OperationalListingDeliveryMethod, OperationalListingProduct, OperationalListingPublicLocation, + OperationalListingStatus, }; use radroots_nostr::prelude::RadrootsNostrKeys; use radroots_sdk::{ @@ -63,15 +62,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { Ok(()) } -fn sample_listing(seller: &str) -> RadrootsOperationalListing { - RadrootsOperationalListing { - d_tag: RadrootsDTag::parse("AAAAAAAAAAAAAAAAAAAAAQ").expect("d tag"), +fn sample_listing(seller: &str) -> OperationalListing { + OperationalListing { + d_tag: DTag::parse("AAAAAAAAAAAAAAAAAAAAAQ").expect("d tag"), published_at: None, - farm: RadrootsFarmRef { + farm: FarmRef { pubkey: seller.to_owned(), d_tag: "AAAAAAAAAAAAAAAAAAAAAA".to_owned(), }, - product: RadrootsOperationalListingProduct { + product: OperationalListingProduct { key: "coffee".to_owned(), title: "Coffee".to_owned(), category: "coffee".to_owned(), @@ -82,9 +81,9 @@ fn sample_listing(seller: &str) -> RadrootsOperationalListing { profile: None, year: None, }, - primary_bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), - bins: vec![RadrootsOperationalListingBin { - bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), + primary_bin_id: InventoryBinId::parse("bin-1").expect("bin id"), + bins: vec![OperationalListingBin { + bin_id: InventoryBinId::parse("bin-1").expect("bin id"), quantity: Quantity::try_new(Decimal::from(1000u32), Unit::MassG) .expect("positive example quantity"), price_per_canonical_unit: QuantityPrice::try_new( @@ -104,11 +103,11 @@ fn sample_listing(seller: &str) -> RadrootsOperationalListing { plot: None, discounts: None, inventory_available: Some(Decimal::from(5u32)), - availability: Some(RadrootsOperationalListingAvailability::Status { - status: RadrootsOperationalListingStatus::Active, + availability: Some(OperationalListingAvailability::Status { + status: OperationalListingStatus::Active, }), - delivery_method: Some(RadrootsOperationalListingDeliveryMethod::Pickup), - location: Some(RadrootsOperationalListingPublicLocation { + delivery_method: Some(OperationalListingDeliveryMethod::Pickup), + location: Some(OperationalListingPublicLocation { primary: "Victoria".to_owned(), city: Some("Victoria".to_owned()), region: Some("British Columbia".to_owned()), 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_event::draft::RadrootsSignedEvent; +use radroots_event::draft::SignedEvent; use radroots_protocol::radrootsd::transport_publish::v5::{ DeliveryPolicy as TransportPublishDeliveryPolicy, Error as TransportPublishProtocolError, EventRequest as TransportPublishEventRequest, EventResponse as TransportPublishEventResponse, @@ -102,7 +102,7 @@ impl RadrootsdPublishAdapter { #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsdPublishRequest { - pub signed_event: RadrootsSignedEvent, + pub signed_event: SignedEvent, pub target_policy: TransportPublishTargetPolicy, pub delivery_policy: TransportPublishDeliveryPolicy, pub idempotency_key: Option<String>, @@ -129,7 +129,7 @@ struct RadrootsdPublishEventIdentity { } impl RadrootsdPublishEventIdentity { - fn from_signed_event(event: &RadrootsSignedEvent) -> Self { + fn from_signed_event(event: &SignedEvent) -> Self { Self { event_id: event.id_str().to_owned(), pubkey: event.pubkey().to_hex().to_owned(), diff --git a/crates/sdk/src/error.rs b/crates/sdk/src/error.rs @@ -6,7 +6,7 @@ use crate::privacy::{PrivacyPreflightStatus, ProductSensitivityField}; #[cfg(feature = "runtime")] use crate::transport::ReticulumBehavior; #[cfg(feature = "runtime")] -use radroots_event::trade::validation::RadrootsOperationalListingValidationError; +use radroots_event::trade::validation::OperationalListingValidationError; #[cfg(feature = "runtime")] use serde_json::{Value, json}; @@ -89,54 +89,44 @@ pub enum RadrootsSdkListingValidationErrorKind { } #[cfg(feature = "runtime")] -impl From<&RadrootsOperationalListingValidationError> for RadrootsSdkListingValidationErrorKind { - fn from(error: &RadrootsOperationalListingValidationError) -> Self { +impl From<&OperationalListingValidationError> for RadrootsSdkListingValidationErrorKind { + fn from(error: &OperationalListingValidationError) -> Self { match error { - RadrootsOperationalListingValidationError::InvalidKind { .. } => Self::InvalidKind, - RadrootsOperationalListingValidationError::InvalidProfile => Self::InvalidProfile, - RadrootsOperationalListingValidationError::MissingListingId => Self::MissingListingId, - RadrootsOperationalListingValidationError::ListingEventNotFound { .. } => { + OperationalListingValidationError::InvalidKind { .. } => Self::InvalidKind, + OperationalListingValidationError::InvalidProfile => Self::InvalidProfile, + OperationalListingValidationError::MissingListingId => Self::MissingListingId, + OperationalListingValidationError::ListingEventNotFound { .. } => { Self::ListingEventNotFound } - RadrootsOperationalListingValidationError::ListingEventFetchFailed { .. } => { + OperationalListingValidationError::ListingEventFetchFailed { .. } => { Self::ListingEventFetchFailed } - RadrootsOperationalListingValidationError::ParseError { .. } => Self::ParseError, - RadrootsOperationalListingValidationError::InvalidSeller => Self::InvalidSeller, - RadrootsOperationalListingValidationError::MissingFarmProfile => { - Self::MissingFarmProfile - } - RadrootsOperationalListingValidationError::MissingFarmRecord => Self::MissingFarmRecord, - RadrootsOperationalListingValidationError::MissingTitle => Self::MissingTitle, - RadrootsOperationalListingValidationError::MissingDescription => { - Self::MissingDescription - } - RadrootsOperationalListingValidationError::MissingProductType => { - Self::MissingProductType - } - RadrootsOperationalListingValidationError::MissingBins => Self::MissingBins, - RadrootsOperationalListingValidationError::MissingPrimaryBin => Self::MissingPrimaryBin, - RadrootsOperationalListingValidationError::InvalidBin => Self::InvalidBin, - RadrootsOperationalListingValidationError::MissingPrice => Self::MissingPrice, - RadrootsOperationalListingValidationError::InvalidPrice => Self::InvalidPrice, - RadrootsOperationalListingValidationError::MissingInventory => Self::MissingInventory, - RadrootsOperationalListingValidationError::InvalidInventory => Self::InvalidInventory, - RadrootsOperationalListingValidationError::MissingAvailability => { - Self::MissingAvailability - } - RadrootsOperationalListingValidationError::MissingLocation => Self::MissingLocation, - RadrootsOperationalListingValidationError::MissingLocationLocality => { + OperationalListingValidationError::ParseError { .. } => Self::ParseError, + OperationalListingValidationError::InvalidSeller => Self::InvalidSeller, + OperationalListingValidationError::MissingFarmProfile => Self::MissingFarmProfile, + OperationalListingValidationError::MissingFarmRecord => Self::MissingFarmRecord, + OperationalListingValidationError::MissingTitle => Self::MissingTitle, + OperationalListingValidationError::MissingDescription => Self::MissingDescription, + OperationalListingValidationError::MissingProductType => Self::MissingProductType, + OperationalListingValidationError::MissingBins => Self::MissingBins, + OperationalListingValidationError::MissingPrimaryBin => Self::MissingPrimaryBin, + OperationalListingValidationError::InvalidBin => Self::InvalidBin, + OperationalListingValidationError::MissingPrice => Self::MissingPrice, + OperationalListingValidationError::InvalidPrice => Self::InvalidPrice, + OperationalListingValidationError::MissingInventory => Self::MissingInventory, + OperationalListingValidationError::InvalidInventory => Self::InvalidInventory, + OperationalListingValidationError::MissingAvailability => Self::MissingAvailability, + OperationalListingValidationError::MissingLocation => Self::MissingLocation, + OperationalListingValidationError::MissingLocationLocality => { Self::MissingLocationLocality } - RadrootsOperationalListingValidationError::MissingLocationGeohash => { + OperationalListingValidationError::MissingLocationGeohash => { Self::MissingLocationGeohash } - RadrootsOperationalListingValidationError::InvalidLocationGeohash => { + OperationalListingValidationError::InvalidLocationGeohash => { Self::InvalidLocationGeohash } - RadrootsOperationalListingValidationError::MissingDeliveryMethod => { - Self::MissingDeliveryMethod - } + OperationalListingValidationError::MissingDeliveryMethod => Self::MissingDeliveryMethod, } } } diff --git a/crates/sdk/src/farm.rs b/crates/sdk/src/farm.rs @@ -2,8 +2,8 @@ pub use radroots_event::farm::*; pub use radroots_event_codec::error::EventEncodeError; -use radroots_event::wire::RadrootsNip01EventWireParts; +use radroots_event::wire::Nip01EventWireParts; -pub fn build_draft(farm: &RadrootsFarm) -> Result<RadrootsNip01EventWireParts, EventEncodeError> { +pub fn build_draft(farm: &Farm) -> Result<Nip01EventWireParts, EventEncodeError> { radroots_event_codec::farm::encode::to_wire_parts(farm) } diff --git a/crates/sdk/src/farms_runtime.rs b/crates/sdk/src/farms_runtime.rs @@ -16,11 +16,11 @@ use radroots_authority::{RadrootsActorContext, RadrootsEventSigner}; #[cfg(feature = "runtime")] use radroots_event::{ contract::AuthorRole, - draft::RadrootsEventDraft, + draft::EventDraft, envelope::kind::KIND_FARM, - farm::{RadrootsFarm, RadrootsFarmPublicLocation}, - id::{RadrootsAddressableCoordinate, RadrootsEventId}, - listing::operational::RadrootsOperationalListingPublicLocation, + farm::{Farm, FarmPublicLocation}, + id::{AddressableCoordinate, EventId}, + listing::operational::OperationalListingPublicLocation, }; #[cfg(feature = "runtime")] #[cfg(feature = "runtime")] @@ -41,13 +41,13 @@ const GEOHASH_BASE32: &[u8; 32] = b"0123456789bcdefghjkmnpqrstuvwxyz"; pub struct FarmPreparePublishRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub farm: RadrootsFarm, + pub farm: Farm, pub created_at: Option<RadrootsSdkTimestamp>, } #[cfg(feature = "runtime")] impl FarmPreparePublishRequest { - pub fn new(actor: RadrootsActorContext, farm: RadrootsFarm) -> Self { + pub fn new(actor: RadrootsActorContext, farm: Farm) -> Self { Self { actor, farm, @@ -67,7 +67,7 @@ impl FarmPreparePublishRequest { pub struct FarmEnqueuePublishRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub farm: RadrootsFarm, + pub farm: Farm, pub target_policy: TargetPolicy, pub idempotency_key: Option<SdkIdempotencyKey>, pub created_at: Option<RadrootsSdkTimestamp>, @@ -75,11 +75,7 @@ pub struct FarmEnqueuePublishRequest { #[cfg(feature = "runtime")] impl FarmEnqueuePublishRequest { - pub fn new( - actor: RadrootsActorContext, - farm: RadrootsFarm, - target_policy: TargetPolicy, - ) -> Self { + pub fn new(actor: RadrootsActorContext, farm: Farm, target_policy: TargetPolicy) -> Self { Self { actor, farm, @@ -124,23 +120,23 @@ impl FarmEnqueuePublishRequest { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct FarmPublishPlan { - farm_addr: RadrootsAddressableCoordinate, - expected_event_id: RadrootsEventId, - frozen_draft: RadrootsEventDraft, + farm_addr: AddressableCoordinate, + expected_event_id: EventId, + frozen_draft: EventDraft, created_at: RadrootsSdkTimestamp, } #[cfg(feature = "runtime")] impl FarmPublishPlan { - pub fn farm_addr(&self) -> &RadrootsAddressableCoordinate { + pub fn farm_addr(&self) -> &AddressableCoordinate { &self.farm_addr } - pub fn expected_event_id(&self) -> &RadrootsEventId { + pub fn expected_event_id(&self) -> &EventId { &self.expected_event_id } - pub fn frozen_draft(&self) -> &RadrootsEventDraft { + pub fn frozen_draft(&self) -> &EventDraft { &self.frozen_draft } @@ -152,9 +148,9 @@ impl FarmPublishPlan { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct FarmEnqueueReceipt { - pub farm_addr: RadrootsAddressableCoordinate, - pub expected_event_id: RadrootsEventId, - pub signed_event_id: RadrootsEventId, + pub farm_addr: AddressableCoordinate, + pub expected_event_id: EventId, + pub signed_event_id: EventId, pub local_event_seq: i64, pub outbox_operation_id: i64, pub outbox_event_id: i64, @@ -191,8 +187,8 @@ pub struct SdkPublicLocality { #[cfg(feature = "runtime")] impl SdkPublicLocality { - pub fn to_farm_public_location(&self) -> RadrootsFarmPublicLocation { - RadrootsFarmPublicLocation { + pub fn to_farm_public_location(&self) -> FarmPublicLocation { + FarmPublicLocation { primary: self.primary.clone(), city: self.city.clone(), region: self.region.clone(), @@ -201,8 +197,8 @@ impl SdkPublicLocality { } } - pub fn to_listing_public_location(&self) -> RadrootsOperationalListingPublicLocation { - RadrootsOperationalListingPublicLocation { + pub fn to_listing_public_location(&self) -> OperationalListingPublicLocation { + OperationalListingPublicLocation { primary: self.primary.clone(), city: self.city.clone(), region: self.region.clone(), @@ -375,14 +371,14 @@ impl FarmPrivateLocationClearRequest { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct FarmPrivateLocationClearReceipt { - pub farm_addr: RadrootsAddressableCoordinate, + pub farm_addr: AddressableCoordinate, pub cleared: bool, } #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FarmPrivateLocationReceipt { - pub farm_addr: RadrootsAddressableCoordinate, + pub farm_addr: AddressableCoordinate, pub farm_pubkey: String, pub farm_d_tag: String, pub label: Option<String>, @@ -408,7 +404,7 @@ pub struct FarmPrivateLocationLookupCandidate { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FarmPrivateLocationLookupReceipt { - pub farm_addr: RadrootsAddressableCoordinate, + pub farm_addr: AddressableCoordinate, pub farm_pubkey: String, pub farm_d_tag: String, pub input: FarmPrivateLocationInput, @@ -693,7 +689,7 @@ impl<'sdk> FarmsClient<'sdk> { pub async fn private_location( &self, - farm_addr: &RadrootsAddressableCoordinate, + farm_addr: &AddressableCoordinate, ) -> Result<Option<FarmPrivateLocationReceipt>, RadrootsSdkError> { self.sdk ._private_store @@ -748,8 +744,8 @@ fn farm_enqueue_receipt( #[cfg(feature = "runtime")] struct ValidatedFarmPublishPlanMetadata { - farm_addr: RadrootsAddressableCoordinate, - expected_event_id: RadrootsEventId, + farm_addr: AddressableCoordinate, + expected_event_id: EventId, } #[cfg(feature = "runtime")] @@ -768,7 +764,7 @@ fn validate_farm_publish_plan( return Err(invalid("contract or kind does not match Farm publish")); } - let expected_event_id = RadrootsEventId::parse(plan.frozen_draft.expected_event_id_hex()) + let expected_event_id = EventId::parse(plan.frozen_draft.expected_event_id_hex()) .expect("validated frozen draft has a typed event ID"); if plan.expected_event_id != expected_event_id { return Err(invalid("expected event ID does not match frozen draft")); @@ -788,7 +784,7 @@ fn validate_farm_publish_plan( if d_tags.next().is_some() { return Err(invalid("frozen draft contains duplicate farm identifiers")); } - let farm_addr = RadrootsAddressableCoordinate::parse(format!( + let farm_addr = AddressableCoordinate::parse(format!( "{KIND_FARM}:{}:{d_tag}", plan.frozen_draft.expected_pubkey().to_hex() )) @@ -805,7 +801,7 @@ fn validate_farm_publish_plan( #[cfg(feature = "runtime")] fn farm_publish_plan( actor: &RadrootsActorContext, - farm_value: RadrootsFarm, + farm_value: Farm, created_at: RadrootsSdkTimestamp, ) -> Result<FarmPublishPlan, RadrootsSdkError> { require_farmer_actor(actor, "farm.prepare_publish")?; @@ -816,7 +812,7 @@ fn farm_publish_plan( })?; let farm_addr = farm_addr(actor, farm_value.d_tag.as_str()) .expect("validated farm d tag forms a farm address"); - let frozen_draft = RadrootsEventDraft::new( + let frozen_draft = EventDraft::new( FARM_PROFILE_CONTRACT_ID, parts.kind, created_at_nostr.into(), @@ -825,7 +821,7 @@ fn farm_publish_plan( actor.pubkey().to_hex(), ) .expect("validated farm publish draft freezes"); - let expected_event_id = RadrootsEventId::parse(frozen_draft.expected_event_id_hex()) + let expected_event_id = EventId::parse(frozen_draft.expected_event_id_hex()) .expect("frozen farm draft produces a valid event id"); Ok(FarmPublishPlan { farm_addr, @@ -854,8 +850,8 @@ fn require_farmer_actor( fn farm_addr( actor: &RadrootsActorContext, d_tag: &str, -) -> Result<RadrootsAddressableCoordinate, RadrootsSdkError> { - RadrootsAddressableCoordinate::parse(format!("{KIND_FARM}:{}:{d_tag}", actor.pubkey())).map_err( +) -> Result<AddressableCoordinate, RadrootsSdkError> { + AddressableCoordinate::parse(format!("{KIND_FARM}:{}:{d_tag}", actor.pubkey())).map_err( |error| RadrootsSdkError::InvalidRequest { message: format!("farm address is invalid: {error}"), }, @@ -1060,7 +1056,7 @@ fn private_location_receipt_from_record( #[cfg(feature = "runtime")] fn farm_private_location_lookup_receipt( - farm_addr: RadrootsAddressableCoordinate, + farm_addr: AddressableCoordinate, farm_pubkey: &str, farm_d_tag: String, input: FarmPrivateLocationInput, diff --git a/crates/sdk/src/idempotency.rs b/crates/sdk/src/idempotency.rs @@ -1,6 +1,6 @@ use crate::RadrootsSdkError; use core::fmt; -use radroots_event::id::RadrootsEventId; +use radroots_event::id::EventId; use radroots_identity::PublicKey; use serde::ser::SerializeStruct; @@ -73,7 +73,7 @@ pub struct SdkTradeIdempotencyRecord { pub actor_pubkey: PublicKey, pub digest: String, pub canonical_payload_hash: String, - pub expected_event_id: RadrootsEventId, + pub expected_event_id: EventId, pub outbox_operation_id: i64, } diff --git a/crates/sdk/src/knowledge.rs b/crates/sdk/src/knowledge.rs @@ -11,33 +11,30 @@ use std::{ use core::fmt; -pub use radroots_event::wire::RadrootsNip01EventWireParts; +pub use radroots_event::wire::Nip01EventWireParts; pub use radroots_event::{ - draft::{RadrootsDraftError, RadrootsEventDraft}, - envelope::RadrootsEventEnvelope, + draft::{DraftError, EventDraft}, + envelope::EventEnvelope, envelope::kind::{ KIND_FILE_METADATA, KIND_KNOWLEDGE_CLAIM, KIND_KNOWLEDGE_FIELD_REPORT, KIND_KNOWLEDGE_RELATION, KIND_KNOWLEDGE_REVIEW, KIND_KNOWLEDGE_SOURCE, KIND_WIKI_ARTICLE, KIND_WIKI_MERGE_REQUEST, KIND_WIKI_REDIRECT, }, knowledge::{ + AddressableRef, ContributionAttestation, EvidenceBounty, KnowledgeChangeProposal, + KnowledgeCitationSpan, KnowledgeClaim, KnowledgeFieldContext, KnowledgeFieldReport, + KnowledgeLocation, KnowledgeLocationPrecision, KnowledgeNodeRef, KnowledgeObservation, + KnowledgeObservationValue, KnowledgeRelation, KnowledgeReview, KnowledgeReviewScope, + KnowledgeReviewScore, KnowledgeReviewTarget, KnowledgeSource, KnowledgeValidationError, RADROOTS_CONTRIBUTION_ATTESTATION_SCHEMA, RADROOTS_EVIDENCE_BOUNTY_SCHEMA, RADROOTS_KNOWLEDGE_CHANGE_PROPOSAL_SCHEMA, RADROOTS_KNOWLEDGE_CLAIM_SCHEMA, RADROOTS_KNOWLEDGE_FIELD_REPORT_SCHEMA, RADROOTS_KNOWLEDGE_RELATION_SCHEMA, RADROOTS_KNOWLEDGE_REVIEW_SCHEMA, RADROOTS_KNOWLEDGE_SCHEMA_VERSION, - RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, RADROOTS_WIKI_D_TAG_MAX_LEN, RadrootsAddressableRef, - RadrootsContributionAttestation, RadrootsEvidenceBounty, RadrootsKnowledgeChangeProposal, - RadrootsKnowledgeCitationSpan, RadrootsKnowledgeClaim, RadrootsKnowledgeFieldContext, - RadrootsKnowledgeFieldReport, RadrootsKnowledgeLocation, - RadrootsKnowledgeLocationPrecision, RadrootsKnowledgeNodeRef, RadrootsKnowledgeObservation, - RadrootsKnowledgeObservationValue, RadrootsKnowledgeRelation, RadrootsKnowledgeReview, - RadrootsKnowledgeReviewScope, RadrootsKnowledgeReviewScore, RadrootsKnowledgeReviewTarget, - RadrootsKnowledgeSource, RadrootsKnowledgeValidationError, RadrootsRightsAssertion, - RadrootsWikiArticle, RadrootsWikiArticleVersionRef, RadrootsWikiDTagError, - RadrootsWikiMergeRequest, RadrootsWikiRedirect, normalize_wiki_d_tag, - validate_knowledge_claim, validate_wiki_article, validate_wiki_d_tag, + RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, RADROOTS_WIKI_D_TAG_MAX_LEN, RightsAssertion, + WikiArticle, WikiArticleVersionRef, WikiDTagError, WikiMergeRequest, WikiRedirect, + normalize_wiki_d_tag, validate_knowledge_claim, validate_wiki_article, validate_wiki_d_tag, }, - tag::RadrootsEventRef, + tag::EventRef, }; pub use radroots_event_codec::{ RADROOTS_KNOWLEDGE_CONTRACT_MANIFEST_SCHEMA_VERSION, @@ -82,7 +79,7 @@ pub const KNOWLEDGE_FIELD_REPORT_CONTRACT_ID: &str = RADROOTS_KNOWLEDGE_FIELD_RE pub enum RadrootsSdkKnowledgeError { Builder(RadrootsKnowledgeBuilderError), Encode(RadrootsEncodeError), - Draft(RadrootsDraftError), + Draft(DraftError), Decode(RadrootsDecodeError), Manifest(serde_json::Error), } @@ -186,8 +183,8 @@ impl From<RadrootsEncodeError> for RadrootsSdkKnowledgeError { } } -impl From<RadrootsDraftError> for RadrootsSdkKnowledgeError { - fn from(value: RadrootsDraftError) -> Self { +impl From<DraftError> for RadrootsSdkKnowledgeError { + fn from(value: DraftError) -> Self { Self::Draft(value) } } @@ -211,9 +208,9 @@ pub struct RadrootsWikiArticleBuilder { content_djot: Option<String>, summary: Option<String>, topics: Vec<String>, - references: Vec<RadrootsEventRef>, - forked_from: Vec<RadrootsWikiArticleVersionRef>, - deferred_to: Option<RadrootsWikiArticleVersionRef>, + references: Vec<EventRef>, + forked_from: Vec<WikiArticleVersionRef>, + deferred_to: Option<WikiArticleVersionRef>, } impl RadrootsWikiArticleBuilder { @@ -244,23 +241,23 @@ impl RadrootsWikiArticleBuilder { self } - pub fn reference(mut self, reference: RadrootsEventRef) -> Self { + pub fn reference(mut self, reference: EventRef) -> Self { self.references.push(reference); self } - pub fn forked_from(mut self, version_ref: RadrootsWikiArticleVersionRef) -> Self { + pub fn forked_from(mut self, version_ref: WikiArticleVersionRef) -> Self { self.forked_from.push(version_ref); self } - pub fn deferred_to(mut self, version_ref: RadrootsWikiArticleVersionRef) -> Self { + pub fn deferred_to(mut self, version_ref: WikiArticleVersionRef) -> Self { self.deferred_to = Some(version_ref); self } - pub fn build(self) -> Result<RadrootsWikiArticle, RadrootsKnowledgeBuilderError> { - let article = RadrootsWikiArticle { + pub fn build(self) -> Result<WikiArticle, RadrootsKnowledgeBuilderError> { + let article = WikiArticle { d_tag: self.d_tag, title: self.title, content_djot: builder_required_string(self.content_djot, "content_djot")?, @@ -273,7 +270,7 @@ impl RadrootsWikiArticleBuilder { builder_validated(article, validate_wiki_article) } - pub fn build_event(self) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + pub fn build_event(self) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_wiki_article_event(&self.build()?) } @@ -281,7 +278,7 @@ impl RadrootsWikiArticleBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_article_draft(&self.build()?, expected_pubkey, created_at) } } @@ -289,7 +286,7 @@ impl RadrootsWikiArticleBuilder { #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct RadrootsWikiRedirectBuilder { d_tag: String, - target: Option<RadrootsAddressableRef>, + target: Option<AddressableRef>, } impl RadrootsWikiRedirectBuilder { @@ -300,20 +297,20 @@ impl RadrootsWikiRedirectBuilder { } } - pub fn target(mut self, target: RadrootsAddressableRef) -> Self { + pub fn target(mut self, target: AddressableRef) -> Self { self.target = Some(target); self } - pub fn build(self) -> Result<RadrootsWikiRedirect, RadrootsKnowledgeBuilderError> { - let redirect = RadrootsWikiRedirect { + pub fn build(self) -> Result<WikiRedirect, RadrootsKnowledgeBuilderError> { + let redirect = WikiRedirect { d_tag: self.d_tag, target: builder_required(self.target, "target")?, }; builder_validated(redirect, validate_wiki_redirect) } - pub fn build_event(self) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + pub fn build_event(self) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_wiki_redirect_event(&self.build()?) } @@ -321,14 +318,14 @@ impl RadrootsWikiRedirectBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_redirect_draft(&self.build()?, expected_pubkey, created_at) } } #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct RadrootsWikiMergeRequestBuilder { - target_article: Option<RadrootsAddressableRef>, + target_article: Option<AddressableRef>, destination_pubkey: Option<String>, base_version_event_id: Option<String>, source_version_event_id: Option<String>, @@ -346,7 +343,7 @@ impl RadrootsWikiMergeRequestBuilder { } } - pub fn target_article(mut self, target_article: RadrootsAddressableRef) -> Self { + pub fn target_article(mut self, target_article: AddressableRef) -> Self { self.target_article = Some(target_article); self } @@ -371,8 +368,8 @@ impl RadrootsWikiMergeRequestBuilder { self } - pub fn build(self) -> Result<RadrootsWikiMergeRequest, RadrootsKnowledgeBuilderError> { - let request = RadrootsWikiMergeRequest { + pub fn build(self) -> Result<WikiMergeRequest, RadrootsKnowledgeBuilderError> { + let request = WikiMergeRequest { target_article: builder_required(self.target_article, "target_article")?, destination_pubkey: builder_required_string( self.destination_pubkey, @@ -388,7 +385,7 @@ impl RadrootsWikiMergeRequestBuilder { builder_validated(request, validate_wiki_merge_request) } - pub fn build_event(self) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + pub fn build_event(self) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_wiki_merge_request_event(&self.build()?) } @@ -396,7 +393,7 @@ impl RadrootsWikiMergeRequestBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_merge_request_draft(&self.build()?, expected_pubkey, created_at) } } @@ -411,8 +408,8 @@ pub struct RadrootsKnowledgeSourceBuilder { publication_year: Option<u16>, edition: Option<String>, canonical_url: Option<String>, - artifact_refs: Vec<RadrootsEventRef>, - author_asserted_rights: Option<RadrootsRightsAssertion>, + artifact_refs: Vec<EventRef>, + author_asserted_rights: Option<RightsAssertion>, topics: Vec<String>, summary: Option<String>, } @@ -460,12 +457,12 @@ impl RadrootsKnowledgeSourceBuilder { self } - pub fn artifact_ref(mut self, artifact_ref: RadrootsEventRef) -> Self { + pub fn artifact_ref(mut self, artifact_ref: EventRef) -> Self { self.artifact_refs.push(artifact_ref); self } - pub fn author_asserted_rights(mut self, rights: RadrootsRightsAssertion) -> Self { + pub fn author_asserted_rights(mut self, rights: RightsAssertion) -> Self { self.author_asserted_rights = Some(rights); self } @@ -480,8 +477,8 @@ impl RadrootsKnowledgeSourceBuilder { self } - pub fn build(self) -> Result<RadrootsKnowledgeSource, RadrootsKnowledgeBuilderError> { - let source = RadrootsKnowledgeSource { + pub fn build(self) -> Result<KnowledgeSource, RadrootsKnowledgeBuilderError> { + let source = KnowledgeSource { schema: RADROOTS_KNOWLEDGE_SOURCE_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, d_tag: self.d_tag, @@ -500,7 +497,7 @@ impl RadrootsKnowledgeSourceBuilder { builder_validated(source, validate_knowledge_source) } - pub fn build_event(self) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + pub fn build_event(self) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_source_event(&self.build()?) } @@ -508,7 +505,7 @@ impl RadrootsKnowledgeSourceBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_source_draft(&self.build()?, expected_pubkey, created_at) } } @@ -517,11 +514,11 @@ impl RadrootsKnowledgeSourceBuilder { pub struct RadrootsKnowledgeClaimBuilder { claim_type: Option<String>, text: Option<String>, - citation_spans: Vec<RadrootsKnowledgeCitationSpan>, + citation_spans: Vec<KnowledgeCitationSpan>, topics: Vec<String>, applies_to: Vec<String>, author_asserted_confidence: Option<String>, - supersedes: Vec<RadrootsEventRef>, + supersedes: Vec<EventRef>, } impl RadrootsKnowledgeClaimBuilder { @@ -547,7 +544,7 @@ impl RadrootsKnowledgeClaimBuilder { self } - pub fn citation_span(mut self, citation_span: RadrootsKnowledgeCitationSpan) -> Self { + pub fn citation_span(mut self, citation_span: KnowledgeCitationSpan) -> Self { self.citation_spans.push(citation_span); self } @@ -570,13 +567,13 @@ impl RadrootsKnowledgeClaimBuilder { self } - pub fn supersedes(mut self, supersedes: RadrootsEventRef) -> Self { + pub fn supersedes(mut self, supersedes: EventRef) -> Self { self.supersedes.push(supersedes); self } - pub fn build(self) -> Result<RadrootsKnowledgeClaim, RadrootsKnowledgeBuilderError> { - let claim = RadrootsKnowledgeClaim { + pub fn build(self) -> Result<KnowledgeClaim, RadrootsKnowledgeBuilderError> { + let claim = KnowledgeClaim { schema: RADROOTS_KNOWLEDGE_CLAIM_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, claim_type: builder_required_string(self.claim_type, "claim_type")?, @@ -590,7 +587,7 @@ impl RadrootsKnowledgeClaimBuilder { builder_validated(claim, validate_knowledge_claim) } - pub fn build_event(self) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + pub fn build_event(self) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_claim_event(&self.build()?) } @@ -598,19 +595,19 @@ impl RadrootsKnowledgeClaimBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_claim_draft(&self.build()?, expected_pubkey, created_at) } } #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct RadrootsKnowledgeRelationBuilder { - subject: Option<RadrootsKnowledgeNodeRef>, + subject: Option<KnowledgeNodeRef>, predicate: Option<String>, - object: Option<RadrootsKnowledgeNodeRef>, - support_refs: Vec<RadrootsEventRef>, + object: Option<KnowledgeNodeRef>, + support_refs: Vec<EventRef>, author_asserted_confidence: Option<String>, - supersedes: Vec<RadrootsEventRef>, + supersedes: Vec<EventRef>, } impl RadrootsKnowledgeRelationBuilder { @@ -625,7 +622,7 @@ impl RadrootsKnowledgeRelationBuilder { } } - pub fn subject(mut self, subject: RadrootsKnowledgeNodeRef) -> Self { + pub fn subject(mut self, subject: KnowledgeNodeRef) -> Self { self.subject = Some(subject); self } @@ -635,12 +632,12 @@ impl RadrootsKnowledgeRelationBuilder { self } - pub fn object(mut self, object: RadrootsKnowledgeNodeRef) -> Self { + pub fn object(mut self, object: KnowledgeNodeRef) -> Self { self.object = Some(object); self } - pub fn support_ref(mut self, support_ref: RadrootsEventRef) -> Self { + pub fn support_ref(mut self, support_ref: EventRef) -> Self { self.support_refs.push(support_ref); self } @@ -653,13 +650,13 @@ impl RadrootsKnowledgeRelationBuilder { self } - pub fn supersedes(mut self, supersedes: RadrootsEventRef) -> Self { + pub fn supersedes(mut self, supersedes: EventRef) -> Self { self.supersedes.push(supersedes); self } - pub fn build(self) -> Result<RadrootsKnowledgeRelation, RadrootsKnowledgeBuilderError> { - let relation = RadrootsKnowledgeRelation { + pub fn build(self) -> Result<KnowledgeRelation, RadrootsKnowledgeBuilderError> { + let relation = KnowledgeRelation { schema: RADROOTS_KNOWLEDGE_RELATION_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, subject: builder_required(self.subject, "subject")?, @@ -672,7 +669,7 @@ impl RadrootsKnowledgeRelationBuilder { builder_validated(relation, validate_knowledge_relation) } - pub fn build_event(self) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + pub fn build_event(self) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_relation_event(&self.build()?) } @@ -680,19 +677,19 @@ impl RadrootsKnowledgeRelationBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_relation_draft(&self.build()?, expected_pubkey, created_at) } } #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct RadrootsKnowledgeReviewBuilder { - target: Option<RadrootsKnowledgeReviewTarget>, + target: Option<KnowledgeReviewTarget>, reviewer_role: Option<String>, verdict: Option<String>, - scores: Vec<RadrootsKnowledgeReviewScore>, + scores: Vec<KnowledgeReviewScore>, notes: Option<String>, - evidence_refs: Vec<RadrootsEventRef>, + evidence_refs: Vec<EventRef>, } impl RadrootsKnowledgeReviewBuilder { @@ -707,7 +704,7 @@ impl RadrootsKnowledgeReviewBuilder { } } - pub fn target(mut self, target: RadrootsKnowledgeReviewTarget) -> Self { + pub fn target(mut self, target: KnowledgeReviewTarget) -> Self { self.target = Some(target); self } @@ -722,7 +719,7 @@ impl RadrootsKnowledgeReviewBuilder { self } - pub fn score(mut self, score: RadrootsKnowledgeReviewScore) -> Self { + pub fn score(mut self, score: KnowledgeReviewScore) -> Self { self.scores.push(score); self } @@ -732,13 +729,13 @@ impl RadrootsKnowledgeReviewBuilder { self } - pub fn evidence_ref(mut self, evidence_ref: RadrootsEventRef) -> Self { + pub fn evidence_ref(mut self, evidence_ref: EventRef) -> Self { self.evidence_refs.push(evidence_ref); self } - pub fn build(self) -> Result<RadrootsKnowledgeReview, RadrootsKnowledgeBuilderError> { - let review = RadrootsKnowledgeReview { + pub fn build(self) -> Result<KnowledgeReview, RadrootsKnowledgeBuilderError> { + let review = KnowledgeReview { schema: RADROOTS_KNOWLEDGE_REVIEW_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, target: builder_required(self.target, "target")?, @@ -751,7 +748,7 @@ impl RadrootsKnowledgeReviewBuilder { builder_validated(review, validate_knowledge_review) } - pub fn build_event(self) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + pub fn build_event(self) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_review_event(&self.build()?) } @@ -759,7 +756,7 @@ impl RadrootsKnowledgeReviewBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_review_draft(&self.build()?, expected_pubkey, created_at) } } @@ -769,10 +766,10 @@ pub struct RadrootsKnowledgeFieldReportBuilder { report_type: Option<String>, title: Option<String>, summary: Option<String>, - context: Option<RadrootsKnowledgeFieldContext>, - observations: Vec<RadrootsKnowledgeObservation>, - artifact_refs: Vec<RadrootsEventRef>, - related_refs: Vec<RadrootsEventRef>, + context: Option<KnowledgeFieldContext>, + observations: Vec<KnowledgeObservation>, + artifact_refs: Vec<EventRef>, + related_refs: Vec<EventRef>, limitations: Vec<String>, } @@ -805,22 +802,22 @@ impl RadrootsKnowledgeFieldReportBuilder { self } - pub fn context(mut self, context: RadrootsKnowledgeFieldContext) -> Self { + pub fn context(mut self, context: KnowledgeFieldContext) -> Self { self.context = Some(context); self } - pub fn observation(mut self, observation: RadrootsKnowledgeObservation) -> Self { + pub fn observation(mut self, observation: KnowledgeObservation) -> Self { self.observations.push(observation); self } - pub fn artifact_ref(mut self, artifact_ref: RadrootsEventRef) -> Self { + pub fn artifact_ref(mut self, artifact_ref: EventRef) -> Self { self.artifact_refs.push(artifact_ref); self } - pub fn related_ref(mut self, related_ref: RadrootsEventRef) -> Self { + pub fn related_ref(mut self, related_ref: EventRef) -> Self { self.related_refs.push(related_ref); self } @@ -830,8 +827,8 @@ impl RadrootsKnowledgeFieldReportBuilder { self } - pub fn build(self) -> Result<RadrootsKnowledgeFieldReport, RadrootsKnowledgeBuilderError> { - let report = RadrootsKnowledgeFieldReport { + pub fn build(self) -> Result<KnowledgeFieldReport, RadrootsKnowledgeBuilderError> { + let report = KnowledgeFieldReport { schema: RADROOTS_KNOWLEDGE_FIELD_REPORT_SCHEMA.to_string(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, report_type: builder_required_string(self.report_type, "report_type")?, @@ -846,7 +843,7 @@ impl RadrootsKnowledgeFieldReportBuilder { builder_validated(report, validate_knowledge_field_report) } - pub fn build_event(self) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + pub fn build_event(self) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_field_report_event(&self.build()?) } @@ -854,7 +851,7 @@ impl RadrootsKnowledgeFieldReportBuilder { self, expected_pubkey: impl AsRef<str>, created_at: u32, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_field_report_draft(&self.build()?, expected_pubkey, created_at) } } @@ -869,57 +866,57 @@ impl KnowledgeEventBuilder { pub fn wiki_article( &self, - article: &RadrootsWikiArticle, - ) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + article: &WikiArticle, + ) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_wiki_article_event(article) } pub fn wiki_redirect( &self, - redirect: &RadrootsWikiRedirect, - ) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + redirect: &WikiRedirect, + ) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_wiki_redirect_event(redirect) } pub fn wiki_merge_request( &self, - request: &RadrootsWikiMergeRequest, - ) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + request: &WikiMergeRequest, + ) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_wiki_merge_request_event(request) } pub fn knowledge_source( &self, - source: &RadrootsKnowledgeSource, - ) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + source: &KnowledgeSource, + ) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_source_event(source) } pub fn knowledge_claim( &self, - claim: &RadrootsKnowledgeClaim, - ) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + claim: &KnowledgeClaim, + ) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_claim_event(claim) } pub fn knowledge_relation( &self, - relation: &RadrootsKnowledgeRelation, - ) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + relation: &KnowledgeRelation, + ) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_relation_event(relation) } pub fn knowledge_review( &self, - review: &RadrootsKnowledgeReview, - ) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + review: &KnowledgeReview, + ) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_review_event(review) } pub fn knowledge_field_report( &self, - report: &RadrootsKnowledgeFieldReport, - ) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + report: &KnowledgeFieldReport, + ) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { build_knowledge_field_report_event(report) } } @@ -948,57 +945,57 @@ impl KnowledgeDraftBuilder { pub fn wiki_article( &self, - article: &RadrootsWikiArticle, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + article: &WikiArticle, + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_article_draft(article, self.expected_pubkey(), self.created_at) } pub fn wiki_redirect( &self, - redirect: &RadrootsWikiRedirect, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + redirect: &WikiRedirect, + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_redirect_draft(redirect, self.expected_pubkey(), self.created_at) } pub fn wiki_merge_request( &self, - request: &RadrootsWikiMergeRequest, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + request: &WikiMergeRequest, + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_wiki_merge_request_draft(request, self.expected_pubkey(), self.created_at) } pub fn knowledge_source( &self, - source: &RadrootsKnowledgeSource, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + source: &KnowledgeSource, + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_source_draft(source, self.expected_pubkey(), self.created_at) } pub fn knowledge_claim( &self, - claim: &RadrootsKnowledgeClaim, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + claim: &KnowledgeClaim, + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_claim_draft(claim, self.expected_pubkey(), self.created_at) } pub fn knowledge_relation( &self, - relation: &RadrootsKnowledgeRelation, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + relation: &KnowledgeRelation, + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_relation_draft(relation, self.expected_pubkey(), self.created_at) } pub fn knowledge_review( &self, - review: &RadrootsKnowledgeReview, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + review: &KnowledgeReview, + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_review_draft(review, self.expected_pubkey(), self.created_at) } pub fn knowledge_field_report( &self, - report: &RadrootsKnowledgeFieldReport, - ) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { + report: &KnowledgeFieldReport, + ) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_knowledge_field_report_draft(report, self.expected_pubkey(), self.created_at) } } @@ -1013,7 +1010,7 @@ impl KnowledgeCodec { pub fn verify_and_decode_radroots_event( &self, - event: RadrootsEventEnvelope, + event: EventEnvelope, ) -> Result<RadrootsDecodedEvent, RadrootsSdkKnowledgeError> { verify_and_decode_radroots_event(event) } @@ -1032,58 +1029,58 @@ impl KnowledgeCodec { } pub fn build_wiki_article_event( - article: &RadrootsWikiArticle, -) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + article: &WikiArticle, +) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { Ok(wiki_article_to_wire_parts(article)?) } pub fn build_wiki_redirect_event( - redirect: &RadrootsWikiRedirect, -) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + redirect: &WikiRedirect, +) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { Ok(wiki_redirect_to_wire_parts(redirect)?) } pub fn build_wiki_merge_request_event( - request: &RadrootsWikiMergeRequest, -) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + request: &WikiMergeRequest, +) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { Ok(wiki_merge_request_to_wire_parts(request)?) } pub fn build_knowledge_source_event( - source: &RadrootsKnowledgeSource, -) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + source: &KnowledgeSource, +) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { Ok(knowledge_source_to_wire_parts(source)?) } pub fn build_knowledge_claim_event( - claim: &RadrootsKnowledgeClaim, -) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + claim: &KnowledgeClaim, +) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { Ok(knowledge_claim_to_wire_parts(claim)?) } pub fn build_knowledge_relation_event( - relation: &RadrootsKnowledgeRelation, -) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + relation: &KnowledgeRelation, +) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { Ok(knowledge_relation_to_wire_parts(relation)?) } pub fn build_knowledge_review_event( - review: &RadrootsKnowledgeReview, -) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + review: &KnowledgeReview, +) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { Ok(knowledge_review_to_wire_parts(review)?) } pub fn build_knowledge_field_report_event( - report: &RadrootsKnowledgeFieldReport, -) -> Result<RadrootsNip01EventWireParts, RadrootsSdkKnowledgeError> { + report: &KnowledgeFieldReport, +) -> Result<Nip01EventWireParts, RadrootsSdkKnowledgeError> { Ok(knowledge_field_report_to_wire_parts(report)?) } pub fn prepare_wiki_article_draft( - article: &RadrootsWikiArticle, + article: &WikiArticle, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_wiki_article_event(article)?, WIKI_ARTICLE_CONTRACT_ID, @@ -1093,10 +1090,10 @@ pub fn prepare_wiki_article_draft( } pub fn prepare_wiki_redirect_draft( - redirect: &RadrootsWikiRedirect, + redirect: &WikiRedirect, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_wiki_redirect_event(redirect)?, WIKI_REDIRECT_CONTRACT_ID, @@ -1106,10 +1103,10 @@ pub fn prepare_wiki_redirect_draft( } pub fn prepare_wiki_merge_request_draft( - request: &RadrootsWikiMergeRequest, + request: &WikiMergeRequest, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_wiki_merge_request_event(request)?, WIKI_MERGE_REQUEST_CONTRACT_ID, @@ -1119,10 +1116,10 @@ pub fn prepare_wiki_merge_request_draft( } pub fn prepare_knowledge_source_draft( - source: &RadrootsKnowledgeSource, + source: &KnowledgeSource, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_source_event(source)?, KNOWLEDGE_SOURCE_CONTRACT_ID, @@ -1132,10 +1129,10 @@ pub fn prepare_knowledge_source_draft( } pub fn prepare_knowledge_claim_draft( - claim: &RadrootsKnowledgeClaim, + claim: &KnowledgeClaim, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_claim_event(claim)?, KNOWLEDGE_CLAIM_CONTRACT_ID, @@ -1145,10 +1142,10 @@ pub fn prepare_knowledge_claim_draft( } pub fn prepare_knowledge_relation_draft( - relation: &RadrootsKnowledgeRelation, + relation: &KnowledgeRelation, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_relation_event(relation)?, KNOWLEDGE_RELATION_CONTRACT_ID, @@ -1158,10 +1155,10 @@ pub fn prepare_knowledge_relation_draft( } pub fn prepare_knowledge_review_draft( - review: &RadrootsKnowledgeReview, + review: &KnowledgeReview, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_review_event(review)?, KNOWLEDGE_REVIEW_CONTRACT_ID, @@ -1171,10 +1168,10 @@ pub fn prepare_knowledge_review_draft( } pub fn prepare_knowledge_field_report_draft( - report: &RadrootsKnowledgeFieldReport, + report: &KnowledgeFieldReport, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { prepare_draft( build_knowledge_field_report_event(report)?, KNOWLEDGE_FIELD_REPORT_CONTRACT_ID, @@ -1184,7 +1181,7 @@ pub fn prepare_knowledge_field_report_draft( } pub fn verify_and_decode_radroots_event( - event: RadrootsEventEnvelope, + event: EventEnvelope, ) -> Result<RadrootsDecodedEvent, RadrootsSdkKnowledgeError> { Ok(codec_verify_and_decode(event)?) } @@ -1202,12 +1199,12 @@ pub fn contract_manifest_sha256() -> Result<String, RadrootsSdkKnowledgeError> { } fn prepare_draft( - parts: RadrootsNip01EventWireParts, + parts: Nip01EventWireParts, contract_id: &'static str, expected_pubkey: impl AsRef<str>, created_at: u32, -) -> Result<RadrootsEventDraft, RadrootsSdkKnowledgeError> { - Ok(RadrootsEventDraft::new( +) -> Result<EventDraft, RadrootsSdkKnowledgeError> { + Ok(EventDraft::new( contract_id, parts.kind, u64::from(created_at), @@ -1217,33 +1214,25 @@ fn prepare_draft( )?) } -fn draft_error_code(error: &RadrootsDraftError) -> &'static str { +fn draft_error_code(error: &DraftError) -> &'static str { match error { - RadrootsDraftError::UnknownContract(_) => "unknown_contract", - RadrootsDraftError::ContractNotDraftAuthorable { .. } => "contract_not_draft_authorable", - RadrootsDraftError::ContractRegistryVersionMismatch { .. } => { - "contract_registry_version_mismatch" - } - RadrootsDraftError::DraftExpectedEventIdMismatch { .. } => { - "draft_expected_event_id_mismatch" - } - RadrootsDraftError::ContractKindMismatch { .. } => "contract_kind_mismatch", - RadrootsDraftError::ContractShape { error, .. } => error.code(), - RadrootsDraftError::SignedEventPubkeyMismatch { .. } => "signed_event_pubkey_mismatch", - RadrootsDraftError::SignedEventIdMismatch { .. } => "signed_event_id_mismatch", - RadrootsDraftError::SignedEventCreatedAtMismatch { .. } => { - "signed_event_created_at_mismatch" - } - RadrootsDraftError::SignedEventKindMismatch { .. } => "signed_event_kind_mismatch", - RadrootsDraftError::SignedEventTagsMismatch { .. } => "signed_event_tags_mismatch", - RadrootsDraftError::SignedEventContentMismatch { .. } => "signed_event_content_mismatch", - RadrootsDraftError::SignedEventComputedIdMismatch { .. } => { - "signed_event_computed_id_mismatch" - } - RadrootsDraftError::IdParse(_) => "id_parse", - RadrootsDraftError::CanonicalEventId(_) => "canonical_event_id", - RadrootsDraftError::Envelope(_) => "event_envelope", - RadrootsDraftError::SignedEvent(_) => "signed_event", + DraftError::UnknownContract(_) => "unknown_contract", + DraftError::ContractNotDraftAuthorable { .. } => "contract_not_draft_authorable", + DraftError::ContractRegistryVersionMismatch { .. } => "contract_registry_version_mismatch", + DraftError::DraftExpectedEventIdMismatch { .. } => "draft_expected_event_id_mismatch", + DraftError::ContractKindMismatch { .. } => "contract_kind_mismatch", + DraftError::ContractShape { error, .. } => error.code(), + DraftError::SignedEventPubkeyMismatch { .. } => "signed_event_pubkey_mismatch", + DraftError::SignedEventIdMismatch { .. } => "signed_event_id_mismatch", + DraftError::SignedEventCreatedAtMismatch { .. } => "signed_event_created_at_mismatch", + DraftError::SignedEventKindMismatch { .. } => "signed_event_kind_mismatch", + DraftError::SignedEventTagsMismatch { .. } => "signed_event_tags_mismatch", + DraftError::SignedEventContentMismatch { .. } => "signed_event_content_mismatch", + DraftError::SignedEventComputedIdMismatch { .. } => "signed_event_computed_id_mismatch", + DraftError::IdParse(_) => "id_parse", + DraftError::CanonicalEventId(_) => "canonical_event_id", + DraftError::Envelope(_) => "event_envelope", + DraftError::SignedEvent(_) => "signed_event", } } @@ -1272,14 +1261,12 @@ fn builder_non_empty_string( } } -fn builder_validation_error( - error: RadrootsKnowledgeValidationError, -) -> RadrootsKnowledgeBuilderError { +fn builder_validation_error(error: KnowledgeValidationError) -> RadrootsKnowledgeBuilderError { match error { - RadrootsKnowledgeValidationError::EmptyField(field) => { + KnowledgeValidationError::EmptyField(field) => { RadrootsKnowledgeBuilderError::MissingField(field) } - RadrootsKnowledgeValidationError::InvalidField(field) => { + KnowledgeValidationError::InvalidField(field) => { RadrootsKnowledgeBuilderError::InvalidField(field) } } @@ -1287,7 +1274,7 @@ fn builder_validation_error( fn builder_validated<T>( value: T, - validate: fn(&T) -> Result<(), RadrootsKnowledgeValidationError>, + validate: fn(&T) -> Result<(), KnowledgeValidationError>, ) -> Result<T, RadrootsKnowledgeBuilderError> { validate(&value).map_err(builder_validation_error)?; Ok(value) @@ -1295,40 +1282,38 @@ fn builder_validated<T>( pub mod prelude { pub use super::{ - KIND_FILE_METADATA, KIND_KNOWLEDGE_CLAIM, KIND_KNOWLEDGE_FIELD_REPORT, - KIND_KNOWLEDGE_RELATION, KIND_KNOWLEDGE_REVIEW, KIND_KNOWLEDGE_SOURCE, KIND_WIKI_ARTICLE, - KIND_WIKI_MERGE_REQUEST, KIND_WIKI_REDIRECT, KNOWLEDGE_CLAIM_CONTRACT_ID, - KNOWLEDGE_FIELD_REPORT_CONTRACT_ID, KNOWLEDGE_RELATION_CONTRACT_ID, - KNOWLEDGE_REVIEW_CONTRACT_ID, KNOWLEDGE_SOURCE_CONTRACT_ID, KnowledgeCodec, - KnowledgeDraftBuilder, KnowledgeEventBuilder, RADROOTS_CONTRIBUTION_ATTESTATION_SCHEMA, + AddressableRef, DraftError, EventDraft, EventEnvelope, EventRef, KIND_FILE_METADATA, + KIND_KNOWLEDGE_CLAIM, KIND_KNOWLEDGE_FIELD_REPORT, KIND_KNOWLEDGE_RELATION, + KIND_KNOWLEDGE_REVIEW, KIND_KNOWLEDGE_SOURCE, KIND_WIKI_ARTICLE, KIND_WIKI_MERGE_REQUEST, + KIND_WIKI_REDIRECT, KNOWLEDGE_CLAIM_CONTRACT_ID, KNOWLEDGE_FIELD_REPORT_CONTRACT_ID, + KNOWLEDGE_RELATION_CONTRACT_ID, KNOWLEDGE_REVIEW_CONTRACT_ID, KNOWLEDGE_SOURCE_CONTRACT_ID, + KnowledgeChangeProposal, KnowledgeCitationSpan, KnowledgeClaim, KnowledgeCodec, + KnowledgeDraftBuilder, KnowledgeEventBuilder, KnowledgeFieldContext, KnowledgeFieldReport, + KnowledgeLocation, KnowledgeLocationPrecision, KnowledgeNodeRef, KnowledgeObservation, + KnowledgeObservationValue, KnowledgeRelation, KnowledgeReview, KnowledgeReviewScope, + KnowledgeReviewScore, KnowledgeReviewTarget, KnowledgeSource, KnowledgeValidationError, + Nip01EventWireParts, RADROOTS_CONTRIBUTION_ATTESTATION_SCHEMA, RADROOTS_EVIDENCE_BOUNTY_SCHEMA, RADROOTS_KNOWLEDGE_CHANGE_PROPOSAL_SCHEMA, RADROOTS_KNOWLEDGE_CLAIM_SCHEMA, RADROOTS_KNOWLEDGE_CONTRACT_MANIFEST_SCHEMA_VERSION, RADROOTS_KNOWLEDGE_FIELD_REPORT_SCHEMA, RADROOTS_KNOWLEDGE_RELATION_SCHEMA, RADROOTS_KNOWLEDGE_REVIEW_SCHEMA, RADROOTS_KNOWLEDGE_SCHEMA_VERSION, - RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, RADROOTS_WIKI_D_TAG_MAX_LEN, RadrootsAddressableRef, + RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, RADROOTS_WIKI_D_TAG_MAX_LEN, RadrootsContractValidatedEvent, RadrootsDecodeError, RadrootsDecodedEvent, - RadrootsDraftError, RadrootsEncodeError, RadrootsEventDraft, RadrootsEventEnvelope, - RadrootsEventRef, RadrootsIdVerifiedEvent, RadrootsKnowledgeBuilderError, - RadrootsKnowledgeChangeProposal, RadrootsKnowledgeCitationSpan, RadrootsKnowledgeClaim, + RadrootsEncodeError, RadrootsIdVerifiedEvent, RadrootsKnowledgeBuilderError, RadrootsKnowledgeClaimBuilder, RadrootsKnowledgeContractManifest, - RadrootsKnowledgeContractManifestEntry, RadrootsKnowledgeFieldContext, - RadrootsKnowledgeFieldReport, RadrootsKnowledgeFieldReportBuilder, - RadrootsKnowledgeLocation, RadrootsKnowledgeLocationPrecision, + RadrootsKnowledgeContractManifestEntry, RadrootsKnowledgeFieldReportBuilder, RadrootsKnowledgeManifestCodecSupport, RadrootsKnowledgeManifestDiscriminator, - RadrootsKnowledgeManifestTagContract, RadrootsKnowledgeNodeRef, - RadrootsKnowledgeObservation, RadrootsKnowledgeObservationValue, RadrootsKnowledgeRelation, - RadrootsKnowledgeRelationBuilder, RadrootsKnowledgeReview, RadrootsKnowledgeReviewBuilder, - RadrootsKnowledgeReviewScope, RadrootsKnowledgeReviewScore, RadrootsKnowledgeReviewTarget, - RadrootsKnowledgeSource, RadrootsKnowledgeSourceBuilder, RadrootsKnowledgeValidationError, - RadrootsNip01EventWireParts, 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, 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, + RadrootsKnowledgeManifestTagContract, RadrootsKnowledgeRelationBuilder, + RadrootsKnowledgeReviewBuilder, RadrootsKnowledgeSourceBuilder, + RadrootsNip01VerificationError, RadrootsSdkKnowledgeError, RadrootsSignatureVerifiedEvent, + RadrootsWikiArticleBuilder, RadrootsWikiMergeRequestBuilder, RadrootsWikiRedirectBuilder, + RightsAssertion, WIKI_ARTICLE_CONTRACT_ID, WIKI_MERGE_REQUEST_CONTRACT_ID, + WIKI_REDIRECT_CONTRACT_ID, WikiArticle, WikiArticleVersionRef, WikiDTagError, + WikiMergeRequest, WikiRedirect, 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, prepare_knowledge_claim_draft, prepare_knowledge_field_report_draft, prepare_knowledge_relation_draft, prepare_knowledge_review_draft, prepare_knowledge_source_draft, prepare_wiki_article_draft, diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs @@ -85,38 +85,37 @@ pub use crate::idempotency::{ }; #[cfg(feature = "knowledge")] pub use crate::knowledge::{ - KIND_FILE_METADATA, KIND_KNOWLEDGE_CLAIM, KIND_KNOWLEDGE_FIELD_REPORT, KIND_KNOWLEDGE_RELATION, + AddressableRef, DraftError, EventDraft, EventEnvelope, EventRef, KIND_FILE_METADATA, + KIND_KNOWLEDGE_CLAIM, KIND_KNOWLEDGE_FIELD_REPORT, KIND_KNOWLEDGE_RELATION, KIND_KNOWLEDGE_REVIEW, KIND_KNOWLEDGE_SOURCE, KIND_WIKI_ARTICLE, KIND_WIKI_MERGE_REQUEST, KIND_WIKI_REDIRECT, KNOWLEDGE_CLAIM_CONTRACT_ID, KNOWLEDGE_FIELD_REPORT_CONTRACT_ID, KNOWLEDGE_RELATION_CONTRACT_ID, KNOWLEDGE_REVIEW_CONTRACT_ID, KNOWLEDGE_SOURCE_CONTRACT_ID, - KnowledgeCodec, KnowledgeDraftBuilder, KnowledgeEventBuilder, + KnowledgeChangeProposal, KnowledgeCitationSpan, KnowledgeClaim, KnowledgeCodec, + KnowledgeDraftBuilder, KnowledgeEventBuilder, KnowledgeFieldContext, KnowledgeFieldReport, + KnowledgeLocation, KnowledgeLocationPrecision, KnowledgeNodeRef, KnowledgeObservation, + KnowledgeObservationValue, KnowledgeRelation, KnowledgeReview, KnowledgeReviewScope, + KnowledgeReviewScore, KnowledgeReviewTarget, KnowledgeSource, Nip01EventWireParts, RADROOTS_CONTRIBUTION_ATTESTATION_SCHEMA, RADROOTS_EVIDENCE_BOUNTY_SCHEMA, RADROOTS_KNOWLEDGE_CHANGE_PROPOSAL_SCHEMA, RADROOTS_KNOWLEDGE_CLAIM_SCHEMA, RADROOTS_KNOWLEDGE_CONTRACT_MANIFEST_SCHEMA_VERSION, RADROOTS_KNOWLEDGE_FIELD_REPORT_SCHEMA, RADROOTS_KNOWLEDGE_RELATION_SCHEMA, RADROOTS_KNOWLEDGE_REVIEW_SCHEMA, RADROOTS_KNOWLEDGE_SCHEMA_VERSION, RADROOTS_KNOWLEDGE_SOURCE_SCHEMA, - RADROOTS_WIKI_D_TAG_MAX_LEN, RadrootsAddressableRef, RadrootsContractValidatedEvent, - RadrootsDecodeError, RadrootsDecodedEvent, RadrootsDraftError, RadrootsEncodeError, - RadrootsEventDraft, RadrootsEventEnvelope, RadrootsEventRef, RadrootsIdVerifiedEvent, - RadrootsKnowledgeBuilderError, RadrootsKnowledgeChangeProposal, RadrootsKnowledgeCitationSpan, - RadrootsKnowledgeClaim, RadrootsKnowledgeClaimBuilder, RadrootsKnowledgeContractManifest, - RadrootsKnowledgeContractManifestEntry, RadrootsKnowledgeFieldContext, - RadrootsKnowledgeFieldReport, RadrootsKnowledgeFieldReportBuilder, RadrootsKnowledgeLocation, - RadrootsKnowledgeLocationPrecision, RadrootsKnowledgeManifestCodecSupport, + RADROOTS_WIKI_D_TAG_MAX_LEN, RadrootsContractValidatedEvent, RadrootsDecodeError, + RadrootsDecodedEvent, RadrootsEncodeError, RadrootsIdVerifiedEvent, + RadrootsKnowledgeBuilderError, RadrootsKnowledgeClaimBuilder, + RadrootsKnowledgeContractManifest, RadrootsKnowledgeContractManifestEntry, + RadrootsKnowledgeFieldReportBuilder, RadrootsKnowledgeManifestCodecSupport, RadrootsKnowledgeManifestDiscriminator, RadrootsKnowledgeManifestTagContract, - RadrootsKnowledgeNodeRef, RadrootsKnowledgeObservation, RadrootsKnowledgeObservationValue, - RadrootsKnowledgeRelation, RadrootsKnowledgeRelationBuilder, RadrootsKnowledgeReview, - RadrootsKnowledgeReviewBuilder, RadrootsKnowledgeReviewScope, RadrootsKnowledgeReviewScore, - RadrootsKnowledgeReviewTarget, RadrootsKnowledgeSource, RadrootsKnowledgeSourceBuilder, - RadrootsNip01EventWireParts, 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, 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, + RadrootsKnowledgeRelationBuilder, RadrootsKnowledgeReviewBuilder, + RadrootsKnowledgeSourceBuilder, RadrootsNip01VerificationError, RadrootsSdkKnowledgeError, + RadrootsSignatureVerifiedEvent, RadrootsWikiArticleBuilder, RadrootsWikiMergeRequestBuilder, + RadrootsWikiRedirectBuilder, RightsAssertion, WIKI_ARTICLE_CONTRACT_ID, + WIKI_MERGE_REQUEST_CONTRACT_ID, WIKI_REDIRECT_CONTRACT_ID, WikiArticle, WikiArticleVersionRef, + WikiDTagError, WikiMergeRequest, WikiRedirect, 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, prepare_knowledge_claim_draft, prepare_knowledge_field_report_draft, prepare_knowledge_relation_draft, prepare_knowledge_review_draft, prepare_knowledge_source_draft, prepare_wiki_article_draft, prepare_wiki_merge_request_draft, diff --git a/crates/sdk/src/listings_runtime.rs b/crates/sdk/src/listings_runtime.rs @@ -10,10 +10,10 @@ use crate::{ use radroots_authority::{RadrootsActorContext, RadrootsEventSigner}; #[cfg(feature = "runtime")] use radroots_event::{ - draft::RadrootsEventDraft, + draft::EventDraft, envelope::kind::KIND_CLASSIFIED_LISTING, - id::{RadrootsClassifiedListingAddress, RadrootsEventId}, - listing::operational::RadrootsOperationalListing, + id::{ClassifiedListingAddress, EventId}, + listing::operational::OperationalListing, }; #[cfg(feature = "runtime")] use radroots_outbox::RadrootsOutboxEnqueueStatus; @@ -41,7 +41,7 @@ pub struct ListingPreparePublishRequest { #[cfg(feature = "runtime")] impl ListingPreparePublishRequest { - pub fn new(actor: RadrootsActorContext, listing: RadrootsOperationalListing) -> Self { + pub fn new(actor: RadrootsActorContext, listing: OperationalListing) -> Self { Self { actor, document: RadrootsOperationalListingEditDocumentV1::new(listing), @@ -82,7 +82,7 @@ pub struct ListingEnqueuePublishRequest { impl ListingEnqueuePublishRequest { pub fn new( actor: RadrootsActorContext, - listing: RadrootsOperationalListing, + listing: OperationalListing, target_policy: TargetPolicy, ) -> Self { Self::from_document( @@ -141,23 +141,23 @@ impl ListingEnqueuePublishRequest { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct ListingPublishPlan { - public_listing_addr: RadrootsClassifiedListingAddress, - expected_event_id: RadrootsEventId, - frozen_draft: RadrootsEventDraft, + public_listing_addr: ClassifiedListingAddress, + expected_event_id: EventId, + frozen_draft: EventDraft, created_at: RadrootsSdkTimestamp, } #[cfg(feature = "runtime")] impl ListingPublishPlan { - pub fn public_listing_addr(&self) -> &RadrootsClassifiedListingAddress { + pub fn public_listing_addr(&self) -> &ClassifiedListingAddress { &self.public_listing_addr } - pub fn expected_event_id(&self) -> &RadrootsEventId { + pub fn expected_event_id(&self) -> &EventId { &self.expected_event_id } - pub fn frozen_draft(&self) -> &RadrootsEventDraft { + pub fn frozen_draft(&self) -> &EventDraft { &self.frozen_draft } @@ -188,9 +188,9 @@ impl From<RadrootsOutboxEnqueueStatus> for SdkMutationState { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct ListingEnqueueReceipt { - pub public_listing_addr: RadrootsClassifiedListingAddress, - pub expected_event_id: RadrootsEventId, - pub signed_event_id: RadrootsEventId, + pub public_listing_addr: ClassifiedListingAddress, + pub expected_event_id: EventId, + pub signed_event_id: EventId, pub local_event_seq: i64, pub outbox_operation_id: i64, pub outbox_event_id: i64, @@ -345,8 +345,8 @@ fn canonical_listing_edit( #[cfg(feature = "runtime")] struct ValidatedListingPublishPlanMetadata { - public_listing_addr: RadrootsClassifiedListingAddress, - expected_event_id: RadrootsEventId, + public_listing_addr: ClassifiedListingAddress, + expected_event_id: EventId, } #[cfg(feature = "runtime")] @@ -367,7 +367,7 @@ fn validate_listing_publish_plan( )); } - let expected_event_id = RadrootsEventId::parse(plan.frozen_draft.expected_event_id_hex()) + let expected_event_id = EventId::parse(plan.frozen_draft.expected_event_id_hex()) .expect("validated frozen draft has a typed event ID"); if plan.expected_event_id != expected_event_id { return Err(invalid("expected event ID does not match frozen draft")); @@ -389,7 +389,7 @@ fn validate_listing_publish_plan( "frozen draft contains duplicate listing identifiers", )); } - let public_listing_addr = RadrootsClassifiedListingAddress::parse(format!( + let public_listing_addr = ClassifiedListingAddress::parse(format!( "{KIND_CLASSIFIED_LISTING}:{}:{d_tag}", plan.frozen_draft.expected_pubkey().to_hex() )) @@ -415,7 +415,7 @@ fn listing_publish_plan( let mutation = RadrootsOperationalListingMutation::publish(canonical); let frozen_draft = build_operational_listing_mutation_draft(&mutation, u64::from(created_at_nostr))?; - let expected_event_id = RadrootsEventId::parse(frozen_draft.expected_event_id_hex()) + let expected_event_id = EventId::parse(frozen_draft.expected_event_id_hex()) .expect("frozen listing edit produces a valid event id"); Ok(ListingPublishPlan { public_listing_addr, diff --git a/crates/sdk/src/private_store.rs b/crates/sdk/src/private_store.rs @@ -2,7 +2,7 @@ use crate::RadrootsSdkError; use radroots_event::envelope::kind::KIND_FARM; -use radroots_event::id::{RadrootsAddressableCoordinate, RadrootsAddressableCoordinateParts}; +use radroots_event::id::{AddressableCoordinate, AddressableCoordinateParts}; use radroots_event::trade::RADROOTS_TRADE_MAX_PRIVATE_ARTIFACT_BYTES; use radroots_protected_store::{RadrootsProtectedFileKeySource, RadrootsProtectedStoreEnvelope}; use radroots_secret_vault::{RadrootsSecretKeyWrapping, RadrootsSecretVaultAccessError}; @@ -144,7 +144,7 @@ struct SdkPrivateStoreMemoryKeySource; #[derive(Clone, Debug, PartialEq)] pub(crate) struct SdkPrivateFarmLocationRecord { - pub farm_addr: RadrootsAddressableCoordinate, + pub farm_addr: AddressableCoordinate, pub farm_pubkey: String, pub farm_d_tag: String, pub label: Option<String>, @@ -385,7 +385,7 @@ impl SdkPrivateStore { pub async fn farm_location( &self, - farm_addr: &RadrootsAddressableCoordinate, + farm_addr: &AddressableCoordinate, ) -> Result<Option<SdkPrivateFarmLocationRecord>, RadrootsSdkError> { let parts = farm_location_parts(farm_addr)?; let owner_pubkey = parts.pubkey.as_bytes().to_vec(); @@ -408,7 +408,7 @@ impl SdkPrivateStore { pub async fn delete_farm_location( &self, - farm_addr: &RadrootsAddressableCoordinate, + farm_addr: &AddressableCoordinate, ) -> Result<bool, RadrootsSdkError> { let parts = farm_location_parts(farm_addr)?; let owner_pubkey = parts.pubkey.as_bytes().to_vec(); @@ -761,8 +761,8 @@ impl SdkPrivateStore { fn private_farm_location_from_row( &self, - farm_addr: RadrootsAddressableCoordinate, - parts: RadrootsAddressableCoordinateParts, + farm_addr: AddressableCoordinate, + parts: AddressableCoordinateParts, row: sqlx::sqlite::SqliteRow, ) -> Result<SdkPrivateFarmLocationRecord, RadrootsSdkError> { let ciphertext: Vec<u8> = row.try_get("ciphertext").map_err(private_store_error)?; @@ -904,9 +904,9 @@ async fn query_string(pool: &SqlitePool, sql: &'static str) -> Result<String, Ra } fn farm_location_parts( - farm_addr: &RadrootsAddressableCoordinate, -) -> Result<RadrootsAddressableCoordinateParts, RadrootsSdkError> { - let parts = RadrootsAddressableCoordinateParts::parse(farm_addr.as_str()).map_err(|error| { + farm_addr: &AddressableCoordinate, +) -> Result<AddressableCoordinateParts, RadrootsSdkError> { + let parts = AddressableCoordinateParts::parse(farm_addr.as_str()).map_err(|error| { RadrootsSdkError::InvalidRequest { message: format!("farm address is invalid: {error}"), } diff --git a/crates/sdk/src/signer_provider.rs b/crates/sdk/src/signer_provider.rs @@ -4,12 +4,12 @@ use radroots_authority::{ RadrootsActorContext, RadrootsEventSigner, RadrootsSignerError, authorize_actor_for_draft, authorize_signer_for_draft, sign_authorized_draft, validate_signed_event_matches_draft, }; -use radroots_event::draft::{RadrootsEventDraft, RadrootsSignedEvent}; +use radroots_event::draft::{EventDraft, SignedEvent}; use radroots_event::envelope::kind::{ KIND_CLASSIFIED_LISTING, KIND_FARM, KIND_TRADE_CANCELLATION, KIND_TRADE_DECISION, KIND_TRADE_PROPOSAL, KIND_TRADE_REVISION_DECISION, KIND_TRADE_REVISION_PROPOSAL, }; -use radroots_event::wire::RadrootsNip01EventWire; +use radroots_event::wire::Nip01EventWire; use radroots_identity::PublicKey; use radroots_nostr::prelude::{RadrootsNostrEvent, RadrootsNostrKeys}; use radroots_nostr_connect::prelude::{ @@ -120,7 +120,7 @@ where pub struct RadrootsSdkSignRequest<'a> { pub operation_kind: &'a str, pub actor: &'a RadrootsActorContext, - pub frozen_draft: &'a RadrootsEventDraft, + pub frozen_draft: &'a EventDraft, 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 RadrootsEventDraft, + frozen_draft: &'a EventDraft, ) -> 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: RadrootsSignedEvent, + pub signed_event: SignedEvent, } #[derive(Clone)] @@ -524,10 +524,7 @@ impl RadrootsEventSigner for RadrootsSdkSignerIdentityOnly { &self.pubkey } - fn sign_frozen_draft( - &self, - _draft: &RadrootsEventDraft, - ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { + fn sign_frozen_draft(&self, _draft: &EventDraft) -> Result<SignedEvent, RadrootsSignerError> { Err(RadrootsSignerError::Unavailable) } } @@ -552,7 +549,7 @@ impl RadrootsNostrConnectClientTransport for RadrootsSdkNip46TransportAdapter<'_ } fn sign_event_request_from_frozen_draft( - draft: &RadrootsEventDraft, + draft: &EventDraft, ) -> Result<RadrootsNostrConnectRequest, RadrootsSdkError> { let public_key = nip46_unsigned_event_pubkey(draft)?; let kind = nip46_unsigned_event_kind(draft)?; @@ -568,9 +565,7 @@ fn sign_event_request_from_frozen_draft( Ok(RadrootsNostrConnectRequest::SignEvent(unsigned_event)) } -fn nip46_unsigned_event_pubkey( - draft: &RadrootsEventDraft, -) -> Result<NostrPublicKey, RadrootsSdkError> { +fn nip46_unsigned_event_pubkey(draft: &EventDraft) -> Result<NostrPublicKey, RadrootsSdkError> { NostrPublicKey::from_slice(draft.expected_pubkey().as_bytes()).map_err(|error| { nip46_sign_event_protocol_error(format!( "failed to parse frozen draft pubkey for NIP-46 unsigned event: {error}" @@ -578,7 +573,7 @@ fn nip46_unsigned_event_pubkey( }) } -fn nip46_unsigned_event_kind(draft: &RadrootsEventDraft) -> Result<Kind, RadrootsSdkError> { +fn nip46_unsigned_event_kind(draft: &EventDraft) -> Result<Kind, RadrootsSdkError> { let kind = u16::try_from(draft.kind_u32()).map_err(|error| { nip46_sign_event_protocol_error(format!( "failed to convert frozen draft kind to NIP-46 unsigned event: {error}" @@ -587,7 +582,7 @@ fn nip46_unsigned_event_kind(draft: &RadrootsEventDraft) -> Result<Kind, Radroot Ok(Kind::from_u16(kind)) } -fn nip46_unsigned_event_tags(draft: &RadrootsEventDraft) -> Result<Vec<Tag>, RadrootsSdkError> { +fn nip46_unsigned_event_tags(draft: &EventDraft) -> Result<Vec<Tag>, RadrootsSdkError> { let raw_tags = draft.tags_as_vec(); let mut tags = Vec::with_capacity(raw_tags.len()); for raw_tag in raw_tags { @@ -611,18 +606,18 @@ fn nip46_sign_event_protocol_error(reason: String) -> RadrootsSdkError { fn signed_event_from_nip46_response( operation_kind: &str, response: RadrootsNostrConnectResponse, -) -> Result<RadrootsSignedEvent, RadrootsSdkError> { +) -> Result<SignedEvent, RadrootsSdkError> { match response { RadrootsNostrConnectResponse::SignedEvent(event) => { let raw_json = event.as_json(); - let wire = RadrootsNip01EventWire::parse_json(raw_json.as_str()).map_err(|error| { + let wire = Nip01EventWire::parse_json(raw_json.as_str()).map_err(|error| { RadrootsSdkError::SignerProtocol { mode: RadrootsSdkSignerMode::MycNip46.as_str().to_owned(), reason: format!("remote signed event wire is invalid: {error}"), } })?; let signed_event = - RadrootsSignedEvent::from_wire_verified_id(wire, raw_json).map_err(|error| { + SignedEvent::from_wire_verified_id(wire, raw_json).map_err(|error| { RadrootsSdkError::SignerProtocol { mode: RadrootsSdkSignerMode::MycNip46.as_str().to_owned(), reason: format!("remote signed event is invalid: {error}"), @@ -686,7 +681,7 @@ fn sign_receipt( mode: RadrootsSdkSignerMode, signer_pubkey: String, remote_signer_pubkey: Option<String>, - signed_event: RadrootsSignedEvent, + signed_event: SignedEvent, ) -> RadrootsSdkSignReceipt { RadrootsSdkSignReceipt { operation_kind: operation_kind.to_owned(), diff --git a/crates/sdk/src/sync_runtime.rs b/crates/sdk/src/sync_runtime.rs @@ -12,7 +12,7 @@ use crate::{ #[cfg(all(feature = "runtime", feature = "radrootsd-execution"))] use crate::{RadrootsdExecutionAuth, RadrootsdExecutionProfile}; #[cfg(feature = "runtime")] -use radroots_event::id::RadrootsEventId; +use radroots_event::id::EventId; #[cfg(feature = "runtime")] use radroots_event_store::{RADROOTS_EVENT_STORE_QUERY_LIMIT_MAX, RadrootsEventStoreStatusSummary}; #[cfg(all(feature = "runtime", feature = "transport-nostr-runtime"))] @@ -503,7 +503,7 @@ impl PushOutboxReceipt { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct PushOutboxEventReceipt { - pub event_id: RadrootsEventId, + pub event_id: EventId, pub outbox_event_id: i64, pub final_state: PushOutboxEventState, pub attempted_count: usize, @@ -1696,7 +1696,7 @@ fn radrootsd_error_message(error: &RadrootsdError) -> String { #[cfg(all(feature = "runtime", feature = "radrootsd-execution"))] fn radrootsd_transport_error_receipt( claimed: &RadrootsOutboxClaimedEvent, - event: &radroots_event::draft::RadrootsSignedEvent, + event: &radroots_event::draft::SignedEvent, delivery_policy: &TransportPublishDeliveryPolicy, message: String, ) -> Result<PushOutboxEventReceipt, RadrootsSdkError> { @@ -1923,8 +1923,8 @@ fn push_event_receipt( } #[cfg(feature = "runtime")] -fn push_receipt_event_id(value: &str, field: &str) -> Result<RadrootsEventId, RadrootsSdkError> { - RadrootsEventId::parse(value).map_err(|error| RadrootsSdkError::InvalidRequest { +fn push_receipt_event_id(value: &str, field: &str) -> Result<EventId, RadrootsSdkError> { + EventId::parse(value).map_err(|error| RadrootsSdkError::InvalidRequest { message: format!("{field} is invalid: {error}"), }) } diff --git a/crates/sdk/src/trade_runtime.rs b/crates/sdk/src/trade_runtime.rs @@ -19,14 +19,13 @@ use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD}; use radroots_authority::{RadrootsActorContext, RadrootsEventSigner}; #[cfg(feature = "runtime")] use radroots_event::{ - draft::RadrootsEventDraft, + draft::EventDraft, envelope::kind::TRADE_MUTATION_EVENT_KINDS, - id::{RadrootsEventId, RadrootsTradeCandidateId, RadrootsTradeId, RadrootsTradeMutationId}, + id::{CandidateId, EventId, MutationId, TradeId}, trade::{ RADROOTS_TRADE_MAX_PRIVATE_ARTIFACT_BYTES, RADROOTS_TRADE_MUTATION_CONTRACT_IDS, - RADROOTS_TRADE_SCHEMA_VERSION, RadrootsTradeDecisionV1, RadrootsTradeMutationBodyV1, - RadrootsTradeMutationEnvelopeV1, RadrootsTradePrivateTermsRefV1, - trade_mutation_from_canonical_content, + RADROOTS_TRADE_SCHEMA_VERSION, TradeDecisionV1, TradeMutationBodyV1, + TradeMutationEnvelopeV1, TradePrivateTermsRefV1, trade_mutation_from_canonical_content, }, }; #[cfg(feature = "runtime")] @@ -299,7 +298,7 @@ impl<'client> TradesClient<'client> { pub struct SubmitProposalRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub envelope: RadrootsTradeMutationEnvelopeV1, + pub envelope: TradeMutationEnvelopeV1, pub target_policy: TargetPolicy, pub satisfaction_policy: SatisfactionPolicy, pub idempotency_key: Option<SdkIdempotencyKey>, @@ -309,7 +308,7 @@ pub struct SubmitProposalRequest { impl SubmitProposalRequest { pub fn new( actor: RadrootsActorContext, - envelope: RadrootsTradeMutationEnvelopeV1, + envelope: TradeMutationEnvelopeV1, target_policy: TargetPolicy, ) -> Self { Self { @@ -346,7 +345,7 @@ impl SubmitProposalRequest { pub struct ProposeRevisionRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub envelope: RadrootsTradeMutationEnvelopeV1, + pub envelope: TradeMutationEnvelopeV1, pub target_policy: TargetPolicy, pub satisfaction_policy: SatisfactionPolicy, pub idempotency_key: Option<SdkIdempotencyKey>, @@ -356,7 +355,7 @@ pub struct ProposeRevisionRequest { impl ProposeRevisionRequest { pub fn new( actor: RadrootsActorContext, - envelope: RadrootsTradeMutationEnvelopeV1, + envelope: TradeMutationEnvelopeV1, target_policy: TargetPolicy, ) -> Self { Self { @@ -385,7 +384,7 @@ impl ProposeRevisionRequest { pub struct DecideCandidateRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub envelope: RadrootsTradeMutationEnvelopeV1, + pub envelope: TradeMutationEnvelopeV1, pub target_policy: TargetPolicy, pub satisfaction_policy: SatisfactionPolicy, pub idempotency_key: Option<SdkIdempotencyKey>, @@ -396,7 +395,7 @@ pub struct DecideCandidateRequest { impl DecideCandidateRequest { pub fn new( actor: RadrootsActorContext, - envelope: RadrootsTradeMutationEnvelopeV1, + envelope: TradeMutationEnvelopeV1, target_policy: TargetPolicy, ) -> Self { Self { @@ -431,7 +430,7 @@ impl DecideCandidateRequest { pub struct CancelTradeRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub envelope: RadrootsTradeMutationEnvelopeV1, + pub envelope: TradeMutationEnvelopeV1, pub target_policy: TargetPolicy, pub satisfaction_policy: SatisfactionPolicy, pub idempotency_key: Option<SdkIdempotencyKey>, @@ -441,7 +440,7 @@ pub struct CancelTradeRequest { impl CancelTradeRequest { pub fn new( actor: RadrootsActorContext, - envelope: RadrootsTradeMutationEnvelopeV1, + envelope: TradeMutationEnvelopeV1, target_policy: TargetPolicy, ) -> Self { Self { @@ -465,7 +464,7 @@ impl CancelTradeRequest { pub struct ResumeOperationRequest { #[serde(serialize_with = "crate::actor_json::serialize_actor_context")] pub actor: RadrootsActorContext, - pub envelope: RadrootsTradeMutationEnvelopeV1, + pub envelope: TradeMutationEnvelopeV1, pub operation_kind: &'static str, pub target_policy: TargetPolicy, pub satisfaction_policy: SatisfactionPolicy, @@ -477,7 +476,7 @@ pub struct ResumeOperationRequest { impl ResumeOperationRequest { pub fn new( actor: RadrootsActorContext, - envelope: RadrootsTradeMutationEnvelopeV1, + envelope: TradeMutationEnvelopeV1, operation_kind: &'static str, target_policy: TargetPolicy, ) -> Self { @@ -516,10 +515,10 @@ pub struct TradeCommandReceipt { pub api_version: u16, pub operation_kind: String, pub operation_state: TradeCommandLifecycleState, - pub trade_id: RadrootsTradeId, - pub mutation_id: RadrootsTradeMutationId, - pub expected_event_id: RadrootsEventId, - pub signed_event_id: RadrootsEventId, + pub trade_id: TradeId, + pub mutation_id: MutationId, + pub expected_event_id: EventId, + pub signed_event_id: EventId, pub local_event_seq: i64, pub outbox_operation_id: i64, pub outbox_event_id: i64, @@ -569,8 +568,8 @@ impl From<SdkPrivateTradeArtifactKind> for TradePrivateArtifactKind { #[non_exhaustive] pub struct TradePrivateArtifactSealRequest { pub artifact_id: String, - pub trade_id: RadrootsTradeId, - pub candidate_id: Option<RadrootsTradeCandidateId>, + pub trade_id: TradeId, + pub candidate_id: Option<CandidateId>, pub artifact_kind: TradePrivateArtifactKind, pub schema_id: String, pub plaintext: Vec<u8>, @@ -582,7 +581,7 @@ pub struct TradePrivateArtifactSealRequest { impl TradePrivateArtifactSealRequest { pub fn binding_terms( artifact_id: impl Into<String>, - trade_id: RadrootsTradeId, + trade_id: TradeId, schema_id: impl Into<String>, plaintext: impl Into<Vec<u8>>, ) -> Self { @@ -603,7 +602,7 @@ impl TradePrivateArtifactSealRequest { self } - pub fn with_candidate_id(mut self, candidate_id: RadrootsTradeCandidateId) -> Self { + pub fn with_candidate_id(mut self, candidate_id: CandidateId) -> Self { self.candidate_id = Some(candidate_id); self } @@ -618,12 +617,12 @@ impl TradePrivateArtifactSealRequest { #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct TradePrivateArtifactSealReceipt { pub artifact_id: String, - pub trade_id: RadrootsTradeId, - pub candidate_id: Option<RadrootsTradeCandidateId>, + pub trade_id: TradeId, + pub candidate_id: Option<CandidateId>, pub artifact_kind: TradePrivateArtifactKind, pub schema_id: String, pub ciphertext_commitment: String, - pub private_terms_ref: Option<RadrootsTradePrivateTermsRefV1>, + pub private_terms_ref: Option<TradePrivateTermsRefV1>, pub retention_class: String, pub created_at_ms: i64, pub expires_at_ms: Option<i64>, @@ -649,8 +648,8 @@ impl TradePrivateArtifactOpenRequest { #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct TradePrivateArtifactOpenReceipt { pub artifact_id: String, - pub trade_id: RadrootsTradeId, - pub candidate_id: Option<RadrootsTradeCandidateId>, + pub trade_id: TradeId, + pub candidate_id: Option<CandidateId>, pub artifact_kind: TradePrivateArtifactKind, pub schema_id: String, pub plaintext: Vec<u8>, @@ -791,12 +790,12 @@ fn trade_runtime_capabilities() -> TradeRuntimeCapabilityReport { #[derive(Clone, Debug, Serialize)] #[non_exhaustive] pub struct GetTradeRequest { - pub trade_id: RadrootsTradeId, + pub trade_id: TradeId, } #[cfg(feature = "runtime")] impl GetTradeRequest { - pub fn new(trade_id: RadrootsTradeId) -> Self { + pub fn new(trade_id: TradeId) -> Self { Self { trade_id } } } @@ -805,12 +804,12 @@ impl GetTradeRequest { #[derive(Clone, Debug, Serialize)] #[non_exhaustive] pub struct RefreshTradeEvidenceRequest { - pub trade_id: RadrootsTradeId, + pub trade_id: TradeId, } #[cfg(feature = "runtime")] impl RefreshTradeEvidenceRequest { - pub fn new(trade_id: RadrootsTradeId) -> Self { + pub fn new(trade_id: TradeId) -> Self { Self { trade_id } } } @@ -819,14 +818,14 @@ impl RefreshTradeEvidenceRequest { #[derive(Clone, Debug, Serialize)] #[non_exhaustive] pub struct InspectEvidenceRequest { - pub trade_id: RadrootsTradeId, + pub trade_id: TradeId, pub limit: Option<u32>, pub cursor: Option<String>, } #[cfg(feature = "runtime")] impl InspectEvidenceRequest { - pub fn new(trade_id: RadrootsTradeId) -> Self { + pub fn new(trade_id: TradeId) -> Self { Self { trade_id, limit: None, @@ -966,7 +965,7 @@ pub struct Page<T> { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct TradeStatusView { - pub trade_id: RadrootsTradeId, + pub trade_id: TradeId, pub projection: RadrootsTradeProjectionV1, pub source_event_count: usize, pub private_terms: Vec<TradePrivateTermsAvailabilityView>, @@ -975,8 +974,8 @@ pub struct TradeStatusView { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct TradeSummaryView { - pub trade_id: RadrootsTradeId, - pub root_mutation_id: Option<RadrootsTradeMutationId>, + pub trade_id: TradeId, + pub root_mutation_id: Option<MutationId>, pub buyer_pubkey: Option<String>, pub seller_pubkey: Option<String>, pub farm_id: Option<String>, @@ -996,7 +995,7 @@ pub struct TradeSummaryView { #[cfg(feature = "runtime")] #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct TradePrivateTermsAvailabilityView { - pub candidate_id: RadrootsTradeCandidateId, + pub candidate_id: CandidateId, pub artifact_id: Option<String>, pub schema_id: Option<String>, pub ciphertext_commitment: Option<String>, @@ -1007,7 +1006,7 @@ pub struct TradePrivateTermsAvailabilityView { #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct EvidenceRefreshReceipt { pub api_version: u16, - pub trade_id: RadrootsTradeId, + pub trade_id: TradeId, pub evidence_count: usize, pub projection_digest: String, pub projection_state: RadrootsTradePrivateTermsStateV1, @@ -1017,8 +1016,8 @@ pub struct EvidenceRefreshReceipt { #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct EvidenceView { pub artifact_id: String, - pub trade_id: RadrootsTradeId, - pub candidate_id: Option<RadrootsTradeCandidateId>, + pub trade_id: TradeId, + pub candidate_id: Option<CandidateId>, pub artifact_kind: TradePrivateArtifactKind, pub schema_id: String, pub ciphertext_commitment: String, @@ -1034,9 +1033,9 @@ pub struct EvidenceView { struct TradeCommandPlan { operation_kind: &'static str, actor: RadrootsActorContext, - frozen_draft: RadrootsEventDraft, - trade_id: RadrootsTradeId, - mutation_id: RadrootsTradeMutationId, + frozen_draft: EventDraft, + trade_id: TradeId, + mutation_id: MutationId, target_policy: TargetPolicy, satisfaction_policy: SatisfactionPolicy, idempotency_key: Option<SdkIdempotencyKey>, @@ -1067,7 +1066,7 @@ impl TradeCommandRequest { self, ) -> ( RadrootsActorContext, - RadrootsTradeMutationEnvelopeV1, + TradeMutationEnvelopeV1, TargetPolicy, SatisfactionPolicy, Option<SdkIdempotencyKey>, @@ -1131,14 +1130,14 @@ struct TradeListCursorPayload { #[cfg(feature = "runtime")] #[derive(Clone, Debug)] struct TradeListRow { - trade_id: RadrootsTradeId, + trade_id: TradeId, updated_event_seq: i64, } #[cfg(feature = "runtime")] #[derive(Clone, Debug)] struct LastTradeMutationSnapshot { - mutation_id: Option<RadrootsTradeMutationId>, + mutation_id: Option<MutationId>, event_seq: Option<i64>, } @@ -1196,7 +1195,7 @@ async fn trade_command_plan( "canonical trade mutation is missing mutation id", ) })?; - let frozen_draft = RadrootsEventDraft::new( + let frozen_draft = EventDraft::new( canonical.contract_id.as_str(), wire.kind, canonical.authored_at_unix_s, @@ -1248,7 +1247,7 @@ async fn trade_command_receipt( operation_state: TradeCommandLifecycleState::Committed, trade_id: plan.trade_id, mutation_id: plan.mutation_id, - expected_event_id: RadrootsEventId::parse(plan.frozen_draft.expected_event_id_hex()) + expected_event_id: EventId::parse(plan.frozen_draft.expected_event_id_hex()) .expect("trade workflow draft has a valid expected event id"), signed_event_id: enqueue.signed_event_id, local_event_seq: enqueue.local_event_seq, @@ -1265,28 +1264,21 @@ async fn trade_command_receipt( #[cfg(feature = "runtime")] fn validate_operation_body( operation_kind: &'static str, - envelope: &RadrootsTradeMutationEnvelopeV1, + envelope: &TradeMutationEnvelopeV1, ) -> Result<(), RadrootsSdkError> { let valid = match operation_kind { TRADE_SUBMIT_PROPOSAL_OPERATION_KIND => { - matches!(envelope.body, RadrootsTradeMutationBodyV1::Proposal { .. }) + matches!(envelope.body, TradeMutationBodyV1::Proposal { .. }) } TRADE_PROPOSE_REVISION_OPERATION_KIND => { - matches!( - envelope.body, - RadrootsTradeMutationBodyV1::RevisionProposal { .. } - ) + matches!(envelope.body, TradeMutationBodyV1::RevisionProposal { .. }) } TRADE_DECIDE_CANDIDATE_OPERATION_KIND | TRADE_RESUME_OPERATION_KIND => matches!( envelope.body, - RadrootsTradeMutationBodyV1::Decision { .. } - | RadrootsTradeMutationBodyV1::RevisionDecision { .. } + TradeMutationBodyV1::Decision { .. } | TradeMutationBodyV1::RevisionDecision { .. } ), TRADE_CANCEL_OPERATION_KIND => { - matches!( - envelope.body, - RadrootsTradeMutationBodyV1::Cancellation { .. } - ) + matches!(envelope.body, TradeMutationBodyV1::Cancellation { .. }) } _ => true, }; @@ -1305,7 +1297,7 @@ fn validate_operation_body( fn validate_actor_matches_envelope( operation_kind: &'static str, actor: &RadrootsActorContext, - envelope: &RadrootsTradeMutationEnvelopeV1, + envelope: &TradeMutationEnvelopeV1, ) -> Result<(), RadrootsSdkError> { if actor.pubkey() == &envelope.author_pubkey { Ok(()) @@ -1321,12 +1313,12 @@ fn validate_actor_matches_envelope( async fn validate_command_private_terms( sdk: &RadrootsClient, operation_kind: &'static str, - envelope: &RadrootsTradeMutationEnvelopeV1, + envelope: &TradeMutationEnvelopeV1, private_terms_acknowledged: bool, ) -> Result<(), RadrootsSdkError> { match &envelope.body { - RadrootsTradeMutationBodyV1::Proposal { candidate } - | RadrootsTradeMutationBodyV1::RevisionProposal { candidate } => { + TradeMutationBodyV1::Proposal { candidate } + | TradeMutationBodyV1::RevisionProposal { candidate } => { let Some(candidate_id) = &candidate.candidate_id else { return Ok(()); }; @@ -1349,17 +1341,17 @@ async fn validate_command_private_terms( } Ok(()) } - RadrootsTradeMutationBodyV1::Decision { + TradeMutationBodyV1::Decision { proposal_mutation_id, candidate_id, decision, } - | RadrootsTradeMutationBodyV1::RevisionDecision { + | TradeMutationBodyV1::RevisionDecision { proposal_mutation_id, candidate_id, decision, } => { - if !matches!(decision, RadrootsTradeDecisionV1::Accepted { .. }) { + if !matches!(decision, TradeDecisionV1::Accepted { .. }) { return Ok(()); } let Some(candidate_ref) = referenced_candidate_for_decision( @@ -1400,7 +1392,7 @@ async fn validate_command_private_terms( ) .await } - RadrootsTradeMutationBodyV1::Cancellation { .. } => Ok(()), + TradeMutationBodyV1::Cancellation { .. } => Ok(()), } } @@ -1408,9 +1400,9 @@ async fn validate_command_private_terms( async fn referenced_candidate_for_decision( sdk: &RadrootsClient, operation_kind: &'static str, - proposal_mutation_id: &RadrootsTradeMutationId, - candidate_id: &RadrootsTradeCandidateId, -) -> Result<Option<radroots_event::trade::RadrootsTradeCandidateTermsV1>, RadrootsSdkError> { + proposal_mutation_id: &MutationId, + candidate_id: &CandidateId, +) -> Result<Option<radroots_event::trade::TradeCandidateTermsV1>, RadrootsSdkError> { let Some(stored) = sdk ._event_store .get_trade_mutation(proposal_mutation_id) @@ -1424,8 +1416,8 @@ async fn referenced_candidate_for_decision( }; let envelope = stored_trade_envelope(&stored)?; let candidate = match envelope.body { - RadrootsTradeMutationBodyV1::Proposal { candidate } - | RadrootsTradeMutationBodyV1::RevisionProposal { candidate } => candidate, + TradeMutationBodyV1::Proposal { candidate } + | TradeMutationBodyV1::RevisionProposal { candidate } => candidate, _ => { return Err(trade_command_error( RadrootsSdkTradeErrorKind::InvalidCommandBody, @@ -1448,9 +1440,9 @@ async fn referenced_candidate_for_decision( async fn ensure_private_terms_ref_available( sdk: &RadrootsClient, operation_kind: &'static str, - trade_id: &RadrootsTradeId, - candidate_id: &RadrootsTradeCandidateId, - private_ref: &RadrootsTradePrivateTermsRefV1, + trade_id: &TradeId, + candidate_id: &CandidateId, + private_ref: &TradePrivateTermsRefV1, ) -> Result<(), RadrootsSdkError> { let trade_id_hex = trade_id.to_hex(); let candidate_id_hex = candidate_id.to_hex(); @@ -1488,10 +1480,7 @@ async fn seal_private_artifact( let input = SdkPrivateTradeArtifactInput { artifact_id: request.artifact_id, trade_id: request.trade_id.to_hex(), - candidate_id: request - .candidate_id - .as_ref() - .map(RadrootsTradeCandidateId::to_hex), + candidate_id: request.candidate_id.as_ref().map(CandidateId::to_hex), artifact_kind: request.artifact_kind.into(), schema_id: request.schema_id, plaintext: request.plaintext, @@ -1509,7 +1498,7 @@ fn seal_receipt_from_metadata( ) -> TradePrivateArtifactSealReceipt { let artifact_kind = TradePrivateArtifactKind::from(metadata.artifact_kind); let private_terms_ref = if artifact_kind == TradePrivateArtifactKind::BindingTerms { - Some(RadrootsTradePrivateTermsRefV1 { + Some(TradePrivateTermsRefV1 { artifact_id: metadata.artifact_id.clone(), schema_id: metadata.schema_id.clone(), ciphertext_commitment: metadata.ciphertext_commitment.clone(), @@ -1520,7 +1509,7 @@ fn seal_receipt_from_metadata( }; TradePrivateArtifactSealReceipt { artifact_id: metadata.artifact_id, - trade_id: RadrootsTradeId::parse(metadata.trade_id).expect("stored trade id is valid"), + trade_id: TradeId::parse(metadata.trade_id).expect("stored trade id is valid"), candidate_id: parse_optional_candidate_id(metadata.candidate_id), artifact_kind, schema_id: metadata.schema_id, @@ -1546,7 +1535,7 @@ async fn open_private_artifact( }; Ok(Some(TradePrivateArtifactOpenReceipt { artifact_id: record.artifact_id, - trade_id: RadrootsTradeId::parse(record.trade_id).expect("stored trade id is valid"), + trade_id: TradeId::parse(record.trade_id).expect("stored trade id is valid"), candidate_id: parse_optional_candidate_id(record.candidate_id), artifact_kind: record.artifact_kind.into(), schema_id: record.schema_id, @@ -1578,7 +1567,7 @@ async fn delete_private_artifact( #[cfg(feature = "runtime")] async fn trade_status_view( sdk: &RadrootsClient, - trade_id: &RadrootsTradeId, + trade_id: &TradeId, ) -> Result<TradeStatusView, RadrootsSdkError> { let projection = trade_projection_for_trade(sdk, trade_id).await?; let private_terms = private_terms_views_for_trade(sdk, trade_id).await?; @@ -1598,7 +1587,7 @@ async fn trade_status_view( #[cfg(feature = "runtime")] async fn trade_projection_for_trade( sdk: &RadrootsClient, - trade_id: &RadrootsTradeId, + trade_id: &TradeId, ) -> Result<RadrootsTradeProjectionV1, RadrootsSdkError> { let stored = sdk ._event_store @@ -1625,7 +1614,7 @@ async fn trade_projection_for_trade( #[cfg(feature = "runtime")] async fn private_terms_views_for_trade( sdk: &RadrootsClient, - trade_id: &RadrootsTradeId, + trade_id: &TradeId, ) -> Result<Vec<TradePrivateTermsAvailabilityView>, RadrootsSdkError> { let stored = sdk ._event_store @@ -1640,7 +1629,7 @@ async fn private_terms_views_for_trade( .into_iter() .map(|item| (item.candidate_id, item.state)) .collect::<BTreeMap<_, _>>(); - let mut views = BTreeMap::<RadrootsTradeCandidateId, TradePrivateTermsAvailabilityView>::new(); + let mut views = BTreeMap::<CandidateId, TradePrivateTermsAvailabilityView>::new(); for record in records { if let Some((candidate_id, private_ref)) = candidate_private_ref(&record.mutation) { let state = evidence_by_candidate @@ -1664,7 +1653,7 @@ async fn private_terms_views_for_trade( #[cfg(feature = "runtime")] async fn private_terms_evidence_for_mutations( sdk: &RadrootsClient, - trade_id: &RadrootsTradeId, + trade_id: &TradeId, mutations: &[RadrootsTradeMutationRecordV1], ) -> Result<Vec<RadrootsTradePrivateTermsEvidenceV1>, RadrootsSdkError> { let mut evidence = Vec::new(); @@ -1694,11 +1683,11 @@ async fn private_terms_evidence_for_mutations( #[cfg(feature = "runtime")] fn candidate_private_ref( - envelope: &RadrootsTradeMutationEnvelopeV1, -) -> Option<(RadrootsTradeCandidateId, RadrootsTradePrivateTermsRefV1)> { + envelope: &TradeMutationEnvelopeV1, +) -> Option<(CandidateId, TradePrivateTermsRefV1)> { match &envelope.body { - RadrootsTradeMutationBodyV1::Proposal { candidate } - | RadrootsTradeMutationBodyV1::RevisionProposal { candidate } => { + TradeMutationBodyV1::Proposal { candidate } + | TradeMutationBodyV1::RevisionProposal { candidate } => { let candidate_id = candidate.candidate_id?; let private_ref = candidate.private_terms.clone()?; Some((candidate_id, private_ref)) @@ -1720,7 +1709,7 @@ fn stored_trade_mutation_record( #[cfg(feature = "runtime")] fn stored_trade_envelope( stored: &RadrootsStoredTradeMutation, -) -> Result<RadrootsTradeMutationEnvelopeV1, RadrootsSdkError> { +) -> Result<TradeMutationEnvelopeV1, RadrootsSdkError> { let content = std::str::from_utf8(stored.canonical_payload_bytes.as_slice()).map_err(|error| { RadrootsSdkError::Projection { @@ -1871,7 +1860,7 @@ async fn list_trade_rows( rows.into_iter() .map(|row| { Ok(TradeListRow { - trade_id: RadrootsTradeId::parse( + trade_id: TradeId::parse( row.try_get::<String, _>("trade_id") .map_err(trade_query_store_error)?, ) @@ -1922,8 +1911,7 @@ async fn inspect_evidence_views( }; items.push(EvidenceView { artifact_id: item.artifact_id.clone(), - trade_id: RadrootsTradeId::parse(item.trade_id.clone()) - .expect("stored trade id is valid"), + trade_id: TradeId::parse(item.trade_id.clone()).expect("stored trade id is valid"), candidate_id: parse_optional_candidate_id(item.candidate_id.clone()), artifact_kind: item.artifact_kind.into(), schema_id: item.schema_id.clone(), @@ -1947,7 +1935,7 @@ async fn inspect_evidence_views( #[cfg(feature = "runtime")] async fn last_trade_mutation_snapshot( sdk: &RadrootsClient, - trade_id: &RadrootsTradeId, + trade_id: &TradeId, ) -> Result<LastTradeMutationSnapshot, RadrootsSdkError> { let row = sqlx::query( "SELECT mutation_id, first_event_seq FROM trade_mutation WHERE trade_id = ? ORDER BY first_event_seq DESC, mutation_id DESC LIMIT 1", @@ -1959,7 +1947,7 @@ async fn last_trade_mutation_snapshot( match row { Some(row) => Ok(LastTradeMutationSnapshot { mutation_id: Some( - RadrootsTradeMutationId::parse( + MutationId::parse( row.try_get::<String, _>("mutation_id") .map_err(trade_query_store_error)?, ) @@ -2134,10 +2122,9 @@ fn enum_label<T: Serialize>(value: &T) -> Result<String, RadrootsSdkError> { } #[cfg(feature = "runtime")] -fn parse_optional_candidate_id(value: Option<String>) -> Option<RadrootsTradeCandidateId> { - value.map(|candidate_id| { - RadrootsTradeCandidateId::parse(candidate_id).expect("stored candidate id is valid") - }) +fn parse_optional_candidate_id(value: Option<String>) -> Option<CandidateId> { + value + .map(|candidate_id| CandidateId::parse(candidate_id).expect("stored candidate id is valid")) } #[cfg(feature = "runtime")] diff --git a/crates/sdk/src/transport.rs b/crates/sdk/src/transport.rs @@ -6,7 +6,7 @@ use radroots_transport::{ RadrootsTransportSatisfactionPolicy, RadrootsTransportStatus, RadrootsTransportTarget, RadrootsTransportTargetFingerprint, RadrootsTransportTargetSet, }; -use radroots_transport_nostr::{RadrootsRelayUrl, RadrootsRelayUrlPolicy}; +use radroots_transport_nostr::{RadrootsRelayUrlPolicy, RelayUrl}; use serde::ser::{SerializeStruct, Serializer}; use std::collections::BTreeSet; @@ -765,7 +765,7 @@ fn normalized_nostr_relay_url( value: &str, policy: NostrRelayUrlPolicy, ) -> Result<String, RadrootsSdkError> { - let relay = RadrootsRelayUrl::parse(value, policy.nostr_transport_policy())?; + let relay = RelayUrl::parse(value, policy.nostr_transport_policy())?; Ok(relay.into_string()) } diff --git a/crates/sdk/src/workflow_runtime.rs b/crates/sdk/src/workflow_runtime.rs @@ -7,9 +7,9 @@ use crate::{ }; use radroots_authority::{RadrootsActorContext, RadrootsEventSigner, sign_authorized_draft}; use radroots_event::{ - draft::{RadrootsEventDraft, RadrootsSignedEvent}, - envelope::{RadrootsEventKind, RadrootsEventKindClass}, - id::RadrootsEventId, + draft::{EventDraft, SignedEvent}, + envelope::{EventKind, EventKindClass}, + id::EventId, }; use radroots_event_store::{ RadrootsEventIngest, RadrootsEventPersistence, RadrootsEventStoreError, @@ -31,7 +31,7 @@ const SDK_RUNTIME_CONTRACT_VERSION: &str = "1"; pub(crate) struct SdkWorkflowEnqueueRequest<'a> { pub(crate) operation_kind: &'static str, pub(crate) actor: &'a RadrootsActorContext, - pub(crate) frozen_draft: &'a RadrootsEventDraft, + pub(crate) frozen_draft: &'a EventDraft, pub(crate) target_policy: TargetPolicy, pub(crate) satisfaction_policy: SatisfactionPolicy, pub(crate) idempotency_key: Option<SdkIdempotencyKey>, @@ -39,7 +39,7 @@ pub(crate) struct SdkWorkflowEnqueueRequest<'a> { #[derive(Debug)] pub(crate) struct SdkWorkflowEnqueueReceipt { - pub(crate) signed_event_id: RadrootsEventId, + pub(crate) signed_event_id: EventId, pub(crate) local_event_seq: i64, pub(crate) outbox_operation_id: i64, pub(crate) outbox_event_id: i64, @@ -134,7 +134,7 @@ pub(crate) async fn enqueue_configured_signed_workflow( async fn enqueue_signed_workflow_event( sdk: &RadrootsClient, request: &SdkWorkflowEnqueueRequest<'_>, - signed_event: RadrootsSignedEvent, + signed_event: SignedEvent, delivery_plan: SdkResolvedDeliveryPlan, ) -> Result<SdkWorkflowEnqueueReceipt, RadrootsSdkError> { if radroots_event::envelope::kind::TRADE_MUTATION_EVENT_KINDS @@ -154,7 +154,7 @@ async fn enqueue_signed_workflow_event( ), })?; let observed_at_ms = sdk_now_ms(sdk)?; - let signed_event_id = RadrootsEventId::parse(request.frozen_draft.expected_event_id_hex()) + let signed_event_id = EventId::parse(request.frozen_draft.expected_event_id_hex()) .expect("frozen workflow draft has a valid expected event id"); let delivery_plan_value = delivery_plan.delivery_plan; let mut tx = @@ -219,7 +219,7 @@ async fn enqueue_signed_workflow_event( async fn enqueue_signed_trade_workflow_event( sdk: &RadrootsClient, request: &SdkWorkflowEnqueueRequest<'_>, - signed_event: RadrootsSignedEvent, + signed_event: SignedEvent, delivery_plan: SdkResolvedDeliveryPlan, ) -> Result<SdkWorkflowEnqueueReceipt, RadrootsSdkError> { let idempotency_key = @@ -233,7 +233,7 @@ async fn enqueue_signed_trade_workflow_event( ), })?; let observed_at_ms = sdk_now_ms(sdk)?; - let signed_event_id = RadrootsEventId::parse(request.frozen_draft.expected_event_id_hex()) + let signed_event_id = EventId::parse(request.frozen_draft.expected_event_id_hex()) .expect("frozen workflow draft has a valid expected event id"); let delivery_plan_value = delivery_plan.delivery_plan; let mut tx = @@ -436,9 +436,7 @@ fn digest_prefix(digest: &str) -> String { fn ensure_durable_workflow_kind( request: &SdkWorkflowEnqueueRequest<'_>, ) -> Result<(), RadrootsSdkError> { - if RadrootsEventKind::new(request.frozen_draft.kind_u32()).class() - == RadrootsEventKindClass::Ephemeral - { + if EventKind::new(request.frozen_draft.kind_u32()).class() == EventKindClass::Ephemeral { return Err(RadrootsSdkError::InvalidRequest { message: format!( "{} cannot enqueue ephemeral event kind {} into a durable workflow", @@ -452,7 +450,7 @@ fn ensure_durable_workflow_kind( fn workflow_event_ingest( operation_kind: &str, - signed_event: RadrootsSignedEvent, + signed_event: SignedEvent, observed_at_ms: i64, ) -> Result<RadrootsEventIngest, RadrootsSdkError> { RadrootsEventIngest::from_signed_event(signed_event, observed_at_ms).map_err( @@ -525,16 +523,16 @@ struct PreparedRuntimeOperation { } #[cfg(test)] -fn parse_event_id(value: &str, field: &str) -> Result<RadrootsEventId, RadrootsSdkError> { - RadrootsEventId::parse(value).map_err(|error| RadrootsSdkError::InvalidRequest { +fn parse_event_id(value: &str, field: &str) -> Result<EventId, RadrootsSdkError> { + EventId::parse(value).map_err(|error| RadrootsSdkError::InvalidRequest { message: format!("{field} is invalid: {error}"), }) } fn signed_outbox_input( operation_kind: &'static str, - frozen_draft: &RadrootsEventDraft, - signed_event: RadrootsSignedEvent, + frozen_draft: &EventDraft, + signed_event: SignedEvent, delivery_plan: RadrootsOutboxDeliveryPlanInput, idempotency_key: SdkIdempotencyKey, event_store_inserted: bool, @@ -554,8 +552,8 @@ fn signed_outbox_input( fn signed_trade_outbox_input( operation_kind: &'static str, - frozen_draft: &RadrootsEventDraft, - signed_event: RadrootsSignedEvent, + frozen_draft: &EventDraft, + signed_event: SignedEvent, delivery_plan: RadrootsOutboxDeliveryPlanInput, idempotency_key: SdkIdempotencyKey, event_store_inserted: bool, @@ -930,7 +928,7 @@ fn workflow_receipt_from_result_json( })? .to_owned(); Ok(SdkWorkflowEnqueueReceipt { - signed_event_id: RadrootsEventId::parse(signed_event_id).map_err(|error| { + signed_event_id: EventId::parse(signed_event_id).map_err(|error| { RadrootsSdkError::EventStore { message: error.to_string(), } @@ -962,7 +960,7 @@ fn outbox_enqueue_status_from_str( } } -fn frozen_draft_json(frozen_draft: &RadrootsEventDraft) -> Result<String, RadrootsSdkError> { +fn frozen_draft_json(frozen_draft: &EventDraft) -> Result<String, RadrootsSdkError> { serde_json::to_string(&serde_json::json!({ "contract_id": frozen_draft.contract_id(), "contract_registry_version": frozen_draft.contract_registry_version(), @@ -978,7 +976,7 @@ fn frozen_draft_json(frozen_draft: &RadrootsEventDraft) -> Result<String, Radroo }) } -fn mutation_id_from_draft(frozen_draft: &RadrootsEventDraft) -> Option<String> { +fn mutation_id_from_draft(frozen_draft: &EventDraft) -> Option<String> { if !radroots_event::envelope::kind::TRADE_MUTATION_EVENT_KINDS .contains(&frozen_draft.kind_u32()) { diff --git a/crates/sdk/tests/farms_runtime.rs b/crates/sdk/tests/farms_runtime.rs @@ -4,8 +4,8 @@ use radroots_authority::RadrootsActorContext; use radroots_event::{ contract::AuthorRole, envelope::kind::{KIND_FARM, KIND_PROFILE}, - farm::RadrootsFarm, - id::RadrootsAddressableCoordinate, + farm::Farm, + id::AddressableCoordinate, }; use radroots_event_store::RadrootsEventStore; use radroots_outbox::{ @@ -60,8 +60,8 @@ fn non_farmer_actor() -> RadrootsActorContext { RadrootsActorContext::test(farmer_pubkey(), [AuthorRole::Buyer]).expect("actor") } -fn farm(d_tag: &str, name: &str) -> RadrootsFarm { - RadrootsFarm { +fn farm(d_tag: &str, name: &str) -> Farm { + Farm { d_tag: d_tag.to_owned(), name: name.to_owned(), about: Some("Vegetable farm".to_owned()), @@ -73,8 +73,8 @@ fn farm(d_tag: &str, name: &str) -> RadrootsFarm { } } -fn farm_addr(actor: &RadrootsActorContext, d_tag: &str) -> RadrootsAddressableCoordinate { - RadrootsAddressableCoordinate::parse(format!("{KIND_FARM}:{}:{d_tag}", actor.pubkey())) +fn farm_addr(actor: &RadrootsActorContext, d_tag: &str) -> AddressableCoordinate { + AddressableCoordinate::parse(format!("{KIND_FARM}:{}:{d_tag}", actor.pubkey())) .expect("farm addr") } diff --git a/crates/sdk/tests/knowledge_public_api.rs b/crates/sdk/tests/knowledge_public_api.rs @@ -1,7 +1,7 @@ #![cfg(feature = "knowledge")] use nostr::{EventBuilder, Keys, Kind, Tag, Timestamp}; -use radroots_event::envelope::RadrootsEventEnvelopeParts; +use radroots_event::envelope::EventEnvelopeParts; use radroots_identity::PublicKey; use radroots_sdk::knowledge::prelude::*; use std::sync::LazyLock; @@ -161,13 +161,13 @@ fn fluent_builders_reject_core_invalid_nested_models() { RadrootsKnowledgeBuilderError::InvalidField("support_refs") ); - let zero_kind_target = RadrootsKnowledgeReviewTarget { + let zero_kind_target = KnowledgeReviewTarget { event_id: hex_64('8'), author_pubkey: hex_64('a'), kind: 0, address: None, relays: vec![RELAY.to_owned()], - review_scope: RadrootsKnowledgeReviewScope::SpecificVersion, + review_scope: KnowledgeReviewScope::SpecificVersion, }; let zero_kind_error = review_builder() .target(zero_kind_target) @@ -178,13 +178,13 @@ fn fluent_builders_reject_core_invalid_nested_models() { RadrootsKnowledgeBuilderError::InvalidField("review_target") ); - let malformed_pubkey_target = RadrootsKnowledgeReviewTarget { + let malformed_pubkey_target = KnowledgeReviewTarget { event_id: hex_64('8'), author_pubkey: "bad".to_owned(), kind: KIND_KNOWLEDGE_CLAIM, address: None, relays: vec![RELAY.to_owned()], - review_scope: RadrootsKnowledgeReviewScope::SpecificVersion, + review_scope: KnowledgeReviewScope::SpecificVersion, }; let malformed_pubkey_error = review_builder() .target(malformed_pubkey_target) @@ -196,7 +196,7 @@ fn fluent_builders_reject_core_invalid_nested_models() { ); let blank_score_dimension_error = review_builder() - .score(RadrootsKnowledgeReviewScore { + .score(KnowledgeReviewScore { dimension: " ".to_owned(), value: "partial".to_owned(), note: None, @@ -209,8 +209,8 @@ fn fluent_builders_reject_core_invalid_nested_models() { ); let exact_private_without_ref_error = field_report_builder() - .context(RadrootsKnowledgeFieldContext { - location_precision: RadrootsKnowledgeLocationPrecision::ExactPrivateReference, + .context(KnowledgeFieldContext { + location_precision: KnowledgeLocationPrecision::ExactPrivateReference, public_location: None, private_location_ref: None, topics: vec!["field".to_owned()], @@ -224,7 +224,7 @@ fn fluent_builders_reject_core_invalid_nested_models() { ); let blank_observation_error = field_report_builder() - .observation(RadrootsKnowledgeObservation { + .observation(KnowledgeObservation { observation_type: " ".to_owned(), text: "Residue was visible across beds.".to_owned(), observed_at: Some("2026-07-05".to_owned()), @@ -400,7 +400,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 = RadrootsEventDraft::new( + let draft_error: RadrootsSdkKnowledgeError = EventDraft::new( KNOWLEDGE_CLAIM_CONTRACT_ID, KIND_KNOWLEDGE_CLAIM, u64::from(CREATED_AT), @@ -415,20 +415,20 @@ fn knowledge_errors_expose_stable_codes() { let draft_errors = [ ( - RadrootsDraftError::ContractNotDraftAuthorable { + DraftError::ContractNotDraftAuthorable { contract_id: KNOWLEDGE_CLAIM_CONTRACT_ID.to_owned(), }, "contract_not_draft_authorable", ), ( - RadrootsDraftError::ContractRegistryVersionMismatch { + DraftError::ContractRegistryVersionMismatch { expected: 2, actual: 1, }, "contract_registry_version_mismatch", ), ( - RadrootsDraftError::DraftExpectedEventIdMismatch { + DraftError::DraftExpectedEventIdMismatch { expected_event_id: hex_64('a'), actual_event_id: hex_64('b'), }, @@ -443,7 +443,7 @@ fn knowledge_errors_expose_stable_codes() { } } -fn sign_parts(parts: RadrootsNip01EventWireParts) -> RadrootsEventEnvelope { +fn sign_parts(parts: Nip01EventWireParts) -> EventEnvelope { let tags = parts .tags .into_iter() @@ -455,7 +455,7 @@ fn sign_parts(parts: RadrootsNip01EventWireParts) -> RadrootsEventEnvelope { .custom_created_at(Timestamp::from_secs(u64::from(CREATED_AT))) .sign_with_keys(&KNOWLEDGE_KEYS) .expect("signed event"); - RadrootsEventEnvelope::new(RadrootsEventEnvelopeParts { + EventEnvelope::new(EventEnvelopeParts { id: event.id.to_hex(), author: event.pubkey.to_hex(), created_at: event.created_at.as_secs(), @@ -480,8 +480,8 @@ fn hex_64(character: char) -> String { character.to_string().repeat(64) } -fn event_ref(character: char, kind: u32) -> RadrootsEventRef { - RadrootsEventRef { +fn event_ref(character: char, kind: u32) -> EventRef { + EventRef { id: hex_64(character), author: PublicKey::from_hex(&public_key_hex()).expect("fixture public key"), kind, @@ -490,14 +490,14 @@ fn event_ref(character: char, kind: u32) -> RadrootsEventRef { } } -fn malformed_event_ref(kind: u32) -> RadrootsEventRef { +fn malformed_event_ref(kind: u32) -> EventRef { let mut reference = event_ref('f', kind); reference.id = "bad".to_owned(); reference } -fn address_ref() -> RadrootsAddressableRef { - RadrootsAddressableRef { +fn address_ref() -> AddressableRef { + AddressableRef { kind: KIND_WIKI_ARTICLE, pubkey: hex_64('a'), d_tag: "soil-health".to_owned(), @@ -505,8 +505,8 @@ fn address_ref() -> RadrootsAddressableRef { } } -fn wiki_article() -> RadrootsWikiArticle { - RadrootsWikiArticle { +fn wiki_article() -> WikiArticle { + WikiArticle { d_tag: "soil-health".to_owned(), title: Some("Soil health".to_owned()), content_djot: "# Soil health".to_owned(), @@ -518,22 +518,22 @@ fn wiki_article() -> RadrootsWikiArticle { } } -fn wiki_redirect() -> RadrootsWikiRedirect { - RadrootsWikiRedirect { +fn wiki_redirect() -> WikiRedirect { + WikiRedirect { d_tag: "soil".to_owned(), target: address_ref(), } } -fn article_version_ref() -> RadrootsWikiArticleVersionRef { - RadrootsWikiArticleVersionRef { +fn article_version_ref() -> WikiArticleVersionRef { + WikiArticleVersionRef { event_id: hex_64('b'), address_ref: address_ref(), } } -fn wiki_merge_request() -> RadrootsWikiMergeRequest { - RadrootsWikiMergeRequest { +fn wiki_merge_request() -> WikiMergeRequest { + WikiMergeRequest { target_article: address_ref(), destination_pubkey: hex_64('a'), base_version_event_id: Some(hex_64('e')), @@ -583,7 +583,7 @@ fn claim_builder() -> RadrootsKnowledgeClaimBuilder { RadrootsKnowledgeClaimBuilder::new() .claim_type("practice_effect") .text("Cover crops improve soil structure.") - .citation_span(RadrootsKnowledgeCitationSpan { + .citation_span(KnowledgeCitationSpan { source_ref: event_ref('4', KIND_KNOWLEDGE_SOURCE), artifact_ref: None, page_start: Some(12), @@ -608,17 +608,17 @@ fn relation_builder() -> RadrootsKnowledgeRelationBuilder { fn review_builder() -> RadrootsKnowledgeReviewBuilder { RadrootsKnowledgeReviewBuilder::new() - .target(RadrootsKnowledgeReviewTarget { + .target(KnowledgeReviewTarget { event_id: hex_64('8'), author_pubkey: hex_64('a'), kind: KIND_KNOWLEDGE_CLAIM, address: None, relays: vec![RELAY.to_owned()], - review_scope: RadrootsKnowledgeReviewScope::SpecificVersion, + review_scope: KnowledgeReviewScope::SpecificVersion, }) .reviewer_role("peer") .verdict("needs_more_evidence") - .score(RadrootsKnowledgeReviewScore { + .score(KnowledgeReviewScore { dimension: "evidence".to_owned(), value: "partial".to_owned(), note: None, @@ -632,9 +632,9 @@ fn field_report_builder() -> RadrootsKnowledgeFieldReportBuilder { .report_type("observation") .title("Field observation") .summary("Observed cover crop residue.") - .context(RadrootsKnowledgeFieldContext { - location_precision: RadrootsKnowledgeLocationPrecision::CoarseGeohash, - public_location: Some(RadrootsKnowledgeLocation { + .context(KnowledgeFieldContext { + location_precision: KnowledgeLocationPrecision::CoarseGeohash, + public_location: Some(KnowledgeLocation { label: Some("watershed".to_owned()), region: Some("synthetic-region".to_owned()), locality: None, @@ -644,11 +644,11 @@ fn field_report_builder() -> RadrootsKnowledgeFieldReportBuilder { topics: vec!["field".to_owned()], context_tags: vec!["observation".to_owned()], }) - .observation(RadrootsKnowledgeObservation { + .observation(KnowledgeObservation { observation_type: "residue".to_owned(), text: "Residue was visible across beds.".to_owned(), observed_at: Some("2026-07-05".to_owned()), - values: vec![RadrootsKnowledgeObservationValue { + values: vec![KnowledgeObservationValue { key: "coverage".to_owned(), value: "medium".to_owned(), unit: None, @@ -659,8 +659,8 @@ fn field_report_builder() -> RadrootsKnowledgeFieldReportBuilder { .limitation("single observer") } -fn knowledge_source() -> RadrootsKnowledgeSource { - RadrootsKnowledgeSource { +fn knowledge_source() -> KnowledgeSource { + KnowledgeSource { schema: RADROOTS_KNOWLEDGE_SOURCE_SCHEMA.to_owned(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, d_tag: "soil-source".to_owned(), @@ -678,13 +678,13 @@ fn knowledge_source() -> RadrootsKnowledgeSource { } } -fn knowledge_claim() -> RadrootsKnowledgeClaim { - RadrootsKnowledgeClaim { +fn knowledge_claim() -> KnowledgeClaim { + KnowledgeClaim { schema: RADROOTS_KNOWLEDGE_CLAIM_SCHEMA.to_owned(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, claim_type: "practice_effect".to_owned(), text: "Cover crops improve soil structure.".to_owned(), - citation_spans: vec![RadrootsKnowledgeCitationSpan { + citation_spans: vec![KnowledgeCitationSpan { source_ref: event_ref('4', KIND_KNOWLEDGE_SOURCE), artifact_ref: None, page_start: Some(12), @@ -700,8 +700,8 @@ fn knowledge_claim() -> RadrootsKnowledgeClaim { } } -fn knowledge_node_ref(label: &str) -> RadrootsKnowledgeNodeRef { - RadrootsKnowledgeNodeRef { +fn knowledge_node_ref(label: &str) -> KnowledgeNodeRef { + KnowledgeNodeRef { node_type: "event".to_owned(), event_ref: Some(event_ref('6', KIND_KNOWLEDGE_CLAIM)), address_ref: None, @@ -710,8 +710,8 @@ fn knowledge_node_ref(label: &str) -> RadrootsKnowledgeNodeRef { } } -fn knowledge_relation() -> RadrootsKnowledgeRelation { - RadrootsKnowledgeRelation { +fn knowledge_relation() -> KnowledgeRelation { + KnowledgeRelation { schema: RADROOTS_KNOWLEDGE_RELATION_SCHEMA.to_owned(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, subject: knowledge_node_ref("cover crops"), @@ -723,21 +723,21 @@ fn knowledge_relation() -> RadrootsKnowledgeRelation { } } -fn knowledge_review() -> RadrootsKnowledgeReview { - RadrootsKnowledgeReview { +fn knowledge_review() -> KnowledgeReview { + KnowledgeReview { schema: RADROOTS_KNOWLEDGE_REVIEW_SCHEMA.to_owned(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, - target: RadrootsKnowledgeReviewTarget { + target: KnowledgeReviewTarget { event_id: hex_64('8'), author_pubkey: hex_64('a'), kind: KIND_KNOWLEDGE_CLAIM, address: None, relays: vec![RELAY.to_owned()], - review_scope: RadrootsKnowledgeReviewScope::SpecificVersion, + review_scope: KnowledgeReviewScope::SpecificVersion, }, reviewer_role: "peer".to_owned(), verdict: "needs_more_evidence".to_owned(), - scores: vec![RadrootsKnowledgeReviewScore { + scores: vec![KnowledgeReviewScore { dimension: "evidence".to_owned(), value: "partial".to_owned(), note: None, @@ -747,16 +747,16 @@ fn knowledge_review() -> RadrootsKnowledgeReview { } } -fn knowledge_field_report() -> RadrootsKnowledgeFieldReport { - RadrootsKnowledgeFieldReport { +fn knowledge_field_report() -> KnowledgeFieldReport { + KnowledgeFieldReport { schema: RADROOTS_KNOWLEDGE_FIELD_REPORT_SCHEMA.to_owned(), schema_version: RADROOTS_KNOWLEDGE_SCHEMA_VERSION, report_type: "observation".to_owned(), title: "Field observation".to_owned(), summary: Some("Observed cover crop residue.".to_owned()), - context: RadrootsKnowledgeFieldContext { - location_precision: RadrootsKnowledgeLocationPrecision::CoarseGeohash, - public_location: Some(RadrootsKnowledgeLocation { + context: KnowledgeFieldContext { + location_precision: KnowledgeLocationPrecision::CoarseGeohash, + public_location: Some(KnowledgeLocation { label: Some("watershed".to_owned()), region: Some("synthetic-region".to_owned()), locality: None, @@ -766,11 +766,11 @@ fn knowledge_field_report() -> RadrootsKnowledgeFieldReport { topics: vec!["field".to_owned()], context_tags: vec!["observation".to_owned()], }, - observations: vec![RadrootsKnowledgeObservation { + observations: vec![KnowledgeObservation { observation_type: "residue".to_owned(), text: "Residue was visible across beds.".to_owned(), observed_at: Some("2026-07-05".to_owned()), - values: vec![RadrootsKnowledgeObservationValue { + values: vec![KnowledgeObservationValue { key: "coverage".to_owned(), value: "medium".to_owned(), unit: None, diff --git a/crates/sdk/tests/listings_runtime.rs b/crates/sdk/tests/listings_runtime.rs @@ -5,13 +5,12 @@ use radroots_core::{Currency, Decimal, Money, Quantity, QuantityPrice, Unit}; use radroots_event::{ contract::AuthorRole, envelope::kind::KIND_CLASSIFIED_LISTING, - farm::RadrootsFarmRef, - id::{RadrootsDTag, RadrootsInventoryBinId}, + farm::FarmRef, + id::{DTag, InventoryBinId}, listing::operational::{ - RadrootsOperationalListing, RadrootsOperationalListingAvailability, - RadrootsOperationalListingBin, RadrootsOperationalListingDeliveryMethod, - RadrootsOperationalListingProduct, RadrootsOperationalListingPublicLocation, - RadrootsOperationalListingStatus, + OperationalListing, OperationalListingAvailability, OperationalListingBin, + OperationalListingDeliveryMethod, OperationalListingProduct, + OperationalListingPublicLocation, OperationalListingStatus, }, }; use radroots_event_store::RadrootsEventStore; @@ -69,15 +68,15 @@ fn non_seller_actor() -> RadrootsActorContext { RadrootsActorContext::test(seller_pubkey(), [AuthorRole::Buyer]).expect("actor") } -fn listing(d_tag: &str, title: &str) -> RadrootsOperationalListing { - RadrootsOperationalListing { - d_tag: RadrootsDTag::parse(d_tag).expect("d tag"), +fn listing(d_tag: &str, title: &str) -> OperationalListing { + OperationalListing { + d_tag: DTag::parse(d_tag).expect("d tag"), published_at: None, - farm: RadrootsFarmRef { + farm: FarmRef { pubkey: seller_pubkey().to_owned(), d_tag: FARM_D_TAG.to_owned(), }, - product: RadrootsOperationalListingProduct { + product: OperationalListingProduct { key: "coffee".to_owned(), title: title.to_owned(), category: "coffee".to_owned(), @@ -88,9 +87,9 @@ fn listing(d_tag: &str, title: &str) -> RadrootsOperationalListing { profile: None, year: None, }, - primary_bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), - bins: vec![RadrootsOperationalListingBin { - bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), + primary_bin_id: InventoryBinId::parse("bin-1").expect("bin id"), + bins: vec![OperationalListingBin { + bin_id: InventoryBinId::parse("bin-1").expect("bin id"), quantity: Quantity::try_new(Decimal::from(1000u32), Unit::MassG) .expect("positive fixture quantity"), price_per_canonical_unit: QuantityPrice::try_new( @@ -110,11 +109,11 @@ fn listing(d_tag: &str, title: &str) -> RadrootsOperationalListing { plot: None, discounts: None, inventory_available: Some(Decimal::from(5u32)), - availability: Some(RadrootsOperationalListingAvailability::Status { - status: RadrootsOperationalListingStatus::Active, + availability: Some(OperationalListingAvailability::Status { + status: OperationalListingStatus::Active, }), - delivery_method: Some(RadrootsOperationalListingDeliveryMethod::Pickup), - location: Some(RadrootsOperationalListingPublicLocation { + delivery_method: Some(OperationalListingDeliveryMethod::Pickup), + location: Some(OperationalListingPublicLocation { primary: "Victoria".to_owned(), city: Some("Victoria".to_owned()), region: Some("British Columbia".to_owned()), diff --git a/crates/sdk/tests/replica_ingest.rs b/crates/sdk/tests/replica_ingest.rs @@ -1,6 +1,6 @@ use radroots_event::{ - envelope::{RadrootsEventEnvelope, RadrootsEventEnvelopeParts}, - farm::RadrootsFarm, + envelope::{EventEnvelope, EventEnvelopeParts}, + farm::Farm, }; use radroots_replica_schema::farm::IFarmFindMany; use radroots_replica_store::ReplicaSql; @@ -19,8 +19,8 @@ fn sdk_event( kind: u32, content: String, tags: Vec<Vec<String>>, -) -> RadrootsEventEnvelope { - RadrootsEventEnvelope::new(RadrootsEventEnvelopeParts { +) -> EventEnvelope { + EventEnvelope::new(EventEnvelopeParts { id: format!("{id:064x}"), author: author.to_owned(), created_at: u64::from(created_at), @@ -32,8 +32,8 @@ fn sdk_event( .expect("sdk event envelope") } -fn sample_farm() -> RadrootsFarm { - RadrootsFarm { +fn sample_farm() -> Farm { + Farm { d_tag: "AAAAAAAAAAAAAAAAAAAAAA".into(), name: "North Farm".into(), about: Some("Organic coffee".into()), @@ -57,7 +57,7 @@ fn open_replica() -> (TempDir, ReplicaSql<SqlxSqliteExecutor>) { (dir, replica) } -fn ingest_farm(replica: &ReplicaSql<SqlxSqliteExecutor>) -> RadrootsEventEnvelope { +fn ingest_farm(replica: &ReplicaSql<SqlxSqliteExecutor>) -> EventEnvelope { let farm_value = sample_farm(); let author = seller_pubkey(); let parts = radroots_event_codec::farm::encode::to_wire_parts(&farm_value).expect("farm draft"); diff --git a/crates/sdk/tests/support/fixture_signer.rs b/crates/sdk/tests/support/fixture_signer.rs @@ -1,5 +1,5 @@ use radroots_authority::{RadrootsEventSigner, RadrootsSignerError, RadrootsSignerIdentity}; -use radroots_event::draft::{RadrootsEventDraft, RadrootsSignedEvent}; +use radroots_event::draft::{EventDraft, SignedEvent}; use radroots_identity::PublicKey; use radroots_nostr::prelude::{RadrootsNostrKeys, radroots_nostr_sign_frozen_draft}; use std::sync::LazyLock; @@ -53,10 +53,7 @@ impl RadrootsEventSigner for FixtureSigner { self.identity.pubkey() } - fn sign_frozen_draft( - &self, - draft: &RadrootsEventDraft, - ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { + fn sign_frozen_draft(&self, draft: &EventDraft) -> Result<SignedEvent, RadrootsSignerError> { if self.pubkey() != draft.expected_pubkey() { return Err(RadrootsSignerError::SigningFailed { message: "wrong fixture signer".to_owned(), diff --git a/crates/sdk/tests/sync_runtime.rs b/crates/sdk/tests/sync_runtime.rs @@ -5,13 +5,12 @@ use radroots_authority::{RadrootsActorContext, RadrootsEventSigner}; use radroots_core::{Currency, Decimal, Money, Quantity, QuantityPrice, Unit}; use radroots_event::{ contract::AuthorRole, - farm::RadrootsFarmRef, - id::{RadrootsDTag, RadrootsEventId, RadrootsInventoryBinId}, + farm::FarmRef, + id::{DTag, EventId, InventoryBinId}, listing::operational::{ - RadrootsOperationalListing, RadrootsOperationalListingAvailability, - RadrootsOperationalListingBin, RadrootsOperationalListingDeliveryMethod, - RadrootsOperationalListingProduct, RadrootsOperationalListingPublicLocation, - RadrootsOperationalListingStatus, + OperationalListing, OperationalListingAvailability, OperationalListingBin, + OperationalListingDeliveryMethod, OperationalListingProduct, + OperationalListingPublicLocation, OperationalListingStatus, }, }; use radroots_event_store::{RadrootsEventStore, RadrootsTransportObservationType}; @@ -388,15 +387,15 @@ fn actor() -> RadrootsActorContext { RadrootsActorContext::test(seller_pubkey(), [AuthorRole::Seller]).expect("actor") } -fn listing(d_tag: &str, title: &str) -> RadrootsOperationalListing { - RadrootsOperationalListing { - d_tag: RadrootsDTag::parse(d_tag).expect("d tag"), +fn listing(d_tag: &str, title: &str) -> OperationalListing { + OperationalListing { + d_tag: DTag::parse(d_tag).expect("d tag"), published_at: None, - farm: RadrootsFarmRef { + farm: FarmRef { pubkey: seller_pubkey().to_owned(), d_tag: FARM_D_TAG.to_owned(), }, - product: RadrootsOperationalListingProduct { + product: OperationalListingProduct { key: "coffee".to_owned(), title: title.to_owned(), category: "coffee".to_owned(), @@ -407,9 +406,9 @@ fn listing(d_tag: &str, title: &str) -> RadrootsOperationalListing { profile: None, year: None, }, - primary_bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), - bins: vec![RadrootsOperationalListingBin { - bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), + primary_bin_id: InventoryBinId::parse("bin-1").expect("bin id"), + bins: vec![OperationalListingBin { + bin_id: InventoryBinId::parse("bin-1").expect("bin id"), quantity: Quantity::try_new(Decimal::from(1000u32), Unit::MassG) .expect("positive fixture quantity"), price_per_canonical_unit: QuantityPrice::try_new( @@ -429,11 +428,11 @@ fn listing(d_tag: &str, title: &str) -> RadrootsOperationalListing { plot: None, discounts: None, inventory_available: Some(Decimal::from(5u32)), - availability: Some(RadrootsOperationalListingAvailability::Status { - status: RadrootsOperationalListingStatus::Active, + availability: Some(OperationalListingAvailability::Status { + status: OperationalListingStatus::Active, }), - delivery_method: Some(RadrootsOperationalListingDeliveryMethod::Pickup), - location: Some(RadrootsOperationalListingPublicLocation { + delivery_method: Some(OperationalListingDeliveryMethod::Pickup), + location: Some(OperationalListingPublicLocation { primary: "Victoria".to_owned(), city: Some("Victoria".to_owned()), region: Some("British Columbia".to_owned()), @@ -2169,7 +2168,7 @@ fn push_outbox_contract_dtos_serialize_deterministically() { retryable_events: 0, terminal_events: 0, events: vec![PushOutboxEventReceipt { - event_id: RadrootsEventId::parse("a".repeat(64)).expect("event id"), + event_id: EventId::parse("a".repeat(64)).expect("event id"), outbox_event_id: 7, final_state: PushOutboxEventState::Published, attempted_count: 2, diff --git a/crates/sdk/tests/unit/adapters_radrootsd_tests.rs b/crates/sdk/tests/unit/adapters_radrootsd_tests.rs @@ -1,5 +1,5 @@ use super::*; -use radroots_event::wire::RadrootsNip01EventWire; +use radroots_event::wire::Nip01EventWire; use radroots_protocol::radrootsd::transport_publish::v5::{ DeliveryPolicy as TransportPublishDeliveryPolicy, EventRequest as TransportPublishEventRequest, EventResponse as TransportPublishEventResponse, Job as TransportPublishJobView, @@ -93,8 +93,8 @@ fn spawn_http_server( (endpoint, handle) } -fn signed_event() -> RadrootsSignedEvent { - let mut wire = RadrootsNip01EventWire { +fn signed_event() -> SignedEvent { + let mut wire = Nip01EventWire { id: String::new(), pubkey: SIGNED_EVENT_PUBLIC_KEY.to_owned(), created_at: 1_700_000_000, @@ -106,7 +106,7 @@ fn signed_event() -> RadrootsSignedEvent { }; wire.id = wire.computed_event_id().expect("event id").into_string(); let raw_json = serde_json::to_string(&wire).expect("raw event json"); - RadrootsSignedEvent::from_wire_verified_id(wire, raw_json).expect("signed event") + SignedEvent::from_wire_verified_id(wire, raw_json).expect("signed event") } fn publish_request() -> TransportPublishEventRequest { diff --git a/crates/sdk/tests/unit/error_tests.rs b/crates/sdk/tests/unit/error_tests.rs @@ -56,7 +56,7 @@ fn listing_and_store_errors_convert_to_sdk_error_classes() { let invalid_model = RadrootsSdkError::from( radroots_trade::operational_listing::RadrootsOperationalListingEditError::InvalidModel( - radroots_event::trade::validation::RadrootsOperationalListingValidationError::MissingInventory, + radroots_event::trade::validation::OperationalListingValidationError::MissingInventory, ), ); assert!(matches!( diff --git a/crates/sdk/tests/unit/farms_runtime_tests.rs b/crates/sdk/tests/unit/farms_runtime_tests.rs @@ -19,8 +19,8 @@ fn farmer_actor() -> RadrootsActorContext { RadrootsActorContext::test(farmer_pubkey(), [AuthorRole::Farmer]).expect("actor") } -fn farm(d_tag: &str, name: &str) -> RadrootsFarm { - RadrootsFarm { +fn farm(d_tag: &str, name: &str) -> Farm { + Farm { d_tag: d_tag.to_owned(), name: name.to_owned(), about: Some("Vegetable farm".to_owned()), @@ -122,7 +122,7 @@ fn farm_publish_plan_rejects_invalid_draft_tags() { [AuthorRole::Farmer], ) .expect("actor"); - let farm = RadrootsFarm { + let farm = Farm { d_tag: "AAAAAAAAAAAAAAAAAAAAA!".to_owned(), name: "Invalid Farm".to_owned(), about: None, @@ -528,7 +528,7 @@ async fn farm_prepared_plan_rejects_forged_state_before_signing_or_mutation() { ); // Frozen drafts enforce registry contract-kind consistency, so a valid foreign pair is the // safe representable substitution for both identity fields. - let foreign_draft = RadrootsEventDraft::new( + let foreign_draft = EventDraft::new( "radroots.social.geochat.v1", radroots_event::envelope::kind::KIND_GEOCHAT, plan.created_at().unix_seconds(), @@ -547,7 +547,7 @@ async fn farm_prepared_plan_rejects_forged_state_before_signing_or_mutation() { let mut forged_event_id = plan.clone(); forged_event_id.expected_event_id = - RadrootsEventId::parse(fixture_bob_pubkey()).expect("alternate event ID"); + EventId::parse(fixture_bob_pubkey()).expect("alternate event ID"); assert!(matches!( validate_farm_publish_plan(&forged_event_id), Err(RadrootsSdkError::InvalidRequest { ref message }) @@ -555,11 +555,9 @@ async fn farm_prepared_plan_rejects_forged_state_before_signing_or_mutation() { )); let mut forged_address = plan.clone(); - forged_address.farm_addr = RadrootsAddressableCoordinate::parse(format!( - "{KIND_FARM}:{}:{FARM_B_D_TAG}", - farmer_pubkey() - )) - .expect("alternate farm address"); + forged_address.farm_addr = + AddressableCoordinate::parse(format!("{KIND_FARM}:{}:{FARM_B_D_TAG}", farmer_pubkey())) + .expect("alternate farm address"); assert!(matches!( validate_farm_publish_plan(&forged_address), Err(RadrootsSdkError::InvalidRequest { ref message }) diff --git a/crates/sdk/tests/unit/idempotency_tests.rs b/crates/sdk/tests/unit/idempotency_tests.rs @@ -1,6 +1,6 @@ use super::{SdkIdempotencyKey, SdkTradeIdempotencyRecord}; use crate::RadrootsSdkError; -use radroots_event::id::RadrootsEventId; +use radroots_event::id::EventId; use radroots_identity::PublicKey; use crate::serializer_failure::assert_struct_serialize_error_paths; @@ -62,7 +62,7 @@ fn trade_idempotency_record_binds_payload_and_reports_conflicts() { digest: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb".to_owned(), canonical_payload_hash: "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" .to_owned(), - expected_event_id: RadrootsEventId::parse( + expected_event_id: EventId::parse( "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", ) .expect("event id"), diff --git a/crates/sdk/tests/unit/listings_runtime_tests.rs b/crates/sdk/tests/unit/listings_runtime_tests.rs @@ -3,13 +3,12 @@ use crate::{RadrootsSdkLocalKeySigner, RadrootsSdkSignerProvider}; use radroots_core::{Currency, Decimal, Money, Quantity, QuantityPrice, Unit}; use radroots_event::{ contract::AuthorRole, - farm::RadrootsFarmRef, - farm::resource_area::RadrootsResourceAreaRef, - id::{RadrootsDTag, RadrootsInventoryBinId}, + farm::FarmRef, + farm::resource_area::ResourceAreaRef, + id::{DTag, InventoryBinId}, listing::operational::{ - RadrootsOperationalListingAvailability, RadrootsOperationalListingBin, - RadrootsOperationalListingDeliveryMethod, RadrootsOperationalListingProduct, - RadrootsOperationalListingPublicLocation, RadrootsOperationalListingStatus, + OperationalListingAvailability, OperationalListingBin, OperationalListingDeliveryMethod, + OperationalListingProduct, OperationalListingPublicLocation, OperationalListingStatus, }, }; @@ -31,19 +30,19 @@ fn actor() -> RadrootsActorContext { RadrootsActorContext::test(seller_pubkey(), [AuthorRole::Seller]).expect("actor") } -fn listing(d_tag: &str, title: &str) -> RadrootsOperationalListing { +fn listing(d_tag: &str, title: &str) -> OperationalListing { listing_for_seller(seller_pubkey(), d_tag, title) } -fn listing_for_seller(seller: &str, d_tag: &str, title: &str) -> RadrootsOperationalListing { - RadrootsOperationalListing { - d_tag: RadrootsDTag::parse(d_tag).expect("d tag"), +fn listing_for_seller(seller: &str, d_tag: &str, title: &str) -> OperationalListing { + OperationalListing { + d_tag: DTag::parse(d_tag).expect("d tag"), published_at: None, - farm: RadrootsFarmRef { + farm: FarmRef { pubkey: seller.to_owned(), d_tag: FARM_D_TAG.to_owned(), }, - product: RadrootsOperationalListingProduct { + product: OperationalListingProduct { key: "lettuce".to_owned(), title: title.to_owned(), category: "greens".to_owned(), @@ -54,9 +53,9 @@ fn listing_for_seller(seller: &str, d_tag: &str, title: &str) -> RadrootsOperati profile: None, year: None, }, - primary_bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), - bins: vec![RadrootsOperationalListingBin { - bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), + primary_bin_id: InventoryBinId::parse("bin-1").expect("bin id"), + bins: vec![OperationalListingBin { + bin_id: InventoryBinId::parse("bin-1").expect("bin id"), quantity: Quantity::try_new(Decimal::from(12u32), Unit::Each) .expect("positive fixture quantity"), price_per_canonical_unit: QuantityPrice::try_new( @@ -76,11 +75,11 @@ fn listing_for_seller(seller: &str, d_tag: &str, title: &str) -> RadrootsOperati plot: None, discounts: None, inventory_available: Some(Decimal::from(12u32)), - availability: Some(RadrootsOperationalListingAvailability::Status { - status: RadrootsOperationalListingStatus::Active, + availability: Some(OperationalListingAvailability::Status { + status: OperationalListingStatus::Active, }), - delivery_method: Some(RadrootsOperationalListingDeliveryMethod::Pickup), - location: Some(RadrootsOperationalListingPublicLocation { + delivery_method: Some(OperationalListingDeliveryMethod::Pickup), + location: Some(OperationalListingPublicLocation { primary: "Victoria".to_owned(), city: Some("Victoria".to_owned()), region: Some("British Columbia".to_owned()), @@ -159,7 +158,7 @@ fn listing_request_builders_reject_invalid_options_and_timestamp_bounds() { let mut invalid_resource_area_listing = listing(LISTING_C_D_TAG, "Invalid Resource Area Greens"); - invalid_resource_area_listing.resource_area = Some(RadrootsResourceAreaRef { + invalid_resource_area_listing.resource_area = Some(ResourceAreaRef { pubkey: seller_pubkey().to_owned(), d_tag: "bad d tag".to_owned(), }); @@ -236,7 +235,7 @@ async fn listing_prepared_plan_rejects_forged_state_before_signing_or_mutation() ); // Frozen drafts enforce registry contract-kind consistency, so a valid foreign pair is the // safe representable substitution for both identity fields. - let foreign_draft = RadrootsEventDraft::new( + let foreign_draft = EventDraft::new( "radroots.social.geochat.v1", radroots_event::envelope::kind::KIND_GEOCHAT, plan.created_at().unix_seconds(), @@ -255,7 +254,7 @@ async fn listing_prepared_plan_rejects_forged_state_before_signing_or_mutation() let mut forged_event_id = plan.clone(); forged_event_id.expected_event_id = - RadrootsEventId::parse(fixture_bob_pubkey()).expect("alternate event ID"); + EventId::parse(fixture_bob_pubkey()).expect("alternate event ID"); assert!(matches!( validate_listing_publish_plan(&forged_event_id), Err(RadrootsSdkError::InvalidRequest { ref message }) @@ -263,7 +262,7 @@ async fn listing_prepared_plan_rejects_forged_state_before_signing_or_mutation() )); let mut forged_address = plan.clone(); - forged_address.public_listing_addr = RadrootsClassifiedListingAddress::parse(format!( + forged_address.public_listing_addr = ClassifiedListingAddress::parse(format!( "{KIND_CLASSIFIED_LISTING}:{}:{LISTING_B_D_TAG}", seller_pubkey() )) diff --git a/crates/sdk/tests/unit/private_store_tests.rs b/crates/sdk/tests/unit/private_store_tests.rs @@ -1,10 +1,10 @@ use super::*; -use radroots_event::id::RadrootsAddressableCoordinate; +use radroots_event::id::AddressableCoordinate; use sqlx::Row; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; -fn farm_addr_for(d_tag: &str) -> RadrootsAddressableCoordinate { - RadrootsAddressableCoordinate::parse(format!( +fn farm_addr_for(d_tag: &str) -> AddressableCoordinate { + AddressableCoordinate::parse(format!( "{}:{}:{}", radroots_event::envelope::kind::KIND_FARM, "a".repeat(64), @@ -13,7 +13,7 @@ fn farm_addr_for(d_tag: &str) -> RadrootsAddressableCoordinate { .expect("farm addr") } -fn farm_addr() -> RadrootsAddressableCoordinate { +fn farm_addr() -> AddressableCoordinate { farm_addr_for("AAAAAAAAAAAAAAAAAAAAAA") } diff --git a/crates/sdk/tests/unit/runtime_tests.rs b/crates/sdk/tests/unit/runtime_tests.rs @@ -213,7 +213,7 @@ fn manifest() -> SdkBackupManifest { fn private_farm_location_record() -> crate::private_store::SdkPrivateFarmLocationRecord { crate::private_store::SdkPrivateFarmLocationRecord { - farm_addr: radroots_event::id::RadrootsAddressableCoordinate::parse(format!( + farm_addr: radroots_event::id::AddressableCoordinate::parse(format!( "{}:{}:{}", radroots_event::envelope::kind::KIND_FARM, "a".repeat(64), @@ -1976,7 +1976,7 @@ async fn restore_archive_private_failures_cover_staging_and_verification_edges() .await .expect("populated sdk"); let populated_event_keys = radroots_nostr::prelude::RadrootsNostrKeys::generate(); - let populated_event_draft = radroots_event::draft::RadrootsEventDraft::new( + let populated_event_draft = radroots_event::draft::EventDraft::new( "radroots.farm.profile.v1", radroots_event::envelope::kind::KIND_FARM, 1_700_000_002, diff --git a/crates/sdk/tests/unit/signer_provider_tests.rs b/crates/sdk/tests/unit/signer_provider_tests.rs @@ -3,7 +3,7 @@ use nostr::nips::nip44::{self, Version}; use nostr::{EventBuilder, JsonUtil, Kind, Tag}; use radroots_authority::RadrootsLocalEventSigner; use radroots_event::contract::AuthorRole; -use radroots_event::draft::RadrootsEventDraft; +use radroots_event::draft::EventDraft; use radroots_event::envelope::kind::{ KIND_CLASSIFIED_LISTING, KIND_COOP, KIND_FARM, TRADE_MUTATION_EVENT_KINDS, }; @@ -50,7 +50,7 @@ fn actor() -> RadrootsActorContext { RadrootsActorContext::test(user_pubkey(), [AuthorRole::Farmer]).expect("actor") } -fn frozen_draft() -> RadrootsEventDraft { +fn frozen_draft() -> EventDraft { frozen_draft_with( "radroots.farm.profile.v1", user_pubkey(), @@ -68,8 +68,8 @@ fn frozen_draft_with( created_at: u32, tags: Vec<Vec<String>>, content: &str, -) -> RadrootsEventDraft { - RadrootsEventDraft::new( +) -> EventDraft { + EventDraft::new( contract_id, kind, u64::from(created_at), @@ -80,7 +80,7 @@ fn frozen_draft_with( .expect("frozen draft") } -fn sign_event(keys: &RadrootsNostrKeys, draft: &RadrootsEventDraft) -> RadrootsNostrEvent { +fn sign_event(keys: &RadrootsNostrKeys, draft: &EventDraft) -> RadrootsNostrEvent { let signed = radroots_nostr::prelude::radroots_nostr_sign_frozen_draft(keys, draft).expect("signed"); RadrootsNostrEvent::from_json(signed.raw_json()).expect("event") diff --git a/crates/sdk/tests/unit/sync_runtime_tests.rs b/crates/sdk/tests/unit/sync_runtime_tests.rs @@ -24,10 +24,10 @@ use radroots_authority::{ #[cfg(feature = "radrootsd-execution")] use radroots_event::contract::AuthorRole; #[cfg(feature = "radrootsd-execution")] -use radroots_event::draft::{RadrootsEventDraft, RadrootsSignedEvent}; +use radroots_event::draft::{EventDraft, SignedEvent}; #[cfg(feature = "radrootsd-execution")] use radroots_event::envelope::kind::KIND_FARM; -use radroots_event::id::RadrootsEventId; +use radroots_event::id::EventId; use radroots_event_store::RadrootsEventStoreStatusSummary; #[cfg(feature = "radrootsd-execution")] use radroots_identity::PublicKey; @@ -110,10 +110,7 @@ impl RadrootsEventSigner for RadrootsdFixtureSigner { self.identity.pubkey() } - fn sign_frozen_draft( - &self, - draft: &RadrootsEventDraft, - ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { + fn sign_frozen_draft(&self, draft: &EventDraft) -> Result<SignedEvent, RadrootsSignerError> { radroots_nostr_sign_frozen_draft(&self.keys, draft).map_err(|error| { RadrootsSignerError::SigningFailed { message: error.to_string(), @@ -139,8 +136,8 @@ fn radrootsd_actor() -> RadrootsActorContext { } #[cfg(feature = "radrootsd-execution")] -fn radrootsd_frozen_draft(d_tag: &str) -> RadrootsEventDraft { - RadrootsEventDraft::new( +fn radrootsd_frozen_draft(d_tag: &str) -> EventDraft { + EventDraft::new( "radroots.farm.profile.v1", KIND_FARM, 1_700_000_000, @@ -399,7 +396,7 @@ fn push_event_receipt_parses_typed_event_id() { assert_eq!( receipt.event_id, - RadrootsEventId::parse(event_id).expect("event id") + EventId::parse(event_id).expect("event id") ); assert_eq!(receipt.targets.len(), 1); assert_eq!(receipt.targets[0].transport_kind, "nostr"); @@ -1112,7 +1109,7 @@ async fn radrootsd_push_reports_missing_signed_claim_before_daemon_publish() { state: RadrootsOutboxEventState::Signed, claim_token: "claim-token".to_owned(), active_delivery_plan_id: Some(1), - draft: RadrootsEventDraft::new( + draft: EventDraft::new( "radroots.farm.profile.v1", KIND_FARM, 1_700_000_000, @@ -1760,7 +1757,7 @@ impl OutboxPublishReceiptFixture for RadrootsOutboxPublishReceipt { fn push_receipt(final_state: PushOutboxEventState) -> PushOutboxEventReceipt { PushOutboxEventReceipt { - event_id: RadrootsEventId::parse("a".repeat(64)).expect("event id"), + event_id: EventId::parse("a".repeat(64)).expect("event id"), outbox_event_id: 1, final_state, attempted_count: 0, diff --git a/crates/sdk/tests/unit/trade_runtime_tests.rs b/crates/sdk/tests/unit/trade_runtime_tests.rs @@ -7,19 +7,15 @@ use radroots_authority::{RadrootsActorContext, RadrootsLocalEventSigner}; use radroots_event::{ contract::AuthorRole, envelope::kind::TRADE_MUTATION_EVENT_KINDS, - id::{ - RadrootsClassifiedListingAddress, RadrootsDTag, RadrootsEventId, RadrootsInventoryBinId, - RadrootsTradeId, - }, + id::{ClassifiedListingAddress, DTag, EventId, InventoryBinId, TradeId}, trade::{ - RADROOTS_TRADE_DECISION_CONTRACT_ID, RADROOTS_TRADE_MAX_PRIVATE_ARTIFACT_BYTES, - RADROOTS_TRADE_MUTATION_CONTRACT_IDS, RADROOTS_TRADE_PROPOSAL_CONTRACT_ID, - RADROOTS_TRADE_SCHEMA_VERSION, RadrootsFulfillmentProfileV1, - RadrootsSellerReservationAssertionV1, RadrootsSellerReservationLineV1, - RadrootsTradeCancellationProfileV1, RadrootsTradeCandidateLineV1, - RadrootsTradeCandidateTermsV1, RadrootsTradeDecisionV1, RadrootsTradeEconomicAdjustmentV1, - RadrootsTradeEconomicsProfileV1, RadrootsTradeMutationBodyV1, - RadrootsTradeMutationEnvelopeV1, canonical_trade_mutation_content, + FulfillmentProfileV1, RADROOTS_TRADE_DECISION_CONTRACT_ID, + RADROOTS_TRADE_MAX_PRIVATE_ARTIFACT_BYTES, RADROOTS_TRADE_MUTATION_CONTRACT_IDS, + RADROOTS_TRADE_PROPOSAL_CONTRACT_ID, RADROOTS_TRADE_SCHEMA_VERSION, + SellerReservationAssertionV1, SellerReservationLineV1, TradeCancellationProfileV1, + TradeCandidateLineV1, TradeCandidateTermsV1, TradeDecisionV1, TradeEconomicAdjustmentV1, + TradeEconomicsProfileV1, TradeMutationBodyV1, TradeMutationEnvelopeV1, + canonical_trade_mutation_content, }, }; use radroots_identity::PublicKey; @@ -33,12 +29,12 @@ fn pubkey(value: &str) -> PublicKey { PublicKey::from_hex(value).expect("pubkey") } -fn event_id(marker: char) -> RadrootsEventId { - RadrootsEventId::parse(std::iter::repeat_n(marker, 64).collect::<String>()).expect("event id") +fn event_id(marker: char) -> EventId { + EventId::parse(std::iter::repeat_n(marker, 64).collect::<String>()).expect("event id") } -fn trade_id() -> RadrootsTradeId { - RadrootsTradeId::parse("11111111111111111111111111111111").expect("trade id") +fn trade_id() -> TradeId { + TradeId::parse("11111111111111111111111111111111").expect("trade id") } fn local_signer() -> (String, RadrootsLocalEventSigner) { @@ -119,18 +115,18 @@ fn seller_actor(seller_pubkey: &str) -> RadrootsActorContext { RadrootsActorContext::test(seller_pubkey, [AuthorRole::Seller]).expect("seller") } -fn candidate(buyer_pubkey: &str, seller_pubkey: &str) -> RadrootsTradeCandidateTermsV1 { - RadrootsTradeCandidateTermsV1 { +fn candidate(buyer_pubkey: &str, seller_pubkey: &str) -> TradeCandidateTermsV1 { + TradeCandidateTermsV1 { candidate_id: None, schema_version: RADROOTS_TRADE_SCHEMA_VERSION, base_candidate_id: None, supersession_intent: None, buyer_pubkey: pubkey(buyer_pubkey), seller_pubkey: pubkey(seller_pubkey), - farm_id: RadrootsDTag::parse("farm-1").expect("farm id"), - lines: vec![RadrootsTradeCandidateLineV1 { - line_id: RadrootsDTag::parse("line-1").expect("line id"), - listing_addr: RadrootsClassifiedListingAddress::parse(format!( + farm_id: DTag::parse("farm-1").expect("farm id"), + lines: vec![TradeCandidateLineV1 { + line_id: DTag::parse("line-1").expect("line id"), + listing_addr: ClassifiedListingAddress::parse(format!( "30402:{seller_pubkey}:listing-1" )) .expect("listing address"), @@ -138,7 +134,7 @@ fn candidate(buyer_pubkey: &str, seller_pubkey: &str) -> RadrootsTradeCandidateT listing_snapshot_sha256: "d".repeat(64), product_id: "carrots".to_owned(), option_id: None, - bin_id: RadrootsInventoryBinId::parse("bin-1").expect("bin id"), + bin_id: InventoryBinId::parse("bin-1").expect("bin id"), quantity_mantissa: "2".to_owned(), quantity_scale: 0, unit_code: "count".to_owned(), @@ -149,7 +145,7 @@ fn candidate(buyer_pubkey: &str, seller_pubkey: &str) -> RadrootsTradeCandidateT replaces_line_id: None, }], line_tombstones: Vec::new(), - economics: RadrootsTradeEconomicsProfileV1 { + economics: TradeEconomicsProfileV1 { profile_id: "mvp-fixed".to_owned(), currency_code: "USD".to_owned(), currency_exponent: 2, @@ -158,9 +154,9 @@ fn candidate(buyer_pubkey: &str, seller_pubkey: &str) -> RadrootsTradeCandidateT discount_total_mantissa: "0".to_owned(), adjustment_total_mantissa: "0".to_owned(), total_mantissa: "1000".to_owned(), - adjustments: Vec::<RadrootsTradeEconomicAdjustmentV1>::new(), + adjustments: Vec::<TradeEconomicAdjustmentV1>::new(), }, - fulfillment: RadrootsFulfillmentProfileV1 { + fulfillment: FulfillmentProfileV1 { profile_id: "market-pickup".to_owned(), method: "pickup".to_owned(), starts_at_unix_s: 1_800_000_000, @@ -171,7 +167,7 @@ fn candidate(buyer_pubkey: &str, seller_pubkey: &str) -> RadrootsTradeCandidateT location_class: "farmstand".to_owned(), requires_private_terms: true, }, - cancellation: RadrootsTradeCancellationProfileV1 { + cancellation: TradeCancellationProfileV1 { profile_id: "buyer-pre-agreement".to_owned(), buyer_pre_agreement: true, post_agreement_cutoff_unix_s: None, @@ -182,11 +178,11 @@ fn candidate(buyer_pubkey: &str, seller_pubkey: &str) -> RadrootsTradeCandidateT } fn proposal( - candidate: RadrootsTradeCandidateTermsV1, + candidate: TradeCandidateTermsV1, buyer_pubkey: &str, seller_pubkey: &str, -) -> RadrootsTradeMutationEnvelopeV1 { - RadrootsTradeMutationEnvelopeV1 { +) -> TradeMutationEnvelopeV1 { + TradeMutationEnvelopeV1 { mutation_id: None, contract_id: RADROOTS_TRADE_PROPOSAL_CONTRACT_ID.to_owned(), schema_version: RADROOTS_TRADE_SCHEMA_VERSION, @@ -194,28 +190,28 @@ fn proposal( root_mutation_id: None, buyer_pubkey: pubkey(buyer_pubkey), seller_pubkey: pubkey(seller_pubkey), - farm_id: RadrootsDTag::parse("farm-1").expect("farm id"), + farm_id: DTag::parse("farm-1").expect("farm id"), parent_mutation_ids: Vec::new(), author_pubkey: pubkey(buyer_pubkey), counterparty_pubkey: pubkey(seller_pubkey), authored_at_unix_s: 1_799_000_000, - body: RadrootsTradeMutationBodyV1::Proposal { candidate }, + body: TradeMutationBodyV1::Proposal { candidate }, } } fn reservation( - candidate: &RadrootsTradeCandidateTermsV1, + candidate: &TradeCandidateTermsV1, seller_pubkey: &str, -) -> RadrootsSellerReservationAssertionV1 { - RadrootsSellerReservationAssertionV1 { - reservation_id: RadrootsDTag::parse("reservation-1").expect("reservation id"), +) -> SellerReservationAssertionV1 { + SellerReservationAssertionV1 { + reservation_id: DTag::parse("reservation-1").expect("reservation id"), inventory_authority_id: pubkey(seller_pubkey), inventory_epoch: 42, candidate_id: candidate.candidate_id.expect("candidate id"), commitments: candidate .lines .iter() - .map(|line| RadrootsSellerReservationLineV1 { + .map(|line| SellerReservationLineV1 { line_id: line.line_id.clone(), bin_id: line.bin_id.clone(), quantity_mantissa: line.quantity_mantissa.clone(), @@ -229,16 +225,16 @@ fn reservation( } fn accepted_decision( - proposal: &RadrootsTradeMutationEnvelopeV1, + proposal: &TradeMutationEnvelopeV1, buyer_pubkey: &str, seller_pubkey: &str, -) -> RadrootsTradeMutationEnvelopeV1 { +) -> TradeMutationEnvelopeV1 { let proposal_id = proposal.mutation_id.expect("proposal id"); let candidate = match &proposal.body { - RadrootsTradeMutationBodyV1::Proposal { candidate } => candidate.clone(), + TradeMutationBodyV1::Proposal { candidate } => candidate.clone(), _ => unreachable!(), }; - RadrootsTradeMutationEnvelopeV1 { + TradeMutationEnvelopeV1 { mutation_id: None, contract_id: RADROOTS_TRADE_DECISION_CONTRACT_ID.to_owned(), schema_version: RADROOTS_TRADE_SCHEMA_VERSION, @@ -246,15 +242,15 @@ fn accepted_decision( root_mutation_id: Some(proposal_id), buyer_pubkey: pubkey(buyer_pubkey), seller_pubkey: pubkey(seller_pubkey), - farm_id: RadrootsDTag::parse("farm-1").expect("farm id"), + farm_id: DTag::parse("farm-1").expect("farm id"), parent_mutation_ids: vec![proposal_id], author_pubkey: pubkey(seller_pubkey), counterparty_pubkey: pubkey(buyer_pubkey), authored_at_unix_s: 1_799_000_060, - body: RadrootsTradeMutationBodyV1::Decision { + body: TradeMutationBodyV1::Decision { proposal_mutation_id: proposal_id, candidate_id: candidate.candidate_id.expect("candidate id"), - decision: RadrootsTradeDecisionV1::Accepted { + decision: TradeDecisionV1::Accepted { reservation_assertion: Some(reservation(&candidate, seller_pubkey)), }, }, 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_event::contract::AuthorRole; -use radroots_event::draft::{RadrootsEventDraft, RadrootsSignedEvent, RadrootsSignedEventParts}; +use radroots_event::draft::{EventDraft, SignedEvent, SignedEventParts}; use radroots_event::envelope::kind::{KIND_FARM, KIND_GEOCHAT}; use radroots_identity::PublicKey; use radroots_nostr::prelude::{RadrootsNostrKeys, radroots_nostr_sign_frozen_draft}; @@ -60,10 +60,7 @@ impl RadrootsEventSigner for FailIfCalledSigner { self.identity.pubkey() } - fn sign_frozen_draft( - &self, - _draft: &RadrootsEventDraft, - ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { + fn sign_frozen_draft(&self, _draft: &EventDraft) -> Result<SignedEvent, RadrootsSignerError> { panic!("ephemeral workflow preflight must not invoke the signer") } } @@ -81,16 +78,13 @@ impl RadrootsEventSigner for InvalidSignatureSigner { self.0.pubkey() } - fn sign_frozen_draft( - &self, - draft: &RadrootsEventDraft, - ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { + fn sign_frozen_draft(&self, draft: &EventDraft) -> Result<SignedEvent, RadrootsSignerError> { let signed = self.0.sign_frozen_draft(draft)?; let mut wire = signed.wire().clone(); wire.sig = "0".repeat(128); let raw_json = serde_json::to_string(&wire).expect("invalid-signature fixture must serialize"); - RadrootsSignedEvent::from_wire_verified_id(wire, raw_json).map_err(|error| { + SignedEvent::from_wire_verified_id(wire, raw_json).map_err(|error| { RadrootsSignerError::SigningFailed { message: error.to_string(), } @@ -103,10 +97,7 @@ impl RadrootsEventSigner for WorkflowSigner { self.identity.pubkey() } - fn sign_frozen_draft( - &self, - draft: &RadrootsEventDraft, - ) -> Result<RadrootsSignedEvent, RadrootsSignerError> { + fn sign_frozen_draft(&self, draft: &EventDraft) -> Result<SignedEvent, RadrootsSignerError> { radroots_nostr_sign_frozen_draft(&self.keys, draft).map_err(|error| { RadrootsSignerError::SigningFailed { message: error.to_string(), @@ -115,12 +106,12 @@ impl RadrootsEventSigner for WorkflowSigner { } } -fn frozen_draft_for(pubkey: &str) -> RadrootsEventDraft { +fn frozen_draft_for(pubkey: &str) -> EventDraft { frozen_draft_for_d_tag(pubkey, "test") } -fn frozen_draft_for_d_tag(pubkey: &str, d_tag: &str) -> RadrootsEventDraft { - RadrootsEventDraft::new( +fn frozen_draft_for_d_tag(pubkey: &str, d_tag: &str) -> EventDraft { + EventDraft::new( "radroots.farm.profile.v1", KIND_FARM, 1_700_000_000, @@ -131,12 +122,12 @@ fn frozen_draft_for_d_tag(pubkey: &str, d_tag: &str) -> RadrootsEventDraft { .expect("frozen draft") } -fn frozen_draft() -> RadrootsEventDraft { +fn frozen_draft() -> EventDraft { frozen_draft_for("a".repeat(64).as_str()) } -fn ephemeral_draft_for(pubkey: &str) -> RadrootsEventDraft { - RadrootsEventDraft::new( +fn ephemeral_draft_for(pubkey: &str) -> EventDraft { + EventDraft::new( "radroots.social.geochat.v1", KIND_GEOCHAT, 1_700_000_000, @@ -147,7 +138,7 @@ fn ephemeral_draft_for(pubkey: &str) -> RadrootsEventDraft { .expect("ephemeral draft") } -fn signed_event() -> RadrootsSignedEvent { +fn signed_event() -> SignedEvent { let draft = frozen_draft(); let sig = "c".repeat(128); let raw_json = serde_json::json!({ @@ -160,7 +151,7 @@ fn signed_event() -> RadrootsSignedEvent { "sig": sig, }) .to_string(); - RadrootsSignedEvent::new(RadrootsSignedEventParts { + SignedEvent::new(SignedEventParts { id: draft.expected_event_id_hex().to_owned(), pubkey: draft.expected_pubkey().to_hex().to_owned(), created_at: draft.created_at_u64(), @@ -199,7 +190,7 @@ fn workflow_digest_and_event_helpers_cover_error_and_input_paths() { assert_eq!(digest_prefix("abcdef1234567890"), "abcdef123456"); assert_eq!( parse_event_id("b".repeat(64).as_str(), "event id").expect("event id"), - RadrootsEventId::parse("b".repeat(64)).expect("event id") + EventId::parse("b".repeat(64)).expect("event id") ); assert!(matches!( parse_event_id("not-an-event-id", "signed event id"), @@ -258,7 +249,7 @@ fn workflow_digest_and_event_helpers_cover_error_and_input_paths() { let frozen = frozen_draft_json(&draft).expect("frozen draft json"); assert!(frozen.contains("\"expected_event_id\"")); let receipt = SdkWorkflowEnqueueReceipt { - signed_event_id: RadrootsEventId::parse(draft.expected_event_id_hex()).expect("event id"), + signed_event_id: EventId::parse(draft.expected_event_id_hex()).expect("event id"), local_event_seq: 1, outbox_operation_id: 2, outbox_event_id: 3, diff --git a/tools/xtask/src/smoke.rs b/tools/xtask/src/smoke.rs @@ -120,7 +120,7 @@ fn is_exact_crates_version(version: &str) -> bool { } const CONSUMER_MAIN: &str = r#"use nostr::{EventBuilder, Keys, Kind, Tag, Timestamp}; -use radroots_event::envelope::RadrootsEventEnvelopeParts; +use radroots_event::envelope::EventEnvelopeParts; use radroots_sdk::knowledge::prelude::*; const CREATED_AT: u32 = 1_800_000_000; @@ -143,9 +143,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { } fn sign_parts( - parts: RadrootsNip01EventWireParts, + parts: Nip01EventWireParts, keys: &Keys, -) -> Result<RadrootsEventEnvelope, Box<dyn std::error::Error>> { +) -> Result<EventEnvelope, Box<dyn std::error::Error>> { let tags = parts .tags .into_iter() @@ -155,7 +155,7 @@ fn sign_parts( .tags(tags) .custom_created_at(Timestamp::from_secs(u64::from(CREATED_AT))) .sign_with_keys(keys)?; - Ok(RadrootsEventEnvelope::new(RadrootsEventEnvelopeParts { + Ok(EventEnvelope::new(EventEnvelopeParts { id: event.id.to_hex(), author: event.pubkey.to_hex(), created_at: event.created_at.as_secs(), @@ -175,8 +175,8 @@ fn hex_64(character: char) -> String { character.to_string().repeat(64) } -fn event_ref(character: char, kind: u32) -> RadrootsEventRef { - RadrootsEventRef { +fn event_ref(character: char, kind: u32) -> EventRef { + EventRef { id: hex_64(character), author: radroots_identity::PublicKey::from_hex( "585591529da0bab31b3b1b1f986611cf5f435dca84f978c89ee8a40cca7103df", @@ -192,7 +192,7 @@ fn claim_builder() -> RadrootsKnowledgeClaimBuilder { RadrootsKnowledgeClaimBuilder::new() .claim_type("practice_effect") .text("Cover crops improve soil structure.") - .citation_span(RadrootsKnowledgeCitationSpan { + .citation_span(KnowledgeCitationSpan { source_ref: event_ref('4', KIND_KNOWLEDGE_SOURCE), artifact_ref: None, page_start: Some(12),