cardano_serialization_lib/protocol_types/
protocol_param_update.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
use crate::*;

#[wasm_bindgen]
#[derive(
    Clone,
    Debug,
    Hash,
    Eq,
    Ord,
    PartialEq,
    PartialOrd,
    serde::Serialize,
    serde::Deserialize,
    JsonSchema,
)]
pub struct PoolVotingThresholds {
    pub(crate) motion_no_confidence: UnitInterval,
    pub(crate) committee_normal: UnitInterval,
    pub(crate) committee_no_confidence: UnitInterval,
    pub(crate) hard_fork_initiation: UnitInterval,
    pub(crate) security_relevant_threshold: UnitInterval,
}

impl_to_from!(PoolVotingThresholds);

#[wasm_bindgen]
impl PoolVotingThresholds {
    pub fn new(
        motion_no_confidence: &UnitInterval,
        committee_normal: &UnitInterval,
        committee_no_confidence: &UnitInterval,
        hard_fork_initiation: &UnitInterval,
        security_relevant_threshold: &UnitInterval,
    ) -> Self {
        Self {
            motion_no_confidence: motion_no_confidence.clone(),
            committee_normal: committee_normal.clone(),
            committee_no_confidence: committee_no_confidence.clone(),
            hard_fork_initiation: hard_fork_initiation.clone(),
            security_relevant_threshold: security_relevant_threshold.clone(),
        }
    }

    pub fn motion_no_confidence(&self) -> UnitInterval {
        self.motion_no_confidence.clone()
    }

    pub fn committee_normal(&self) -> UnitInterval {
        self.committee_normal.clone()
    }

    pub fn committee_no_confidence(&self) -> UnitInterval {
        self.committee_no_confidence.clone()
    }

    pub fn hard_fork_initiation(&self) -> UnitInterval {
        self.hard_fork_initiation.clone()
    }

    pub fn security_relevant_threshold(&self) -> UnitInterval {
        self.security_relevant_threshold.clone()
    }
}

#[wasm_bindgen]
#[derive(
    Clone,
    Debug,
    Hash,
    Eq,
    Ord,
    PartialEq,
    PartialOrd,
    Default,
    serde::Serialize,
    serde::Deserialize,
    JsonSchema,
)]
pub struct DRepVotingThresholds {
    pub(crate) motion_no_confidence: UnitInterval,
    pub(crate) committee_normal: UnitInterval,
    pub(crate) committee_no_confidence: UnitInterval,
    pub(crate) update_constitution: UnitInterval,
    pub(crate) hard_fork_initiation: UnitInterval,
    pub(crate) pp_network_group: UnitInterval,
    pub(crate) pp_economic_group: UnitInterval,
    pub(crate) pp_technical_group: UnitInterval,
    pub(crate) pp_governance_group: UnitInterval,
    pub(crate) treasury_withdrawal: UnitInterval,
}

impl_to_from!(DRepVotingThresholds);

#[wasm_bindgen]
impl DRepVotingThresholds {
    pub fn new(
        motion_no_confidence: &UnitInterval,
        committee_normal: &UnitInterval,
        committee_no_confidence: &UnitInterval,
        update_constitution: &UnitInterval,
        hard_fork_initiation: &UnitInterval,
        pp_network_group: &UnitInterval,
        pp_economic_group: &UnitInterval,
        pp_technical_group: &UnitInterval,
        pp_governance_group: &UnitInterval,
        treasury_withdrawal: &UnitInterval,
    ) -> Self {
        Self {
            motion_no_confidence: motion_no_confidence.clone(),
            committee_normal: committee_normal.clone(),
            committee_no_confidence: committee_no_confidence.clone(),
            update_constitution: update_constitution.clone(),
            hard_fork_initiation: hard_fork_initiation.clone(),
            pp_network_group: pp_network_group.clone(),
            pp_economic_group: pp_economic_group.clone(),
            pp_technical_group: pp_technical_group.clone(),
            pp_governance_group: pp_governance_group.clone(),
            treasury_withdrawal: treasury_withdrawal.clone(),
        }
    }

