Skip to content

Commit b6f3bd4

Browse files
committed
Several minor docs enhancements
1 parent 081d368 commit b6f3bd4

7 files changed

Lines changed: 40 additions & 54 deletions

File tree

components_move/README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ within the IOTA Trust Framework. These components are designed to be modular and
55
Trust Framework products and community-developed smart contracts.
66

77
Modules Overview:
8-
* `role_map`: Implements the `RoleMap` struct for role-based access control, allowing mapping of roles to
8+
9+
* `role_map`: Implements the `RoleMap` struct for role-based access control, allowing mapping of roles to
910
application specific permissions.
10-
* `capability`: Defines the `Capability` struct for granting access rights within smart contracts in conjunction with
11+
* `capability`: Defines the `Capability` struct for granting access rights within smart contracts in conjunction with
1112
the `RoleMap<P>` struct.
1213
* `timelock`: Provides the `Timelock` struct for expressing and processing time-based restrictions
1314

1415
## Role-Based Access Control - The `role_map` and the `capability` Module
1516

16-
The `role_map` module provides the `RoleMap<P>` struct, which is
17+
The `role_map` module provides the `RoleMap<P>` struct, which is
1718
a role-based access control helper that maps unique role identifiers to their associated permissions.
1819

1920
The `capability` module provides the `capability::Capability` struct,
@@ -22,24 +23,26 @@ a capability token that grants access rights defined by one specific role in the
2223
The `role_map` module directly depends on the `capability` module. Both modules are tight strongly together.
2324

2425
The `RoleMap<P>` struct provides the following functionalities:
25-
- Uses custom permission types defined by the integrating module using the generic argument `P`
26-
- Defines an initial role with a custom set of permissions (i.e. for an Admin role) and creates an initial
26+
27+
* Uses custom permission-types, defined by the integrating module, using the generic argument `P`
28+
* Defines an initial role with a custom set of permissions (i.e. for an Admin role) and creates an initial
2729
`Capability` for this role to allow later access control administration by the creator of the integrating module
28-
- Allows to create, delete, and update roles and their permissions
29-
- Allows to issue, revoke, and destroy `Capability`s associated with a specific role
30-
- Validates `Capability`s against the defined roles to facilitate proper access control by the integrating module
30+
* Allows to create, delete, and update roles and their permissions
31+
* Allows to issue, revoke, and destroy `Capability`s associated with a specific role
32+
* Validates `Capability`s against the defined roles to facilitate proper access control by the integrating module
3133
(function `RoleMap.is_capability_valid()`)
32-
- All functions are access restricted by custom permissions defined during `RoleMap` instantiation
34+
* All functions are access restricted by custom permissions defined during `RoleMap` instantiation
3335

3436
### Usage Examples
3537

3638
The [`Counter` example](./examples/counter/README.md) is a very simple example, demonstrating how to use
37-
`RoleMap` and `Capability` for role based access control. The accompanying
39+
`RoleMap` and `Capability` for role based access control. The accompanying
3840
[test file](./examples/counter/tests/counter_tests.move) demonstrates the Move user experience.
3941

