Skip to content

Commit

Permalink
chore: renaming approval prefrence (#781)
Browse files Browse the repository at this point in the history
* update types to 0.5.9

* fix testnet build

* fix: rename ApprovalPrefrence

* fix: rename ApprovalPrefrence
  • Loading branch information
1xstj authored Oct 3, 2024
1 parent 7c12d9e commit efb9f4d
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 75 deletions.
24 changes: 12 additions & 12 deletions pallets/services/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ benchmarks! {
let _= Pallet::<T>::create_blueprint(RawOrigin::Signed(alice.clone()).into(), blueprint);

let bob: T::AccountId = mock_account_id::<T>(2u8);
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() };

}: _(RawOrigin::Signed(bob.clone()), 0, operator_preference, Default::default())

Expand All @@ -81,7 +81,7 @@ benchmarks! {
let _= Pallet::<T>::create_blueprint(RawOrigin::Signed(alice.clone()).into(), blueprint);

let bob: T::AccountId = mock_account_id::<T>(2u8);
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() };

let _= Pallet::<T>::register(RawOrigin::Signed(bob.clone()).into(), 0, operator_preference, Default::default());

Expand All @@ -94,19 +94,19 @@ benchmarks! {
let _= Pallet::<T>::create_blueprint(RawOrigin::Signed(alice.clone()).into(), blueprint);

let bob: T::AccountId = mock_account_id::<T>(2u8);
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() };

let _= Pallet::<T>::register(RawOrigin::Signed(bob.clone()).into(), 0, operator_preference, Default::default());

}: _(RawOrigin::Signed(bob.clone()), 0, ApprovalPrefrence::Required)
}: _(RawOrigin::Signed(bob.clone()), 0, ApprovalPreference::Required)


request {
let alice: T::AccountId = mock_account_id::<T>(1u8);
let blueprint = cggmp21_blueprint::<T>();
let _= Pallet::<T>::create_blueprint(RawOrigin::Signed(alice.clone()).into(), blueprint);

let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() };
let bob: T::AccountId = mock_account_id::<T>(2u8);
let _= Pallet::<T>::register(RawOrigin::Signed(bob.clone()).into(), 0, operator_preference, Default::default());

Expand Down Expand Up @@ -137,11 +137,11 @@ benchmarks! {
let _= Pallet::<T>::register(
RawOrigin::Signed(bob.clone()).into(),
0,
OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() },
OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() },
Default::default()
);

let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::Required };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::Required };

let charlie: T::AccountId = mock_account_id::<T>(3u8);
let _= Pallet::<T>::register(RawOrigin::Signed(charlie.clone()).into(), 0, operator_preference, Default::default());
Expand Down Expand Up @@ -171,11 +171,11 @@ benchmarks! {
let _= Pallet::<T>::register(
RawOrigin::Signed(bob.clone()).into(),
0,
OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() },
OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() },
Default::default()
);

let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::Required };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::Required };

let charlie: T::AccountId = mock_account_id::<T>(3u8);
let _= Pallet::<T>::register(RawOrigin::Signed(charlie.clone()).into(), 0, operator_preference, Default::default());
Expand All @@ -201,7 +201,7 @@ benchmarks! {
let blueprint = cggmp21_blueprint::<T>();
let _= Pallet::<T>::create_blueprint(RawOrigin::Signed(alice.clone()).into(), blueprint);

let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() };

let bob: T::AccountId = mock_account_id::<T>(2u8);
let _= Pallet::<T>::register(RawOrigin::Signed(bob.clone()).into(), 0, operator_preference, Default::default());
Expand Down Expand Up @@ -230,7 +230,7 @@ benchmarks! {
let blueprint = cggmp21_blueprint::<T>();
let _= Pallet::<T>::create_blueprint(RawOrigin::Signed(alice.clone()).into(), blueprint);

let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() };

let bob: T::AccountId = mock_account_id::<T>(2u8);
let _= Pallet::<T>::register(RawOrigin::Signed(bob.clone()).into(), 0, operator_preference, Default::default());
Expand Down Expand Up @@ -264,7 +264,7 @@ benchmarks! {
let blueprint = cggmp21_blueprint::<T>();
let _= Pallet::<T>::create_blueprint(RawOrigin::Signed(alice.clone()).into(), blueprint);

let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPrefrence::default() };
let operator_preference = OperatorPreferences { key: zero_key(), approval: ApprovalPreference::default() };

let bob: T::AccountId = mock_account_id::<T>(2u8);
let _= Pallet::<T>::register(RawOrigin::Signed(bob.clone()).into(), 0, operator_preference, Default::default());
Expand Down
6 changes: 3 additions & 3 deletions pallets/services/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub mod module {
/// The ID of the service blueprint.
blueprint_id: u64,
/// The new approval preference.
approval_preference: ApprovalPrefrence,
approval_preference: ApprovalPreference,
},

