whisky_csl/
constants.rs

1use cardano_serialization_lib as csl;
2use whisky_common::*;
3
4pub fn build_csl_cost_models(network: &Network) -> csl::Costmdls {
5    let mut csl_cost_mdls = csl::Costmdls::new();
6    let cost_model_list = get_cost_models_from_network(network);
7    (0..cost_model_list.len()).for_each(|i| {
8        let current_cost_model = &cost_model_list[i];
9        if i == 0 {
10            csl_cost_mdls.insert(
11                &csl::Language::new_plutus_v1(),
12                &csl::CostModel::from(
13                    current_cost_model
14                        .iter()
15                        .map(|&i| i as i128)
16                        .collect::<Vec<i128>>(),
17                ),
18            );
19        }
20
21        if i == 1 {
22            csl_cost_mdls.insert(
23                &csl::Language::new_plutus_v2(),
24                &csl::CostModel::from(
25                    current_cost_model
26                        .iter()
27                        .map(|&i| i as i128)
28                        .collect::<Vec<i128>>(),
29                ),
30            );
31        }
32
33        if i == 2 {
34            csl_cost_mdls.insert(
35                &csl::Language::new_plutus_v3(),
36                &csl::CostModel::from(
37                    current_cost_model
38                        .iter()
39                        .map(|&i| i as i128)
40                        .collect::<Vec<i128>>(),
41                ),
42            );
43        }
44    });
45
46    csl_cost_mdls
47}