fix: blueprint still needs to load older plutus versions
This commit is contained in:
parent
620fe6b299
commit
b3de1b048b
|
@ -4,9 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[derive(Debug, Default, Deserialize, Serialize, Clone, Copy, PartialEq)]
|
#[derive(Debug, Default, Deserialize, Serialize, Clone, Copy, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum PlutusVersion {
|
pub enum PlutusVersion {
|
||||||
#[serde(skip_deserializing)]
|
|
||||||
V1,
|
V1,
|
||||||
#[serde(skip_deserializing)]
|
|
||||||
V2,
|
V2,
|
||||||
#[default]
|
#[default]
|
||||||
V3,
|
V3,
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub struct Config {
|
||||||
default = "default_version"
|
default = "default_version"
|
||||||
)]
|
)]
|
||||||
pub compiler: Version,
|
pub compiler: Version,
|
||||||
#[serde(default)]
|
#[serde(default, deserialize_with = "validate_v3_only")]
|
||||||
pub plutus: PlutusVersion,
|
pub plutus: PlutusVersion,
|
||||||
pub license: Option<String>,
|
pub license: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
@ -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 {
|
mod built_info {
|
||||||
include!(concat!(env!("OUT_DIR"), "/built.rs"));
|
include!(concat!(env!("OUT_DIR"), "/built.rs"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use aiken_project::{
|
use aiken_project::{
|
||||||
blueprint::{error::Error as BlueprintError, Blueprint},
|
blueprint::{error::Error as BlueprintError, Blueprint},
|
||||||
config::Config,
|
|
||||||
error::Error as ProjectError,
|
error::Error as ProjectError,
|
||||||
};
|
};
|
||||||
use clap::ValueEnum;
|
use clap::ValueEnum;
|
||||||
|
@ -22,7 +21,7 @@ pub struct Args {
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
validator: Option<String>,
|
validator: Option<String>,
|
||||||
|
|
||||||
// Format to convert to
|
/// Format to convert to
|
||||||
#[clap(long, default_value = "cardano-cli")]
|
#[clap(long, default_value = "cardano-cli")]
|
||||||
to: Format,
|
to: Format,
|
||||||
}
|
}
|
||||||
|
@ -56,13 +55,6 @@ pub fn exec(
|
||||||
let blueprint: Blueprint =
|
let blueprint: Blueprint =
|
||||||
serde_json::from_reader(BufReader::new(blueprint)).into_diagnostic()?;
|
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
|
// Perform the conversion
|
||||||
let when_too_many =
|
let when_too_many =
|
||||||
|known_validators| ProjectError::MoreThanOneValidatorFound { known_validators };
|
|known_validators| ProjectError::MoreThanOneValidatorFound { known_validators };
|
||||||
|
@ -85,6 +77,8 @@ pub fn exec(
|
||||||
|
|
||||||
let cbor_hex = hex::encode(double_cbor_bytes);
|
let cbor_hex = hex::encode(double_cbor_bytes);
|
||||||
|
|
||||||
|
let cardano_cli_type = blueprint.preamble.plutus_version.cardano_cli_type();
|
||||||
|
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"type": cardano_cli_type,
|
"type": cardano_cli_type,
|
||||||
"description": "Generated by Aiken",
|
"description": "Generated by Aiken",
|
||||||
|
|
Loading…
Reference in New Issue