pub struct Costmdls(_);

Implementations§

Examples found in repository?
src/plutus.rs (line 399)
398
399
400
401
402
403
404
405
406
407
    pub fn retain_language_versions(&self, languages: &Languages) -> Costmdls {
        let mut result = Costmdls::new();
        for lang in &languages.0 {
            match self.get(&lang) {
                Some(costmodel) => { result.insert(&lang, &costmodel); },
                _ => {}
            }
        }
        result
    }
More examples
Hide additional examples
src/tx_builder_constants.rs (line 18)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
    pub fn plutus_alonzo_cost_models() -> Costmdls {
        let mut res = Costmdls::new();
        res.insert(
            &Language::new_plutus_v1(),
            &CostModel::from(vec![
                197209, 0, 1, 1, 396231, 621, 0, 1, 150000, 1000, 0, 1, 150000, 32, 2477736, 29175,
                4, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 100,
                100, 29773, 100, 150000, 32, 150000, 32, 150000, 32, 150000, 1000, 0, 1, 150000,
                32, 150000, 1000, 0, 8, 148000, 425507, 118, 0, 1, 1, 150000, 1000, 0, 8, 150000,
                112536, 247, 1, 150000, 10000, 1, 136542, 1326, 1, 1000, 150000, 1000, 1, 150000,
                32, 150000, 32, 150000, 32, 1, 1, 150000, 1, 150000, 4, 103599, 248, 1, 103599,
                248, 1, 145276, 1366, 1, 179690, 497, 1, 150000, 32, 150000, 32, 150000, 32,
                150000, 32, 150000, 32, 150000, 32, 148000, 425507, 118, 0, 1, 1, 61516, 11218, 0,
                1, 150000, 32, 148000, 425507, 118, 0, 1, 1, 148000, 425507, 118, 0, 1, 1, 2477736,
                29175, 4, 0, 82363, 4, 150000, 5000, 0, 1, 150000, 32, 197209, 0, 1, 1, 150000, 32,
                150000, 32, 150000, 32, 150000, 32, 150000, 32, 150000, 32, 150000, 32, 3345831, 1,
                1,
            ]),
        );
        res
    }

    pub fn plutus_vasil_cost_models() -> Costmdls {
        let mut res = Costmdls::new();
        res.insert(
            &Language::new_plutus_v1(),
            &CostModel::from(vec![
                205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4,
                23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100,
                23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525,
                14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4, 2, 245000, 216773, 62,
                1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32, 43249, 32,
                1000, 32, 80556, 1, 57667, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924,
                473, 1, 208896, 511, 1, 52467, 32, 64832, 32, 65493, 32, 22558, 32, 16563, 32,
                76511, 32, 196500, 453240, 220, 0, 1, 1, 69522, 11687, 0, 1, 60091, 32, 196500,
                453240, 220, 0, 1, 1, 196500, 453240, 220, 0, 1, 1, 806990, 30482, 4, 1927926,
                82523, 4, 265318, 0, 4, 0, 85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32,
                31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
            ]),
        );
        res.insert(
            &Language::new_plutus_v2(),
            &CostModel::from(vec![
                205665,
                812,
                1,
                1,
                1000,
                571,
                0,
                1,
                1000,
                24177,
                4,
                1,
                1000,
                32,
                117366,
                10475,
                4,
                23000,
                100,
                23000,
                100,
                23000,
                100,
                23000,
                100,
                23000,
                100,
                23000,
                100,
                100,
                100,
                23000,
                100,
                19537,
                32,
                175354,
                32,
                46417,
                4,
                221973,
                511,
                0,
                1,
                89141,
                32,
                497525,
                14068,
                4,
                2,
                196500,
                453240,
                220,
                0,
                1,
                1,
                1000,
                28662,
                4,
                2,
                245000,
                216773,
                62,
                1,
                1060367,
                12586,
                1,
                208512,
                421,
                1,
                187000,
                1000,
                52998,
                1,
                80436,
                32,
                43249,
                32,
                1000,
                32,
                80556,
                1,
                57667,
                4,
                1000,
                10,
                197145,
                156,
                1,
                197145,
                156,
                1,
                204924,
                473,
                1,
                208896,
                511,
                1,
                52467,
                32,
                64832,
                32,
                65493,
                32,
                22558,
                32,
                16563,
                32,
                76511,
                32,
                196500,
                453240,
                220,
                0,
                1,
                1,
                69522,
                11687,
                0,
                1,
                60091,
                32,
                196500,
                453240,
                220,
                0,
                1,
                1,
                196500,
                453240,
                220,
                0,
                1,
                1,
                1159724,
                392670,
                0,
                2,
                806990,
                30482,
                4,
                1927926,
                82523,
                4,
                265318,
                0,
                4,
                0,
                85931,
                32,
                205665,
                812,
                1,
                1,
                41182,
                32,
                212342,
                32,
                31220,
                32,
                32696,
                32,
                43357,
                32,
                32247,
                32,
                38314,
                32,
                20000000000,
                20000000000,
                9462713,
                1021,
                10,
                20000000000,
                0,
                20000000000,
            ]),
        );
        res
    }
