@@ -3,6 +3,27 @@ use utxorpc_spec::utxorpc::v1alpha::cardano as u5c;
3
3
4
4
use crate :: { LedgerContext , Mapper } ;
5
5
6
+ fn rational_number_to_u5c ( value : pallas_primitives:: RationalNumber ) -> u5c:: RationalNumber {
7
+ u5c:: RationalNumber {
8
+ numerator : value. numerator as i32 ,
9
+ denominator : value. denominator as u32 ,
10
+ }
11
+ }
12
+
13
+ fn execution_prices_to_u5c ( value : pallas_primitives:: ExUnitPrices ) -> u5c:: ExPrices {
14
+ u5c:: ExPrices {
15
+ steps : Some ( rational_number_to_u5c ( value. step_price ) ) ,
16
+ memory : Some ( rational_number_to_u5c ( value. mem_price ) ) ,
17
+ }
18
+ }
19
+
20
+ fn execution_units_to_u5c ( value : pallas_primitives:: ExUnits ) -> u5c:: ExUnits {
21
+ u5c:: ExUnits {
22
+ memory : value. mem ,
23
+ steps : value. steps ,
24
+ }
25
+ }
26
+
6
27
impl < C : LedgerContext > Mapper < C > {
7
28
pub fn map_pparams ( & self , pparams : MultiEraProtocolParameters ) -> u5c:: PParams {
8
29
match pparams {
@@ -16,18 +37,9 @@ impl<C: LedgerContext> Mapper<C> {
16
37
stake_key_deposit : params. key_deposit ,
17
38
pool_deposit : params. pool_deposit ,
18
39
desired_number_of_pools : params. desired_number_of_stake_pools . into ( ) ,
19
- pool_influence : Some ( u5c:: RationalNumber {
20
- numerator : params. pool_pledge_influence . numerator as i32 ,
21
- denominator : params. pool_pledge_influence . denominator as u32 ,
22
- } ) ,
23
- monetary_expansion : Some ( u5c:: RationalNumber {
24
- numerator : params. expansion_rate . numerator as i32 ,
25
- denominator : params. expansion_rate . denominator as u32 ,
26
- } ) ,
27
- treasury_expansion : Some ( u5c:: RationalNumber {
28
- numerator : params. treasury_growth_rate . numerator as i32 ,
29
- denominator : params. treasury_growth_rate . denominator as u32 ,
30
- } ) ,
40
+ pool_influence : Some ( rational_number_to_u5c ( params. pool_pledge_influence ) ) ,
41
+ monetary_expansion : Some ( rational_number_to_u5c ( params. expansion_rate ) ) ,
42
+ treasury_expansion : Some ( rational_number_to_u5c ( params. treasury_growth_rate ) ) ,
31
43
min_pool_cost : params. min_pool_cost ,
32
44
protocol_version : Some ( u5c:: ProtocolVersion {
33
45
major : params. protocol_version . 0 as u32 ,
@@ -36,24 +48,13 @@ impl<C: LedgerContext> Mapper<C> {
36
48
max_value_size : params. max_value_size . into ( ) ,
37
49
collateral_percentage : params. collateral_percentage . into ( ) ,
38
50
max_collateral_inputs : params. max_collateral_inputs . into ( ) ,
39
- prices : Some ( u5c:: ExPrices {
40
- steps : Some ( u5c:: RationalNumber {
41
- numerator : params. execution_costs . step_price . numerator as i32 ,
42
- denominator : params. execution_costs . step_price . denominator as u32 ,
43
- } ) ,
44
- memory : Some ( u5c:: RationalNumber {
45
- numerator : params. execution_costs . mem_price . numerator as i32 ,
46
- denominator : params. execution_costs . mem_price . denominator as u32 ,
47
- } ) ,
48
- } ) ,
49
- max_execution_units_per_transaction : Some ( u5c:: ExUnits {
50
- memory : params. max_tx_ex_units . mem ,
51
- steps : params. max_tx_ex_units . steps ,
52
- } ) ,
53
- max_execution_units_per_block : Some ( u5c:: ExUnits {
54
- memory : params. max_block_ex_units . mem ,
55
- steps : params. max_block_ex_units . steps ,
56
- } ) ,
51
+ prices : Some ( execution_prices_to_u5c ( params. execution_costs ) ) ,
52
+ max_execution_units_per_transaction : Some ( execution_units_to_u5c (
53
+ params. max_tx_ex_units ,
54
+ ) ) ,
55
+ max_execution_units_per_block : Some ( execution_units_to_u5c (
56
+ params. max_block_ex_units ,
57
+ ) ) ,
57
58
cost_models : u5c:: CostModels {
58
59
// Only plutusv1.
59
60
plutus_v1 : params
@@ -76,18 +77,9 @@ impl<C: LedgerContext> Mapper<C> {
76
77
stake_key_deposit : params. key_deposit ,
77
78
pool_deposit : params. pool_deposit ,
78
79
desired_number_of_pools : params. desired_number_of_stake_pools . into ( ) ,
79
- pool_influence : Some ( u5c:: RationalNumber {
80
- numerator : params. pool_pledge_influence . numerator as i32 ,
81
- denominator : params. pool_pledge_influence . denominator as u32 ,
82
- } ) ,
83
- monetary_expansion : Some ( u5c:: RationalNumber {
84
- numerator : params. expansion_rate . numerator as i32 ,
85
- denominator : params. expansion_rate . denominator as u32 ,
86
- } ) ,
87
- treasury_expansion : Some ( u5c:: RationalNumber {
88
- numerator : params. treasury_growth_rate . numerator as i32 ,
89
- denominator : params. treasury_growth_rate . denominator as u32 ,
90
- } ) ,
80
+ pool_influence : Some ( rational_number_to_u5c ( params. pool_pledge_influence ) ) ,
81
+ monetary_expansion : Some ( rational_number_to_u5c ( params. expansion_rate ) ) ,
82
+ treasury_expansion : Some ( rational_number_to_u5c ( params. treasury_growth_rate ) ) ,
91
83
min_pool_cost : params. min_pool_cost ,
92
84
protocol_version : Some ( u5c:: ProtocolVersion {
93
85
major : params. protocol_version . 0 as u32 ,
@@ -105,19 +97,9 @@ impl<C: LedgerContext> Mapper<C> {
105
97
stake_key_deposit : params. key_deposit ,
106
98
pool_deposit : params. pool_deposit ,
107
99
desired_number_of_pools : params. desired_number_of_stake_pools . into ( ) ,
108
- pool_influence : Some ( u5c:: RationalNumber {
109
- numerator : params. pool_pledge_influence . numerator as i32 ,
110
- denominator : params. pool_pledge_influence . denominator as u32 ,
111
- } ) ,
112
- monetary_expansion : u5c:: RationalNumber {
113
- numerator : params. expansion_rate . numerator as i32 ,
114
- denominator : params. expansion_rate . denominator as u32 ,
115
- }
116
- . into ( ) ,
117
- treasury_expansion : Some ( u5c:: RationalNumber {
118
- numerator : params. treasury_growth_rate . numerator as i32 ,
119
- denominator : params. treasury_growth_rate . denominator as u32 ,
120
- } ) ,
100
+ pool_influence : Some ( rational_number_to_u5c ( params. pool_pledge_influence ) ) ,
101
+ monetary_expansion : Some ( rational_number_to_u5c ( params. expansion_rate ) ) ,
102
+ treasury_expansion : Some ( rational_number_to_u5c ( params. treasury_growth_rate ) ) ,
121
103
min_pool_cost : params. min_pool_cost ,
122
104
protocol_version : u5c:: ProtocolVersion {
123
105
major : params. protocol_version . 0 as u32 ,
@@ -127,24 +109,13 @@ impl<C: LedgerContext> Mapper<C> {
127
109
max_value_size : params. max_value_size . into ( ) ,
128
110
collateral_percentage : params. collateral_percentage . into ( ) ,
129
111
max_collateral_inputs : params. max_collateral_inputs . into ( ) ,
130
- prices : Some ( u5c:: ExPrices {
131
- steps : Some ( u5c:: RationalNumber {
132
- numerator : params. execution_costs . step_price . numerator as i32 ,
133
- denominator : params. execution_costs . step_price . denominator as u32 ,
134
- } ) ,
135
- memory : Some ( u5c:: RationalNumber {
136
- numerator : params. execution_costs . mem_price . numerator as i32 ,
137
- denominator : params. execution_costs . mem_price . denominator as u32 ,
138
- } ) ,
139
- } ) ,
140
- max_execution_units_per_transaction : Some ( u5c:: ExUnits {
141
- memory : params. max_tx_ex_units . mem ,
142
- steps : params. max_tx_ex_units . steps ,
143
- } ) ,
144
- max_execution_units_per_block : Some ( u5c:: ExUnits {
145
- memory : params. max_block_ex_units . mem ,
146
- steps : params. max_block_ex_units . steps ,
147
- } ) ,
112
+ prices : Some ( execution_prices_to_u5c ( params. execution_costs ) ) ,
113
+ max_execution_units_per_transaction : Some ( execution_units_to_u5c (
114
+ params. max_tx_ex_units ,
115
+ ) ) ,
116
+ max_execution_units_per_block : Some ( execution_units_to_u5c (
117
+ params. max_block_ex_units ,
118
+ ) ) ,
148
119
cost_models : u5c:: CostModels {
149
120
plutus_v1 : params
150
121
. cost_models_for_script_languages
@@ -175,19 +146,9 @@ impl<C: LedgerContext> Mapper<C> {
175
146
stake_key_deposit : params. key_deposit ,
176
147
pool_deposit : params. pool_deposit ,
177
148
desired_number_of_pools : params. desired_number_of_stake_pools . into ( ) ,
178
- pool_influence : Some ( u5c:: RationalNumber {
179
- numerator : params. pool_pledge_influence . numerator as i32 ,
180
- denominator : params. pool_pledge_influence . denominator as u32 ,
181
- } ) ,
182
- monetary_expansion : u5c:: RationalNumber {
183
- numerator : params. expansion_rate . numerator as i32 ,
184
- denominator : params. expansion_rate . denominator as u32 ,
185
- }
186
- . into ( ) ,
187
- treasury_expansion : Some ( u5c:: RationalNumber {
188
- numerator : params. treasury_growth_rate . numerator as i32 ,
189
- denominator : params. treasury_growth_rate . denominator as u32 ,
190
- } ) ,
149
+ pool_influence : Some ( rational_number_to_u5c ( params. pool_pledge_influence ) ) ,
150
+ monetary_expansion : Some ( rational_number_to_u5c ( params. expansion_rate ) ) ,
151
+ treasury_expansion : Some ( rational_number_to_u5c ( params. treasury_growth_rate ) ) ,
191
152
min_pool_cost : params. min_pool_cost ,
192
153
protocol_version : u5c:: ProtocolVersion {
193
154
major : params. protocol_version . 0 as u32 ,
@@ -197,24 +158,51 @@ impl<C: LedgerContext> Mapper<C> {
197
158
max_value_size : params. max_value_size . into ( ) ,
198
159
collateral_percentage : params. collateral_percentage . into ( ) ,
199
160
max_collateral_inputs : params. max_collateral_inputs . into ( ) ,
200
- prices : Some ( u5c:: ExPrices {
201
- steps : Some ( u5c:: RationalNumber {
202
- numerator : params. execution_costs . step_price . numerator as i32 ,
203
- denominator : params. execution_costs . step_price . denominator as u32 ,
204
- } ) ,
205
- memory : Some ( u5c:: RationalNumber {
206
- numerator : params. execution_costs . mem_price . numerator as i32 ,
207
- denominator : params. execution_costs . mem_price . denominator as u32 ,
208
- } ) ,
209
- } ) ,
210
- max_execution_units_per_transaction : Some ( u5c:: ExUnits {
211
- memory : params. max_tx_ex_units . mem ,
212
- steps : params. max_tx_ex_units . steps ,
213
- } ) ,
214
- max_execution_units_per_block : Some ( u5c:: ExUnits {
215
- memory : params. max_block_ex_units . mem ,
216
- steps : params. max_block_ex_units . steps ,
217
- } ) ,
161
+ prices : Some ( execution_prices_to_u5c ( params. execution_costs ) ) ,
162
+ max_execution_units_per_transaction : Some ( execution_units_to_u5c (
163
+ params. max_tx_ex_units ,
164
+ ) ) ,
165
+ max_execution_units_per_block : Some ( execution_units_to_u5c (
166
+ params. max_block_ex_units ,
167
+ ) ) ,
168
+ min_fee_script_ref_cost_per_byte : Some ( rational_number_to_u5c (
169
+ params. minfee_refscript_cost_per_byte ,
170
+ ) ) ,
171
+ pool_voting_thresholds : Some ( u5c:: VotingThresholds {
172
+ thresholds : vec ! [
173
+ rational_number_to_u5c( params. pool_voting_thresholds. motion_no_confidence) ,
174
+ rational_number_to_u5c( params. pool_voting_thresholds. committee_normal) ,
175
+ rational_number_to_u5c(
176
+ params. pool_voting_thresholds. committee_no_confidence,
177
+ ) ,
178
+ rational_number_to_u5c( params. pool_voting_thresholds. hard_fork_initiation) ,
179
+ rational_number_to_u5c(
180
+ params. pool_voting_thresholds. security_voting_threshold,
181
+ ) ,
182
+ ] ,
183
+ } ) ,
184
+ drep_voting_thresholds : Some ( u5c:: VotingThresholds {
185
+ thresholds : vec ! [
186
+ rational_number_to_u5c( params. drep_voting_thresholds. motion_no_confidence) ,
187
+ rational_number_to_u5c( params. drep_voting_thresholds. committee_normal) ,
188
+ rational_number_to_u5c(
189
+ params. drep_voting_thresholds. committee_no_confidence,
190
+ ) ,
191
+ rational_number_to_u5c( params. drep_voting_thresholds. update_constitution) ,
192
+ rational_number_to_u5c( params. drep_voting_thresholds. hard_fork_initiation) ,
193
+ rational_number_to_u5c( params. drep_voting_thresholds. pp_network_group) ,
194
+ rational_number_to_u5c( params. drep_voting_thresholds. pp_economic_group) ,
195
+ rational_number_to_u5c( params. drep_voting_thresholds. pp_technical_group) ,
196
+ rational_number_to_u5c( params. drep_voting_thresholds. pp_governance_group) ,
197
+ rational_number_to_u5c( params. drep_voting_thresholds. treasury_withdrawal) ,
198
+ ] ,
199
+ } ) ,
200
+ min_committee_size : params. min_committee_size as u32 ,
201
+ committee_term_limit : params. committee_term_limit ,
202
+ governance_action_validity_period : params. governance_action_validity_period ,
203
+ governance_action_deposit : params. governance_action_deposit ,
204
+ drep_deposit : params. drep_deposit ,
205
+ drep_inactivity_period : params. drep_inactivity_period ,
218
206
cost_models : u5c:: CostModels {
219
207
plutus_v1 : params
220
208
. cost_models_for_script_languages
@@ -224,10 +212,7 @@ impl<C: LedgerContext> Mapper<C> {
224
212
. cost_models_for_script_languages
225
213
. plutus_v2
226
214
. map ( |values| u5c:: CostModel { values } ) ,
227
- plutus_v3 : params
228
- . cost_models_for_script_languages
229
- . plutus_v3
230
- . map ( |values| u5c:: CostModel { values } ) ,
215
+ ..Default :: default ( )
231
216
}
232
217
. into ( ) ,
233
218
..Default :: default ( )
0 commit comments