40-
The Trust Framework product *Audit Trails* uses the `RoleMap` to manage access to the audit trail records and their operations, which
42+
The Trust Framework product *Audit Trails* uses the `RoleMap` to manage access to the audit trail records and their operations, which
4143
can be seen as a more complex example:
42-
* The `RoleMap` is integrated in the `audit_trail::main` module to manage access to the audit trail records and
43-
their operations. See [here](https://github.com/iotaledger/notarization/blob/main/audit-trail-move/sources/audit_trail.move#L208) for an example.
44+
45+
* The `RoleMap` is integrated in the `audit_trail::main` module to manage access to the audit trail records and
46+
their operations. See [audit_trail.move](https://github.com/iotaledger/notarization/blob/main/audit-trail-move/sources/audit_trail.move#L208) for an example.
4447
* The `RoleMap` is created by the `AuditTrail` in it's [create function](https://github.com/iotaledger/notarization/blob/main/audit-trail-move/sources/audit_trail.move#L114).
4548
* An example for the Move user experience can be found in the [capability_tests.move](https://github.com/iotaledger/notarization/blob/main/audit-trail-move/tests/capability_tests.move) file.

components_move/examples/counter/README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# RoleMap Integration Example
22

3-
The Counter example shows how the `RoleMap` can be integrated into 3rd party shared objects
4-
(or Trust Framework products). In this example the `role_map` and `capability` modules are
5-
integrated into a simple shared `Counter` object, as being described
3+
This Counter example shows how the `role_map::RoleMap` can be integrated into 3rd party shared objects (or Trust Framework products). The example integrates the `role_map` and `capability` modules into a simple shared `Counter` object, as being described
64
[here](https://docs.iota.org/developer/iota-101/move-overview/package-upgrades/upgrade#4-guard-function-access).
75

86
## Permissions
@@ -15,20 +13,15 @@ can be found in the [permission.move](./sources/permission.move) file.
1513

1614
## RoleMap Integration
1715

18-
The integration of the `RoleMap<CounterPermission>` into the target object, which is the `Counter` object in
19-
this example, requires the following steps.
16+
The `RoleMap` is used to manage access control to target objects. In this example a target object is a `Counter` object. The integration of the `RoleMap<CounterPermission>` into the target object type (the `Counter` struct), requires the following steps (implementation of the shared `Counter` example can be found in [counter.move](./sources/counter.move)):
2017

21-
The implementation of the shared `Counter` example can be found in the
22-
[counter.move](./sources/counter.move) file.
23-
24-
The target object needs to:
2518
* instantiate the `RoleMap` instance in its `create()` function
2619
* provide the necessary getter and mutator functions for users to access the `RoleMap` instance
27-
(function `access()` and `access_mut()` in the [counter.move](./sources/counter.move) file)
20+
(function `access()` and `access_mut()` in [counter.move](./sources/counter.move))
2821
* use the `RoleMap.is_capability_valid()` function to check whether a provided capability has the required permission
29-
(used in function `increment()` in the [counter.move](./sources/counter.move) file)
22+
(used in function `increment()` in [counter.move](./sources/counter.move))
3023

31-
## User experience and testing the Integration
24+
## `RoleMap` User experience and testing the Integration
3225

3326
The accompanying [counter_tests.move](./tests/counter_tests.move) file demonstrates the
3427
user experience of Move users interacting with the shared `Counter` object via the integrated

components_move/examples/counter/sources/counter.move

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2026 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
/// Simple example Permissions for a shared counter
4+
/// Simple shared counter to demonstrate role_mao::RoleMap integration
55
#[test_only]
66
module tf_components::counter;
77

@@ -25,7 +25,7 @@ public fun create(ctx: &mut TxContext): (Capability, ID) {
2525
let counter_id = object::uid_to_inner(&counter_uid);
2626

2727
// Create a `CapabilityAdminPermissions` instance to configure the permissions
28-
// that will be needed by users to issue and revoke cabilities with the `RoleMap`.
28+
// that will be needed by users to issue and revoke capabilities with the `RoleMap`.
2929
//
3030
// There are two actions that need to be configured with a permission of your choice:
3131
// * `add`: Permission required to add (issue) a new capability
@@ -48,8 +48,8 @@ public fun create(ctx: &mut TxContext): (Capability, ID) {
4848
//
4949
// In this example we allow to use all three actions with the `ManageRoles` permission
5050
// for the sake of simplicity. In a real world application you would probably have action
51-
// specific permissiions like `AddRoles`, `DeleteRoles` and `UpdateRoles` like we did
52-
// above to specifify the `CapabilityAdminPermissions`.
51+
// specific permissions like `AddRoles`, `DeleteRoles` and `UpdateRoles` like we did
52+
// above to specify the `CapabilityAdminPermissions`.
5353
//
5454
let role_admin_permissions = role_map::new_role_admin_permissions(
5555
permission::manage_roles(),

components_move/examples/counter/tests/counter_tests.move

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ use tf_components::counter::{Self, Counter};
1111
use tf_components::counter_permission as permission;
1212

1313
/// Test capability lifecycle: creation, usage, revocation and destruction in a complete workflow.
14-
///
15-
/// This test validates:
16-
/// - A capability can be created for the `counter-admin` role
17-
/// - The Capability can be used to perform authorized actions
18-
/// - The Capability can be revoked
19-
/// - The Capability can be destroyed thereafter
2014
#[test]
2115
fun test_capability_lifecycle() {
2216
let super_admin_user = @0xAD;

components_move/sources/role_map.move

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// Copyright (c) 2026 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
/// A role-based access control helper mapping unique role identifiers to their associated permissions.
4+
/// A role-based access control helper, mapping unique role identifiers to their associated permissions.
55
///
6-
/// Provides the following functionalities:
7-
/// - Define an initial role with a custom set of permissions (i.e. an Admin role).
8-
/// - Use custom permission types defined by the integrating module using the generic parameter `P`.
9-
/// - Create, delete, and update roles and their permissions
10-
/// - Issue, revoke, and destroy `tf_components::capability`s associated with a specific role.
11-
/// - Validate `tf_components::capability`s against the defined roles to facilitate proper access control by other modules
6+
/// A `RoleMap<P>` provides the following functionalities:
7+
/// - Uses custom permission-types, defined by the integrating module, using the generic argument `P`
8+
/// - Defines an initial role with a custom set of permissions (i.e. for an Admin role) and creates an initial
9+
/// `Capability` for this role to allow later access control administration by the creator of the integrating module
10+
/// - Allows to create, delete, and update roles and their permissions
11+
/// - Allows to issue, revoke, and destroy `Capability`s associated with a specific role
12+
/// - Validates `Capability`s against the defined roles to facilitate proper access control by the integrating module
1213
/// (function `RoleMap.is_capability_valid()`)
13-
/// - All functions are access restricted by custom permissions defined during `RoleMap` instantiation.
14+
/// - All functions are access restricted by custom permissions defined during `RoleMap` instantiation
1415
///
1516
/// Examples:
1617
/// - The TF product Audit Trails uses `RoleMap` to manage access to the audit trail records and their operations.
17-
/// - The `tf_components` package README provides a "Hello World" like simple usage example
18-
/// ([Counter Example](../README.md#rolemap-integration-example)).
19-
18+
/// - The `TfComponents` package provides a "Hello World" like simple [`Counter` example](../examples/counter/README.md).
19+
///
2020
module tf_components::role_map;
2121

2222
use iota::clock::Clock;

components_move/sources/timelock.move

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
/// # Timelock Unlock Condition Module
55
///
66
/// This module implements a timelock mechanism that restricts access to resources
7-
/// until a specified time has passed. It provides functionality to create and validate
8-
/// different types of time-based locks:
9-
///
10-
/// - Simple time locks that unlock at a specific Unix timestamp
11-
/// - UntilDestroyed lock that never unlocks until the locked object is destroyed
12-
/// - None lock that is not locked
7+
/// until a specified time has passed.
138
module tf_components::timelock;
149

1510
use iota::clock::{Self, Clock};
@@ -188,7 +183,7 @@ public fun is_valid_period_ms(unix_time: u64, current_time: u64): bool {
188183
}
189184

190185
#[test_only]
191-
/// Test helper to delete a TimeLock for testing purposes, especially usefull for Infinite locks.
186+
/// Test helper to delete a TimeLock for testing purposes, especially useful for Infinite locks.
192187
public fun destroy_for_testing(lock: TimeLock) {
193188
match (lock) {
194189
TimeLock::UnlockAt(_time) => {},

components_move/tests/core_test_utils.move

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) 2026 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#[test_only]
45
module tf_components::core_test_utils;
56

67
use iota::object::id_from_bytes;
@@ -116,4 +117,4 @@ public fun create_test_role_map(
116117
(role_map, admin_cap, target_key)
117118
}
118119

119-
// --------------------------- Helper Fuctions -------------------------------------------------------------------
120+
// --------------------------- Helper Functions -------------------------------------------------------------------

0 commit comments

Comments
 (0)