commit f0f142265096cb8da7e2ede732e7c599bd243bdb
parent 3020f5bb3370c0d84e28510761373d4b516491e5
Author: triesap <tyson@radroots.org>
Date: Fri, 26 Jun 2026 15:00:07 +0000
bindings: align event dto imports
- consume typed listing projection addresses from event bindings
- update trade bindings to import canonical commercial and order DTO names
- regenerate event and trade TypeScript bindings from dto-bindgen
- validate fmt, unit, xtask, coverage, build, and typecheck gates
Diffstat:
7 files changed, 139 insertions(+), 153 deletions(-)
diff --git a/crates/sdk/src/market_runtime.rs b/crates/sdk/src/market_runtime.rs
@@ -111,15 +111,7 @@ impl MarketListingSearchRow {
fn try_from_projection_row(
row: RadrootsListingProjectionRow,
) -> Result<Self, RadrootsSdkError> {
- let listing_addr =
- RadrootsListingAddress::parse(row.listing_addr.as_str()).map_err(|source| {
- RadrootsSdkError::Projection {
- message: format!(
- "stored listing projection address `{}` is invalid: {source}",
- row.listing_addr
- ),
- }
- })?;
+ let listing_addr = row.listing_addr;
let listing_event_id =
RadrootsEventId::parse(row.listing_event_id.as_str()).map_err(|source| {
RadrootsSdkError::Projection {
diff --git a/crates/sdk/tests/unit/market_runtime_tests.rs b/crates/sdk/tests/unit/market_runtime_tests.rs
@@ -5,7 +5,10 @@ const SELLER_PUBLIC_KEY_HEX: &str =
fn projection_row() -> RadrootsListingProjectionRow {
RadrootsListingProjectionRow {
- listing_addr: format!("30402:{SELLER_PUBLIC_KEY_HEX}:AAAAAAAAAAAAAAAAAAAAAg"),
+ listing_addr: RadrootsListingAddress::parse(format!(
+ "30402:{SELLER_PUBLIC_KEY_HEX}:AAAAAAAAAAAAAAAAAAAAAg"
+ ))
+ .expect("listing address"),
listing_event_id: "a".repeat(64),
seller_pubkey: SELLER_PUBLIC_KEY_HEX.to_owned(),
title: "Blueberries".to_owned(),
@@ -47,20 +50,11 @@ fn listing_projection_row_conversion_validates_stored_identity_columns() {
let row = projection_row();
let search_row =
MarketListingSearchRow::try_from_projection_row(row.clone()).expect("search row");
- assert_eq!(search_row.listing_addr.as_str(), row.listing_addr);
+ assert_eq!(search_row.listing_addr, row.listing_addr);
assert_eq!(search_row.listing_event_id.as_str(), row.listing_event_id);
assert_eq!(search_row.seller_pubkey.as_str(), row.seller_pubkey);
assert_eq!(search_row.title, "Blueberries");
- let mut invalid_addr = row.clone();
- invalid_addr.listing_addr = "not-an-address".to_owned();
- assert!(
- projection_error_message(
- MarketListingSearchRow::try_from_projection_row(invalid_addr).unwrap_err()
- )
- .contains("projection address")
- );
-
let mut invalid_event_id = row.clone();
invalid_event_id.listing_event_id = "not-an-event-id".to_owned();
assert!(
diff --git a/crates/trade_bindings/src/dto.rs b/crates/trade_bindings/src/dto.rs
@@ -83,16 +83,16 @@ imported_ts_type!(RadrootsNostrEventPtrImport, "RadrootsNostrEventPtr");
imported_ts_type!(RadrootsPlotRefImport, "RadrootsPlotRef");
imported_ts_type!(RadrootsResourceAreaRefImport, "RadrootsResourceAreaRef");
imported_ts_type!(
- RadrootsTradeMessagePayloadImport,
- "RadrootsTradeMessagePayload"
+ RadrootsCommercialMessagePayloadImport,
+ "RadrootsCommercialMessagePayload"
);
-imported_ts_type!(RadrootsTradeMessageTypeImport, "RadrootsTradeMessageType");
imported_ts_type!(
- RadrootsTradeOrderEconomicLineImport,
- "RadrootsTradeOrderEconomicLine"
+ RadrootsCommercialMessageTypeImport,
+ "RadrootsCommercialMessageType"
);
-imported_ts_type!(RadrootsTradeOrderItemImport, "RadrootsTradeOrderItem");
-imported_ts_type!(RadrootsTradeOrderStatusImport, "RadrootsTradeOrderStatus");
+imported_ts_type!(RadrootsOrderEconomicLineImport, "RadrootsOrderEconomicLine");
+imported_ts_type!(RadrootsOrderItemImport, "RadrootsOrderItem");
+imported_ts_type!(RadrootsOrderStatusImport, "RadrootsOrderStatus");
#[derive(dto_bindgen::Dto)]
pub struct RadrootsTradeFacetCount {
@@ -278,8 +278,8 @@ pub struct RadrootsTradeMarketplaceOrderSummary {
pub listing_addr: String,
pub buyer_pubkey: String,
pub seller_pubkey: String,
- pub status: RadrootsTradeOrderStatusImport,
- pub last_message_type: RadrootsTradeMessageTypeImport,
+ pub status: RadrootsOrderStatusImport,
+ pub last_message_type: RadrootsCommercialMessageTypeImport,
pub item_count: u32,
pub total_bin_count: u32,
pub has_requested_discounts: bool,
@@ -351,7 +351,7 @@ pub struct RadrootsTradeOrderQuery {
pub listing_addr: Option<String>,
pub buyer_pubkey: Option<String>,
pub seller_pubkey: Option<String>,
- pub status: Option<RadrootsTradeOrderStatusImport>,
+ pub status: Option<RadrootsOrderStatusImport>,
}
#[derive(dto_bindgen::Dto)]
@@ -388,7 +388,7 @@ pub struct RadrootsTradeOrderWorkflowMessage {
pub listing_event: Option<RadrootsNostrEventPtrImport>,
pub root_event_id: Option<String>,
pub prev_event_id: Option<String>,
- pub payload: RadrootsTradeMessagePayloadImport,
+ pub payload: RadrootsCommercialMessagePayloadImport,
}
#[derive(dto_bindgen::Dto)]
@@ -397,9 +397,9 @@ pub struct RadrootsTradeOrderWorkflowProjection {
pub listing_addr: String,
pub buyer_pubkey: String,
pub seller_pubkey: String,
- pub items: Vec<RadrootsTradeOrderItemImport>,
- pub requested_discounts: Option<Vec<RadrootsTradeOrderEconomicLineImport>>,
- pub status: RadrootsTradeOrderStatusImport,
+ pub items: Vec<RadrootsOrderItemImport>,
+ pub requested_discounts: Option<Vec<RadrootsOrderEconomicLineImport>>,
+ pub status: RadrootsOrderStatusImport,
pub listing_snapshot: Option<RadrootsNostrEventPtrImport>,
pub root_event_id: String,
pub last_event_id: String,
@@ -416,7 +416,7 @@ pub struct RadrootsTradeOrderWorkflowProjection {
pub discount_accept_count: u32,
pub discount_decline_count: u32,
pub cancellation_count: u32,
- pub last_message_type: RadrootsTradeMessageTypeImport,
+ pub last_message_type: RadrootsCommercialMessageTypeImport,
pub last_actor_pubkey: String,
}
diff --git a/crates/trade_bindings/src/lib.rs b/crates/trade_bindings/src/lib.rs
@@ -54,7 +54,7 @@ pub const TRADE_TYPE_INVENTORY: &[TradeTypeInventoryEntry] = &[
source_root("RadrootsTradeListingTotal"),
local_shape("RadrootsTradeMarketplaceListingSummary"),
local_shape("RadrootsTradeMarketplaceOrderSummary"),
- event_import("RadrootsTradeMessageType"),
+ event_import("RadrootsCommercialMessageType"),
local_shape("RadrootsTradeModerationFlag"),
local_shape("RadrootsTradeModerationSeverity"),
local_shape("RadrootsTradeModerationStatus"),
@@ -65,7 +65,7 @@ pub const TRADE_TYPE_INVENTORY: &[TradeTypeInventoryEntry] = &[
local_shape("RadrootsTradeOrderQuery"),
local_shape("RadrootsTradeOrderSort"),
local_shape("RadrootsTradeOrderSortField"),
- event_import("RadrootsTradeOrderStatus"),
+ event_import("RadrootsOrderStatus"),
local_shape("RadrootsTradeOrderWorkflowMessage"),
local_shape("RadrootsTradeOrderWorkflowProjection"),
local_shape("RadrootsTradeReviewPriority"),
@@ -200,7 +200,7 @@ mod tests {
"RadrootsTradeListingTotal",
"RadrootsTradeMarketplaceListingSummary",
"RadrootsTradeMarketplaceOrderSummary",
- "RadrootsTradeMessageType",
+ "RadrootsCommercialMessageType",
"RadrootsTradeModerationFlag",
"RadrootsTradeModerationSeverity",
"RadrootsTradeModerationStatus",
@@ -211,7 +211,7 @@ mod tests {
"RadrootsTradeOrderQuery",
"RadrootsTradeOrderSort",
"RadrootsTradeOrderSortField",
- "RadrootsTradeOrderStatus",
+ "RadrootsOrderStatus",
"RadrootsTradeOrderWorkflowMessage",
"RadrootsTradeOrderWorkflowProjection",
"RadrootsTradeReviewPriority",
@@ -233,8 +233,8 @@ mod tests {
"RadrootsListingProduct",
"RadrootsListingPublicLocation",
"RadrootsListingStatus",
- "RadrootsTradeMessageType",
- "RadrootsTradeOrderStatus",
+ "RadrootsCommercialMessageType",
+ "RadrootsOrderStatus",
] {
assert_eq!(
disposition(export_name),
diff --git a/packages/events-bindings/src/generated/types.ts b/packages/events-bindings/src/generated/types.ts
@@ -19,14 +19,20 @@ export type JobPaymentRequest = { amount_sat: number, bolt11?: string | null, };
export type RadrootsAccountClaim = { username: string, pubkey: string, nip05?: string | null, };
-export type RadrootsActiveTradeEnvelope<T> = { version: number, domain: RadrootsTradeDomain, type: RadrootsActiveTradeMessageType, order_id: string, listing_addr: string, payload: T, };
-
-export type RadrootsActiveTradeMessageType = "TradeOrderRequested" | "TradeOrderDecision" | "TradeOrderRevisionProposed" | "TradeOrderRevisionDecision" | "TradeOrderCancelled";
-
export type RadrootsAppData = { d_tag: string, content: string, };
export type RadrootsComment = { root: RadrootsNostrEventRef, parent: RadrootsNostrEventRef, content: string, };
+export type RadrootsCommercialDomain = "trade:listing";
+
+export type RadrootsCommercialEnvelope<T> = { version: number, domain: RadrootsCommercialDomain, type: RadrootsCommercialMessageType, order_id?: string | null, listing_addr: string, payload: T, };
+
+export type RadrootsCommercialMessagePayload = { kind: "listing_validate_request", amount: RadrootsTradeListingValidateRequest, } | { kind: "listing_validate_result", amount: RadrootsTradeListingValidateResult, } | { kind: "trade_order_requested", amount: RadrootsOrderRequest, } | { kind: "order_response", amount: RadrootsOrderResponse, } | { kind: "order_revision", amount: RadrootsOrderRevision, } | { kind: "order_revision_accept", amount: RadrootsOrderRevisionResponse, } | { kind: "order_revision_decline", amount: RadrootsOrderRevisionResponse, } | { kind: "question", amount: RadrootsOrderQuestion, } | { kind: "answer", amount: RadrootsOrderAnswer, } | { kind: "discount_request", amount: RadrootsOrderDiscountRequest, } | { kind: "discount_offer", amount: RadrootsOrderDiscountOffer, } | { kind: "discount_accept", amount: RadrootsOrderDiscountDecision, } | { kind: "discount_decline", amount: RadrootsOrderDiscountDecision, } | { kind: "cancel", amount: RadrootsListingCancel, };
+
+export type RadrootsCommercialMessageType = "listing_validate_request" | "listing_validate_result" | "order_request" | "order_response" | "order_revision" | "order_revision_accept" | "order_revision_decline" | "question" | "answer" | "discount_request" | "discount_offer" | "discount_accept" | "discount_decline" | "cancel";
+
+export type RadrootsCommercialTransportLane = "service" | "public";
+
export type RadrootsCoop = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsCoopLocation | null, tags?: Array<string> | null, };
export type RadrootsCoopLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, };
@@ -81,12 +87,16 @@ export type RadrootsListingAvailability = { kind: "window", amount: { start?: nu
export type RadrootsListingBin = { bin_id: string, quantity: RadrootsCoreQuantity, price_per_canonical_unit: RadrootsCoreQuantityPrice, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, display_price?: RadrootsCoreMoney | null, display_price_unit?: RadrootsCoreUnit | null, };
+export type RadrootsListingCancel = { reason?: string | null, };
+
export type RadrootsListingDeliveryMethod = { kind: "pickup", } | { kind: "local_delivery", } | { kind: "shipping", } | { kind: "other", amount: { method: string, }, };
export type RadrootsListingImage = { url: string, size?: RadrootsListingImageSize | null, };
export type RadrootsListingImageSize = { w: number, h: number, };
+export type RadrootsListingParseError = { InvalidKind: number, } | { MissingTag: string, } | { InvalidTag: string, } | { InvalidNumber: string, } | "InvalidUnit" | "InvalidCurrency" | { InvalidJson: string, } | { InvalidDiscount: string, };
+
export type RadrootsListingProduct = { key: string, title: string, category: string, summary?: string | null, process?: string | null, lot?: string | null, location?: string | null, profile?: string | null, year?: string | null, };
export type RadrootsListingProductTagKeys = readonly ["key", "title", "category", "summary", "process", "lot", "location", "profile", "year"];
@@ -109,104 +119,94 @@ export type RadrootsNostrEventPtr = { id: string, relays?: string | null, };
export type RadrootsNostrEventRef = { id: string, author: string, kind: number, d_tag?: string | null, relays?: Array<string> | null, };
-export type RadrootsPlot = { d_tag: string, farm: RadrootsFarmRef, name: string, about?: string | null, location?: RadrootsPlotLocation | null, tags?: Array<string> | null, };
+export type RadrootsOrderAnswer = { question_id: string, };
-export type RadrootsPlotLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, };
+export type RadrootsOrderCancellation = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, reason: string, };
-export type RadrootsPlotRef = { pubkey: string, d_tag: string, };
+export type RadrootsOrderChange = { kind: "bin_count", amount: { item_index: number, bin_count: number, }, } | { kind: "item_add", amount: { item: RadrootsOrderItem, }, } | { kind: "item_remove", amount: { item_index: number, }, };
-export type RadrootsPost = { content: string, };
-
-export type RadrootsProfile = { name: string, display_name?: string | null, nip05?: string | null, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, lud06?: string | null, lud16?: string | null, bot?: string | null, };
-
-export type RadrootsProfileType = "individual" | "farm" | "coop" | "any" | "radrootsd";
-
-export type RadrootsReaction = { root: RadrootsNostrEventRef, content: string, };
-
-export type RadrootsRelayDocument = { name?: string | null, description?: string | null, pubkey?: string | null, contact?: string | null, supported_nips?: Array<number> | null, software?: string | null, version?: string | null, };
-
-export type RadrootsResourceArea = { d_tag: string, name: string, about?: string | null, location: RadrootsResourceAreaLocation, tags?: Array<string> | null, };
+export type RadrootsOrderDecision = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, decision: RadrootsOrderDecisionOutcome, };
-export type RadrootsResourceAreaLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, };
+export type RadrootsOrderDecisionOutcome = { decision: "accepted", inventory_commitments: Array<RadrootsOrderInventoryCommitment>, } | { decision: "declined", reason: string, };
-export type RadrootsResourceAreaRef = { pubkey: string, d_tag: string, };
+export type RadrootsOrderDiscountDecision = { kind: "accept", amount: { value: RadrootsCoreDiscountValue, }, } | { kind: "decline", amount: { reason?: string | null, }, };
-export type RadrootsResourceHarvestCap = { d_tag: string, resource_area: RadrootsResourceAreaRef, product: RadrootsResourceHarvestProduct, start: bigint, end: bigint, cap_quantity: RadrootsCoreQuantity, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, tags?: Array<string> | null, };
+export type RadrootsOrderDiscountOffer = { discount_id: string, value: RadrootsCoreDiscountValue, };
-export type RadrootsResourceHarvestProduct = { key: string, category?: string | null, };
+export type RadrootsOrderDiscountRequest = { discount_id: string, value: RadrootsCoreDiscountValue, };
-export type RadrootsSeal = { content: string, };
+export type RadrootsOrderEconomicActor = "buyer" | "seller";
-export type RadrootsTradeAnswer = { question_id: string, };
+export type RadrootsOrderEconomicEffect = "increase" | "decrease";
-export type RadrootsTradeDiscountDecision = { kind: "accept", amount: { value: RadrootsCoreDiscountValue, }, } | { kind: "decline", amount: { reason?: string | null, }, };
+export type RadrootsOrderEconomicItem = { bin_id: string, bin_count: number, quantity_amount: RadrootsCoreDecimal, quantity_unit: RadrootsCoreUnit, unit_price_amount: RadrootsCoreDecimal, unit_price_currency: RadrootsCoreCurrency, line_subtotal: RadrootsCoreMoney, };
-export type RadrootsTradeDiscountOffer = { discount_id: string, value: RadrootsCoreDiscountValue, };
+export type RadrootsOrderEconomicLine = { id: string, kind: RadrootsOrderEconomicLineKind, actor: RadrootsOrderEconomicActor, effect: RadrootsOrderEconomicEffect, amount: RadrootsCoreMoney, reason: string, };
-export type RadrootsTradeDiscountRequest = { discount_id: string, value: RadrootsCoreDiscountValue, };
+export type RadrootsOrderEconomicLineKind = "listing_discount" | "basket_adjustment" | "revision_adjustment";
-export type RadrootsTradeDomain = "trade:listing";
+export type RadrootsOrderEconomicTotals = { subtotal: RadrootsCoreMoney, discount_total: RadrootsCoreMoney, adjustment_total: RadrootsCoreMoney, total: RadrootsCoreMoney, };
-export type RadrootsTradeEconomicActor = "buyer" | "seller";
+export type RadrootsOrderEconomics = { quote_id: string, quote_version: number, pricing_basis: RadrootsOrderPricingBasis, currency: RadrootsCoreCurrency, items: Array<RadrootsOrderEconomicItem>, discounts: Array<RadrootsOrderEconomicLine>, adjustments: Array<RadrootsOrderEconomicLine>, subtotal: RadrootsCoreMoney, discount_total: RadrootsCoreMoney, adjustment_total: RadrootsCoreMoney, total: RadrootsCoreMoney, };
-export type RadrootsTradeEconomicEffect = "increase" | "decrease";
+export type RadrootsOrderEnvelope<T> = { version: number, domain: RadrootsCommercialDomain, type: RadrootsOrderEventType, order_id: string, listing_addr: string, payload: T, };
-export type RadrootsTradeEconomicLineKind = "listing_discount" | "basket_adjustment" | "revision_adjustment";
+export type RadrootsOrderEventType = "TradeOrderRequested" | "TradeOrderDecision" | "TradeOrderRevisionProposed" | "TradeOrderRevisionDecision" | "TradeOrderCancelled";
-export type RadrootsTradeEnvelope<T> = { version: number, domain: RadrootsTradeDomain, type: RadrootsTradeMessageType, order_id?: string | null, listing_addr: string, payload: T, };
+export type RadrootsOrderInventoryCommitment = { bin_id: string, bin_count: number, };
-export type RadrootsTradeInventoryCommitment = { bin_id: string, bin_count: number, };
+export type RadrootsOrderItem = { bin_id: string, bin_count: number, };
-export type RadrootsTradeListingCancel = { reason?: string | null, };
+export type RadrootsOrderPricingBasis = "listing_event";
-export type RadrootsTradeListingParseError = { InvalidKind: number, } | { MissingTag: string, } | { InvalidTag: string, } | { InvalidNumber: string, } | "InvalidUnit" | "InvalidCurrency" | { InvalidJson: string, } | { InvalidDiscount: string, };
+export type RadrootsOrderQuestion = { question_id: string, };
-export type RadrootsTradeListingValidateRequest = { listing_event?: RadrootsNostrEventPtr | null, };
+export type RadrootsOrderRequest = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, items: Array<RadrootsOrderItem>, economics: RadrootsOrderEconomics, };
-export type RadrootsTradeListingValidateResult = { valid: boolean, errors: Array<RadrootsTradeListingValidationError>, };
+export type RadrootsOrderResponse = { accepted: boolean, reason?: string | null, };
-export type RadrootsTradeListingValidationError = { kind: "invalid_kind", amount: { kind: number, }, } | { kind: "missing_listing_id", } | { kind: "listing_event_not_found", amount: { listing_addr: string, }, } | { kind: "listing_event_fetch_failed", amount: { listing_addr: string, }, } | { kind: "parse_error", amount: { error: RadrootsTradeListingParseError, }, } | { kind: "invalid_seller", } | { kind: "missing_farm_profile", } | { kind: "missing_farm_record", } | { kind: "missing_title", } | { kind: "missing_description", } | { kind: "missing_product_type", } | { kind: "missing_bins", } | { kind: "missing_primary_bin", } | { kind: "invalid_bin", } | { kind: "missing_price", } | { kind: "invalid_price", } | { kind: "missing_inventory", } | { kind: "invalid_inventory", } | { kind: "missing_availability", } | { kind: "missing_location", } | { kind: "missing_delivery_method", };
+export type RadrootsOrderRevision = { revision_id: string, changes: Array<RadrootsOrderChange>, };
-export type RadrootsTradeMessagePayload = { kind: "listing_validate_request", amount: RadrootsTradeListingValidateRequest, } | { kind: "listing_validate_result", amount: RadrootsTradeListingValidateResult, } | { kind: "trade_order_requested", amount: RadrootsTradeOrderRequested, } | { kind: "order_response", amount: RadrootsTradeOrderResponse, } | { kind: "order_revision", amount: RadrootsTradeOrderRevision, } | { kind: "order_revision_accept", amount: RadrootsTradeOrderRevisionResponse, } | { kind: "order_revision_decline", amount: RadrootsTradeOrderRevisionResponse, } | { kind: "question", amount: RadrootsTradeQuestion, } | { kind: "answer", amount: RadrootsTradeAnswer, } | { kind: "discount_request", amount: RadrootsTradeDiscountRequest, } | { kind: "discount_offer", amount: RadrootsTradeDiscountOffer, } | { kind: "discount_accept", amount: RadrootsTradeDiscountDecision, } | { kind: "discount_decline", amount: RadrootsTradeDiscountDecision, } | { kind: "cancel", amount: RadrootsTradeListingCancel, };
+export type RadrootsOrderRevisionDecision = { revision_id: string, order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, root_event_id: string, prev_event_id: string, decision: RadrootsOrderRevisionOutcome, };
-export type RadrootsTradeMessageType = "listing_validate_request" | "listing_validate_result" | "order_request" | "order_response" | "order_revision" | "order_revision_accept" | "order_revision_decline" | "question" | "answer" | "discount_request" | "discount_offer" | "discount_accept" | "discount_decline" | "cancel";
+export type RadrootsOrderRevisionOutcome = { decision: "accepted", } | { decision: "declined", reason: string, };
-export type RadrootsTradeOrderCancelled = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, reason: string, };
+export type RadrootsOrderRevisionProposal = { revision_id: string, order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, root_event_id: string, prev_event_id: string, items: Array<RadrootsOrderItem>, economics: RadrootsOrderEconomics, reason: string, };
-export type RadrootsTradeOrderChange = { kind: "bin_count", amount: { item_index: number, bin_count: number, }, } | { kind: "item_add", amount: { item: RadrootsTradeOrderItem, }, } | { kind: "item_remove", amount: { item_index: number, }, };
+export type RadrootsOrderRevisionResponse = { accepted: boolean, reason?: string | null, };
-export type RadrootsTradeOrderDecision = { decision: "accepted", inventory_commitments: Array<RadrootsTradeInventoryCommitment>, } | { decision: "declined", reason: string, };
+export type RadrootsOrderStatus = "draft" | "validated" | "requested" | "questioned" | "revised" | "accepted" | "declined" | "cancelled";
-export type RadrootsTradeOrderDecisionEvent = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, decision: RadrootsTradeOrderDecision, };
+export type RadrootsPlot = { d_tag: string, farm: RadrootsFarmRef, name: string, about?: string | null, location?: RadrootsPlotLocation | null, tags?: Array<string> | null, };
-export type RadrootsTradeOrderEconomicItem = { bin_id: string, bin_count: number, quantity_amount: RadrootsCoreDecimal, quantity_unit: RadrootsCoreUnit, unit_price_amount: RadrootsCoreDecimal, unit_price_currency: RadrootsCoreCurrency, line_subtotal: RadrootsCoreMoney, };
+export type RadrootsPlotLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, };
-export type RadrootsTradeOrderEconomicLine = { id: string, kind: RadrootsTradeEconomicLineKind, actor: RadrootsTradeEconomicActor, effect: RadrootsTradeEconomicEffect, amount: RadrootsCoreMoney, reason: string, };
+export type RadrootsPlotRef = { pubkey: string, d_tag: string, };
-export type RadrootsTradeOrderEconomicTotals = { subtotal: RadrootsCoreMoney, discount_total: RadrootsCoreMoney, adjustment_total: RadrootsCoreMoney, total: RadrootsCoreMoney, };
+export type RadrootsPost = { content: string, };
-export type RadrootsTradeOrderEconomics = { quote_id: string, quote_version: number, pricing_basis: RadrootsTradePricingBasis, currency: RadrootsCoreCurrency, items: Array<RadrootsTradeOrderEconomicItem>, discounts: Array<RadrootsTradeOrderEconomicLine>, adjustments: Array<RadrootsTradeOrderEconomicLine>, subtotal: RadrootsCoreMoney, discount_total: RadrootsCoreMoney, adjustment_total: RadrootsCoreMoney, total: RadrootsCoreMoney, };
+export type RadrootsProfile = { name: string, display_name?: string | null, nip05?: string | null, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, lud06?: string | null, lud16?: string | null, bot?: string | null, };
-export type RadrootsTradeOrderItem = { bin_id: string, bin_count: number, };
+export type RadrootsProfileType = "individual" | "farm" | "coop" | "any" | "radrootsd";
-export type RadrootsTradeOrderRequested = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, items: Array<RadrootsTradeOrderItem>, economics: RadrootsTradeOrderEconomics, };
+export type RadrootsReaction = { root: RadrootsNostrEventRef, content: string, };
-export type RadrootsTradeOrderResponse = { accepted: boolean, reason?: string | null, };
+export type RadrootsRelayDocument = { name?: string | null, description?: string | null, pubkey?: string | null, contact?: string | null, supported_nips?: Array<number> | null, software?: string | null, version?: string | null, };
-export type RadrootsTradeOrderRevision = { revision_id: string, changes: Array<RadrootsTradeOrderChange>, };
+export type RadrootsResourceArea = { d_tag: string, name: string, about?: string | null, location: RadrootsResourceAreaLocation, tags?: Array<string> | null, };
-export type RadrootsTradeOrderRevisionDecision = { decision: "accepted", } | { decision: "declined", reason: string, };
+export type RadrootsResourceAreaLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, };
-export type RadrootsTradeOrderRevisionDecisionEvent = { revision_id: string, order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, root_event_id: string, prev_event_id: string, decision: RadrootsTradeOrderRevisionDecision, };
+export type RadrootsResourceAreaRef = { pubkey: string, d_tag: string, };
-export type RadrootsTradeOrderRevisionProposed = { revision_id: string, order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, root_event_id: string, prev_event_id: string, items: Array<RadrootsTradeOrderItem>, economics: RadrootsTradeOrderEconomics, reason: string, };
+export type RadrootsResourceHarvestCap = { d_tag: string, resource_area: RadrootsResourceAreaRef, product: RadrootsResourceHarvestProduct, start: bigint, end: bigint, cap_quantity: RadrootsCoreQuantity, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, tags?: Array<string> | null, };
-export type RadrootsTradeOrderRevisionResponse = { accepted: boolean, reason?: string | null, };
+export type RadrootsResourceHarvestProduct = { key: string, category?: string | null, };
-export type RadrootsTradeOrderStatus = "draft" | "validated" | "requested" | "questioned" | "revised" | "accepted" | "declined" | "cancelled";
+export type RadrootsSeal = { content: string, };
-export type RadrootsTradePricingBasis = "listing_event";
+export type RadrootsTradeListingValidateRequest = { listing_event?: RadrootsNostrEventPtr | null, };
-export type RadrootsTradeQuestion = { question_id: string, };
+export type RadrootsTradeListingValidateResult = { valid: boolean, errors: Array<RadrootsTradeListingValidationError>, };
-export type RadrootsTradeTransportLane = "service" | "public";
+export type RadrootsTradeListingValidationError = { kind: "invalid_kind", amount: { kind: number, }, } | { kind: "missing_listing_id", } | { kind: "listing_event_not_found", amount: { listing_addr: string, }, } | { kind: "listing_event_fetch_failed", amount: { listing_addr: string, }, } | { kind: "parse_error", amount: { error: RadrootsListingParseError, }, } | { kind: "invalid_seller", } | { kind: "missing_farm_profile", } | { kind: "missing_farm_record", } | { kind: "missing_title", } | { kind: "missing_description", } | { kind: "missing_product_type", } | { kind: "missing_bins", } | { kind: "missing_primary_bin", } | { kind: "invalid_bin", } | { kind: "missing_price", } | { kind: "invalid_price", } | { kind: "missing_inventory", } | { kind: "invalid_inventory", } | { kind: "missing_availability", } | { kind: "missing_location", } | { kind: "missing_delivery_method", };
diff --git a/packages/trade-bindings/src/generated/types.ts b/packages/trade-bindings/src/generated/types.ts
@@ -10,6 +10,8 @@ import type {
RadrootsCoreUnit,
} from "@radroots/core-bindings";
import type {
+ RadrootsCommercialMessagePayload,
+ RadrootsCommercialMessageType,
RadrootsFarmRef,
RadrootsListing,
RadrootsListingAvailability,
@@ -19,13 +21,11 @@ import type {
RadrootsListingProduct,
RadrootsListingPublicLocation,
RadrootsNostrEventPtr,
+ RadrootsOrderEconomicLine,
+ RadrootsOrderItem,
+ RadrootsOrderStatus,
RadrootsPlotRef,
RadrootsResourceAreaRef,
- RadrootsTradeMessagePayload,
- RadrootsTradeMessageType,
- RadrootsTradeOrderEconomicLine,
- RadrootsTradeOrderItem,
- RadrootsTradeOrderStatus,
} from "@radroots/events-bindings";
export type RadrootsTradeFacetCount = { key: string, count: number, };
@@ -58,7 +58,7 @@ export type RadrootsTradeListingTotal = { price_amount: RadrootsCoreMoney, price
export type RadrootsTradeMarketplaceListingSummary = { listing_addr: string, seller_pubkey: string, farm_pubkey: string, farm_id: string, product_key: string, product_title: string, product_category: string, product_summary?: string | null, listing_status: RadrootsTradeListingMarketStatus, location_primary?: string | null, inventory_available?: RadrootsCoreDecimal | null, primary_bin_id: string, primary_bin_label?: string | null, primary_bin_total: RadrootsTradeListingTotal, order_count: number, open_order_count: number, terminal_order_count: number, };
-export type RadrootsTradeMarketplaceOrderSummary = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, status: RadrootsTradeOrderStatus, last_message_type: RadrootsTradeMessageType, item_count: number, total_bin_count: number, has_requested_discounts: boolean, last_reason?: string | null, };
+export type RadrootsTradeMarketplaceOrderSummary = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, status: RadrootsOrderStatus, last_message_type: RadrootsCommercialMessageType, item_count: number, total_bin_count: number, has_requested_discounts: boolean, last_reason?: string | null, };
export type RadrootsTradeModerationFlag = { code: string, severity: RadrootsTradeModerationSeverity, status: RadrootsTradeModerationStatus, source?: string | null, reason?: string | null, };
@@ -74,15 +74,15 @@ export type RadrootsTradeOrderBackofficeView = { order: RadrootsTradeOrderWorkfl
export type RadrootsTradeOrderFacets = { buyer_pubkeys: Array<RadrootsTradeFacetCount>, seller_pubkeys: Array<RadrootsTradeFacetCount>, listing_addrs: Array<RadrootsTradeFacetCount>, statuses: Array<RadrootsTradeFacetCount>, };
-export type RadrootsTradeOrderQuery = { listing_addr?: string | null, buyer_pubkey?: string | null, seller_pubkey?: string | null, status?: RadrootsTradeOrderStatus | null, };
+export type RadrootsTradeOrderQuery = { listing_addr?: string | null, buyer_pubkey?: string | null, seller_pubkey?: string | null, status?: RadrootsOrderStatus | null, };
export type RadrootsTradeOrderSort = { field: RadrootsTradeOrderSortField, direction: RadrootsTradeSortDirection, };
export type RadrootsTradeOrderSortField = "order_id" | "listing_addr" | "buyer_pubkey" | "seller_pubkey" | "status" | "last_message_type" | "total_bin_count";
-export type RadrootsTradeOrderWorkflowMessage = { event_id: string, actor_pubkey: string, counterparty_pubkey: string, listing_addr: string, order_id?: string | null, listing_event?: RadrootsNostrEventPtr | null, root_event_id?: string | null, prev_event_id?: string | null, payload: RadrootsTradeMessagePayload, };
+export type RadrootsTradeOrderWorkflowMessage = { event_id: string, actor_pubkey: string, counterparty_pubkey: string, listing_addr: string, order_id?: string | null, listing_event?: RadrootsNostrEventPtr | null, root_event_id?: string | null, prev_event_id?: string | null, payload: RadrootsCommercialMessagePayload, };
-export type RadrootsTradeOrderWorkflowProjection = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, items: Array<RadrootsTradeOrderItem>, requested_discounts?: Array<RadrootsTradeOrderEconomicLine> | null, status: RadrootsTradeOrderStatus, listing_snapshot?: RadrootsNostrEventPtr | null, root_event_id: string, last_event_id: string, last_discount_request?: RadrootsCoreDiscountValue | null, last_discount_offer?: RadrootsCoreDiscountValue | null, accepted_discount?: RadrootsCoreDiscountValue | null, last_reason?: string | null, last_discount_decline_reason?: string | null, question_count: number, answer_count: number, revision_count: number, discount_request_count: number, discount_offer_count: number, discount_accept_count: number, discount_decline_count: number, cancellation_count: number, last_message_type: RadrootsTradeMessageType, last_actor_pubkey: string, };
+export type RadrootsTradeOrderWorkflowProjection = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, items: Array<RadrootsOrderItem>, requested_discounts?: Array<RadrootsOrderEconomicLine> | null, status: RadrootsOrderStatus, listing_snapshot?: RadrootsNostrEventPtr | null, root_event_id: string, last_event_id: string, last_discount_request?: RadrootsCoreDiscountValue | null, last_discount_offer?: RadrootsCoreDiscountValue | null, accepted_discount?: RadrootsCoreDiscountValue | null, last_reason?: string | null, last_discount_decline_reason?: string | null, question_count: number, answer_count: number, revision_count: number, discount_request_count: number, discount_offer_count: number, discount_accept_count: number, discount_decline_count: number, cancellation_count: number, last_message_type: RadrootsCommercialMessageType, last_actor_pubkey: string, };
export type RadrootsTradeReviewPriority = "low" | "normal" | "high" | "critical";
diff --git a/tools/xtask/src/dto_roots.rs b/tools/xtask/src/dto_roots.rs
@@ -268,11 +268,11 @@ fn trade_import_options(mut options: DtoRegistryRenderOptions) -> DtoRegistryRen
"RadrootsNostrEventPtr",
"RadrootsPlotRef",
"RadrootsResourceAreaRef",
- "RadrootsTradeMessagePayload",
- "RadrootsTradeMessageType",
- "RadrootsTradeOrderEconomicLine",
- "RadrootsTradeOrderItem",
- "RadrootsTradeOrderStatus",
+ "RadrootsCommercialMessagePayload",
+ "RadrootsCommercialMessageType",
+ "RadrootsOrderEconomicLine",
+ "RadrootsOrderItem",
+ "RadrootsOrderStatus",
] {
options =
options.with_external_override(export_name, export_name, "@radroots/events-bindings");
@@ -370,10 +370,13 @@ mod tests {
"JobInputType",
"JobPaymentRequest",
"RadrootsAccountClaim",
- "RadrootsActiveTradeEnvelope",
- "RadrootsActiveTradeMessageType",
"RadrootsAppData",
"RadrootsComment",
+ "RadrootsCommercialDomain",
+ "RadrootsCommercialEnvelope",
+ "RadrootsCommercialMessagePayload",
+ "RadrootsCommercialMessageType",
+ "RadrootsCommercialTransportLane",
"RadrootsCoop",
"RadrootsCoopLocation",
"RadrootsCoopRef",
@@ -401,9 +404,11 @@ mod tests {
"RadrootsListing",
"RadrootsListingAvailability",
"RadrootsListingBin",
+ "RadrootsListingCancel",
"RadrootsListingDeliveryMethod",
"RadrootsListingImage",
"RadrootsListingImageSize",
+ "RadrootsListingParseError",
"RadrootsListingProduct",
"RadrootsListingProductTagKeys",
"RadrootsListingPublicLocation",
@@ -415,6 +420,35 @@ mod tests {
"RadrootsNostrEvent",
"RadrootsNostrEventPtr",
"RadrootsNostrEventRef",
+ "RadrootsOrderAnswer",
+ "RadrootsOrderCancellation",
+ "RadrootsOrderChange",
+ "RadrootsOrderDecision",
+ "RadrootsOrderDecisionOutcome",
+ "RadrootsOrderDiscountDecision",
+ "RadrootsOrderDiscountOffer",
+ "RadrootsOrderDiscountRequest",
+ "RadrootsOrderEconomicActor",
+ "RadrootsOrderEconomicEffect",
+ "RadrootsOrderEconomicItem",
+ "RadrootsOrderEconomicLine",
+ "RadrootsOrderEconomicLineKind",
+ "RadrootsOrderEconomicTotals",
+ "RadrootsOrderEconomics",
+ "RadrootsOrderEnvelope",
+ "RadrootsOrderEventType",
+ "RadrootsOrderInventoryCommitment",
+ "RadrootsOrderItem",
+ "RadrootsOrderPricingBasis",
+ "RadrootsOrderQuestion",
+ "RadrootsOrderRequest",
+ "RadrootsOrderResponse",
+ "RadrootsOrderRevision",
+ "RadrootsOrderRevisionDecision",
+ "RadrootsOrderRevisionOutcome",
+ "RadrootsOrderRevisionProposal",
+ "RadrootsOrderRevisionResponse",
+ "RadrootsOrderStatus",
"RadrootsPlot",
"RadrootsPlotLocation",
"RadrootsPlotRef",
@@ -429,43 +463,9 @@ mod tests {
"RadrootsResourceHarvestCap",
"RadrootsResourceHarvestProduct",
"RadrootsSeal",
- "RadrootsTradeAnswer",
- "RadrootsTradeDiscountDecision",
- "RadrootsTradeDiscountOffer",
- "RadrootsTradeDiscountRequest",
- "RadrootsTradeDomain",
- "RadrootsTradeEconomicActor",
- "RadrootsTradeEconomicEffect",
- "RadrootsTradeEconomicLineKind",
- "RadrootsTradeEnvelope",
- "RadrootsTradeInventoryCommitment",
- "RadrootsTradeListingCancel",
- "RadrootsTradeListingParseError",
"RadrootsTradeListingValidateRequest",
"RadrootsTradeListingValidateResult",
"RadrootsTradeListingValidationError",
- "RadrootsTradeMessagePayload",
- "RadrootsTradeMessageType",
- "RadrootsTradeOrderCancelled",
- "RadrootsTradeOrderChange",
- "RadrootsTradeOrderDecision",
- "RadrootsTradeOrderDecisionEvent",
- "RadrootsTradeOrderEconomicItem",
- "RadrootsTradeOrderEconomicLine",
- "RadrootsTradeOrderEconomicTotals",
- "RadrootsTradeOrderEconomics",
- "RadrootsTradeOrderItem",
- "RadrootsTradeOrderRequested",
- "RadrootsTradeOrderResponse",
- "RadrootsTradeOrderRevision",
- "RadrootsTradeOrderRevisionDecision",
- "RadrootsTradeOrderRevisionDecisionEvent",
- "RadrootsTradeOrderRevisionProposed",
- "RadrootsTradeOrderRevisionResponse",
- "RadrootsTradeOrderStatus",
- "RadrootsTradePricingBasis",
- "RadrootsTradeQuestion",
- "RadrootsTradeTransportLane",
];
const EVENTS_INDEXED_TYPE_INVENTORY: &[&str] = &[
"RadrootsEventsIndexedShardId",
@@ -643,8 +643,8 @@ mod tests {
for duplicate in [
"export type RadrootsListing = ",
"export type RadrootsFarmRef = ",
- "export type RadrootsTradeMessageType = ",
- "export type RadrootsTradeOrderStatus = ",
+ "export type RadrootsCommercialMessageType = ",
+ "export type RadrootsOrderStatus = ",
] {
assert!(!TRADE_BINDINGS_TYPES_TS.contains(duplicate));
}