/// The price targets for an operator has been updated.
Expand Down Expand Up @@ -649,7 +649,7 @@ pub mod module {
pub fn update_approval_preference(
origin: OriginFor<T>,
#[pallet::compact] blueprint_id: u64,
approval_preference: ApprovalPrefrence,
approval_preference: ApprovalPreference,
) -> DispatchResult {
let caller = ensure_signed(origin)?;
ensure!(Blueprints::<T>::contains_key(blueprint_id), Error::<T>::BlueprintNotFound);
Expand Down Expand Up @@ -719,7 +719,7 @@ pub mod module {
let mut approved = Vec::new();
for provider in &service_providers {
let prefs = Self::operators(blueprint_id, provider)?;
if prefs.approval == ApprovalPrefrence::Required {
if prefs.approval == ApprovalPreference::Required {
pending_approvals.push(provider.clone());
} else {
approved.push(provider.clone());
Expand Down
60 changes: 30 additions & 30 deletions pallets/services/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn register_on_blueprint() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: price_targets(MachineKind::Large),
},
Default::default(),
Expand All @@ -135,7 +135,7 @@ fn register_on_blueprint() {
blueprint_id: 0,
preferences: OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: price_targets(MachineKind::Large),
},
registration_args: Default::default(),
Expand All @@ -152,7 +152,7 @@ fn register_on_blueprint() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -167,7 +167,7 @@ fn register_on_blueprint() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand Down Expand Up @@ -216,7 +216,7 @@ fn update_approval_preference() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: price_targets(MachineKind::Small)
},
Default::default(),
Expand All @@ -226,7 +226,7 @@ fn update_approval_preference() {
Operators::<Runtime>::get(0, &bob).unwrap(),
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: price_targets(MachineKind::Small)
}
);
Expand All @@ -236,7 +236,7 @@ fn update_approval_preference() {
blueprint_id: 0,
preferences: OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: price_targets(MachineKind::Small),
},
registration_args: Default::default(),
Expand All @@ -246,18 +246,18 @@ fn update_approval_preference() {
assert_ok!(Services::update_approval_preference(
RuntimeOrigin::signed(bob.clone()),
0,
ApprovalPrefrence::Required,
ApprovalPreference::Required,
));

assert_eq!(
Operators::<Runtime>::get(0, &bob).unwrap().approval,
ApprovalPrefrence::Required
ApprovalPreference::Required
);

assert_events(vec![RuntimeEvent::Services(crate::Event::ApprovalPreferenceUpdated {
operator: bob,
blueprint_id: 0,
approval_preference: ApprovalPrefrence::Required,
approval_preference: ApprovalPreference::Required,
})]);

// try to update approval preference when not registered
Expand All @@ -266,7 +266,7 @@ fn update_approval_preference() {
Services::update_approval_preference(
RuntimeOrigin::signed(charlie),
0,
ApprovalPrefrence::Required
ApprovalPreference::Required
),
crate::Error::<Runtime>::NotRegistered
);
Expand All @@ -290,7 +290,7 @@ fn update_price_targets() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: price_targets(MachineKind::Small)
},
Default::default(),
Expand All @@ -300,7 +300,7 @@ fn update_price_targets() {
Operators::<Runtime>::get(0, &bob).unwrap(),
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: price_targets(MachineKind::Small)
}
);
Expand All @@ -310,7 +310,7 @@ fn update_price_targets() {
blueprint_id: 0,
preferences: OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: price_targets(MachineKind::Small),
},
registration_args: Default::default(),
Expand Down Expand Up @@ -361,7 +361,7 @@ fn unregister_from_blueprint() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand Down Expand Up @@ -400,7 +400,7 @@ fn request_service() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -411,7 +411,7 @@ fn request_service() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -422,7 +422,7 @@ fn request_service() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand Down Expand Up @@ -471,7 +471,7 @@ fn request_service_with_approval_process() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -483,7 +483,7 @@ fn request_service_with_approval_process() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::Required,
approval: ApprovalPreference::Required,
price_targets: Default::default()
},
Default::default(),
Expand All @@ -495,7 +495,7 @@ fn request_service_with_approval_process() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::Required,
approval: ApprovalPreference::Required,
price_targets: Default::default()
},
Default::default(),
Expand Down Expand Up @@ -582,7 +582,7 @@ fn job_calls() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -593,7 +593,7 @@ fn job_calls() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -604,7 +604,7 @@ fn job_calls() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand Down Expand Up @@ -662,7 +662,7 @@ fn job_calls_fails_with_invalid_input() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -673,7 +673,7 @@ fn job_calls_fails_with_invalid_input() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -684,7 +684,7 @@ fn job_calls_fails_with_invalid_input() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand Down Expand Up @@ -739,7 +739,7 @@ fn job_result() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -750,7 +750,7 @@ fn job_result() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand All @@ -761,7 +761,7 @@ fn job_result() {
0,
OperatorPreferences {
key: zero_key(),
approval: ApprovalPrefrence::default(),
approval: ApprovalPreference::default(),
price_targets: Default::default()
},
Default::default(),
Expand Down
Loading

0 comments on commit efb9f4d

Please sign in to comment.