    pub fn set_motion_no_confidence(&mut self, motion_no_confidence: &UnitInterval) {
        self.motion_no_confidence = motion_no_confidence.clone()
    }

    pub fn set_committee_normal(&mut self, committee_normal: &UnitInterval) {
        self.committee_normal = committee_normal.clone()
    }

    pub fn set_committee_no_confidence(&mut self, committee_no_confidence: &UnitInterval) {
        self.committee_no_confidence = committee_no_confidence.clone()
    }

    pub fn set_update_constitution(&mut self, update_constitution: &UnitInterval) {
        self.update_constitution = update_constitution.clone()
    }

    pub fn set_hard_fork_initiation(&mut self, hard_fork_initiation: &UnitInterval) {
        self.hard_fork_initiation = hard_fork_initiation.clone()
    }

    pub fn set_pp_network_group(&mut self, pp_network_group: &UnitInterval) {
        self.pp_network_group = pp_network_group.clone()
    }

    pub fn set_pp_economic_group(&mut self, pp_economic_group: &UnitInterval) {
        self.pp_economic_group = pp_economic_group.clone()
    }

    pub fn set_pp_technical_group(&mut self, pp_technical_group: &UnitInterval) {
        self.pp_technical_group = pp_technical_group.clone()
    }

    pub fn set_pp_governance_group(&mut self, pp_governance_group: &UnitInterval) {
        self.pp_governance_group = pp_governance_group.clone()
    }

    pub fn set_treasury_withdrawal(&mut self, treasury_withdrawal: &UnitInterval) {
        self.treasury_withdrawal = treasury_withdrawal.clone()
    }

    pub fn motion_no_confidence(&self) -> UnitInterval {
        self.motion_no_confidence.clone()
    }

    pub fn committee_normal(&self) -> UnitInterval {
        self.committee_normal.clone()
    }

    pub fn committee_no_confidence(&self) -> UnitInterval {
        self.committee_no_confidence.clone()
    }

    pub fn update_constitution(&self) -> UnitInterval {
        self.update_constitution.clone()
    }

    pub fn hard_fork_initiation(&self) -> UnitInterval {
        self.hard_fork_initiation.clone()
    }

    pub fn pp_network_group(&self) -> UnitInterval {
        self.pp_network_group.clone()
    }

    pub fn pp_economic_group(&self) -> UnitInterval {
        self.pp_economic_group.clone()
    }

    pub fn pp_technical_group(&self) -> UnitInterval {
        self.pp_technical_group.clone()
    }

    pub fn pp_governance_group(&self) -> UnitInterval {
        self.pp_governance_group.clone()
    }

    pub fn treasury_withdrawal(&self) -> UnitInterval {
        self.treasury_withdrawal.clone()
    }
}

#[wasm_bindgen]
#[derive(
    Clone,
    Debug,
    Hash,
    Eq,
    Ord,
    PartialEq,
    PartialOrd,
    serde::Serialize,
    serde::Deserialize,
    JsonSchema,
)]
pub struct ProtocolParamUpdate {
    pub(crate) minfee_a: Option<Coin>,
    pub(crate) minfee_b: Option<Coin>,
    pub(crate) max_block_body_size: Option<u32>,
    pub(crate) max_tx_size: Option<u32>,
    pub(crate) max_block_header_size: Option<u32>,
    pub(crate) key_deposit: Option<Coin>,
    pub(crate) pool_deposit: Option<Coin>,
    pub(crate) max_epoch: Option<Epoch>,
    // desired number of stake pools
    pub(crate) n_opt: Option<u32>,
    pub(crate) pool_pledge_influence: Option<UnitInterval>,
    pub(crate) expansion_rate: Option<UnitInterval>,
    pub(crate) treasury_growth_rate: Option<UnitInterval>,
    // decentralization constant
    pub(crate) d: Option<UnitInterval>,
    pub(crate) extra_entropy: Option<Nonce>,
    pub(crate) protocol_version: Option<ProtocolVersion>,
    pub(crate) min_pool_cost: Option<Coin>,
    pub(crate) ada_per_utxo_byte: Option<Coin>,
    pub(crate) cost_models: Option<Costmdls>,
    pub(crate) execution_costs: Option<ExUnitPrices>,
    pub(crate) max_tx_ex_units: Option<ExUnits>,
    pub(crate) max_block_ex_units: Option<ExUnits>,
    pub(crate) max_value_size: Option<u32>,
    pub(crate) collateral_percentage: Option<u32>,
    pub(crate) max_collateral_inputs: Option<u32>,
    pub(crate) pool_voting_thresholds: Option<PoolVotingThresholds>,
    pub(crate) drep_voting_thresholds: Option<DRepVotingThresholds>,
    pub(crate) min_committee_size: Option<u32>,
    pub(crate) committee_term_limit: Option<Epoch>,
    pub(crate) governance_action_validity_period: Option<Epoch>,
    pub(crate) governance_action_deposit: Option<Coin>,
    pub(crate) drep_deposit: Option<Coin>,
    pub(crate) drep_inactivity_period: Option<Epoch>,
    pub(crate) ref_script_coins_per_byte: Option<UnitInterval>,
}

