commit 6c81102ea7142fac6917059df64bd5fabfdc9ab6
parent c5e73d968eb8848d2ef0916528db0ae9d8a965c7
Author: triesap <tyson@radroots.org>
Date: Sat, 27 Jun 2026 08:30:13 +0000
events: derive dto events relay resource seal validation
Diffstat:
7 files changed, 15 insertions(+), 273 deletions(-)
diff --git a/crates/events/src/dto.rs b/crates/events/src/dto.rs
@@ -1,5 +1,5 @@
use dto_bindgen_core::{
- DescribeCtx, Dto, EnumDef, EnumRepr, FieldDef, FieldPresence, GenericParam, IdentName, IntRepr,
+ DescribeCtx, Dto, EnumDef, EnumRepr, FieldDef, FieldPresence, GenericParam, IdentName,
RootDescriptor, RustTypeId, SourceSpan, StructDef, TargetFieldNames, TypeDef, TypeRef,
VariantDef, VariantShape, WireFieldNames,
};
@@ -174,263 +174,6 @@ pub struct RadrootsOrderStatusDto;
pub struct RadrootsOrderQuestionDto;
pub struct RadrootsCommercialTransportLaneDto;
-impl Dto for RadrootsResourceHarvestCap {
- fn describe(ctx: &mut DescribeCtx) -> TypeRef {
- let def = StructDef::new(
- "RadrootsResourceHarvestCap",
- "RadrootsResourceHarvestCap",
- span("crates/events/src/resource_cap.rs", 20),
- )
- .with_field(field(
- "d_tag",
- "d_tag",
- String::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 21,
- ))
- .with_field(field(
- "resource_area",
- "resource_area",
- RadrootsResourceAreaRef::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 22,
- ))
- .with_field(field(
- "product",
- "product",
- RadrootsResourceHarvestProduct::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 23,
- ))
- .with_field(
- field(
- "start",
- "start",
- u64::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 24,
- )
- .with_int_repr(IntRepr::JsonString),
- )
- .with_field(
- field(
- "end",
- "end",
- u64::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 25,
- )
- .with_int_repr(IntRepr::JsonString),
- )
- .with_field(field(
- "cap_quantity",
- "cap_quantity",
- radroots_core::RadrootsCoreQuantity::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 26,
- ))
- .with_field(optional_nullable_field(
- "display_amount",
- "display_amount",
- TypeRef::option(core_decimal(ctx)),
- "crates/events/src/resource_cap.rs",
- 27,
- ))
- .with_field(optional_nullable_field(
- "display_unit",
- "display_unit",
- <Option<radroots_core::RadrootsCoreUnit> as Dto>::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 28,
- ))
- .with_field(optional_nullable_field(
- "display_label",
- "display_label",
- <Option<String> as Dto>::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 29,
- ))
- .with_field(optional_nullable_field(
- "tags",
- "tags",
- <Option<Vec<String>> as Dto>::describe(ctx),
- "crates/events/src/resource_cap.rs",
- 30,
- ));
- register(ctx, "RadrootsResourceHarvestCap", TypeDef::Struct(def))
- }
-}
-
-impl Dto for RadrootsTradeValidationListingError {
- fn describe(ctx: &mut DescribeCtx) -> TypeRef {
- let parse_error = RadrootsListingParseError::describe(ctx);
- let def = EnumDef::new(
- "RadrootsTradeValidationListingError",
- "RadrootsTradeListingValidationError",
- EnumRepr::Adjacent {
- tag: "kind".to_owned(),
- content: "amount".to_owned(),
- },
- span("crates/events/src/trade_validation.rs", 14),
- )
- .with_variant(VariantDef::new(
- "InvalidKind",
- "invalid_kind",
- VariantShape::Struct(vec![field(
- "kind",
- "kind",
- u32::describe(ctx),
- "crates/events/src/trade_validation.rs",
- 15,
- )]),
- span("crates/events/src/trade_validation.rs", 15),
- ))
- .with_variant(unit_variant(
- "MissingListingId",
- "missing_listing_id",
- "crates/events/src/trade_validation.rs",
- 16,
- ))
- .with_variant(VariantDef::new(
- "ListingEventNotFound",
- "listing_event_not_found",
- VariantShape::Struct(vec![field(
- "listing_addr",
- "listing_addr",
- String::describe(ctx),
- "crates/events/src/trade_validation.rs",
- 17,
- )]),
- span("crates/events/src/trade_validation.rs", 17),
- ))
- .with_variant(VariantDef::new(
- "ListingEventFetchFailed",
- "listing_event_fetch_failed",
- VariantShape::Struct(vec![field(
- "listing_addr",
- "listing_addr",
- String::describe(ctx),
- "crates/events/src/trade_validation.rs",
- 18,
- )]),
- span("crates/events/src/trade_validation.rs", 18),
- ))
- .with_variant(VariantDef::new(
- "ParseError",
- "parse_error",
- VariantShape::Struct(vec![field(
- "error",
- "error",
- parse_error,
- "crates/events/src/trade_validation.rs",
- 19,
- )]),
- span("crates/events/src/trade_validation.rs", 19),
- ))
- .with_variant(unit_variant(
- "InvalidSeller",
- "invalid_seller",
- "crates/events/src/trade_validation.rs",
- 20,
- ))
- .with_variant(unit_variant(
- "MissingFarmProfile",
- "missing_farm_profile",
- "crates/events/src/trade_validation.rs",
- 21,
- ))
- .with_variant(unit_variant(
- "MissingFarmRecord",
- "missing_farm_record",
- "crates/events/src/trade_validation.rs",
- 22,
- ))
- .with_variant(unit_variant(
- "MissingTitle",
- "missing_title",
- "crates/events/src/trade_validation.rs",
- 23,
- ))
- .with_variant(unit_variant(
- "MissingDescription",
- "missing_description",
- "crates/events/src/trade_validation.rs",
- 24,
- ))
- .with_variant(unit_variant(
- "MissingProductType",
- "missing_product_type",
- "crates/events/src/trade_validation.rs",
- 25,
- ))
- .with_variant(unit_variant(
- "MissingBins",
- "missing_bins",
- "crates/events/src/trade_validation.rs",
- 26,
- ))
- .with_variant(unit_variant(
- "MissingPrimaryBin",
- "missing_primary_bin",
- "crates/events/src/trade_validation.rs",
- 27,
- ))
- .with_variant(unit_variant(
- "InvalidBin",
- "invalid_bin",
- "crates/events/src/trade_validation.rs",
- 28,
- ))
- .with_variant(unit_variant(
- "MissingPrice",
- "missing_price",
- "crates/events/src/trade_validation.rs",
- 29,
- ))
- .with_variant(unit_variant(
- "InvalidPrice",
- "invalid_price",
- "crates/events/src/trade_validation.rs",
- 30,
- ))
- .with_variant(unit_variant(
- "MissingInventory",
- "missing_inventory",
- "crates/events/src/trade_validation.rs",
- 31,
- ))
- .with_variant(unit_variant(
- "InvalidInventory",
- "invalid_inventory",
- "crates/events/src/trade_validation.rs",
- 32,
- ))
- .with_variant(unit_variant(
- "MissingAvailability",
- "missing_availability",
- "crates/events/src/trade_validation.rs",
- 33,
- ))
- .with_variant(unit_variant(
- "MissingLocation",
- "missing_location",
- "crates/events/src/trade_validation.rs",
- 34,
- ))
- .with_variant(unit_variant(
- "MissingDeliveryMethod",
- "missing_delivery_method",
- "crates/events/src/trade_validation.rs",
- 35,
- ));
- register(
- ctx,
- "RadrootsTradeValidationListingError",
- TypeDef::Enum(def),
- )
- }
-}
-
impl Dto for RadrootsOrderEnvelopeDto {
fn describe(ctx: &mut DescribeCtx) -> TypeRef {
let def = StructDef {
@@ -1067,21 +810,6 @@ fn register(ctx: &mut DescribeCtx, rust_ident: &str, type_def: TypeDef) -> TypeR
)
}
-fn core_decimal(ctx: &mut DescribeCtx) -> TypeRef {
- external_core_alias(ctx, "RadrootsCoreDecimal")
-}
-
-fn external_core_alias(ctx: &mut DescribeCtx, rust_ident: &str) -> TypeRef {
- ctx.register_type(
- RustTypeId::new("radroots_core", "radroots_core", rust_ident),
- TypeDef::Struct(StructDef::new(
- rust_ident,
- rust_ident,
- span("crates/core/src/dto.rs", 1),
- )),
- )
-}
-
fn accepted_reason_struct(ctx: &mut DescribeCtx, rust_ident: &str, export_name: &str) -> TypeRef {
let def = StructDef::new(
rust_ident,
diff --git a/crates/events/src/geochat.rs b/crates/events/src/geochat.rs
@@ -4,6 +4,7 @@
use alloc::string::String;
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug)]
pub struct RadrootsGeoChat {
diff --git a/crates/events/src/gift_wrap.rs b/crates/events/src/gift_wrap.rs
@@ -4,6 +4,7 @@
use alloc::string::String;
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug)]
pub struct RadrootsGiftWrap {
@@ -13,6 +14,7 @@ pub struct RadrootsGiftWrap {
}
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug)]
pub struct RadrootsGiftWrapRecipient {
diff --git a/crates/events/src/relay_document.rs b/crates/events/src/relay_document.rs
@@ -2,6 +2,7 @@
use alloc::{string::String, vec::Vec};
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug)]
pub struct RadrootsRelayDocument {
diff --git a/crates/events/src/resource_cap.rs b/crates/events/src/resource_cap.rs
@@ -8,6 +8,7 @@ use crate::resource_area::RadrootsResourceAreaRef;
use alloc::{string::String, vec::Vec};
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug)]
pub struct RadrootsResourceHarvestProduct {
@@ -16,12 +17,16 @@ pub struct RadrootsResourceHarvestProduct {
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[derive(Clone, Debug)]
pub struct RadrootsResourceHarvestCap {
pub d_tag: String,
pub resource_area: RadrootsResourceAreaRef,
pub product: RadrootsResourceHarvestProduct,
+ #[cfg_attr(feature = "dto-bindgen", dto(int = "json_string"))]
pub start: u64,
+ #[cfg_attr(feature = "dto-bindgen", dto(int = "json_string"))]
pub end: u64,
pub cap_quantity: RadrootsCoreQuantity,
pub display_amount: Option<RadrootsCoreDecimal>,
diff --git a/crates/events/src/seal.rs b/crates/events/src/seal.rs
@@ -4,6 +4,7 @@
use alloc::string::String;
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug)]
pub struct RadrootsSeal {
diff --git a/crates/events/src/trade_validation.rs b/crates/events/src/trade_validation.rs
@@ -6,6 +6,8 @@ use alloc::{string::String, vec::Vec};
use crate::{RadrootsNostrEventPtr, order::RadrootsListingParseError};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(
feature = "serde",
serde(rename_all = "snake_case", tag = "kind", content = "amount")
@@ -77,6 +79,7 @@ impl core::fmt::Display for RadrootsTradeValidationListingError {
impl std::error::Error for RadrootsTradeValidationListingError {}
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(
feature = "dto-bindgen",
dto(ts(name = "RadrootsTradeListingValidateRequest"))
@@ -88,6 +91,7 @@ pub struct RadrootsTradeValidationListingRequest {
}
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
+#[cfg_attr(feature = "dto-bindgen", dto(export))]
#[cfg_attr(
feature = "dto-bindgen",
dto(ts(name = "RadrootsTradeListingValidateResult"))