@@ -2,13 +2,15 @@ use super::{command::CommandResponse, explorer_link::OutputLink};
2
2
use crate :: helpers:: block_explorer:: LinkProvider ;
3
3
use crate :: response:: cast_message:: SncastMessage ;
4
4
use conversions:: string:: IntoHexStr ;
5
- use conversions:: { padded_felt:: PaddedFelt , serde:: serialize:: CairoSerialize } ;
5
+ use conversions:: { IntoConv , padded_felt:: PaddedFelt , serde:: serialize:: CairoSerialize } ;
6
6
use foundry_ui:: Message ;
7
7
use foundry_ui:: styling;
8
8
use indoc:: formatdoc;
9
9
use serde:: { Deserialize , Serialize } ;
10
10
use serde_json:: Value ;
11
11
use serde_json:: json;
12
+ use starknet_types_core:: felt:: Felt ;
13
+
12
14
#[ derive( Clone , Serialize , Deserialize , CairoSerialize , Debug , PartialEq ) ]
13
15
pub struct DeclareTransactionResponse {
14
16
pub class_hash : PaddedFelt ,
@@ -51,29 +53,6 @@ pub struct AlreadyDeclaredResponse {
51
53
52
54
impl CommandResponse for AlreadyDeclaredResponse { }
53
55
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
-
77
56
#[ derive( Clone , Serialize , Deserialize , CairoSerialize , Debug , PartialEq ) ]
78
57
#[ serde( tag = "status" ) ]
79
58
pub enum DeclareResponse {
@@ -82,39 +61,18 @@ pub enum DeclareResponse {
82
61
Success ( DeclareTransactionResponse ) ,
83
62
}
84
63
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_ ( ) ,
104
70
}
105
71
}
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
- }
116
72
}
117
73
74
+ impl CommandResponse for DeclareResponse { }
75
+
118
76
impl OutputLink for DeclareTransactionResponse {
119
77
const TITLE : & ' static str = "declaration" ;
120
78
0 commit comments