From e7780613188656c9f9cf0acfa38c1491576bbb96 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 3 Oct 2025 11:55:54 +0200 Subject: [PATCH] Remove unused response structs commit-id:fcef8826 # Conflicts: # crates/sncast/src/response/declare.rs --- crates/sncast/src/response/declare.rs | 64 ++++----------------------- 1 file changed, 9 insertions(+), 55 deletions(-) diff --git a/crates/sncast/src/response/declare.rs b/crates/sncast/src/response/declare.rs index cbc77e5a55..011988d6c0 100644 --- a/crates/sncast/src/response/declare.rs +++ b/crates/sncast/src/response/declare.rs @@ -4,7 +4,7 @@ use crate::response::cast_message::SncastMessage; use anyhow::Error; use camino::Utf8PathBuf; use conversions::string::IntoHexStr; -use conversions::{padded_felt::PaddedFelt, serde::serialize::CairoSerialize}; +use conversions::{IntoConv, padded_felt::PaddedFelt, serde::serialize::CairoSerialize}; use foundry_ui::Message; use foundry_ui::styling; use indoc::formatdoc; @@ -12,7 +12,9 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use serde_json::json; use starknet::core::types::contract::{AbiConstructor, AbiEntry}; +use starknet_types_core::felt::Felt; use std::fmt::Write; + #[derive(Clone, Serialize, Deserialize, CairoSerialize, Debug, PartialEq)] pub struct DeclareTransactionResponse { pub class_hash: PaddedFelt, @@ -53,31 +55,6 @@ pub struct AlreadyDeclaredResponse { pub class_hash: PaddedFelt, } -impl CommandResponse for AlreadyDeclaredResponse {} - -impl Message for SncastMessage { - fn text(&self) -> String { - styling::OutputBuilder::new() - .success_message("Contract class already declared") - .blank_line() - .field( - "Class Hash", - &self.command_response.class_hash.into_hex_string(), - ) - .build() - } - - fn json(&self) -> Value { - serde_json::to_value(&self.command_response).unwrap_or_else(|err| { - json!({ - "error": "Failed to serialize response", - "command": self.command, - "details": err.to_string() - }) - }) - } -} - #[derive(Clone, Serialize, Deserialize, CairoSerialize, Debug, PartialEq)] #[serde(tag = "status")] pub enum DeclareResponse { @@ -86,37 +63,14 @@ pub enum DeclareResponse { Success(DeclareTransactionResponse), } -impl CommandResponse for DeclareResponse {} - -impl Message for SncastMessage { - fn text(&self) -> String { - match &self.command_response { - DeclareResponse::AlreadyDeclared(response) => styling::OutputBuilder::new() - .success_message("Contract class already declared") - .blank_line() - .field("Class Hash", &response.class_hash.into_hex_string()) - .build(), - DeclareResponse::Success(response) => styling::OutputBuilder::new() - .success_message("Declaration completed") - .blank_line() - .field("Class Hash", &response.class_hash.into_hex_string()) - .field( - "Transaction Hash", - &response.transaction_hash.into_hex_string(), - ) - .build(), +impl DeclareResponse { + #[must_use] + pub fn class_hash(&self) -> Felt { + match self { + DeclareResponse::AlreadyDeclared(response) => response.class_hash.into_(), + DeclareResponse::Success(response) => response.class_hash.into_(), } } - - fn json(&self) -> Value { - serde_json::to_value(&self.command_response).unwrap_or_else(|err| { - json!({ - "error": "Failed to serialize response", - "command": self.command, - "details": err.to_string() - }) - }) - } } impl OutputLink for DeclareTransactionResponse {