pub struct PlutusScripts(_);

Implementations§

Examples found in repository?
src/plutus.rs (line 202)
201
202
203
204
205
206
207
    pub(crate) fn map_as_version(&self, language: &Language) -> PlutusScripts {
        let mut res = PlutusScripts::new();
        for s in &self.0 {
            res.add(&s.clone_as_version(language));
        }
        res
    }
More examples
Hide additional examples
src/tx_builder/tx_inputs_builder.rs (line 213)
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    pub(crate) fn collect(&self) -> (PlutusScripts, Option<PlutusList>, Redeemers) {
        let mut used_scripts = BTreeSet::new();
        let mut used_datums = BTreeSet::new();
        let mut used_redeemers = BTreeSet::new();
        let mut s = PlutusScripts::new();
        let mut d : Option<PlutusList> = None;
        let mut r = Redeemers::new();
        self.0.iter().for_each(|w| {
            if let PlutusScriptSourceEnum::Script(script) = &w.script {
                if used_scripts.insert(script.clone()) {
                    s.add(script);
                }
            }
            if let Some(DatumSourceEnum::Datum(datum)) = &w.datum {
                if used_datums.insert(datum) {
                    match d {
                        Some(ref mut d) => d.add(datum),
                        None => d =  {
                            let mut initial_list = PlutusList::new();
                            initial_list.add(datum);
                            Some(initial_list)
                        }
                    }
                }
            }
            if used_redeemers.insert(w.redeemer.clone()) {
                r.add(&w.redeemer);
            }
        });
        (s, d, r)
    }
Examples found in repository?
src/metadata.rs (line 1012)
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
    fn serialize<'se, W: Write>(
        &self,
        serializer: &'se mut Serializer<W>,
    ) -> cbor_event::Result<&'se mut Serializer<W>> {
        // we still serialize using the shelley-mary era format as it is still supported
        // and it takes up less space on-chain so this should be better for scaling.
        // Plus the code was already written for shelley-mary anyway
        if !self.prefer_alonzo_format && self.metadata.is_some() && self.plutus_scripts.is_none() {
            match &self.native_scripts() {
                Some(native_scripts) => {
                    serializer.write_array(cbor_event::Len::Len(2))?;
                    self.metadata.as_ref().unwrap().serialize(serializer)?;
                    native_scripts.serialize(serializer)
                }
                None => self.metadata.as_ref().unwrap().serialize(serializer),
            }
        } else {
            let plutus_added_length = match &self.plutus_scripts {
                Some(scripts) => 1 + (scripts.has_version(&Language::new_plutus_v2()) as u64),
                _ => 0,
            };
            // new format with plutus support
            serializer.write_tag(259u64)?;
            serializer.write_map(cbor_event::Len::Len(
                opt64(&self.metadata) + opt64(&self.native_scripts) + plutus_added_length,
            ))?;
            if let Some(metadata) = &self.metadata {
                serializer.write_unsigned_integer(0)?;
                metadata.serialize(serializer)?;
            }
            if let Some(native_scripts) = &self.native_scripts {
                serializer.write_unsigned_integer(1)?;
                native_scripts.serialize(serializer)?;
            }
            if let Some(plutus_scripts) = &self.plutus_scripts {
                serializer.write_unsigned_integer(2)?;
                plutus_scripts
                    .by_version(&Language::new_plutus_v1())
                    .serialize(serializer)?;
                let v2 = plutus_scripts.by_version(&Language::new_plutus_v2());
                if v2.len() > 0 {
                    serializer.write_unsigned_integer(3)?;
                    v2.serialize(serializer)?;
                }
            }
            Ok(serializer)
        }
    }
Examples found in repository?
src/plutus.rs (line 196)
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
    pub(crate) fn merge(&self, other: &PlutusScripts) -> PlutusScripts {
        let mut res = self.clone();
        for s in &other.0 {
            res.add(s);
        }
        res
    }

    pub(crate) fn map_as_version(&self, language: &Language) -> PlutusScripts {
        let mut res = PlutusScripts::new();
        for s in &self.0 {
            res.add(&s.clone_as_version(language));
        }
        res
    }
More examples
Hide additional examples
src/tx_builder/tx_inputs_builder.rs (line 219)
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    pub(crate) fn collect(&self) -> (PlutusScripts, Option<PlutusList>, Redeemers) {
        let mut used_scripts = BTreeSet::new();
        let mut used_datums = BTreeSet::new();
        let mut used_redeemers = BTreeSet::new();
        let mut s = PlutusScripts::new();
        let mut d : Option<PlutusList> = None;
        let mut r = Redeemers::new();
        self.0.iter().for_each(|w| {
            if let PlutusScriptSourceEnum::Script(script) = &w.script {
                if used_scripts.insert(script.clone()) {
                    s.add(script);
                }
            }
            if let Some(DatumSourceEnum::Datum(datum)) = &w.datum {
                if used_datums.insert(datum) {
                    match d {
                        Some(ref mut d) => d.add(datum),
                        None => d =  {
                            let mut initial_list = PlutusList::new();
                            initial_list.add(datum);
                            Some(initial_list)
                        }
                    }
                }
            }
            if used_redeemers.insert(w.redeemer.clone()) {
                r.add(&w.redeemer);
            }
        });
        (s, d, r)
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
The name of the generated JSON Schema. Read more
Generates a JSON Schema for this type. Read more
Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.