Skip to content

Conversation

@itsyaasir
Copy link
Contributor

@itsyaasir itsyaasir commented Jan 12, 2026

Description of change

This pull request makes significant improvements and refactoring to the audit_trail Move module, focusing on standardizing naming conventions, adding record deletion functionality, and cleaning up the public API. The changes improve clarity, maintainability, and feature completeness of the audit trail system.

Key changes include:

New Features

  • Added support for deleting records from the audit trail, including the delete_record function, a corresponding RecordDeleted event, and a destroy destructor for records. Deletion respects locking configuration and permission checks. [1] [2] [3]

Naming and API Refactoring

  • Renamed many public functions to use concise, consistent names (e.g., trail_add_recordadd_record, trail_is_record_lockedis_record_locked, trail_get_recordget_record, etc.) and updated internal struct names for clarity (e.g., TrailImmutableMetadataImmutableMetadata). [1] [2] [3] [4] [5] [6] [7]

  • Removed the block of public use statements at the end of the module in favor of the new direct function names, simplifying the API surface.

Events and Error Handling

  • Added new events for audit trail and record deletion (AuditTrailDeleted, RecordDeleted) and a new error code for locked records (ERecordLocked). [1] [2] [3]

Documentation and Comments

  • Updated and clarified documentation, including comments for new features and correcting typos. [1] [2] [3]

These changes collectively improve the usability, safety, and extensibility of the audit trail module.

Links to any relevant issues

Type of change

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

Change checklist

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes
  • I have updated the CHANGELOG.md, if my changes are significant enough

- Changed capability permission checks in `has_capability_permission` and `destroy_capability` functions to use `cap.trail_id()` instead of `cap.id()`.
- Improved test cases for capability creation, revocation, and metadata updates, ensuring proper permission handling and error scenarios.
- Added new tests for locking configurations and metadata management, enhancing overall test coverage for the audit trail functionality.
@itsyaasir itsyaasir changed the title chore: function sig refactor & adding of emitting events chore: function refactor, adding of emitting events & improving test coverage Jan 12, 2026
- Reformatted function calls in locking and role tests for better readability by aligning parameters across multiple lines.
- Enhanced clarity in test cases related to locking configurations and role permissions, ensuring easier maintenance and understanding of the test logic.
@itsyaasir itsyaasir marked this pull request as ready for review January 13, 2026 03:52
- Fixed typos in comments related to the `Permission` enum and `admin_permissions` function for clarity.
- Enhanced documentation to better reflect the intended roles and permissions within the audit trail system.
@itsyaasir itsyaasir self-assigned this Jan 13, 2026
public fun issued_capabilities<D: store + copy>(trail: &AuditTrail<D>): &VecSet<ID> {
&trail.issued_capabilities
}

Copy link
Contributor

@chrisgitiota chrisgitiota Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove these statements we can not use the dot method call syntax anymore.

https://docs.iota.org/developer/advanced/introducing-move-2024#method-syntax

Why do we remove it?

If we want to stay with the dot method call syntax, we also need to maintain the "trail_" prefix (or use a different prefix) for the function implementations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove these statements we can not use the dot method call syntax anymore.

We can still use the dot method syntax, a quick example is found here

I don't think the trail_ prefix is necessary, and I removed it because of the "noise" it was producing as well as it is not a move conventions and we don't do this in our products.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. The documentation states the following:

You can call any function defined in the same module as the receiver's type as a method if it takes the receiver as its first argument.

For functions defined outside the module, you can declare methods using public use fun and use fun.

When has the " the new direct function names" been introduced? Is it documented somewhere?

The tests run in its own module so the behavior described in the docs is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you check the audit_trail.move file, you will see we are using the dot notation for all the function implementation taking the AuditTrail as it's first argument.

@itsyaasir itsyaasir merged commit 446eb4e into feat/audit-trails-dev Jan 14, 2026
9 checks passed
@itsyaasir itsyaasir deleted the chore/add-events-audit-trails branch January 14, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants