@@ -4,15 +4,17 @@ use crate::response::cast_message::SncastMessage;
4
4
use anyhow:: Error ;
5
5
use camino:: Utf8PathBuf ;
6
6
use conversions:: string:: IntoHexStr ;
7
- use conversions:: { padded_felt:: PaddedFelt , serde:: serialize:: CairoSerialize } ;
7
+ use conversions:: { IntoConv , padded_felt:: PaddedFelt , serde:: serialize:: CairoSerialize } ;
8
8
use foundry_ui:: Message ;
9
9
use foundry_ui:: styling;
10
10
use indoc:: formatdoc;
11
11
use serde:: { Deserialize , Serialize } ;
12
12
use serde_json:: Value ;
13
13
use serde_json:: json;
14
14
use starknet:: core:: types:: contract:: { AbiConstructor , AbiEntry } ;
15
+ use starknet_types_core:: felt:: Felt ;
15
16
use std:: fmt:: Write ;
17
+
16
18
#[ derive( Clone , Serialize , Deserialize , CairoSerialize , Debug , PartialEq ) ]
17
19
pub struct DeclareTransactionResponse {
18
20
pub class_hash : PaddedFelt ,
@@ -53,31 +55,6 @@ pub struct AlreadyDeclaredResponse {
53
55
pub class_hash : PaddedFelt ,
54
56
}
55
57
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
-
81
58
#[ derive( Clone , Serialize , Deserialize , CairoSerialize , Debug , PartialEq ) ]
82
59
#[ serde( tag = "status" ) ]
83
60
pub enum DeclareResponse {
@@ -86,37 +63,14 @@ pub enum DeclareResponse {
86
63
Success ( DeclareTransactionResponse ) ,
87
64
}
88
65
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_ ( ) ,
108
72
}
109
73
}
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
- }
120
74
}
121
75
122
76
impl OutputLink for DeclareTransactionResponse {
0 commit comments