Skip to content

Commit 5fd4e5e

Browse files
committed
feat(permission0): add last update field
1 parent 7a16a9a commit 5fd4e5e

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

pallets/permission0/src/ext/namespace_impl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use pallet_permission0_api::Permission0NamespacesApi;
77
use pallet_torus0_api::{NamespacePath, NamespacePathInner, Torus0Api};
88
use polkadot_sdk::{
99
frame_support::{dispatch::DispatchResult, ensure},
10-
frame_system::ensure_signed,
10+
frame_system::{self, ensure_signed},
1111
polkadot_sdk_frame::prelude::OriginFor,
1212
sp_core::Get,
1313
sp_runtime::{BoundedBTreeMap, BoundedBTreeSet, DispatchError},
@@ -309,6 +309,7 @@ pub(crate) fn update_namespace_permission<T: Config>(
309309
}
310310

311311
permission.max_instances = max_instances;
312+
permission.last_update = frame_system::Pallet::<T>::block_number();
312313
Permissions::<T>::set(permission_id, Some(permission));
313314

314315
Ok(())

pallets/permission0/src/ext/stream_impl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use pallet_permission0_api::{
1313
};
1414
use polkadot_sdk::{
1515
frame_support::{dispatch::DispatchResult, ensure, traits::ReservableCurrency},
16-
frame_system::{ensure_signed, ensure_signed_or_root},
16+
frame_system::{self, ensure_signed, ensure_signed_or_root},
1717
polkadot_sdk_frame::prelude::{BlockNumberFor, OriginFor},
1818
sp_core::{Get, TryCollect},
1919
sp_runtime::{
@@ -424,6 +424,7 @@ pub(crate) fn update_stream_permission<T: Config>(
424424
}
425425

426426
permission.scope = PermissionScope::Stream(scope);
427+
permission.last_update = frame_system::Pallet::<T>::block_number();
427428
Permissions::<T>::set(permission_id, Some(permission));
428429

429430
Ok(())

pallets/permission0/src/migrations.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ pub mod v6 {
169169
duration: old_contract.duration,
170170
revocation: old_contract.revocation,
171171
enforcement: old_contract.enforcement,
172+
last_update: old_contract.created_at,
172173
last_execution: old_contract.last_execution,
173174
execution_count: old_contract.execution_count,
174175
children: old_contract.children,

pallets/permission0/src/permission.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ pub struct PermissionContract<T: Config> {
6161
pub revocation: RevocationTerms<T>,
6262
/// Enforcement authority that can toggle the permission
6363
pub enforcement: EnforcementAuthority<T>,
64+
/// Last update block
65+
pub last_update: BlockNumberFor<T>,
6466
/// Last execution block
6567
#[doc(hidden)]
6668
pub last_execution: Option<BlockNumberFor<T>>,
@@ -83,6 +85,7 @@ impl<T: Config> PermissionContract<T> {
8385
enforcement: EnforcementAuthority<T>,
8486
max_instances: u32,
8587
) -> Self {
88+
let now = frame_system::Pallet::<T>::block_number();
8689
Self {
8790
delegator,
8891
scope,
@@ -91,10 +94,11 @@ impl<T: Config> PermissionContract<T> {
9194
enforcement,
9295
max_instances,
9396

97+
last_update: now,
9498
last_execution: None,
9599
execution_count: 0,
96100
children: BoundedBTreeSet::new(),
97-
created_at: frame_system::Pallet::<T>::block_number(),
101+
created_at: now,
98102
}
99103
}
100104
}

0 commit comments

Comments
 (0)