impl_to_from!(ProtocolParamUpdate);

#[wasm_bindgen]
impl ProtocolParamUpdate {
    pub fn set_minfee_a(&mut self, minfee_a: &Coin) {
        self.minfee_a = Some(minfee_a.clone())
    }

    pub fn minfee_a(&self) -> Option<Coin> {
        self.minfee_a.clone()
    }

    pub fn set_minfee_b(&mut self, minfee_b: &Coin) {
        self.minfee_b = Some(minfee_b.clone())
    }

    pub fn minfee_b(&self) -> Option<Coin> {
        self.minfee_b.clone()
    }

    pub fn set_max_block_body_size(&mut self, max_block_body_size: u32) {
        self.max_block_body_size = Some(max_block_body_size)
    }

    pub fn max_block_body_size(&self) -> Option<u32> {
        self.max_block_body_size.clone()
    }

    pub fn set_max_tx_size(&mut self, max_tx_size: u32) {
        self.max_tx_size = Some(max_tx_size)
    }

    pub fn max_tx_size(&self) -> Option<u32> {
        self.max_tx_size.clone()
    }

    pub fn set_max_block_header_size(&mut self, max_block_header_size: u32) {
        self.max_block_header_size = Some(max_block_header_size)
    }

    pub fn max_block_header_size(&self) -> Option<u32> {
        self.max_block_header_size.clone()
    }

    pub fn set_key_deposit(&mut self, key_deposit: &Coin) {
        self.key_deposit = Some(key_deposit.clone())
    }

    pub fn key_deposit(&self) -> Option<Coin> {
        self.key_deposit.clone()
    }

    pub fn set_pool_deposit(&mut self, pool_deposit: &Coin) {
        self.pool_deposit = Some(pool_deposit.clone())
    }

    pub fn pool_deposit(&self) -> Option<Coin> {
        self.pool_deposit.clone()
    }

    pub fn set_max_epoch(&mut self, max_epoch: Epoch) {
        self.max_epoch = Some(max_epoch.clone())
    }

    pub fn max_epoch(&self) -> Option<Epoch> {
        self.max_epoch.clone()
    }

    pub fn set_n_opt(&mut self, n_opt: u32) {
        self.n_opt = Some(n_opt)
    }

    pub fn n_opt(&self) -> Option<u32> {
        self.n_opt.clone()
    }

    pub fn set_pool_pledge_influence(&mut self, pool_pledge_influence: &UnitInterval) {
        self.pool_pledge_influence = Some(pool_pledge_influence.clone())
    }

    pub fn pool_pledge_influence(&self) -> Option<UnitInterval> {
        self.pool_pledge_influence.clone()
    }

    pub fn set_expansion_rate(&mut self, expansion_rate: &UnitInterval) {
        self.expansion_rate = Some(expansion_rate.clone())
    }

