zksync_error/error/
domains.rs

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