Skip to content

Commit d741469

Browse files
committed
Remove unused response structs
commit-id:fcef8826
1 parent 6a7fed0 commit d741469

File tree

1 file changed

+11
-53
lines changed

1 file changed

+11
-53
lines changed

crates/sncast/src/response/declare.rs

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ use super::{command::CommandResponse, explorer_link::OutputLink};
22
use crate::helpers::block_explorer::LinkProvider;
33
use crate::response::cast_message::SncastMessage;
44
use conversions::string::IntoHexStr;
5-
use conversions::{padded_felt::PaddedFelt, serde::serialize::CairoSerialize};
5+
use conversions::{IntoConv, padded_felt::PaddedFelt, serde::serialize::CairoSerialize};
66
use foundry_ui::Message;
77
use foundry_ui::styling;
88
use indoc::formatdoc;
99
use serde::{Deserialize, Serialize};
1010
use serde_json::Value;
1111
use serde_json::json;
12+
use starknet_types_core::felt::Felt;
13+
1214
#[derive(Clone, Serialize, Deserialize, CairoSerialize, Debug, PartialEq)]
1315
pub struct DeclareTransactionResponse {
1416
pub class_hash: PaddedFelt,
@@ -51,29 +53,6 @@ pub struct AlreadyDeclaredResponse {
5153

5254
impl CommandResponse for AlreadyDeclaredResponse {}
5355

54-
impl Message for SncastMessage<AlreadyDeclaredResponse> {
55-
fn text(&self) -> String {
56-
styling::OutputBuilder::new()
57-
.success_message("Contract class already declared")
58-
.blank_line()
59-
.field(
60-
"Class Hash",
61-
&self.command_response.class_hash.into_hex_string(),
62-
)
63-
.build()
64-
}
65-
66-
fn json(&self) -> Value {
67-
serde_json::to_value(&self.command_response).unwrap_or_else(|err| {
68-
json!({
69-
"error": "Failed to serialize response",
70-
"command": self.command,
71-
"details": err.to_string()
72-
})
73-
})
74-
}
75-
}
76-
7756
#[derive(Clone, Serialize, Deserialize, CairoSerialize, Debug, PartialEq)]
7857
#[serde(tag = "status")]
7958
pub enum DeclareResponse {
@@ -82,39 +61,18 @@ pub enum DeclareResponse {
8261
Success(DeclareTransactionResponse),
8362
}
8463

85-
impl CommandResponse for DeclareResponse {}
86-
87-
impl Message for SncastMessage<DeclareResponse> {
88-
fn text(&self) -> String {
89-
match &self.command_response {
90-
DeclareResponse::AlreadyDeclared(response) => styling::OutputBuilder::new()
91-
.success_message("Contract class already declared")
92-
.blank_line()
93-
.field("Class Hash", &response.class_hash.into_hex_string())
94-
.build(),
95-
DeclareResponse::Success(response) => styling::OutputBuilder::new()
96-
.success_message("Declaration completed")
97-
.blank_line()
98-
.field("Class Hash", &response.class_hash.into_hex_string())
99-
.field(
100-
"Transaction Hash",
101-
&response.transaction_hash.into_hex_string(),
102-
)
103-
.build(),
64+
impl DeclareResponse {
65+
#[must_use]
66+
pub fn class_hash(&self) -> Felt {
67+
match self {
68+
DeclareResponse::AlreadyDeclared(response) => response.class_hash.into_(),
69+
DeclareResponse::Success(response) => response.class_hash.into_(),
10470
}
10571
}
106-
107-
fn json(&self) -> Value {
108-
serde_json::to_value(&self.command_response).unwrap_or_else(|err| {
109-
json!({
110-
"error": "Failed to serialize response",
111-
"command": self.command,
112-
"details": err.to_string()
113-
})
114-
})
115-
}
11672
}
11773

74+
impl CommandResponse for DeclareResponse {}
75+
11876
impl OutputLink for DeclareTransactionResponse {
11977
const TITLE: &'static str = "declaration";
12078

0 commit comments

Comments
 (0)