src/tx_builder.rs (line 1694)
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
    pub fn calc_script_data_hash(&mut self, cost_models: &Costmdls) -> Result<(), JsError> {
        let mut used_langs = BTreeSet::new();
        let mut retained_cost_models = Costmdls::new();
        let mut plutus_witnesses = PlutusWitnesses::new();
        if let Some(mut inputs_plutus) = self.inputs.get_plutus_input_scripts() {
            used_langs.append(&mut self.inputs.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut inputs_plutus.0)
        }
        if let Some(mut collateral_plutus) = self.collateral.get_plutus_input_scripts() {
            used_langs.append(&mut self.collateral.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut collateral_plutus.0)
        }
        if let Some(mint_builder) = &self.mint {
            used_langs.append(&mut mint_builder.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut mint_builder.get_plutus_witnesses().0)
        }

        if plutus_witnesses.len() > 0 {
            let (_scripts, datums, redeemers) = plutus_witnesses.collect();
            for lang in used_langs {
                match cost_models.get(&lang) {
                    Some(cost) => {
                        retained_cost_models.insert(&lang, &cost);
                    }
                    _ => {
                        return Err(JsError::from_str(&format!(
                            "Missing cost model for language version: {:?}",
                            lang
                        )))
                    }
                }
            }
            self.script_data_hash = Some(hash_script_data(
                &redeemers,
                &retained_cost_models,
                datums,
            ));
        }
        Ok(())
    }
Examples found in repository?
src/plutus.rs (line 402)
398
399
400
401
402
403
404
405
406
407
    pub fn retain_language_versions(&self, languages: &Languages) -> Costmdls {
        let mut result = Costmdls::new();
        for lang in &languages.0 {
            match self.get(&lang) {
                Some(costmodel) => { result.insert(&lang, &costmodel); },
                _ => {}
            }
        }
        result
    }
More examples
Hide additional examples
src/tx_builder_constants.rs (lines 19-35)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
    pub fn plutus_alonzo_cost_models() -> Costmdls {
        let mut res = Costmdls::new();
        res.insert(
            &Language::new_plutus_v1(),
            &CostModel::from(vec![
                197209, 0, 1, 1, 396231, 621, 0, 1, 150000, 1000, 0, 1, 150000, 32, 2477736, 29175,
                4, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 100,
                100, 29773, 100, 150000, 32, 150000, 32, 150000, 32, 150000, 1000, 0, 1, 150000,
                32, 150000, 1000, 0, 8, 148000, 425507, 118, 0, 1, 1, 150000, 1000, 0, 8, 150000,
                112536, 247, 1, 150000, 10000, 1, 136542, 1326, 1, 1000, 150000, 1000, 1, 150000,
                32, 150000, 32, 150000, 32, 1, 1, 150000, 1, 150000, 4, 103599, 248, 1, 103599,
                248, 1, 145276, 1366, 1, 179690, 497, 1, 150000, 32, 150000, 32, 150000, 32,
                150000, 32, 150000, 32, 150000, 32, 148000, 425507, 118, 0, 1, 1, 61516, 11218, 0,
                1, 150000, 32, 148000, 425507, 118, 0, 1, 1, 148000, 425507, 118, 0, 1, 1, 2477736,
                29175, 4, 0, 82363, 4, 150000, 5000, 0, 1, 150000, 32, 197209, 0, 1, 1, 150000, 32,
                150000, 32, 150000, 32, 150000, 32, 150000, 32, 150000, 32, 150000, 32, 3345831, 1,
                1,
            ]),
        );
        res
    }

    pub fn plutus_vasil_cost_models() -> Costmdls {
        let mut res = Costmdls::new();
        res.insert(
            &Language::new_plutus_v1(),
            &CostModel::from(vec![
                205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4,
                23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100,
                23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525,
                14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4, 2, 245000, 216773, 62,
                1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32, 43249, 32,
                1000, 32, 80556, 1, 57667, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924,
                473, 1, 208896, 511, 1, 52467, 32, 64832, 32, 65493, 32, 22558, 32, 16563, 32,
                76511, 32, 196500, 453240, 220, 0, 1, 1, 69522, 11687, 0, 1, 60091, 32, 196500,
                453240, 220, 0, 1, 1, 196500, 453240, 220, 0, 1, 1, 806990, 30482, 4, 1927926,
                82523, 4, 265318, 0, 4, 0, 85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32,
                31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
            ]),
        );
        res.insert(
            &Language::new_plutus_v2(),
            &CostModel::from(vec![
                205665,
                812,
                1,
                1,
                1000,
                571,
                0,
                1,
                1000,
                24177,
                4,
                1,
                1000,
                32,
                117366,
                10475,
                4,
                23000,
                100,
                23000,
                100,
                23000,
                100,
                23000,
                100,
                23000,
                100,
                23000,
                100,
                100,
                100,
                23000,
                100,
                19537,
                32,
                175354,
                32,
                46417,
                4,
                221973,
                511,
                0,
                1,
                89141,
                32,
                497525,
                14068,
                4,
                2,
                196500,
                453240,
                220,
                0,
                1,
                1,
                1000,
                28662,
                4,
                2,
                245000,
                216773,
                62,
                1,
                1060367,
                12586,
                1,
                208512,
                421,
                1,
                187000,
                1000,
                52998,
                1,
                80436,
                32,
                43249,
                32,
                1000,
                32,
                80556,
                1,
                57667,
                4,
                1000,
                10,
                197145,
                156,
                1,
                197145,
                156,
                1,
                204924,
                473,
                1,
                208896,
                511,
                1,
                52467,
                32,
                64832,
                32,
                65493,
                32,
                22558,
                32,
                16563,
                32,
                76511,
                32,
                196500,
                453240,
                220,
                0,
                1,
                1,
                69522,
                11687,
                0,
                1,
                60091,
                32,
                196500,
                453240,
                220,
                0,
                1,
                1,
                196500,
                453240,
                220,
                0,
                1,
                1,
                1159724,
                392670,
                0,
                2,
                806990,
                30482,
                4,
                1927926,
                82523,
                4,
                265318,
                0,
                4,
                0,
                85931,
                32,
                205665,
                812,
                1,
                1,
                41182,
                32,
                212342,
                32,
                31220,
                32,
                32696,
                32,
                43357,
                32,
                32247,
                32,
                38314,
                32,
                20000000000,
                20000000000,
                9462713,
                1021,
                10,
                20000000000,
                0,
                20000000000,
            ]),
        );
        res
    }
