Update blueprint outputs to reflect latest specification.
Schemas of datums, redeemers and parameters are now nested under a field 'schema'. This allows to define a field 'purpose' at the same level.
This commit is contained in:
parent
433af4638b
commit
65c336cb82
|
@ -15,18 +15,34 @@ use uplc::ast::{DeBruijn, Program, Term};
|
|||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Validator<T> {
|
||||
pub title: String,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub description: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub datum: Option<Annotated<T>>,
|
||||
pub redeemer: Annotated<T>,
|
||||
pub datum: Option<Argument<T>>,
|
||||
|
||||
pub redeemer: Argument<T>,
|
||||
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
#[serde(default)]
|
||||
pub parameters: Vec<Annotated<T>>,
|
||||
pub parameters: Vec<Argument<T>>,
|
||||
|
||||
#[serde(flatten)]
|
||||
pub program: Program<DeBruijn>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Argument<T> {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub title: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub description: Option<String>,
|
||||
|
||||
pub schema: T,
|
||||
}
|
||||
|
||||
impl Display for Validator<Schema> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let s = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?;
|
||||
|
@ -34,6 +50,23 @@ impl Display for Validator<Schema> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Display for Argument<Schema> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let s = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?;
|
||||
f.write_str(&s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<Annotated<T>> for Argument<T> {
|
||||
fn from(annotated: Annotated<T>) -> Self {
|
||||
Argument {
|
||||
title: annotated.title,
|
||||
description: annotated.description,
|
||||
schema: annotated.annotated,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Validator<Schema> {
|
||||
pub fn from_checked_module(
|
||||
modules: &CheckedModules,
|
||||
|
@ -71,7 +104,7 @@ impl Validator<Schema> {
|
|||
annotation.title = annotation
|
||||
.title
|
||||
.or_else(|| Some(param.arg_name.get_label()));
|
||||
annotation
|
||||
annotation.into()
|
||||
})
|
||||
})
|
||||
.collect::<Result<_, _>>()?,
|
||||
|
@ -88,7 +121,8 @@ impl Validator<Schema> {
|
|||
},
|
||||
)
|
||||
})
|
||||
.transpose()?,
|
||||
.transpose()?
|
||||
.map(|annotated| annotated.into()),
|
||||
redeemer: Annotated::from_type(modules.into(), &redeemer.tipo, &HashMap::new())
|
||||
.map_err(|error| Error::Schema {
|
||||
error,
|
||||
|
@ -97,7 +131,8 @@ impl Validator<Schema> {
|
|||
module.input_path.display().to_string(),
|
||||
module.code.clone(),
|
||||
),
|
||||
})?,
|
||||
})?
|
||||
.into(),
|
||||
program: generator
|
||||
.generate(&def.fun.body, &arguments, true)
|
||||
.try_into()
|
||||
|
@ -266,7 +301,8 @@ mod test {
|
|||
"hash": "afddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72",
|
||||
"redeemer": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data."
|
||||
"description": "Any Plutus data.",
|
||||
"schema": {}
|
||||
},
|
||||
"compiledCode": "583b010000323232323232322253330054a22930b180080091129998030010a4c26600a6002600e0046660060066010004002ae695cdaab9f5742ae881"
|
||||
}),
|
||||
|
@ -288,12 +324,14 @@ mod test {
|
|||
"hash": "a82df717fd39f5b273c4eb89ae5252e11cc272ac59d815419bf2e4c3",
|
||||
"parameters": [{
|
||||
"title": "utxo_ref",
|
||||
"schema": {
|
||||
"dataType": "integer"
|
||||
|
||||
}
|
||||
}],
|
||||
"redeemer": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data."
|
||||
"description": "Any Plutus data.",
|
||||
"schema": {}
|
||||
},
|
||||
"compiledCode": "5840010000323232323232322322253330074a22930b1bad0013001001222533300600214984cc014c004c01c008ccc00c00cc0200080055cd2b9b5573eae855d101"
|
||||
}),
|
||||
|
@ -346,6 +384,7 @@ mod test {
|
|||
"datum": {
|
||||
"title": "State",
|
||||
"description": "On-chain state",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "State",
|
||||
|
@ -384,9 +423,11 @@ mod test {
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"redeemer": {
|
||||
"title": "Input",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "CollectCom",
|
||||
|
@ -408,6 +449,7 @@ mod test {
|
|||
"fields": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"compiledCode": "583b0100003232323232323222253330064a22930b180080091129998030010a4c26600a6002600e0046660060066010004002ae695cdaab9f5742ae89"
|
||||
}),
|
||||
|
@ -428,14 +470,18 @@ mod test {
|
|||
"title": "test_module.spend",
|
||||
"hash": "3c6766e7a36df2aa13c0e9e6e071317ed39d05f405771c4f1a81c6cc",
|
||||
"datum": {
|
||||
"schema": {
|
||||
"dataType": "list",
|
||||
"items": [
|
||||
{ "dataType": "integer" },
|
||||
{ "dataType": "bytes" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"redeemer": {
|
||||
"schema": {
|
||||
"dataType": "#string"
|
||||
}
|
||||
},
|
||||
"compiledCode": "585501000032323232323232232232253330084a22930b1b99375c002646466ec0c024008c024004c024004dd6000980080091129998030010a4c26600a6002600e0046660060066010004002ae695cdaab9f5742ae881"
|
||||
}),
|
||||
|
@ -457,6 +503,7 @@ mod test {
|
|||
"hash": "f335ce0436fd7df56e727a66ada7298534a27b98f887bc3b7947ee48",
|
||||
"datum": {
|
||||
"title": "Tuple",
|
||||
"schema": {
|
||||
"dataType": "list",
|
||||
"items": [
|
||||
{
|
||||
|
@ -469,10 +516,12 @@ mod test {
|
|||
"dataType": "integer"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"redeemer": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data."
|
||||
"description": "Any Plutus data.",
|
||||
"schema": {}
|
||||
},
|
||||
"compiledCode": "5840010000323232323232322322253330074a22930b1bac0013001001222533300600214984cc014c004c01c008ccc00c00cc0200080055cd2b9b5573eae855d101"
|
||||
}),
|
||||
|
@ -505,6 +554,7 @@ mod test {
|
|||
"hash": "afddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72",
|
||||
"redeemer": {
|
||||
"title": "Either",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "Left",
|
||||
|
@ -545,6 +595,7 @@ mod test {
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"compiledCode": "583b010000323232323232322253330054a22930b180080091129998030010a4c26600a6002600e0046660060066010004002ae695cdaab9f5742ae881"
|
||||
}
|
||||
|
@ -574,6 +625,7 @@ mod test {
|
|||
"hash": "afddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72",
|
||||
"redeemer": {
|
||||
"title": "Dict",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "Dict",
|
||||
|
@ -593,6 +645,7 @@ mod test {
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"compiledCode": "583b010000323232323232322253330054a22930b180080091129998030010a4c26600a6002600e0046660060066010004002ae695cdaab9f5742ae881"
|
||||
}
|
||||
|
@ -622,6 +675,7 @@ mod test {
|
|||
"hash": "afddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72",
|
||||
"redeemer": {
|
||||
"title": "Dict",
|
||||
"schema": {
|
||||
"dataType": "map",
|
||||
"keys": {
|
||||
"dataType": "bytes"
|
||||
|
@ -629,6 +683,7 @@ mod test {
|
|||
"values": {
|
||||
"dataType": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"compiledCode": "583b010000323232323232322253330054a22930b180080091129998030010a4c26600a6002600e0046660060066010004002ae695cdaab9f5742ae881"
|
||||
}
|
||||
|
@ -657,9 +712,12 @@ mod test {
|
|||
"datum": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data.",
|
||||
"schema": {},
|
||||
},
|
||||
"redeemer": {
|
||||
"schema": {
|
||||
"dataType": "integer",
|
||||
}
|
||||
},
|
||||
"compiledCode": "5840010000323232323232322232253330074a22930b1bad0013001001222533300600214984cc014c004c01c008ccc00c00cc0200080055cd2b9b5573eae855d101"
|
||||
}
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
"title": "spend.spend",
|
||||
"datum": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data."
|
||||
"description": "Any Plutus data.",
|
||||
"schema": {}
|
||||
},
|
||||
"redeemer": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data."
|
||||
"description": "Any Plutus data.",
|
||||
"schema": {}
|
||||
},
|
||||
"compiledCode": "59015f010000323232323232323232322225333006323232323233001003232323322323232323330140014a0944004c94ccc05c0045288a5000133223233223253330173370e00290010801099190009bab301e00130110033018375400400297adef6c6033223300800200100200100100237566601260140049001001a441050000000000003001001222533301300213374a900125eb804c8c8c8c94ccc04ccdc7802800899ba548000cc060dd300125eb804ccc01c01c00c014dd7180a0019bab3014002301700330150023001001222533301000214a026464a66601c600600429444ccc01401400400cc05000cc048008dd6198009801198009801001a400090021119199800800a4000006444666601866e1c0100080488ccc010010cdc0001a40046028002002460146ea8004526163001001222533300800214984cc014c004c028008ccc00c00cc02c0080055cd2b9b5573aaae7955cfaba05742ae89",
|
||||
"hash": "3f46b921ead33594e1da4afa1f1ba31807c0d8deca029f96fe9fe394"
|
||||
|
@ -23,6 +25,7 @@
|
|||
"redeemer": {
|
||||
"title": "Unit",
|
||||
"description": "The nullary constructor.",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"dataType": "constructor",
|
||||
|
@ -30,11 +33,13 @@
|
|||
"fields": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"title": "OutputReference",
|
||||
"description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "OutputReference",
|
||||
|
@ -66,6 +71,7 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"compiledCode": "58e301000032323232323232323232222533300632323232533300a3370e0029000099251300400214a060166ea8004c8c8cc004dd6198019802198019802002a40009000119baf33004300500148000020c0040048894ccc03c0084cdd2a400497ae013232533300d300300213374a90001980900125eb804ccc01401400400cc04c00cc04400888c8ccc0040052000003222333300c3370e008004024466600800866e0000d200230140010012300a37540022930b180080091129998040010a4c26600a600260140046660060066016004002ae695cdaab9d5573caae7d5d02ba157441",
|
||||
"hash": "5a5aef5525783c007ee817dd5869ee67000ae5fd730815af7d87ec97"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"datum": {
|
||||
"title": "Unit",
|
||||
"description": "The nullary constructor.",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"dataType": "constructor",
|
||||
|
@ -17,10 +18,12 @@
|
|||
"fields": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"redeemer": {
|
||||
"title": "Unit",
|
||||
"description": "The nullary constructor.",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"dataType": "constructor",
|
||||
|
@ -28,6 +31,7 @@
|
|||
"fields": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"compiledCode": "583b0100003232323232323222253330064a22930b180080091129998030010a4c26600a6002600e0046660060066010004002ae695cdaab9f5742ae89",
|
||||
"hash": "e37db487fbd58c45d059bcbf5cd6b1604d3bec16cf888f1395a4ebc4"
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
"title": "foo.spend",
|
||||
"datum": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data."
|
||||
"description": "Any Plutus data.",
|
||||
"schema": {}
|
||||
},
|
||||
"redeemer": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data."
|
||||
"description": "Any Plutus data.",
|
||||
"schema": {}
|
||||
},
|
||||
"compiledCode": "586001000032323232323232323222253330063370e6464640046eb4c02c008dd69804800a5ef6c6010104000101010048020526163001001222533300800214984cc014c004c024008ccc00c00cc0280080055cd2b9b5573aaae7955cfaba157441",
|
||||
"hash": "7ecbfc3ae91c4d5ba3799b4d283e385d457c860cd22034d825379ae2"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"title": "spend.pool_contract",
|
||||
"datum": {
|
||||
"title": "PoolDatum",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "PoolDatum",
|
||||
|
@ -46,9 +47,11 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"redeemer": {
|
||||
"title": "PoolRedeemer",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "PoolRedeemer",
|
||||
|
@ -159,6 +162,7 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"compiledCode": "59030501000032323232323232323232322225333006323232323232323232533300f3370e002900009925130090021533300f3370e0029001099191919299980999b87001480084c8c8cccc8888c8c8c8c8c9289812000980b19299980e99b8748000c080dd500088008a9980fa492a4173736572746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e0016330120070033022001301432533301b3370e9000180f1baa0011001153301d49012a4173736572746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e00163300f005001300d48901ff00010001012005301b001300d00214a0602a6ea8004cc028c02c03120023017001300900213232323253330133370e0029001099191999911119191919192513024001301632533301d3370e900018101baa0011001153301f49012a4173736572746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e0016330120070033022001301432533301b3370e9000180f1baa0011001153301d49012a4173736572746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e00163300f005001300d48901ff00010001012005301b001300d00214a0602a6ea8004cc028c02c031200230170013009002301137540026600c600e0129000119ba548000cc04ccdd2a4004660266ea40052f5c06602666e9520024bd7025eb8088cc010dd6198031803998031803801240009002119baf3300730080014800000888cc00cdd6198029803198029803001240009000119baf3300630073300630070014800920000023001001222533301000213374a900125eb804c8c94ccc034c00c0084cdd2a40006602600497ae013330050050010033014003301200222323330010014800000c888cccc030cdc3802001009919980200219b8000348008c0540040048c02cdd50008a4c2c6002002444a666012004293099802980098058011998018019806001000ab9a5736ae7155ceaab9e5573eae815d0aba201",
|
||||
"hash": "c95b3842362b77afec21773b7c0b1f09e61bf5e4c58b685533e6d342"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"title": "hello_world.spend",
|
||||
"datum": {
|
||||
"title": "Datum",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "Datum",
|
||||
|
@ -23,9 +24,11 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"redeemer": {
|
||||
"title": "Redeemer",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "Redeemer",
|
||||
|
@ -39,6 +42,7 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"compiledCode": "58dd0100003232323232323232222533300632323232533300a002100114a06464660026eb0cc010c014cc010c014019200048040dd7198021802804240006002002444a66601e00429404c8c94ccc038cdc78010018a5113330050050010033012003375c602000466e3cdd71980098010022400091010d48656c6c6f2c20576f726c64210022323330010014800000c888cccc030cdc3802001008119980200219b8000348008c0480040048c024dd50008a4c2c6002002444a66600e004293099802980098040011998018019804801000ab9a5736aae7955cfaba15745",
|
||||
"hash": "46872294cadbacb2c3214086c0129ede75cf9f767e95a449f996685f"
|
||||
|
|
Loading…
Reference in New Issue