commit a778f2d58f4f05c09d281e43d25eaf64eb774421
parent 956fa20f4f050816f0a798b39882a59772b6bd8c
Author: triesap <tyson@radroots.org>
Date: Mon, 6 Jul 2026 08:40:33 +0000
runtime: align SDK drafts with strict contracts
- Add the generic root event tag required by frozen order lifecycle drafts.
- Collapse transition proof request indexing to one contract-valid service input.
- Replace an invalid workflow freeze fixture with a canonical SDK draft.
- Keep all-features SDK runtime validation green against strict lib contracts.
Diffstat:
4 files changed, 47 insertions(+), 53 deletions(-)
diff --git a/crates/sdk/src/dvm_runtime.rs b/crates/sdk/src/dvm_runtime.rs
@@ -568,18 +568,6 @@ fn dvm_trade_transition_proof_plan(
vec!["p".to_owned(), request.worker_pubkey.as_str().to_owned()],
vec![
"i".to_owned(),
- request.listing_event_id.as_str().to_owned(),
- "event".to_owned(),
- "radroots:listing_event".to_owned(),
- ],
- vec![
- "i".to_owned(),
- request.request_event_id.as_str().to_owned(),
- "event".to_owned(),
- "radroots:order_request_event".to_owned(),
- ],
- vec![
- "i".to_owned(),
request.decision_event_id.as_str().to_owned(),
"event".to_owned(),
"radroots:order_decision_event".to_owned(),
diff --git a/crates/sdk/src/order.rs b/crates/sdk/src/order.rs
@@ -5,7 +5,7 @@ pub use radroots_events_codec::order::RadrootsOrderEnvelopeParseError;
use radroots_events::RadrootsNostrEvent;
#[cfg(any(feature = "signer-adapters", test))]
-use radroots_events::{RadrootsNostrEventPtr, ids::RadrootsEventId};
+use radroots_events::{RadrootsNostrEventPtr, ids::RadrootsEventId, tags::TAG_E};
#[cfg(any(feature = "signer-adapters", test))]
use radroots_events_codec::wire::WireEventParts;
@@ -75,6 +75,17 @@ impl RadrootsOrderCancellationDraft {
}
#[cfg(any(feature = "signer-adapters", test))]
+fn with_contract_root_event_tag(
+ mut parts: WireEventParts,
+ root_event_id: &RadrootsEventId,
+) -> WireEventParts {
+ parts
+ .tags
+ .push(vec![TAG_E.to_owned(), root_event_id.as_str().to_owned()]);
+ parts
+}
+
+#[cfg(any(feature = "signer-adapters", test))]
pub fn build_order_request_draft(
listing_event: &RadrootsNostrEventPtr,
payload: &RadrootsOrderRequest,
@@ -91,11 +102,14 @@ pub fn build_order_decision_draft(
payload: &RadrootsOrderDecision,
) -> Result<RadrootsOrderDecisionDraft, EventEncodeError> {
Ok(RadrootsOrderDecisionDraft {
- parts: radroots_events_codec::order::order_decision_event_build(
+ parts: with_contract_root_event_tag(
+ radroots_events_codec::order::order_decision_event_build(
+ root_event_id,
+ prev_event_id,
+ payload,
+ )?,
root_event_id,
- prev_event_id,
- payload,
- )?,
+ ),
})
}
@@ -106,11 +120,14 @@ pub fn build_order_revision_proposal_draft(
payload: &RadrootsOrderRevisionProposal,
) -> Result<RadrootsOrderRevisionProposalDraft, EventEncodeError> {
Ok(RadrootsOrderRevisionProposalDraft {
- parts: radroots_events_codec::order::order_revision_proposal_event_build(
+ parts: with_contract_root_event_tag(
+ radroots_events_codec::order::order_revision_proposal_event_build(
+ root_event_id,
+ prev_event_id,
+ payload,
+ )?,
root_event_id,
- prev_event_id,
- payload,
- )?,
+ ),
})
}
@@ -121,11 +138,14 @@ pub fn build_order_revision_decision_draft(
payload: &RadrootsOrderRevisionDecision,
) -> Result<RadrootsOrderRevisionDecisionDraft, EventEncodeError> {
Ok(RadrootsOrderRevisionDecisionDraft {
- parts: radroots_events_codec::order::order_revision_decision_event_build(
+ parts: with_contract_root_event_tag(
+ radroots_events_codec::order::order_revision_decision_event_build(
+ root_event_id,
+ prev_event_id,
+ payload,
+ )?,
root_event_id,
- prev_event_id,
- payload,
- )?,
+ ),
})
}
@@ -136,11 +156,14 @@ pub fn build_order_cancellation_draft(
payload: &RadrootsOrderCancellation,
) -> Result<RadrootsOrderCancellationDraft, EventEncodeError> {
Ok(RadrootsOrderCancellationDraft {
- parts: radroots_events_codec::order::order_cancellation_event_build(
+ parts: with_contract_root_event_tag(
+ radroots_events_codec::order::order_cancellation_event_build(
+ root_event_id,
+ prev_event_id,
+ payload,
+ )?,
root_event_id,
- prev_event_id,
- payload,
- )?,
+ ),
})
}
diff --git a/crates/sdk/tests/unit/dvm_runtime_tests.rs b/crates/sdk/tests/unit/dvm_runtime_tests.rs
@@ -62,30 +62,12 @@ fn trade_transition_proof_plan_builds_microstandard_wire_payload() {
plan.frozen_draft.tags[1],
vec![
"i",
- event_id('1').as_str(),
- "event",
- "radroots:listing_event"
- ]
- );
- assert_eq!(
- plan.frozen_draft.tags[2],
- vec![
- "i",
- event_id('2').as_str(),
- "event",
- "radroots:order_request_event"
- ]
- );
- assert_eq!(
- plan.frozen_draft.tags[3],
- vec![
- "i",
event_id('3').as_str(),
"event",
"radroots:order_decision_event"
]
);
- assert_eq!(plan.frozen_draft.tags[4], vec!["p", WORKER]);
+ assert_eq!(plan.frozen_draft.tags[2], vec!["p", WORKER]);
}
#[test]
diff --git a/crates/sdk/tests/unit/orders_runtime_tests.rs b/crates/sdk/tests/unit/orders_runtime_tests.rs
@@ -996,12 +996,13 @@ fn workflow_plan_builders_cover_success_and_actor_mismatch_paths() {
.expect("validation error");
assert!(invalid_request_message(validation_error).contains("payload is invalid"));
+ let valid_submit_draft = order::build_order_request_draft(
+ &ptr(event_id('d').as_str().to_owned()),
+ &order_request_payload(),
+ )
+ .expect("valid submit draft");
let (frozen_draft, expected_event_id) = freeze_order_workflow_draft(
- WireEventParts {
- kind: KIND_ORDER_REQUEST,
- content: "{}".to_owned(),
- tags: vec![vec!["p".to_owned(), pubkey('c').as_str().to_owned()]],
- },
+ valid_submit_draft.into_wire_parts(),
TRADE_SUBMIT_CONTRACT_ID,
pubkey('c').as_str(),
1_700_000_000,