CardanoNodePlutusDatumSchema

Enum CardanoNodePlutusDatumSchema 

Source
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:

  1. 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”}]}]}
  2. 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

Source§

fn clone(&self) -> CardanoNodePlutusDatumSchema

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CardanoNodePlutusDatumSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<CardanoNodePlutusDatumSchema> for JsValue

Source§

fn from(value: CardanoNodePlutusDatumSchema) -> JsValue

Converts to this type from the input type.
Source§

impl FromWasmAbi for CardanoNodePlutusDatumSchema

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> CardanoNodePlutusDatumSchema

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for CardanoNodePlutusDatumSchema

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl OptionFromWasmAbi for CardanoNodePlutusDatumSchema

Source§

fn is_none(val: &<CardanoNodePlutusDatumSchema as FromWasmAbi>::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for CardanoNodePlutusDatumSchema

Source§

fn none() -> <CardanoNodePlutusDatumSchema as IntoWasmAbi>::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl PartialEq for CardanoNodePlutusDatumSchema

Source§

fn eq(&self, other: &CardanoNodePlutusDatumSchema) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFromJsValue for CardanoNodePlutusDatumSchema

Source§

type Error = JsValue

The type returned in the event of a conversion error.
Source§

fn try_from_js_value( value: JsValue, ) -> Result<CardanoNodePlutusDatumSchema, <CardanoNodePlutusDatumSchema as TryFromJsValue>::Error>

Performs the conversion.
Source§

impl VectorFromWasmAbi for CardanoNodePlutusDatumSchema

Source§

impl VectorIntoWasmAbi for CardanoNodePlutusDatumSchema

Source§

impl Copy for CardanoNodePlutusDatumSchema

Source§

impl Eq for CardanoNodePlutusDatumSchema

Source§

impl StructuralPartialEq for CardanoNodePlutusDatumSchema

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V