Skip to content

Commit e754423

Browse files
committed
pallet-bounties: defaults to curator if RejectOrigin is unavailable
1 parent 3bde188 commit e754423

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

substrate/frame/bounties/src/benchmarking.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ benchmarks_instance_pallet! {
156156
let bounty_update_period = T::BountyUpdatePeriod::get();
157157
let inactivity_timeout = T::SpendPeriod::get().saturating_add(bounty_update_period);
158158
set_block_number::<T, I>(inactivity_timeout.saturating_add(2u32.into()));
159-
let caller: T::AccountId = whitelisted_caller();
160-
let signed_caller: T::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();
161159

162160
// If `BountyUpdatePeriod` overflows the inactivity timeout the benchmark still executes the slash
163161
let origin = if Pallet::<T, I>::treasury_block_number() <= inactivity_timeout {
164-
T::RejectOrigin::try_successful_origin().unwrap_or_else(|_| signed_caller)
162+
let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?;
163+
T::RejectOrigin::try_successful_origin().unwrap_or_else(|_| RawOrigin::Signed(curator).into())
165164
} else {
166-
signed_caller
165+
let caller = whitelisted_caller();
166+
RawOrigin::Signed(caller).into()
167167
};
168168
}: _<T::RuntimeOrigin>(origin, bounty_id)
169169

substrate/frame/child-bounties/src/benchmarking.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,17 @@ mod benchmarks {
277277
let bounty_update_period = T::BountyUpdatePeriod::get();
278278
let inactivity_timeout = T::SpendPeriod::get().saturating_add(bounty_update_period);
279279
set_block_number::<T>(inactivity_timeout.saturating_add(1u32.into()));
280-
let caller: T::AccountId = whitelisted_caller();
281-
let signed_caller: T::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();
282280

283281
// If `BountyUpdatePeriod` overflows the inactivity timeout the benchmark still
284282
// executes the slash
285-
let origin = if Pallet::<T>::treasury_block_number() <= inactivity_timeout {
286-
T::RejectOrigin::try_successful_origin().unwrap_or_else(|_| signed_caller)
283+
let origin: T::RuntimeOrigin = if Pallet::<T>::treasury_block_number() <= inactivity_timeout
284+
{
285+
let child_curator = bounty_setup.child_curator;
286+
T::RejectOrigin::try_successful_origin()
287+
.unwrap_or_else(|_| RawOrigin::Signed(child_curator).into())
287288
} else {
288-
signed_caller
289+
let caller = whitelisted_caller();
290+
RawOrigin::Signed(caller).into()
289291
};
290292

291293
#[extrinsic_call]

0 commit comments

Comments
 (0)