@@ -24,8 +24,8 @@ use crate::{
2424 domain:: { AddDomainsVotes , DomainRegistry } ,
2525 key_state:: { AuthenticatedAccountId , AuthenticatedParticipantId , KeyForDomain , Keyset } ,
2626 participants:: { ParticipantInfo , Participants } ,
27- threshold_votes:: ThresholdParametersVotes ,
28- thresholds:: { ProposedThresholdParameters , ThresholdParameters } ,
27+ threshold_votes:: GovernanceThresholdParametersVotes ,
28+ thresholds:: { GovernanceThresholdParameters , ProposedGovernanceThresholdParameters } ,
2929 } ,
3030 state:: {
3131 ProtocolContractState ,
@@ -214,21 +214,23 @@ impl IntoContractType<Participants> for dtos::Participants {
214214 }
215215}
216216
217- impl TryIntoContractType < ThresholdParameters > for dtos:: ThresholdParameters {
217+ impl TryIntoContractType < GovernanceThresholdParameters > for dtos:: GovernanceThresholdParameters {
218218 type Error = Error ;
219219
220- fn try_into_contract_type ( self ) -> Result < ThresholdParameters , Self :: Error > {
220+ fn try_into_contract_type ( self ) -> Result < GovernanceThresholdParameters , Self :: Error > {
221221 // Validate eagerly at the DTO boundary so invalid proposal parameters are rejected here.
222- ThresholdParameters :: new ( self . participants . into_contract_type ( ) , self . threshold )
222+ GovernanceThresholdParameters :: new ( self . participants . into_contract_type ( ) , self . threshold )
223223 }
224224}
225225
226- impl TryIntoContractType < ProposedThresholdParameters > for dtos:: ProposedThresholdParameters {
226+ impl TryIntoContractType < ProposedGovernanceThresholdParameters >
227+ for dtos:: ProposedGovernanceThresholdParameters
228+ {
227229 type Error = Error ;
228230
229- fn try_into_contract_type ( self ) -> Result < ProposedThresholdParameters , Self :: Error > {
231+ fn try_into_contract_type ( self ) -> Result < ProposedGovernanceThresholdParameters , Self :: Error > {
230232 // Validates the inner threshold parameters; see the conversion above.
231- Ok ( ProposedThresholdParameters :: new (
233+ Ok ( ProposedGovernanceThresholdParameters :: new (
232234 self . parameters . try_into_contract_type ( ) ?,
233235 self . per_domain_thresholds ,
234236 ) )
@@ -584,14 +586,14 @@ mod test_conversions {
584586 }
585587 }
586588
587- impl From < ThresholdParameters > for dtos:: ThresholdParameters {
588- fn from ( params : ThresholdParameters ) -> Self {
589+ impl From < GovernanceThresholdParameters > for dtos:: GovernanceThresholdParameters {
590+ fn from ( params : GovernanceThresholdParameters ) -> Self {
589591 ( & params) . into_dto_type ( )
590592 }
591593 }
592594
593- impl From < ProposedThresholdParameters > for dtos:: ProposedThresholdParameters {
594- fn from ( params : ProposedThresholdParameters ) -> Self {
595+ impl From < ProposedGovernanceThresholdParameters > for dtos:: ProposedGovernanceThresholdParameters {
596+ fn from ( params : ProposedGovernanceThresholdParameters ) -> Self {
595597 ( & params) . into_dto_type ( )
596598 }
597599 }
@@ -686,18 +688,20 @@ impl IntoInterfaceType<dtos::Participants> for &Participants {
686688 }
687689}
688690
689- impl IntoInterfaceType < dtos:: ThresholdParameters > for & ThresholdParameters {
690- fn into_dto_type ( self ) -> dtos:: ThresholdParameters {
691- dtos:: ThresholdParameters {
691+ impl IntoInterfaceType < dtos:: GovernanceThresholdParameters > for & GovernanceThresholdParameters {
692+ fn into_dto_type ( self ) -> dtos:: GovernanceThresholdParameters {
693+ dtos:: GovernanceThresholdParameters {
692694 participants : self . participants ( ) . into_dto_type ( ) ,
693695 threshold : self . threshold ( ) ,
694696 }
695697 }
696698}
697699
698- impl IntoInterfaceType < dtos:: ProposedThresholdParameters > for & ProposedThresholdParameters {
699- fn into_dto_type ( self ) -> dtos:: ProposedThresholdParameters {
700- dtos:: ProposedThresholdParameters {
700+ impl IntoInterfaceType < dtos:: ProposedGovernanceThresholdParameters >
701+ for & ProposedGovernanceThresholdParameters
702+ {
703+ fn into_dto_type ( self ) -> dtos:: ProposedGovernanceThresholdParameters {
704+ dtos:: ProposedGovernanceThresholdParameters {
701705 parameters : self . parameters ( ) . into_dto_type ( ) ,
702706 per_domain_thresholds : self . per_domain_thresholds ( ) . clone ( ) ,
703707 }
@@ -706,14 +710,16 @@ impl IntoInterfaceType<dtos::ProposedThresholdParameters> for &ProposedThreshold
706710
707711// --- Voting types ---
708712
709- impl IntoInterfaceType < dtos:: ThresholdParametersVotes > for & ThresholdParametersVotes {
710- fn into_dto_type ( self ) -> dtos:: ThresholdParametersVotes {
713+ impl IntoInterfaceType < dtos:: GovernanceThresholdParametersVotes >
714+ for & GovernanceThresholdParametersVotes
715+ {
716+ fn into_dto_type ( self ) -> dtos:: GovernanceThresholdParametersVotes {
711717 let proposal_by_account = self
712718 . proposal_by_account
713719 . iter ( )
714720 . map ( |( account, params) | ( account. into_dto_type ( ) , params. into_dto_type ( ) ) )
715721 . collect ( ) ;
716- dtos:: ThresholdParametersVotes {
722+ dtos:: GovernanceThresholdParametersVotes {
717723 proposal_by_account,
718724 }
719725 }
@@ -868,7 +874,7 @@ mod tests {
868874 use super :: * ;
869875 use crate :: errors:: InvalidThreshold ;
870876 use crate :: primitives:: test_utils:: gen_participants;
871- use crate :: primitives:: thresholds:: Threshold ;
877+ use crate :: primitives:: thresholds:: GovernanceThreshold ;
872878 use assert_matches:: assert_matches;
873879
874880 const TEST_THRESHOLD : u64 = 2 ;
@@ -921,33 +927,40 @@ mod tests {
921927 }
922928
923929 /// Ensures that the JSON produced by serializing the internal
924- /// [`ThresholdParameters `] type can be deserialized into the DTO
925- /// [`dtos::ThresholdParameters `] type and vice versa, producing identical
930+ /// [`GovernanceThresholdParameters `] type can be deserialized into the DTO
931+ /// [`dtos::GovernanceThresholdParameters `] type and vice versa, producing identical
926932 /// JSON in both directions.
927933 #[ test]
928934 fn threshold_parameters_serde_is_compatible_with_dto ( ) {
929- let internal =
930- ThresholdParameters :: new ( test_participants ( ) , Threshold :: new ( TEST_THRESHOLD ) ) . unwrap ( ) ;
935+ let internal = GovernanceThresholdParameters :: new (
936+ test_participants ( ) ,
937+ GovernanceThreshold :: new ( TEST_THRESHOLD ) ,
938+ )
939+ . unwrap ( ) ;
931940 let json = serde_json:: to_value ( & internal) . unwrap ( ) ;
932941
933- let dto: dtos:: ThresholdParameters = serde_json:: from_value ( json. clone ( ) ) . unwrap ( ) ;
942+ let dto: dtos:: GovernanceThresholdParameters =
943+ serde_json:: from_value ( json. clone ( ) ) . unwrap ( ) ;
934944
935945 let dto_json = serde_json:: to_value ( & dto) . unwrap ( ) ;
936946 assert_eq ! ( json, dto_json, "Internal and DTO JSON must be identical" ) ;
937947
938- let roundtrip: ThresholdParameters = serde_json:: from_value ( dto_json) . unwrap ( ) ;
948+ let roundtrip: GovernanceThresholdParameters = serde_json:: from_value ( dto_json) . unwrap ( ) ;
939949 assert_eq ! ( internal, roundtrip) ;
940950 }
941951
942952 /// Verify that [`IntoInterfaceType::into_dto_type`] produces a DTO whose
943953 /// serialization matches the internal type's serialization.
944954 #[ test]
945955 fn into_dto_type_preserves_serialization ( ) {
946- let internal =
947- ThresholdParameters :: new ( test_participants ( ) , Threshold :: new ( TEST_THRESHOLD ) ) . unwrap ( ) ;
956+ let internal = GovernanceThresholdParameters :: new (
957+ test_participants ( ) ,
958+ GovernanceThreshold :: new ( TEST_THRESHOLD ) ,
959+ )
960+ . unwrap ( ) ;
948961 let internal_json = serde_json:: to_value ( & internal) . unwrap ( ) ;
949962
950- let dto: dtos:: ThresholdParameters = ( & internal) . into_dto_type ( ) ;
963+ let dto: dtos:: GovernanceThresholdParameters = ( & internal) . into_dto_type ( ) ;
951964 let dto_json = serde_json:: to_value ( & dto) . unwrap ( ) ;
952965
953966 assert_eq ! ( internal_json, dto_json) ;
@@ -958,13 +971,13 @@ mod tests {
958971 #[ test]
959972 fn try_into_contract_type__should_reject_threshold_below_relative_requirement ( ) {
960973 // Given a DTO with 5 participants and a threshold of 2 (below the 60% bound of 3).
961- let dto = dtos:: ThresholdParameters {
974+ let dto = dtos:: GovernanceThresholdParameters {
962975 participants : ( & gen_participants ( 5 ) ) . into_dto_type ( ) ,
963- threshold : Threshold :: new ( 2 ) ,
976+ threshold : GovernanceThreshold :: new ( 2 ) ,
964977 } ;
965978
966979 // When converting the DTO into the contract type.
967- let result: Result < ThresholdParameters , Error > = dto. try_into_contract_type ( ) ;
980+ let result: Result < GovernanceThresholdParameters , Error > = dto. try_into_contract_type ( ) ;
968981
969982 // Then conversion fails with the relative-threshold error.
970983 assert_matches ! (
0 commit comments