@@ -228,7 +228,7 @@ impl TransactionKind {
228228/// =/ %d02 change-epoch-v3 ; ChangeEpochV3
229229/// =/ %d03 change-epoch-v4 ; ChangeEpochV4
230230/// ```
231- #[ derive( Clone , Debug , PartialEq , Eq ) ]
231+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
232232#[ cfg_attr( feature = "proptest" , derive( test_strategy:: Arbitrary ) ) ]
233233#[ cfg_attr( feature = "bcs-schema" , derive( iota_bcs_schema:: BcsSchema ) ) ]
234234#[ non_exhaustive]
@@ -244,7 +244,130 @@ pub enum EndOfEpochTransactionKind {
244244}
245245
246246impl EndOfEpochTransactionKind {
247- crate :: def_is_as_into_opt!( ChangeEpoch , ChangeEpochV2 ) ;
247+ crate :: def_is_as_into_opt!( ChangeEpoch , ChangeEpochV2 , ChangeEpochV3 , ChangeEpochV4 , ) ;
248+
249+ /// Creates a [`ChangeEpoch`] end-of-epoch transaction kind.
250+ #[ expect( clippy:: too_many_arguments) ]
251+ pub fn new_change_epoch (
252+ next_epoch : EpochId ,
253+ protocol_version : ProtocolVersion ,
254+ storage_charge : u64 ,
255+ computation_charge : u64 ,
256+ storage_rebate : u64 ,
257+ non_refundable_storage_fee : u64 ,
258+ epoch_start_timestamp_ms : u64 ,
259+ system_packages : Vec < SystemPackage > ,
260+ ) -> Self {
261+ Self :: ChangeEpoch ( ChangeEpoch {
262+ epoch : next_epoch,
263+ protocol_version,
264+ storage_charge,
265+ computation_charge,
266+ storage_rebate,
267+ non_refundable_storage_fee,
268+ epoch_start_timestamp_ms,
269+ system_packages,
270+ } )
271+ }
272+
273+ /// Creates a [`ChangeEpochV2`] end-of-epoch transaction kind.
274+ #[ expect( clippy:: too_many_arguments) ]
275+ pub fn new_change_epoch_v2 (
276+ next_epoch : EpochId ,
277+ protocol_version : ProtocolVersion ,
278+ storage_charge : u64 ,
279+ computation_charge : u64 ,
280+ computation_charge_burned : u64 ,
281+ storage_rebate : u64 ,
282+ non_refundable_storage_fee : u64 ,
283+ epoch_start_timestamp_ms : u64 ,
284+ system_packages : Vec < SystemPackage > ,
285+ ) -> Self {
286+ Self :: ChangeEpochV2 ( ChangeEpochV2 {
287+ epoch : next_epoch,
288+ protocol_version,
289+ storage_charge,
290+ computation_charge,
291+ computation_charge_burned,
292+ storage_rebate,
293+ non_refundable_storage_fee,
294+ epoch_start_timestamp_ms,
295+ system_packages,
296+ } )
297+ }
298+
299+ /// Creates a [`ChangeEpochV3`] end-of-epoch transaction kind.
300+ #[ expect( clippy:: too_many_arguments) ]
301+ pub fn new_change_epoch_v3 (
302+ next_epoch : EpochId ,
303+ protocol_version : ProtocolVersion ,
304+ storage_charge : u64 ,
305+ computation_charge : u64 ,
306+ computation_charge_burned : u64 ,
307+ storage_rebate : u64 ,
308+ non_refundable_storage_fee : u64 ,
309+ epoch_start_timestamp_ms : u64 ,
310+ system_packages : Vec < SystemPackage > ,
311+ eligible_active_validators : Vec < u64 > ,
312+ ) -> Self {
313+ Self :: ChangeEpochV3 ( ChangeEpochV3 {
314+ epoch : next_epoch,
315+ protocol_version,
316+ storage_charge,
317+ computation_charge,
318+ computation_charge_burned,
319+ storage_rebate,
320+ non_refundable_storage_fee,
321+ epoch_start_timestamp_ms,
322+ system_packages,
323+ eligible_active_validators,
324+ } )
325+ }
326+
327+ /// Creates a [`ChangeEpochV4`] end-of-epoch transaction kind.
328+ #[ expect( clippy:: too_many_arguments) ]
329+ pub fn new_change_epoch_v4 (
330+ next_epoch : EpochId ,
331+ protocol_version : ProtocolVersion ,
332+ storage_charge : u64 ,
333+ computation_charge : u64 ,
334+ computation_charge_burned : u64 ,
335+ storage_rebate : u64 ,
336+ non_refundable_storage_fee : u64 ,
337+ epoch_start_timestamp_ms : u64 ,
338+ system_packages : Vec < SystemPackage > ,
339+ eligible_active_validators : Vec < u64 > ,
340+ scores : Vec < u64 > ,
341+ adjust_rewards_by_score : bool ,
342+ ) -> Self {
343+ Self :: ChangeEpochV4 ( ChangeEpochV4 {
344+ epoch : next_epoch,
345+ protocol_version,
346+ storage_charge,
347+ computation_charge,
348+ computation_charge_burned,
349+ storage_rebate,
350+ non_refundable_storage_fee,
351+ epoch_start_timestamp_ms,
352+ system_packages,
353+ eligible_active_validators,
354+ scores,
355+ adjust_rewards_by_score,
356+ } )
357+ }
358+
359+ /// Returns an iterator over the shared input objects required by this
360+ /// transaction kind.
361+ pub fn shared_input_objects ( & self ) -> impl Iterator < Item = SharedObjectReference > + ' _ {
362+ match self {
363+ Self :: ChangeEpoch ( _)
364+ | Self :: ChangeEpochV2 ( _)
365+ | Self :: ChangeEpochV3 ( _)
366+ | Self :: ChangeEpochV4 ( _) => {
367+ vec ! [ SharedObjectReference :: IOTA_SYSTEM_STATE_OBJ_MUTABLE ] . into_iter ( )
368+ }
369+ }
370+ }
248371}
249372
250373#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -362,7 +485,7 @@ pub struct ConsensusCommitPrologueV1 {
362485/// u64 ; epoch start timestamp
363486/// (vector system-package)
364487/// ```
365- #[ derive( Clone , Debug , PartialEq , Eq ) ]
488+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
366489#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
367490#[ cfg_attr( feature = "proptest" , derive( test_strategy:: Arbitrary ) ) ]
368491#[ cfg_attr( feature = "bcs-schema" , derive( iota_bcs_schema:: BcsSchema ) ) ]
@@ -417,7 +540,7 @@ pub struct ChangeEpoch {
417540/// u64 ; epoch start timestamp
418541/// (vector system-package)
419542/// ```
420- #[ derive( Clone , Debug , PartialEq , Eq ) ]
543+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
421544#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
422545#[ cfg_attr( feature = "proptest" , derive( test_strategy:: Arbitrary ) ) ]
423546#[ cfg_attr( feature = "bcs-schema" , derive( iota_bcs_schema:: BcsSchema ) ) ]
@@ -458,7 +581,7 @@ pub struct ChangeEpochV2 {
458581 pub system_packages : Vec < SystemPackage > ,
459582}
460583
461- #[ derive( Clone , Debug , PartialEq , Eq ) ]
584+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
462585#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
463586#[ cfg_attr( feature = "proptest" , derive( test_strategy:: Arbitrary ) ) ]
464587#[ cfg_attr( feature = "bcs-schema" , derive( iota_bcs_schema:: BcsSchema ) ) ]
@@ -502,7 +625,7 @@ pub struct ChangeEpochV3 {
502625 pub eligible_active_validators : Vec < u64 > ,
503626}
504627
505- #[ derive( Clone , Debug , PartialEq , Eq ) ]
628+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
506629#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
507630#[ cfg_attr( feature = "proptest" , derive( test_strategy:: Arbitrary ) ) ]
508631#[ cfg_attr( feature = "bcs-schema" , derive( iota_bcs_schema:: BcsSchema ) ) ]
@@ -551,7 +674,7 @@ pub struct ChangeEpochV4 {
551674 pub adjust_rewards_by_score : bool ,
552675}
553676
554- #[ derive( Clone , Debug , PartialEq , Eq ) ]
677+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
555678#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
556679#[ cfg_attr( feature = "proptest" , derive( test_strategy:: Arbitrary ) ) ]
557680#[ cfg_attr( feature = "bcs-schema" , derive( iota_bcs_schema:: BcsSchema ) ) ]
0 commit comments