src/tx_builder.rs (line 1714)
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
    pub fn calc_script_data_hash(&mut self, cost_models: &Costmdls) -> Result<(), JsError> {
        let mut used_langs = BTreeSet::new();
        let mut retained_cost_models = Costmdls::new();
        let mut plutus_witnesses = PlutusWitnesses::new();
        if let Some(mut inputs_plutus) = self.inputs.get_plutus_input_scripts() {
            used_langs.append(&mut self.inputs.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut inputs_plutus.0)
        }
        if let Some(mut collateral_plutus) = self.collateral.get_plutus_input_scripts() {
            used_langs.append(&mut self.collateral.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut collateral_plutus.0)
        }
        if let Some(mint_builder) = &self.mint {
            used_langs.append(&mut mint_builder.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut mint_builder.get_plutus_witnesses().0)
        }

        if plutus_witnesses.len() > 0 {
            let (_scripts, datums, redeemers) = plutus_witnesses.collect();
            for lang in used_langs {
                match cost_models.get(&lang) {
                    Some(cost) => {
                        retained_cost_models.insert(&lang, &cost);
                    }
                    _ => {
                        return Err(JsError::from_str(&format!(
                            "Missing cost model for language version: {:?}",
                            lang
                        )))
                    }
                }
            }
            self.script_data_hash = Some(hash_script_data(
                &redeemers,
                &retained_cost_models,
                datums,
            ));
        }
        Ok(())
    }
Examples found in repository?
src/plutus.rs (line 401)
398
399
400
401
402
403
404
405
406
407
    pub fn retain_language_versions(&self, languages: &Languages) -> Costmdls {
        let mut result = Costmdls::new();
        for lang in &languages.0 {
            match self.get(&lang) {
                Some(costmodel) => { result.insert(&lang, &costmodel); },
                _ => {}
            }
        }
        result
    }
More examples
Hide additional examples
src/tx_builder.rs (line 1712)
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
    pub fn calc_script_data_hash(&mut self, cost_models: &Costmdls) -> Result<(), JsError> {
        let mut used_langs = BTreeSet::new();
        let mut retained_cost_models = Costmdls::new();
        let mut plutus_witnesses = PlutusWitnesses::new();
        if let Some(mut inputs_plutus) = self.inputs.get_plutus_input_scripts() {
            used_langs.append(&mut self.inputs.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut inputs_plutus.0)
        }
        if let Some(mut collateral_plutus) = self.collateral.get_plutus_input_scripts() {
            used_langs.append(&mut self.collateral.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut collateral_plutus.0)
        }
        if let Some(mint_builder) = &self.mint {
            used_langs.append(&mut mint_builder.get_used_plutus_lang_versions());
            plutus_witnesses.0.append(&mut mint_builder.get_plutus_witnesses().0)
        }

        if plutus_witnesses.len() > 0 {
            let (_scripts, datums, redeemers) = plutus_witnesses.collect();
            for lang in used_langs {
                match cost_models.get(&lang) {
                    Some(cost) => {
                        retained_cost_models.insert(&lang, &cost);
                    }
                    _ => {
                        return Err(JsError::from_str(&format!(
                            "Missing cost model for language version: {:?}",
                            lang
                        )))
                    }
                }
            }
            self.script_data_hash = Some(hash_script_data(
                &redeemers,
                &retained_cost_models,
                datums,
            ));
        }
        Ok(())
    }

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.