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