1#![allow(non_camel_case_types)]
5use crate::error::definitions::APICode;
6use crate::error::definitions::AnvilEnvironment;
7use crate::error::definitions::AnvilEnvironmentCode;
8use crate::error::definitions::AnvilGeneric;
9use crate::error::definitions::AnvilGenericCode;
10use crate::error::definitions::AnvilNode;
11use crate::error::definitions::AnvilNodeCode;
12use crate::error::definitions::EraVM;
13use crate::error::definitions::EraVMCode;
14use crate::error::definitions::ExecutionPlatform;
15use crate::error::definitions::ExecutionPlatformCode;
16use crate::error::definitions::FoundryUpstream;
17use crate::error::definitions::FoundryUpstreamCode;
18use crate::error::definitions::FoundryZksync;
19use crate::error::definitions::FoundryZksyncCode;
20use crate::error::definitions::GasEstimation;
21use crate::error::definitions::GasEstimationCode;
22use crate::error::definitions::Halt;
23use crate::error::definitions::HaltCode;
24use crate::error::definitions::HardhatUpstream;
25use crate::error::definitions::HardhatUpstreamCode;
26use crate::error::definitions::HardhatZksync;
27use crate::error::definitions::HardhatZksyncCode;
28use crate::error::definitions::LLVM_EVMCode;
29use crate::error::definitions::LLVM_Era;
30use crate::error::definitions::LLVM_EraCode;
31use crate::error::definitions::Revert;
32use crate::error::definitions::RevertCode;
33use crate::error::definitions::Sequencer;
34use crate::error::definitions::SequencerCode;
35use crate::error::definitions::Solc;
36use crate::error::definitions::SolcCode;
37use crate::error::definitions::SolcFork;
38use crate::error::definitions::SolcForkCode;
39use crate::error::definitions::StateLoader;
40use crate::error::definitions::StateLoaderCode;
41use crate::error::definitions::TransactionValidation;
42use crate::error::definitions::TransactionValidationCode;
43use crate::error::definitions::Zksolc;
44use crate::error::definitions::ZksolcCode;
45use crate::error::definitions::Zkvyper;
46use crate::error::definitions::ZkvyperCode;
47use crate::error::definitions::API;
48use crate::error::definitions::LLVM_EVM;
49use crate::error::ICustomError;
50use crate::error::IUnifiedError;
51use crate::kind::Kind;
52use strum_macros::AsRefStr;
53use strum_macros::EnumDiscriminants;
54use strum_macros::FromRepr;
55#[repr(u32)]
56#[derive(
57 AsRefStr,
58 Clone,
59 Debug,
60 EnumDiscriminants,
61 Eq,
62 PartialEq,
63 serde :: Serialize,
64 serde :: Deserialize,
65)]
66pub enum ZksyncError {
67 AnvilZksync(AnvilZksync),
68 Compiler(Compiler),
69 Core(Core),
70 Foundry(Foundry),
71 Hardhat(Hardhat),
72}
73impl crate::documentation::Documented for ZksyncError {
74 type Documentation = &'static zksync_error_description::ErrorDocumentation;
75 fn get_documentation(
76 &self,
77 ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
78 match self {
79 ZksyncError::AnvilZksync(error) => error.get_documentation(),
80 ZksyncError::Compiler(error) => error.get_documentation(),
81 ZksyncError::Core(error) => error.get_documentation(),
82 ZksyncError::Foundry(error) => error.get_documentation(),
83 ZksyncError::Hardhat(error) => error.get_documentation(),
84 }
85 }
86}
87impl std::fmt::Display for ZksyncError {
88 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
89 match self {
90 ZksyncError::AnvilZksync(domain_error) => domain_error.fmt(f),
91 ZksyncError::Compiler(domain_error) => domain_error.fmt(f),
92 ZksyncError::Core(domain_error) => domain_error.fmt(f),
93 ZksyncError::Foundry(domain_error) => domain_error.fmt(f),
94 ZksyncError::Hardhat(domain_error) => domain_error.fmt(f),
95 }
96 }
97}
98impl ZksyncError {
99 pub fn get_kind(&self) -> crate::kind::Kind {
100 match self {
101 ZksyncError::AnvilZksync(AnvilZksync::AnvilEnvironment(_)) => {
102 Kind::AnvilZksync(AnvilZksyncCode::AnvilEnvironment)
103 }
104 ZksyncError::AnvilZksync(AnvilZksync::AnvilGeneric(_)) => {
105 Kind::AnvilZksync(AnvilZksyncCode::AnvilGeneric)
106 }
107 ZksyncError::AnvilZksync(AnvilZksync::AnvilNode(_)) => {
108 Kind::AnvilZksync(AnvilZksyncCode::AnvilNode)
109 }
110 ZksyncError::AnvilZksync(AnvilZksync::GasEstimation(_)) => {
111 Kind::AnvilZksync(AnvilZksyncCode::GasEstimation)
112 }
113 ZksyncError::AnvilZksync(AnvilZksync::Halt(_)) => {
114 Kind::AnvilZksync(AnvilZksyncCode::Halt)
115 }
116 ZksyncError::AnvilZksync(AnvilZksync::Revert(_)) => {
117 Kind::AnvilZksync(AnvilZksyncCode::Revert)
118 }
119 ZksyncError::AnvilZksync(AnvilZksync::StateLoader(_)) => {
120 Kind::AnvilZksync(AnvilZksyncCode::StateLoader)
121 }
122 ZksyncError::AnvilZksync(AnvilZksync::TransactionValidation(_)) => {
123 Kind::AnvilZksync(AnvilZksyncCode::TransactionValidation)
124 }
125 ZksyncError::Compiler(Compiler::LLVM_EVM(_)) => Kind::Compiler(CompilerCode::LLVM_EVM),
126 ZksyncError::Compiler(Compiler::LLVM_Era(_)) => Kind::Compiler(CompilerCode::LLVM_Era),
127 ZksyncError::Compiler(Compiler::Solc(_)) => Kind::Compiler(CompilerCode::Solc),
128 ZksyncError::Compiler(Compiler::SolcFork(_)) => Kind::Compiler(CompilerCode::SolcFork),
129 ZksyncError::Compiler(Compiler::Zksolc(_)) => Kind::Compiler(CompilerCode::Zksolc),
130 ZksyncError::Compiler(Compiler::Zkvyper(_)) => Kind::Compiler(CompilerCode::Zkvyper),
131 ZksyncError::Core(Core::API(_)) => Kind::Core(CoreCode::API),
132 ZksyncError::Core(Core::EraVM(_)) => Kind::Core(CoreCode::EraVM),
133 ZksyncError::Core(Core::ExecutionPlatform(_)) => {
134 Kind::Core(CoreCode::ExecutionPlatform)
135 }
136 ZksyncError::Core(Core::Sequencer(_)) => Kind::Core(CoreCode::Sequencer),
137 ZksyncError::Foundry(Foundry::FoundryUpstream(_)) => {
138 Kind::Foundry(FoundryCode::FoundryUpstream)
139 }
140 ZksyncError::Foundry(Foundry::FoundryZksync(_)) => {
141 Kind::Foundry(FoundryCode::FoundryZksync)
142 }
143 ZksyncError::Hardhat(Hardhat::HardhatUpstream(_)) => {
144 Kind::Hardhat(HardhatCode::HardhatUpstream)
145 }
146 ZksyncError::Hardhat(Hardhat::HardhatZksync(_)) => {
147 Kind::Hardhat(HardhatCode::HardhatZksync)
148 }
149 }
150 }
151 pub fn get_code(&self) -> u32 {
152 match self {
153 ZksyncError::AnvilZksync(AnvilZksync::AnvilEnvironment(error)) => {
154 Into::<AnvilEnvironmentCode>::into(error) as u32
155 }
156 ZksyncError::AnvilZksync(AnvilZksync::AnvilGeneric(error)) => {
157 Into::<AnvilGenericCode>::into(error) as u32
158 }
159 ZksyncError::AnvilZksync(AnvilZksync::AnvilNode(error)) => {
160 Into::<AnvilNodeCode>::into(error) as u32
161 }
162 ZksyncError::AnvilZksync(AnvilZksync::GasEstimation(error)) => {
163 Into::<GasEstimationCode>::into(error) as u32
164 }
165 ZksyncError::AnvilZksync(AnvilZksync::Halt(error)) => {
166 Into::<HaltCode>::into(error) as u32
167 }
168 ZksyncError::AnvilZksync(AnvilZksync::Revert(error)) => {
169 Into::<RevertCode>::into(error) as u32
170 }
171 ZksyncError::AnvilZksync(AnvilZksync::StateLoader(error)) => {
172 Into::<StateLoaderCode>::into(error) as u32
173 }
174 ZksyncError::AnvilZksync(AnvilZksync::TransactionValidation(error)) => {
175 Into::<TransactionValidationCode>::into(error) as u32
176 }
177 ZksyncError::Compiler(Compiler::LLVM_EVM(error)) => {
178 Into::<LLVM_EVMCode>::into(error) as u32
179 }
180 ZksyncError::Compiler(Compiler::LLVM_Era(error)) => {
181 Into::<LLVM_EraCode>::into(error) as u32
182 }
183 ZksyncError::Compiler(Compiler::Solc(error)) => Into::<SolcCode>::into(error) as u32,
184 ZksyncError::Compiler(Compiler::SolcFork(error)) => {
185 Into::<SolcForkCode>::into(error) as u32
186 }
187 ZksyncError::Compiler(Compiler::Zksolc(error)) => {
188 Into::<ZksolcCode>::into(error) as u32
189 }
190 ZksyncError::Compiler(Compiler::Zkvyper(error)) => {
191 Into::<ZkvyperCode>::into(error) as u32
192 }
193 ZksyncError::Core(Core::API(error)) => Into::<APICode>::into(error) as u32,
194 ZksyncError::Core(Core::EraVM(error)) => Into::<EraVMCode>::into(error) as u32,
195 ZksyncError::Core(Core::ExecutionPlatform(error)) => {
196 Into::<ExecutionPlatformCode>::into(error) as u32
197 }
198 ZksyncError::Core(Core::Sequencer(error)) => Into::<SequencerCode>::into(error) as u32,
199 ZksyncError::Foundry(Foundry::FoundryUpstream(error)) => {
200 Into::<FoundryUpstreamCode>::into(error) as u32
201 }
202 ZksyncError::Foundry(Foundry::FoundryZksync(error)) => {
203 Into::<FoundryZksyncCode>::into(error) as u32
204 }
205 ZksyncError::Hardhat(Hardhat::HardhatUpstream(error)) => {
206 Into::<HardhatUpstreamCode>::into(error) as u32
207 }
208 ZksyncError::Hardhat(Hardhat::HardhatZksync(error)) => {
209 Into::<HardhatZksyncCode>::into(error) as u32
210 }
211 }
212 }
213}
214impl IUnifiedError<ZksyncError> for ZksyncError {}
215impl std::error::Error for ZksyncError {}
216#[repr(u32)]
217#[derive(
218 AsRefStr,
219 Clone,
220 Debug,
221 EnumDiscriminants,
222 Eq,
223 PartialEq,
224 serde :: Serialize,
225 serde :: Deserialize,
226)]
227#[strum_discriminants(name(AnvilZksyncCode))]
228#[strum_discriminants(derive(serde::Serialize, serde::Deserialize, FromRepr))]
229#[strum_discriminants(vis(pub))]
230pub enum AnvilZksync {
231 AnvilEnvironment(AnvilEnvironment),
232 AnvilGeneric(AnvilGeneric),
233 AnvilNode(AnvilNode),
234 GasEstimation(GasEstimation),
235 Halt(Halt),
236 Revert(Revert),
237 StateLoader(StateLoader),
238 TransactionValidation(TransactionValidation),
239}
240impl AnvilZksync {
241 pub fn get_name(&self) -> &str {
242 self.as_ref()
243 }
244}
245impl ICustomError<ZksyncError, ZksyncError> for AnvilEnvironment {
246 fn to_unified(&self) -> ZksyncError {
247 AnvilZksync::AnvilEnvironment(self.clone()).to_unified()
248 }
249}
250impl From<AnvilEnvironment> for AnvilZksync {
251 fn from(val: AnvilEnvironment) -> Self {
252 AnvilZksync::AnvilEnvironment(val)
253 }
254}
255impl ICustomError<ZksyncError, ZksyncError> for AnvilGeneric {
256 fn to_unified(&self) -> ZksyncError {
257 AnvilZksync::AnvilGeneric(self.clone()).to_unified()
258 }
259}
260impl From<AnvilGeneric> for AnvilZksync {
261 fn from(val: AnvilGeneric) -> Self {
262 AnvilZksync::AnvilGeneric(val)
263 }
264}
265impl ICustomError<ZksyncError, ZksyncError> for AnvilNode {
266 fn to_unified(&self) -> ZksyncError {
267 AnvilZksync::AnvilNode(self.clone()).to_unified()
268 }
269}
270impl From<AnvilNode> for AnvilZksync {
271 fn from(val: AnvilNode) -> Self {
272 AnvilZksync::AnvilNode(val)
273 }
274}
275impl ICustomError<ZksyncError, ZksyncError> for GasEstimation {
276 fn to_unified(&self) -> ZksyncError {
277 AnvilZksync::GasEstimation(self.clone()).to_unified()
278 }
279}
280impl From<GasEstimation> for AnvilZksync {
281 fn from(val: GasEstimation) -> Self {
282 AnvilZksync::GasEstimation(val)
283 }
284}
285impl ICustomError<ZksyncError, ZksyncError> for Halt {
286 fn to_unified(&self) -> ZksyncError {
287 AnvilZksync::Halt(self.clone()).to_unified()
288 }
289}
290impl From<Halt> for AnvilZksync {
291 fn from(val: Halt) -> Self {
292 AnvilZksync::Halt(val)
293 }
294}
295impl ICustomError<ZksyncError, ZksyncError> for Revert {
296 fn to_unified(&self) -> ZksyncError {
297 AnvilZksync::Revert(self.clone()).to_unified()
298 }
299}
300impl From<Revert> for AnvilZksync {
301 fn from(val: Revert) -> Self {
302 AnvilZksync::Revert(val)
303 }
304}
305impl ICustomError<ZksyncError, ZksyncError> for StateLoader {
306 fn to_unified(&self) -> ZksyncError {
307 AnvilZksync::StateLoader(self.clone()).to_unified()
308 }
309}
310impl From<StateLoader> for AnvilZksync {
311 fn from(val: StateLoader) -> Self {
312 AnvilZksync::StateLoader(val)
313 }
314}
315impl ICustomError<ZksyncError, ZksyncError> for TransactionValidation {
316 fn to_unified(&self) -> ZksyncError {
317 AnvilZksync::TransactionValidation(self.clone()).to_unified()
318 }
319}
320impl From<TransactionValidation> for AnvilZksync {
321 fn from(val: TransactionValidation) -> Self {
322 AnvilZksync::TransactionValidation(val)
323 }
324}
325impl ICustomError<ZksyncError, ZksyncError> for AnvilZksync {
326 fn to_unified(&self) -> ZksyncError {
327 ZksyncError::AnvilZksync(self.clone())
328 }
329}
330impl From<AnvilZksync> for ZksyncError {
331 fn from(value: AnvilZksync) -> Self {
332 value.to_unified()
333 }
334}
335impl crate::documentation::Documented for AnvilZksync {
336 type Documentation = &'static zksync_error_description::ErrorDocumentation;
337 fn get_documentation(
338 &self,
339 ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
340 match self {
341 AnvilZksync::AnvilEnvironment(error) => error.get_documentation(),
342 AnvilZksync::AnvilGeneric(error) => error.get_documentation(),
343 AnvilZksync::AnvilNode(error) => error.get_documentation(),
344 AnvilZksync::GasEstimation(error) => error.get_documentation(),
345 AnvilZksync::Halt(error) => error.get_documentation(),
346 AnvilZksync::Revert(error) => error.get_documentation(),
347 AnvilZksync::StateLoader(error) => error.get_documentation(),
348 AnvilZksync::TransactionValidation(error) => error.get_documentation(),
349 }
350 }
351}
352impl std::fmt::Display for AnvilZksync {
353 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
354 match self {
355 AnvilZksync::AnvilEnvironment(component) => component.fmt(f),
356 AnvilZksync::AnvilGeneric(component) => component.fmt(f),
357 AnvilZksync::AnvilNode(component) => component.fmt(f),
358 AnvilZksync::GasEstimation(component) => component.fmt(f),
359 AnvilZksync::Halt(component) => component.fmt(f),
360 AnvilZksync::Revert(component) => component.fmt(f),
361 AnvilZksync::StateLoader(component) => component.fmt(f),
362 AnvilZksync::TransactionValidation(component) => component.fmt(f),
363 }
364 }
365}
366impl std::error::Error for AnvilZksync {}
367#[repr(u32)]
368#[derive(
369 AsRefStr,
370 Clone,
371 Debug,
372 EnumDiscriminants,
373 Eq,
374 PartialEq,
375 serde :: Serialize,
376 serde :: Deserialize,
377)]
378#[strum_discriminants(name(CompilerCode))]
379#[strum_discriminants(derive(serde::Serialize, serde::Deserialize, FromRepr))]
380#[strum_discriminants(vis(pub))]
381pub enum Compiler {
382 LLVM_EVM(LLVM_EVM),
383 LLVM_Era(LLVM_Era),
384 Solc(Solc),
385 SolcFork(SolcFork),
386 Zksolc(Zksolc),
387 Zkvyper(Zkvyper),
388}
389impl Compiler {
390 pub fn get_name(&self) -> &str {
391 self.as_ref()
392 }
393}
394impl ICustomError<ZksyncError, ZksyncError> for LLVM_EVM {
395 fn to_unified(&self) -> ZksyncError {
396 Compiler::LLVM_EVM(self.clone()).to_unified()
397 }
398}
399impl From<LLVM_EVM> for Compiler {
400 fn from(val: LLVM_EVM) -> Self {
401 Compiler::LLVM_EVM(val)
402 }
403}
404impl ICustomError<ZksyncError, ZksyncError> for LLVM_Era {
405 fn to_unified(&self) -> ZksyncError {
406 Compiler::LLVM_Era(self.clone()).to_unified()
407 }
408}
409impl From<LLVM_Era> for Compiler {
410 fn from(val: LLVM_Era) -> Self {
411 Compiler::LLVM_Era(val)
412 }
413}
414impl ICustomError<ZksyncError, ZksyncError> for Solc {
415 fn to_unified(&self) -> ZksyncError {
416 Compiler::Solc(self.clone()).to_unified()
417 }
418}
419impl From<Solc> for Compiler {
420 fn from(val: Solc) -> Self {
421 Compiler::Solc(val)
422 }
423}
424impl ICustomError<ZksyncError, ZksyncError> for SolcFork {
425 fn to_unified(&self) -> ZksyncError {
426 Compiler::SolcFork(self.clone()).to_unified()
427 }
428}
429impl From<SolcFork> for Compiler {
430 fn from(val: SolcFork) -> Self {
431 Compiler::SolcFork(val)
432 }
433}
434impl ICustomError<ZksyncError, ZksyncError> for Zksolc {
435 fn to_unified(&self) -> ZksyncError {
436 Compiler::Zksolc(self.clone()).to_unified()
437 }
438}
439impl From<Zksolc> for Compiler {
440 fn from(val: Zksolc) -> Self {
441 Compiler::Zksolc(val)
442 }
443}
444impl ICustomError<ZksyncError, ZksyncError> for Zkvyper {
445 fn to_unified(&self) -> ZksyncError {
446 Compiler::Zkvyper(self.clone()).to_unified()
447 }
448}
449impl From<Zkvyper> for Compiler {
450 fn from(val: Zkvyper) -> Self {
451 Compiler::Zkvyper(val)
452 }
453}
454impl ICustomError<ZksyncError, ZksyncError> for Compiler {
455 fn to_unified(&self) -> ZksyncError {
456 ZksyncError::Compiler(self.clone())
457 }
458}
459impl From<Compiler> for ZksyncError {
460 fn from(value: Compiler) -> Self {
461 value.to_unified()
462 }
463}
464impl crate::documentation::Documented for Compiler {
465 type Documentation = &'static zksync_error_description::ErrorDocumentation;
466 fn get_documentation(
467 &self,
468 ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
469 match self {
470 Compiler::LLVM_EVM(error) => error.get_documentation(),
471 Compiler::LLVM_Era(error) => error.get_documentation(),
472 Compiler::Solc(error) => error.get_documentation(),
473 Compiler::SolcFork(error) => error.get_documentation(),
474 Compiler::Zksolc(error) => error.get_documentation(),
475 Compiler::Zkvyper(error) => error.get_documentation(),
476 }
477 }
478}
479impl std::fmt::Display for Compiler {
480 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
481 match self {
482 Compiler::LLVM_EVM(component) => component.fmt(f),
483 Compiler::LLVM_Era(component) => component.fmt(f),
484 Compiler::Solc(component) => component.fmt(f),
485 Compiler::SolcFork(component) => component.fmt(f),
486 Compiler::Zksolc(component) => component.fmt(f),
487 Compiler::Zkvyper(component) => component.fmt(f),
488 }
489 }
490}
491impl std::error::Error for Compiler {}
492#[repr(u32)]
493#[derive(
494 AsRefStr,
495 Clone,
496 Debug,
497 EnumDiscriminants,
498 Eq,
499 PartialEq,
500 serde :: Serialize,
501 serde :: Deserialize,
502)]
503#[strum_discriminants(name(CoreCode))]
504#[strum_discriminants(derive(serde::Serialize, serde::Deserialize, FromRepr))]
505#[strum_discriminants(vis(pub))]
506pub enum Core {
507 API(API),
508 EraVM(EraVM),
509 ExecutionPlatform(ExecutionPlatform),
510 Sequencer(Sequencer),
511}
512impl Core {
513 pub fn get_name(&self) -> &str {
514 self.as_ref()
515 }
516}
517impl ICustomError<ZksyncError, ZksyncError> for API {
518 fn to_unified(&self) -> ZksyncError {
519 Core::API(self.clone()).to_unified()
520 }
521}
522impl From<API> for Core {
523 fn from(val: API) -> Self {
524 Core::API(val)
525 }
526}
527impl ICustomError<ZksyncError, ZksyncError> for EraVM {
528 fn to_unified(&self) -> ZksyncError {
529 Core::EraVM(self.clone()).to_unified()
530 }
531}
532impl From<EraVM> for Core {
533 fn from(val: EraVM) -> Self {
534 Core::EraVM(val)
535 }
536}
537impl ICustomError<ZksyncError, ZksyncError> for ExecutionPlatform {
538 fn to_unified(&self) -> ZksyncError {
539 Core::ExecutionPlatform(self.clone()).to_unified()
540 }
541}
542impl From<ExecutionPlatform> for Core {
543 fn from(val: ExecutionPlatform) -> Self {
544 Core::ExecutionPlatform(val)
545 }
546}
547impl ICustomError<ZksyncError, ZksyncError> for Sequencer {
548 fn to_unified(&self) -> ZksyncError {
549 Core::Sequencer(self.clone()).to_unified()
550 }
551}
552impl From<Sequencer> for Core {
553 fn from(val: Sequencer) -> Self {
554 Core::Sequencer(val)
555 }
556}
557impl ICustomError<ZksyncError, ZksyncError> for Core {
558 fn to_unified(&self) -> ZksyncError {
559 ZksyncError::Core(self.clone())
560 }
561}
562impl From<Core> for ZksyncError {
563 fn from(value: Core) -> Self {
564 value.to_unified()
565 }
566}
567impl crate::documentation::Documented for Core {
568 type Documentation = &'static zksync_error_description::ErrorDocumentation;
569 fn get_documentation(
570 &self,
571 ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
572 match self {
573 Core::API(error) => error.get_documentation(),
574 Core::EraVM(error) => error.get_documentation(),
575 Core::ExecutionPlatform(error) => error.get_documentation(),
576 Core::Sequencer(error) => error.get_documentation(),
577 }
578 }
579}
580impl std::fmt::Display for Core {
581 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
582 match self {
583 Core::API(component) => component.fmt(f),
584 Core::EraVM(component) => component.fmt(f),
585 Core::ExecutionPlatform(component) => component.fmt(f),
586 Core::Sequencer(component) => component.fmt(f),
587 }
588 }
589}
590impl std::error::Error for Core {}
591#[repr(u32)]
592#[derive(
593 AsRefStr,
594 Clone,
595 Debug,
596 EnumDiscriminants,
597 Eq,
598 PartialEq,
599 serde :: Serialize,
600 serde :: Deserialize,
601)]
602#[strum_discriminants(name(FoundryCode))]
603#[strum_discriminants(derive(serde::Serialize, serde::Deserialize, FromRepr))]
604#[strum_discriminants(vis(pub))]
605pub enum Foundry {
606 FoundryUpstream(FoundryUpstream),
607 FoundryZksync(FoundryZksync),
608}
609impl Foundry {
610 pub fn get_name(&self) -> &str {
611 self.as_ref()
612 }
613}
614impl ICustomError<ZksyncError, ZksyncError> for FoundryUpstream {
615 fn to_unified(&self) -> ZksyncError {
616 Foundry::FoundryUpstream(self.clone()).to_unified()
617 }
618}
619impl From<FoundryUpstream> for Foundry {
620 fn from(val: FoundryUpstream) -> Self {
621 Foundry::FoundryUpstream(val)
622 }
623}
624impl ICustomError<ZksyncError, ZksyncError> for FoundryZksync {
625 fn to_unified(&self) -> ZksyncError {
626 Foundry::FoundryZksync(self.clone()).to_unified()
627 }
628}
629impl From<FoundryZksync> for Foundry {
630 fn from(val: FoundryZksync) -> Self {
631 Foundry::FoundryZksync(val)
632 }
633}
634impl ICustomError<ZksyncError, ZksyncError> for Foundry {
635 fn to_unified(&self) -> ZksyncError {
636 ZksyncError::Foundry(self.clone())
637 }
638}
639impl From<Foundry> for ZksyncError {
640 fn from(value: Foundry) -> Self {
641 value.to_unified()
642 }
643}
644impl crate::documentation::Documented for Foundry {
645 type Documentation = &'static zksync_error_description::ErrorDocumentation;
646 fn get_documentation(
647 &self,
648 ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
649 match self {
650 Foundry::FoundryUpstream(error) => error.get_documentation(),
651 Foundry::FoundryZksync(error) => error.get_documentation(),
652 }
653 }
654}
655impl std::fmt::Display for Foundry {
656 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
657 match self {
658 Foundry::FoundryUpstream(component) => component.fmt(f),
659 Foundry::FoundryZksync(component) => component.fmt(f),
660 }
661 }
662}
663impl std::error::Error for Foundry {}
664#[repr(u32)]
665#[derive(
666 AsRefStr,
667 Clone,
668 Debug,
669 EnumDiscriminants,
670 Eq,
671 PartialEq,
672 serde :: Serialize,
673 serde :: Deserialize,
674)]
675#[strum_discriminants(name(HardhatCode))]
676#[strum_discriminants(derive(serde::Serialize, serde::Deserialize, FromRepr))]
677#[strum_discriminants(vis(pub))]
678pub enum Hardhat {
679 HardhatUpstream(HardhatUpstream),
680 HardhatZksync(HardhatZksync),
681}
682impl Hardhat {
683 pub fn get_name(&self) -> &str {
684 self.as_ref()
685 }
686}
687impl ICustomError<ZksyncError, ZksyncError> for HardhatUpstream {
688 fn to_unified(&self) -> ZksyncError {
689 Hardhat::HardhatUpstream(self.clone()).to_unified()
690 }
691}
692impl From<HardhatUpstream> for Hardhat {
693 fn from(val: HardhatUpstream) -> Self {
694 Hardhat::HardhatUpstream(val)
695 }
696}
697impl ICustomError<ZksyncError, ZksyncError> for HardhatZksync {
698 fn to_unified(&self) -> ZksyncError {
699 Hardhat::HardhatZksync(self.clone()).to_unified()
700 }
701}
702impl From<HardhatZksync> for Hardhat {
703 fn from(val: HardhatZksync) -> Self {
704 Hardhat::HardhatZksync(val)
705 }
706}
707impl ICustomError<ZksyncError, ZksyncError> for Hardhat {
708 fn to_unified(&self) -> ZksyncError {
709 ZksyncError::Hardhat(self.clone())
710 }
711}
712impl From<Hardhat> for ZksyncError {
713 fn from(value: Hardhat) -> Self {
714 value.to_unified()
715 }
716}
717impl crate::documentation::Documented for Hardhat {
718 type Documentation = &'static zksync_error_description::ErrorDocumentation;
719 fn get_documentation(
720 &self,
721 ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
722 match self {
723 Hardhat::HardhatUpstream(error) => error.get_documentation(),
724 Hardhat::HardhatZksync(error) => error.get_documentation(),
725 }
726 }
727}
728impl std::fmt::Display for Hardhat {
729 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
730 match self {
731 Hardhat::HardhatUpstream(component) => component.fmt(f),
732 Hardhat::HardhatZksync(component) => component.fmt(f),
733 }
734 }
735}
736impl std::error::Error for Hardhat {}