    pub fn expansion_rate(&self) -> Option<UnitInterval> {
        self.expansion_rate.clone()
    }

    pub fn set_treasury_growth_rate(&mut self, treasury_growth_rate: &UnitInterval) {
        self.treasury_growth_rate = Some(treasury_growth_rate.clone())
    }

    pub fn treasury_growth_rate(&self) -> Option<UnitInterval> {
        self.treasury_growth_rate.clone()
    }

    /// !!! DEPRECATED !!!
    /// Since babbage era this param is outdated. But this param you can meet in a pre-babbage block.
    #[deprecated(
        since = "11.0.0",
        note = "Since babbage era this param is outdated. But this param you can meet in a pre-babbage block."
    )]
    pub fn d(&self) -> Option<UnitInterval> {
        self.d.clone()
    }

    /// !!! DEPRECATED !!!
    /// Since babbage era this param is outdated. But this param you can meet in a pre-babbage block.
    #[deprecated(
        since = "11.0.0",
        note = "Since babbage era this param is outdated. But this param you can meet in a pre-babbage block."
    )]
    pub fn extra_entropy(&self) -> Option<Nonce> {
        self.extra_entropy.clone()
    }

    /// !!! DEPRECATED !!!
    /// Since conway era this param is outdated. But this param you can meet in a pre-conway block.
    #[deprecated(
        since = "12.0.0",
        note = "Since conway era this param is outdated. But this param you can meet in a pre-conway block."
    )]
    pub fn set_protocol_version(&mut self, protocol_version: &ProtocolVersion) {
        self.protocol_version = Some(protocol_version.clone())
    }

    pub fn protocol_version(&self) -> Option<ProtocolVersion> {
        self.protocol_version.clone()
    }

    pub fn set_min_pool_cost(&mut self, min_pool_cost: &Coin) {
        self.min_pool_cost = Some(min_pool_cost.clone())
    }

    pub fn min_pool_cost(&self) -> Option<Coin> {
        self.min_pool_cost.clone()
    }

    pub fn set_ada_per_utxo_byte(&mut self, ada_per_utxo_byte: &Coin) {
        self.ada_per_utxo_byte = Some(ada_per_utxo_byte.clone())
    }

    pub fn ada_per_utxo_byte(&self) -> Option<Coin> {
        self.ada_per_utxo_byte.clone()
    }

    pub fn set_cost_models(&mut self, cost_models: &Costmdls) {
        self.cost_models = Some(cost_models.clone())
    }

    pub fn cost_models(&self) -> Option<Costmdls> {
        self.cost_models.clone()
    }

    pub fn set_execution_costs(&mut self, execution_costs: &ExUnitPrices) {
        self.execution_costs = Some(execution_costs.clone())
    }

    pub fn execution_costs(&self) -> Option<ExUnitPrices> {
        self.execution_costs.clone()
    }

    pub fn set_max_tx_ex_units(&mut self, max_tx_ex_units: &ExUnits) {
        self.max_tx_ex_units = Some(max_tx_ex_units.clone())
    }

    pub fn max_tx_ex_units(&self) -> Option<ExUnits> {
        self.max_tx_ex_units.clone()
    }

    pub fn set_max_block_ex_units(&mut self, max_block_ex_units: &ExUnits) {
        self.max_block_ex_units = Some(max_block_ex_units.clone())
    }

    pub fn max_block_ex_units(&self) -> Option<ExUnits> {
        self.max_block_ex_units.clone()
    }

    pub fn set_max_value_size(&mut self, max_value_size: u32) {
        self.max_value_size = Some(max_value_size.clone())
    }

    pub fn max_value_size(&self) -> Option<u32> {
        self.max_value_size.clone()
    }

    pub fn set_collateral_percentage(&mut self, collateral_percentage: u32) {
        self.collateral_percentage = Some(collateral_percentage)
    }

    pub fn collateral_percentage(&self) -> Option<u32> {
        self.collateral_percentage.clone()
    }

    pub fn set_max_collateral_inputs(&mut self, max_collateral_inputs: u32) {
        self.max_collateral_inputs = Some(max_collateral_inputs)
    }

    pub fn max_collateral_inputs(&self) -> Option<u32> {
        self.max_collateral_inputs.clone()
    }

    pub fn set_pool_voting_thresholds(&mut self, pool_voting_thresholds: &PoolVotingThresholds) {
        self.pool_voting_thresholds = Some(pool_voting_thresholds.clone())
    }

    pub fn pool_voting_thresholds(&self) -> Option<PoolVotingThresholds> {
        self.pool_voting_thresholds.clone()
    }

    pub fn set_drep_voting_thresholds(&mut self, drep_voting_thresholds: &DRepVotingThresholds) {
        self.drep_voting_thresholds = Some(drep_voting_thresholds.clone())
    }

    pub fn drep_voting_thresholds(&self) -> Option<DRepVotingThresholds> {
        self.drep_voting_thresholds.clone()
    }

    pub fn set_min_committee_size(&mut self, min_committee_size: u32) {
        self.min_committee_size = Some(min_committee_size)
    }

    pub fn min_committee_size(&self) -> Option<u32> {
        self.min_committee_size.clone()
    }

    pub fn set_committee_term_limit(&mut self, committee_term_limit: Epoch) {
        self.committee_term_limit = Some(committee_term_limit)
    }

    pub fn committee_term_limit(&self) -> Option<Epoch> {
        self.committee_term_limit.clone()
    }

    pub fn set_governance_action_validity_period(&mut self, governance_action_validity_period: Epoch) {
        self.governance_action_validity_period = Some(governance_action_validity_period)
    }

    pub fn governance_action_validity_period(&self) -> Option<Epoch> {
        self.governance_action_validity_period.clone()
    }

    pub fn set_governance_action_deposit(&mut self, governance_action_deposit: &Coin) {
        self.governance_action_deposit = Some(governance_action_deposit.clone());
    }

    pub fn governance_action_deposit(&self) -> Option<Coin> {
        self.governance_action_deposit.clone()
    }

    pub fn set_drep_deposit(&mut self, drep_deposit: &Coin) {
        self.drep_deposit = Some(drep_deposit.clone());
    }

    pub fn drep_deposit(&self) -> Option<Coin> {
        self.drep_deposit.clone()
    }

    pub fn set_drep_inactivity_period(&mut self, drep_inactivity_period: Epoch) {
        self.drep_inactivity_period = Some(drep_inactivity_period)
    }

    pub fn drep_inactivity_period(&self) -> Option<Epoch> {
        self.drep_inactivity_period.clone()
    }

    pub fn set_ref_script_coins_per_byte(&mut self, ref_script_coins_per_byte: &UnitInterval) {
        self.ref_script_coins_per_byte = Some(ref_script_coins_per_byte.clone());
    }

    pub fn ref_script_coins_per_byte(&self) -> Option<UnitInterval> {
        self.ref_script_coins_per_byte.clone()
    }

    pub fn new() -> Self {
        Self {
            minfee_a: None,
            minfee_b: None,
            max_block_body_size: None,
            max_tx_size: None,
            max_block_header_size: None,
            key_deposit: None,
            pool_deposit: None,
            max_epoch: None,
            n_opt: None,
            pool_pledge_influence: None,
            expansion_rate: None,
            treasury_growth_rate: None,
            d: None,
            extra_entropy: None,
            protocol_version: None,
            min_pool_cost: None,
            ada_per_utxo_byte: None,
            cost_models: None,
            execution_costs: None,
            max_tx_ex_units: None,
            max_block_ex_units: None,
            max_value_size: None,
            collateral_percentage: None,
            max_collateral_inputs: None,
            pool_voting_thresholds: None,
            drep_voting_thresholds: None,
            min_committee_size: None,
            committee_term_limit: None,
            governance_action_validity_period: None,
            governance_action_deposit: None,
            drep_deposit: None,
            drep_inactivity_period: None,
            ref_script_coins_per_byte: None,
        }
    }
}