From c0230a811f2c0b581846a070140117ffd8731bb5 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 21 Feb 2023 15:37:35 +0100 Subject: [PATCH] Add 'plutusVersion' to blueprints. --- crates/aiken-project/src/blueprint/mod.rs | 18 ++++++++++++++++++ examples/hello_world/plutus.json | 7 ++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/aiken-project/src/blueprint/mod.rs b/crates/aiken-project/src/blueprint/mod.rs index 9e5260c7..06dd097c 100644 --- a/crates/aiken-project/src/blueprint/mod.rs +++ b/crates/aiken-project/src/blueprint/mod.rs @@ -16,15 +16,28 @@ pub struct Blueprint { } #[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)] +#[serde(rename_all = "camelCase")] pub struct Preamble { pub title: String, + #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, + pub version: String, + + pub plutus_version: PlutusVersion, + #[serde(skip_serializing_if = "Option::is_none")] pub license: Option, } +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum PlutusVersion { + V1, + V2, +} + #[derive(Debug, PartialEq, Clone)] pub enum LookupResult<'a, T> { One(&'a T), @@ -112,6 +125,7 @@ impl From<&Config> for Preamble { } else { Some(config.description.clone()) }, + plutus_version: PlutusVersion::V2, version: config.version.clone(), license: config.license.clone(), } @@ -130,6 +144,7 @@ mod test { title: "Foo".to_string(), description: None, version: "1.0.0".to_string(), + plutus_version: PlutusVersion::V2, license: Some("Apache-2.0".to_string()), }, validators: vec![], @@ -140,6 +155,7 @@ mod test { "preamble": { "title": "Foo", "version": "1.0.0", + "plutusVersion": "v2", "license": "Apache-2.0" }, "validators": [] @@ -154,6 +170,7 @@ mod test { title: "Foo".to_string(), description: Some("Lorem ipsum".to_string()), version: "1.0.0".to_string(), + plutus_version: PlutusVersion::V2, license: None, }, validators: vec![], @@ -165,6 +182,7 @@ mod test { "title": "Foo", "description": "Lorem ipsum", "version": "1.0.0", + "plutusVersion": "v2" }, "validators": [] }), diff --git a/examples/hello_world/plutus.json b/examples/hello_world/plutus.json index e0179760..3e1643f4 100644 --- a/examples/hello_world/plutus.json +++ b/examples/hello_world/plutus.json @@ -2,7 +2,8 @@ "preamble": { "title": "aiken-lang/hello_world", "description": "Aiken contracts for project 'aiken-lang/hello_world'", - "version": "1.0.0" + "version": "1.0.0", + "plutusVersion": "v2" }, "validators": [ { @@ -39,8 +40,8 @@ } ] }, - "compiledCode": "58e10100003232323232323232222533300632323232533300a002100114a06464660026eb0cc010c014cc010c014019200048040dd7198021802804240006002002444a66601e00429404c8c94ccc038cdc78010018a5113330050050010033012003375c602000466e5cc8dcc8009bae330013002004480012410d48656c6c6f2c20576f726c64210022323330010014800000c888cccc030cdc3802001008119980200219b8000348008c0480040048c024dd50008a4c2c6002002444a66600e004293099802980098040011998018019804801000ab9a5736aae7955cfaba15745", - "hash": "287233442cf812fafd74ab135d665f110de89ac12775204ad741f220" + "compiledCode": "58dd0100003232323232323232222533300632323232533300a002100114a06464660026eb0cc010c014cc010c014019200048040dd7198021802804240006002002444a66601e00429404c8c94ccc038cdc78010018a5113330050050010033012003375c602000466e3cdd71980098010022400091010d48656c6c6f2c20576f726c64210022323330010014800000c888cccc030cdc3802001008119980200219b8000348008c0480040048c024dd50008a4c2c6002002444a66600e004293099802980098040011998018019804801000ab9a5736aae7955cfaba15745", + "hash": "46872294cadbacb2c3214086c0129ede75cf9f767e95a449f996685f" } ] } \ No newline at end of file