pub enum CardanoNodePlutusDatumSchema {
BasicConversions,
DetailedSchema,
}
Expand description
JSON <-> PlutusData conversion schemas. Follows ScriptDataJsonSchema in cardano-cli defined at: https://github.com/input-output-hk/cardano-node/blob/master/cardano-api/src/Cardano/Api/ScriptData.hs#L254
All methods here have the following restrictions due to limitations on dependencies:
- JSON numbers above u64::MAX (positive) or below i64::MIN (negative) will throw errors
- Hex strings for bytes don’t accept odd-length (half-byte) strings. cardano-cli seems to support these however but it seems to be different than just 0-padding on either side when tested so proceed with caution
Variants§
BasicConversions
ScriptDataJsonNoSchema in cardano-node.
This is the format used by –script-data-value in cardano-cli This tries to accept most JSON but does not support the full spectrum of Plutus datums. From JSON:
- null/true/false/floats NOT supported
- strings starting with 0x are treated as hex bytes. All other strings are encoded as their utf8 bytes. To JSON:
- ConstrPlutusData not supported in ANY FORM (neither keys nor values)
- Lists not supported in keys
- Maps not supported in keys
DetailedSchema
ScriptDataJsonDetailedSchema in cardano-node.
This is the format used by –script-data-file in cardano-cli This covers almost all (only minor exceptions) Plutus datums, but the JSON must conform to a strict schema. The schema specifies that ALL keys and ALL values must be contained in a JSON map with 2 cases:
- For ConstrPlutusData there must be two fields “constructor” contianing a number and “fields” containing its fields e.g. { “constructor”: 2, “fields”: [{“int”: 2}, {“list”: [{“bytes”: “CAFEF00D”}]}]}
- For all other cases there must be only one field named “int”, “bytes”, “list” or “map” BigInteger’s value is a JSON number e.g. {“int”: 100} Bytes’ value is a hex string representing the bytes WITHOUT any prefix e.g. {“bytes”: “CAFEF00D”} Lists’ value is a JSON list of its elements encoded via the same schema e.g. {“list”: [{“bytes”: “CAFEF00D”}]} Maps’ value is a JSON list of objects, one for each key-value pair in the map, with keys “k” and “v” respectively with their values being the plutus datum encoded via this same schema e.g. {“map”: [ {“k”: {“int”: 2}, “v”: {“int”: 5}}, {“k”: {“map”: [{“k”: {“list”: [{“int”: 1}]}, “v”: {“bytes”: “FF03”}}]}, “v”: {“list”: []}} ]} From JSON:
- null/true/false/floats NOT supported
- the JSON must conform to a very specific schema To JSON:
- all Plutus datums should be fully supported outside of the integer range limitations outlined above.
Trait Implementations§
Source§impl Clone for CardanoNodePlutusDatumSchema
impl Clone for CardanoNodePlutusDatumSchema
Source§fn clone(&self) -> CardanoNodePlutusDatumSchema
fn clone(&self) -> CardanoNodePlutusDatumSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CardanoNodePlutusDatumSchema
impl Debug for CardanoNodePlutusDatumSchema
Source§impl PartialEq for CardanoNodePlutusDatumSchema
impl PartialEq for CardanoNodePlutusDatumSchema
Source§fn eq(&self, other: &CardanoNodePlutusDatumSchema) -> bool
fn eq(&self, other: &CardanoNodePlutusDatumSchema) -> bool
self
and other
values to be equal, and is used by ==
.impl Copy for CardanoNodePlutusDatumSchema
impl Eq for CardanoNodePlutusDatumSchema
impl StructuralPartialEq for CardanoNodePlutusDatumSchema
Auto Trait Implementations§
impl Freeze for CardanoNodePlutusDatumSchema
impl RefUnwindSafe for CardanoNodePlutusDatumSchema
impl Send for CardanoNodePlutusDatumSchema
impl Sync for CardanoNodePlutusDatumSchema
impl Unpin for CardanoNodePlutusDatumSchema
impl UnwindSafe for CardanoNodePlutusDatumSchema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more