Skip to content

Commit 2fb5317

Browse files
Thoralf-MDaughterOfMarsthibault-martinez
authored
feat(iota-sdk-types): EndOfEpochTransactionKind changes (#980) (#1106)
* feat(iota-sdk-types): EndOfEpochTransactionKind changes (#980) * feat(iota-sdk-types): EndOfEpochTransactionKind changes * order * add order warning * add shared_input_objects and comments * import position * new_authenticator_state_create doc comment * fix(types): Rename `BinaryEndOfEpochTransactionKindRef` for serde (#1028) Co-authored-by: Thibault Martinez <thibault@iota.org> * clippy expect --------- Co-authored-by: DaughterOfMars <chloedaughterofmars@gmail.com> Co-authored-by: Thibault Martinez <thibault@iota.org>
1 parent ac2e641 commit 2fb5317

5 files changed

Lines changed: 135 additions & 10 deletions

File tree

crates/iota-sdk-ffi/src/graphql/api/package.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl GraphQLClient {
137137
/// Return the normalized Move module data for the provided module.
138138
// TODO: do we want to self paginate everything and return all the data, or keep pagination
139139
// options?
140-
#[allow(clippy::too_many_arguments)]
140+
#[expect(clippy::too_many_arguments)]
141141
#[uniffi::method(default(
142142
version = None,
143143
pagination_filter_enums = None,

crates/iota-sdk-ffi/src/types/checkpoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub struct CheckpointSummary(pub iota_sdk::types::CheckpointSummary);
5858
#[uniffi::export]
5959
impl CheckpointSummary {
6060
#[uniffi::constructor]
61-
#[allow(clippy::too_many_arguments)]
61+
#[expect(clippy::too_many_arguments)]
6262
pub fn new(
6363
epoch: EpochId,
6464
sequence_number: CheckpointSequenceNumber,

crates/iota-sdk-graphql-client/src/api/package.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl Client {
192192
/// Return the normalized Move module data for the provided module.
193193
// TODO: do we want to self paginate everything and return all the data, or keep pagination
194194
// options?
195-
#[allow(clippy::too_many_arguments)]
195+
#[expect(clippy::too_many_arguments)]
196196
pub async fn normalized_move_module(
197197
&self,
198198
package: Address,

crates/iota-sdk-types/src/transaction/mod.rs

Lines changed: 130 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

246246
impl 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))]

crates/iota-sdk-types/src/transaction/serialization.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ mod end_of_epoch {
177177
}
178178

179179
#[derive(serde::Serialize)]
180+
#[serde(rename = "EndOfEpochTransactionKind")]
180181
enum BinaryEndOfEpochTransactionKindRef<'a> {
181182
ChangeEpoch(&'a ChangeEpoch),
182183
ChangeEpochV2(&'a ChangeEpochV2),
@@ -185,6 +186,7 @@ mod end_of_epoch {
185186
}
186187

187188
#[derive(serde::Deserialize)]
189+
#[serde(rename = "EndOfEpochTransactionKind")]
188190
enum BinaryEndOfEpochTransactionKind {
189191
ChangeEpoch(ChangeEpoch),
190192
ChangeEpochV2(ChangeEpochV2),

0 commit comments

Comments
 (0)