Skip to content

Commit e778061

Browse files
committed
Remove unused response structs
commit-id:fcef8826 # Conflicts: # crates/sncast/src/response/declare.rs
1 parent 083097f commit e778061

File tree

1 file changed

+9
-55
lines changed

1 file changed

+9
-55
lines changed

crates/sncast/src/response/declare.rs

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ use crate::response::cast_message::SncastMessage;
44
use anyhow::Error;
55
use camino::Utf8PathBuf;
66
use conversions::string::IntoHexStr;
7-
use conversions::{padded_felt::PaddedFelt, serde::serialize::CairoSerialize};
7+
use conversions::{IntoConv, padded_felt::PaddedFelt, serde::serialize::CairoSerialize};
88
use foundry_ui::Message;
99
use foundry_ui::styling;
1010
use indoc::formatdoc;
1111
use serde::{Deserialize, Serialize};
1212
use serde_json::Value;
1313
use serde_json::json;
1414
use starknet::core::types::contract::{AbiConstructor, AbiEntry};
15+
use starknet_types_core::felt::Felt;
1516
use std::fmt::Write;
17+
1618
#[derive(Clone, Serialize, Deserialize, CairoSerialize, Debug, PartialEq)]
1719
pub struct DeclareTransactionResponse {
1820
pub class_hash: PaddedFelt,
@@ -53,31 +55,6 @@ pub struct AlreadyDeclaredResponse {
5355
pub class_hash: PaddedFelt,
5456
}
5557

56-
impl CommandResponse for AlreadyDeclaredResponse {}
57-
58-
impl Message for SncastMessage<AlreadyDeclaredResponse> {
59-
fn text(&self) -> String {
60-
styling::OutputBuilder::new()
61-
.success_message("Contract class already declared")
62-
.blank_line()
63-
.field(
64-
"Class Hash",
65-
&self.command_response.class_hash.into_hex_string(),
66-
)
67-
.build()
68-
}
69-
70-
fn json(&self) -> Value {
71-
serde_json::to_value(&self.command_response).unwrap_or_else(|err| {
72-
json!({
73-
"error": "Failed to serialize response",
74-
"command": self.command,
75-
"details": err.to_string()
76-
})
77-
})
78-
}
79-
}
80-
8158
#[derive(Clone, Serialize, Deserialize, CairoSerialize, Debug, PartialEq)]
8259
#[serde(tag = "status")]
8360
pub enum DeclareResponse {
@@ -86,37 +63,14 @@ pub enum DeclareResponse {
8663
Success(DeclareTransactionResponse),
8764
}
8865

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

12276
impl OutputLink for DeclareTransactionResponse {

0 commit comments

Comments
 (0)