Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove deprecated types #5

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/amplifier-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ mod client;
pub use client::*;
mod error;
pub use error::AmplifierApiError;
#[expect(deprecated, reason = "Deprecated types within the module")]
pub mod types;
pub use chrono;
64 changes: 0 additions & 64 deletions crates/amplifier-api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,6 @@ pub struct MessageExecutedEventMetadata {
pub child_message_ids: Option<Vec<MessageId>>,
}

/// DEPRECATED: Specialized metadata for `CannotExecuteMessageEvent`.
#[deprecated(
since = "0.2.0",
note = "please use `CannotExecuteMessageEventV2Metadata` instead"
)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, TypedBuilder)]
pub struct CannotExecuteMessageEventMetadata {
/// The initiator of the message
#[serde(rename = "fromAddress", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub from_address: Option<Address>,
/// timestamp of the event
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub timestamp: Option<DateTime<Utc>>,
}

/// Specialized metadata for `CannotExecuteMessageEventV2`.
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, TypedBuilder)]
pub struct CannotExecuteMessageEventV2Metadata {
Expand Down Expand Up @@ -365,25 +348,6 @@ pub struct MessageExecutedEvent {
pub cost: Token,
}

/// DEPRECATED: Represents a Cannot Execute Message Event.
#[deprecated(
since = "0.2.0",
note = "please use `CannotExecuteMessageEventV2` instead"
)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, TypedBuilder)]
pub struct CannotExecuteMessageEvent {
/// Event base
#[serde(flatten)]
pub base: EventBase<CannotExecuteMessageEventMetadata>,
/// task id
#[serde(rename = "taskItemID")]
pub task_item_id: TaskItemId,
/// failed executioin reason
pub reason: CannotExecuteMessageReason,
/// details of the error
pub details: String,
}

/// Represents the v2 of Cannot Execute Message Event.
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, TypedBuilder)]
pub struct CannotExecuteMessageEventV2 {
Expand Down Expand Up @@ -415,8 +379,6 @@ pub enum Event {
MessageApproved(MessageApprovedEvent),
/// message executed event
MessageExecuted(MessageExecutedEvent),
/// cannot execute message event
CannotExecuteMessage(CannotExecuteMessageEvent),
/// v2 of cannot execute message event
#[serde(rename = "CANNOT_EXECUTE_MESSAGE/V2")]
CannotExecuteMessageV2(CannotExecuteMessageEventV2),
Expand Down Expand Up @@ -1036,32 +998,6 @@ mod tests {
test_serialization(&type_in_rust, reference_json);
}

#[test]
fn test_cannot_execute_message_serialization() {
// Setup
let reference_json = to_string(&json!({
"type": "CANNOT_EXECUTE_MESSAGE",
"eventID": "event123",
"taskItemID": "550e8400-e29b-41d4-a716-446655440000",
"reason": "INSUFFICIENT_GAS",
"details": "Not enough gas to execute the message"
}))
.unwrap()
.into_bytes();

let type_in_rust = Event::CannotExecuteMessage(CannotExecuteMessageEvent {
base: EventBase {
event_id: TxEvent("event123".to_owned()),
meta: None,
},
task_item_id: TaskItemId("550e8400-e29b-41d4-a716-446655440000".parse().unwrap()),
reason: CannotExecuteMessageReason::InsufficientGas,
details: "Not enough gas to execute the message".to_owned(),
});

test_serialization(&type_in_rust, reference_json);
}

#[test]
fn can_deserialize_error() {
let reference_json = br#"{"error":"no matching operation was found"}"#;
Expand Down
Loading