diff --git a/pallets/schemas/src/lib.rs b/pallets/schemas/src/lib.rs index ecb3cff04f..4151512c8e 100644 --- a/pallets/schemas/src/lib.rs +++ b/pallets/schemas/src/lib.rs @@ -838,6 +838,13 @@ pub mod pallet { payload_location == PayloadLocation::Itemized, Error::::InvalidSetting ); + // SignatureRequired is only valid for Itemized and Paginated payload locations + ensure!( + !settings.contains(&SchemaSetting::SignatureRequired) || + payload_location == PayloadLocation::Itemized || + payload_location == PayloadLocation::Paginated, + Error::::InvalidSetting + ); let schema_name = match optional_schema_name { None => None, Some(name_payload) => { diff --git a/pallets/schemas/src/tests/other_tests.rs b/pallets/schemas/src/tests/other_tests.rs index b205913131..1852b1414f 100644 --- a/pallets/schemas/src/tests/other_tests.rs +++ b/pallets/schemas/src/tests/other_tests.rs @@ -756,7 +756,33 @@ fn create_schema_via_governance_v2_with_append_only_setting_and_non_itemized_sho ); }) } +#[test] +fn create_schema_via_governance_v2_with_signature_required_setting_and_wrong_location_should_fail() +{ + new_test_ext().execute_with(|| { + sudo_set_max_schema_size(); + + // arrange + let settings = vec![SchemaSetting::SignatureRequired]; + let sender: AccountId = test_public(1); + for location in vec![PayloadLocation::OnChain, PayloadLocation::IPFS] { + // act and assert + assert_noop!( + SchemasPallet::create_schema_via_governance_v2( + RuntimeOrigin::from(pallet_collective::RawOrigin::Members(2, 3)), + sender.clone(), + create_bounded_schema_vec(r#"{"name":"John Doe"}"#), + ModelType::AvroBinary, + location, + BoundedVec::try_from(settings.clone()).unwrap(), + None, + ), + Error::::InvalidSetting + ); + } + }) +} /// Test that a request to be a provider, makes the MSA a provider after the council approves it. #[test] fn propose_to_create_schema_v2_happy_path() { diff --git a/runtime/frequency/src/lib.rs b/runtime/frequency/src/lib.rs index 7cda39cfca..950b4f88ae 100644 --- a/runtime/frequency/src/lib.rs +++ b/runtime/frequency/src/lib.rs @@ -375,7 +375,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("frequency"), impl_name: create_runtime_str!("frequency"), authoring_version: 1, - spec_version: 111, + spec_version: 112, impl_version: 0, apis: apis::RUNTIME_API_VERSIONS, transaction_version: 1, @@ -389,7 +389,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("frequency-testnet"), impl_name: create_runtime_str!("frequency"), authoring_version: 1, - spec_version: 111, + spec_version: 112, impl_version: 0, apis: apis::RUNTIME_API_VERSIONS, transaction_version: 1,