@@ -5,10 +5,10 @@ use core::fmt::{Debug, Display, Error, Formatter};
5
5
6
6
#[derive(Drop , PartialEq , Serde , Debug )]
7
7
pub struct ErrorData {
8
- msg : ByteArray
8
+ revert_error : ContractExecutionError
9
9
}
10
10
11
- #[derive(Drop , PartialEq )]
11
+ #[derive(Drop , PartialEq , Debug )]
12
12
pub struct TransactionExecutionErrorData {
13
13
pub transaction_index : felt252 ,
14
14
pub execution_error : ContractExecutionError ,
@@ -27,13 +27,15 @@ impl TransactionExecutionErrorDataSerde of Serde<TransactionExecutionErrorData>
27
27
}
28
28
29
29
30
- #[derive(Drop , PartialEq , Copy )]
30
+ // TODO(#3120): We should implement displaying message variant as deserialized byte array.
31
+ // ATM, it's dispplayed as a serialized one.
32
+ #[derive(Drop , PartialEq , Copy , Debug )]
31
33
pub enum ContractExecutionError {
32
34
Nested : Box <ContractExecutionErrorInner >,
33
35
Message : Span <felt252 >,
34
36
}
35
37
36
- #[derive(Drop , Serde , Copy )]
38
+ #[derive(Drop , Serde , Copy , Debug )]
37
39
pub struct ContractExecutionErrorInner {
38
40
contract_address : ContractAddress ,
39
41
class_hash : felt252 ,
@@ -62,7 +64,6 @@ impl ContractExecutionErrorSerde of Serde<ContractExecutionError> {
62
64
},
63
65
ContractExecutionError :: Message (msg ) => {
64
66
output . append (1 );
65
- // output.append_span(msg);
66
67
msg . serialize (ref output );
67
68
}
68
69
}
@@ -85,15 +86,12 @@ impl BoxContractExecutionErrorSerde of Serde<Box<ContractExecutionError>> {
85
86
match (* self ). unbox () {
86
87
ContractExecutionError :: Nested (inner ) => {
87
88
let inner = inner . unbox ();
88
- // output.append(0);
89
- // inner.serialize(ref output);
90
89
inner . serialize (ref output );
91
90
},
92
91
ContractExecutionError :: Message (msg ) => {
93
- for each in msg {
94
- output . append (* each );
95
- } // output.append(1);
96
- // msg.serialize(ref output);
92
+ for byte_array_element in msg {
93
+ output . append (* byte_array_element );
94
+ }
97
95
}
98
96
}
99
97
}
@@ -102,77 +100,6 @@ impl BoxContractExecutionErrorSerde of Serde<Box<ContractExecutionError>> {
102
100
}
103
101
}
104
102
105
- fn span_to_array (span : Span <felt252 >) -> Array :: <felt252 > {
106
- let mut result = array! [];
107
- for each in span {
108
- result . append (* each );
109
- };
110
- result
111
- }
112
-
113
- pub impl DisplayTransactionExecutionErrorData of Display <TransactionExecutionErrorData > {
114
- fn fmt (self : @ TransactionExecutionErrorData , ref f : Formatter ) -> Result <(), Error > {
115
- write! (
116
- f ,
117
- " Transaction execution has failed: transaction_index: {}, execution_error: {}" ,
118
- self . transaction_index,
119
- self . execution_error
120
- )
121
- }
122
- }
123
-
124
- pub impl DisplayContractExecutionError of Display <ContractExecutionError > {
125
- fn fmt (self : @ ContractExecutionError , ref f : Formatter ) -> Result <(), Error > {
126
- match self {
127
- ContractExecutionError :: Nested (inner ) => {
128
- let inner = (* inner ). unbox ();
129
- write! (
130
- f ,
131
- " Error in contract (contract address: {}, class hash: {}, selector:
132
- {}):\ n {}" ,
133
- inner . contract_address,
134
- inner . class_hash,
135
- inner . selector,
136
- inner . error
137
- )
138
- },
139
- ContractExecutionError :: Message (msg ) => { write! (f , " Message({:?})" , * msg ) }
140
- }
141
- }
142
- }
143
-
144
- pub impl DisplayContractExecutionErrorInner of Display <ContractExecutionErrorInner > {
145
- fn fmt (self : @ ContractExecutionErrorInner , ref f : Formatter ) -> Result <(), Error > {
146
- write! (
147
- f ,
148
- " Error in contract (contract_address: {}, class_hash: {}, selector: {}, error:
149
- {}):\ n" ,
150
- self . contract_address,
151
- self . class_hash,
152
- self . selector,
153
- self . error
154
- )
155
- }
156
- }
157
-
158
- pub impl DebugTransactionExecutionErrorData of Debug <TransactionExecutionErrorData > {
159
- fn fmt (self : @ TransactionExecutionErrorData , ref f : Formatter ) -> Result <(), Error > {
160
- Display :: fmt (self , ref f )
161
- }
162
- }
163
-
164
- pub impl DebugContractExecutionError of Debug <ContractExecutionError > {
165
- fn fmt (self : @ ContractExecutionError , ref f : Formatter ) -> Result <(), Error > {
166
- Display :: fmt (self , ref f )
167
- }
168
- }
169
-
170
- pub impl DebugContractExecutionErrorInner of Debug <ContractExecutionErrorInner > {
171
- fn fmt (self : @ ContractExecutionErrorInner , ref f : Formatter ) -> Result <(), Error > {
172
- Display :: fmt (self , ref f )
173
- }
174
- }
175
-
176
103
#[derive(Drop , Serde , PartialEq , Debug )]
177
104
pub enum StarknetError {
178
105
/// Failed to receive transaction
@@ -499,22 +426,6 @@ pub fn invoke(
499
426
fee_settings : FeeSettings ,
500
427
nonce : Option <felt252 >
501
428
) -> Result <InvokeResult , ScriptCommandError > {
502
- // let mut raw = array![
503
- // 4660.into(),
504
- // 0.into(),
505
- // 291.into(),
506
- // 2271560481.into(),
507
- // 4660.into(),
508
- // 1.into(),
509
- // 1,
510
- // 184477651815859881857708426232370721322670788429034947509639899811272418401,
511
- // 3265566911520157363207237164170485900701757214916046435088312658391615,
512
- // 29
513
- // ];
514
- // let mut span = raw.span();
515
- // let deserialized = Serde::<TransactionExecutionErrorData>::deserialize(ref span).unwrap();
516
- // println!("deserialized: {:?}", deserialized);
517
-
518
429
let contract_address_felt : felt252 = contract_address . into ();
519
430
let mut inputs = array! [contract_address_felt , entry_point_selector ];
520
431
0 commit comments