Skip to content

Commit 8a4caa7

Browse files
committed
charge & refund in announce_next_key
1 parent c797cd1 commit 8a4caa7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pallets/shield/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,12 @@ pub mod pallet {
244244
.saturating_add(T::DbWeight::get().reads(1_u64))
245245
.saturating_add(T::DbWeight::get().writes(1_u64)),
246246
DispatchClass::Operational,
247-
Pays::No
247+
Pays::Yes
248248
))]
249249
pub fn announce_next_key(
250250
origin: OriginFor<T>,
251251
public_key: BoundedVec<u8, ConstU32<2048>>,
252-
) -> DispatchResult {
252+
) -> DispatchResultWithPostInfo {
253253
// Only a current Aura validator may call this (signed account ∈ Aura authorities)
254254
T::AuthorityOrigin::ensure_validator(origin)?;
255255

@@ -259,9 +259,13 @@ pub mod pallet {
259259
Error::<T>::BadPublicKeyLen
260260
);
261261

262-
NextKey::<T>::put(public_key.clone());
262+
NextKey::<T>::put(public_key);
263263

264-
Ok(())
264+
// Refund the fee on success by setting pays_fee = Pays::No
265+
Ok(PostDispatchInfo {
266+
actual_weight: None,
267+
pays_fee: Pays::No,
268+
})
265269
}
266270

267271
/// Users submit an encrypted wrapper.

0 commit comments

Comments
 (0)