griffin_core/uplc/tx/
error.rs1use crate::pallas_primitives::conway::Language;
2use crate::uplc::{
3 machine::{self, cost_model::ExBudget},
4 TransactionInput,
5};
6use alloc::{
7 boxed::Box,
8 string::{String, ToString},
9 vec::Vec,
10};
11
12#[derive(thiserror_no_std::Error, Debug)]
13pub enum Error {
14 #[error("{0}")]
15 Address(#[from] crate::pallas_addresses::Error),
16 #[error("only shelley reward addresses can be a part of withdrawals")]
17 BadWithdrawalAddress,
18 #[error("{0}")]
19 FlatDecode(#[from] crate::pallas_codec::flat::de::Error),
20 #[error("{0}")]
21 FragmentDecode(#[from] crate::pallas_primitives::Error),
22 #[error("{}{}", .0, .2.iter()
23 .map(|trace| {
24 format!(
25 "\n{:>13} {}",
26 "Trace",
27 if trace.contains('\n') {
28 trace.lines()
29 .enumerate()
30 .map(|(ix, row)| {
31 if ix == 0 {
32 row.to_string()
33 } else {
34 format!("{:>13} {}", "",
35 row
36 )
37 }
38 })
39 .collect::<Vec<_>>()
40 .join("\n")
41 } else {
42 trace.to_string()
43 }
44 )
45 })
46 .collect::<Vec<_>>()
47 .join("")
48 .as_str()
49 )]
50 Machine(machine::Error, ExBudget, Vec<String>),
51
52 #[error("native script can't be executed in phase-two")]
53 NativeScriptPhaseTwo,
54 #[error("can't eval without redeemers")]
55 NoRedeemers,
56 #[error(
57 "missing and/or unexpected validator(s) and/or redeemer(s)\n{:>13} {}\n{:>13} {}",
58 "Missing",
59 if .missing.is_empty() { "ø".to_string() } else { .missing.join(&format!("\n{:>14}", "")) },
60 "Unexpected",
61 if .extra.is_empty() { "ø".to_string() } else { .extra.join(&format!("\n{:>14}", "")) },
62 )]
63 RequiredRedeemersMismatch {
64 missing: Vec<String>,
65 extra: Vec<String>,
66 },
67 #[error("extraneous redeemer")]
68 ExtraneousRedeemer,
69 #[error("resolved Input not found")]
70 ResolvedInputNotFound(TransactionInput),
71 #[error("redeemer points to a non-script withdrawal")]
72 NonScriptWithdrawal,
73 #[error("stake credential points to a non-script withdrawal")]
74 NonScriptStakeCredential,
75 #[error("the designated procedure defines no guardrail script")]
76 NoGuardrailScriptForProcedure,
77 #[error("cost model not found for language\n{:>13} {:?}", "Language", .0)]
78 CostModelNotFound(Language),
79 #[error("unsupported era, please use Conway\n{:>13} {0}", "Decoder error")]
80 WrongEra(#[from] crate::pallas_codec::minicbor::decode::Error),
81 #[error("byron address not allowed when PlutusV2 scripts are present")]
82 ByronAddressNotAllowed,
83 #[error("inline datum not allowed when PlutusV1 scripts are present")]
84 InlineDatumNotAllowed,
85 #[error("script and input reference not allowed in PlutusV1")]
86 ScriptAndInputRefNotAllowed,
87 #[error("address doesn't contain a payment credential")]
88 NoPaymentCredential,
89 #[error("missing required datum\n{:>13} {}", "Datum", hash)]
90 MissingRequiredDatum { hash: String },
91 #[error("missing required script\n{:>13} {}", "Script", hash)]
92 MissingRequiredScript { hash: String },
93 #[error("missing required inline datum or datum hash in script input")]
94 MissingRequiredInlineDatumOrHash,
95 #[error("redeemer points to an unsupported certificate type")]
96 UnsupportedCertificateType,
97 #[error("failed script execution\n{:>13} {}", format!("{}[{}]", tag, index), err)]
98 RedeemerError {
99 tag: String,
100 index: u32,
101 err: Box<Error>,
102 },
103 #[error("missing script for redeemer")]
104 MissingScriptForRedeemer,
105 #[error("failed to apply parameters to Plutus script")]
106 ApplyParamsError,
107 #[error("validity start or end too far in the past")]
108 SlotTooFarInThePast { oldest_allowed: u64 },
109}