Skip to content

Commit

Permalink
fix: blueprint still needs to load older plutus versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Jan 2, 2025
1 parent 620fe6b commit b3de1b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 0 additions & 2 deletions crates/aiken-lang/src/plutus_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Deserialize, Serialize, Clone, Copy, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum PlutusVersion {
#[serde(skip_deserializing)]
V1,
#[serde(skip_deserializing)]
V2,
#[default]
V3,
Expand Down
14 changes: 13 additions & 1 deletion crates/aiken-project/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Config {
default = "default_version"
)]
pub compiler: Version,
#[serde(default)]
#[serde(default, deserialize_with = "validate_v3_only")]
pub plutus: PlutusVersion,
pub license: Option<String>,
#[serde(default)]
Expand Down Expand Up @@ -376,6 +376,18 @@ impl Config {
}
}

fn validate_v3_only<'de, D>(deserializer: D) -> Result<PlutusVersion, D::Error>
where
D: serde::Deserializer<'de>,
{
let version = PlutusVersion::deserialize(deserializer)?;

match version {
PlutusVersion::V3 => Ok(version),
_ => Err(serde::de::Error::custom("Aiken only supports Plutus V3")),
}
}

mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
Expand Down
12 changes: 3 additions & 9 deletions crates/aiken/src/cmd/blueprint/convert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use aiken_project::{
blueprint::{error::Error as BlueprintError, Blueprint},
config::Config,
error::Error as ProjectError,
};
use clap::ValueEnum;
Expand All @@ -22,7 +21,7 @@ pub struct Args {
#[clap(short, long)]
validator: Option<String>,

// Format to convert to
/// Format to convert to
#[clap(long, default_value = "cardano-cli")]
to: Format,
}
Expand Down Expand Up @@ -56,13 +55,6 @@ pub fn exec(
let blueprint: Blueprint =
serde_json::from_reader(BufReader::new(blueprint)).into_diagnostic()?;

let opt_config = Config::load(&project_path).ok();

let cardano_cli_type = opt_config
.map(|config| config.plutus)
.unwrap_or_default()
.cardano_cli_type();

// Perform the conversion
let when_too_many =
|known_validators| ProjectError::MoreThanOneValidatorFound { known_validators };
Expand All @@ -85,6 +77,8 @@ pub fn exec(

let cbor_hex = hex::encode(double_cbor_bytes);

let cardano_cli_type = blueprint.preamble.plutus_version.cardano_cli_type();

Ok(json!({
"type": cardano_cli_type,
"description": "Generated by Aiken",
Expand Down

0 comments on commit b3de1b0

Please sign in to comment.