Skip to content

Conversation

@itsyaasir
Copy link
Contributor

@itsyaasir itsyaasir commented Dec 4, 2025

Description of change

Capability Handling Overhaul

The capability retrieval system has been completely restructured to support package upgrades and improve type safety.

Before

  • A generic get_cap() method that searched for capabilities using runtime-constructed struct tags.

After

  • Two dedicated methods with proper deserialization:
    • get_root_authority_cap() – Retrieves RootAuthorityCap for administrative operations.
    • get_accredit_cap() – Retrieves AccreditCap for delegation operations.

Breaking Changes

Removed Capability enum

  • The Capability enum (RootAuthority, Accredit) has been replaced with concrete struct types.

New capability structs

  • New capability structs with proper MoveType implementations:
    pub struct RootAuthorityCap {
        pub id: UID,
        pub federation_id: ObjectID,
        pub account_id: ObjectID,
    }

    pub struct AccreditCap {
        pub id: UID,
        pub federation_id: ObjectID,
    }

API signature changes

  • Capability retrieval now requires federation_id:
    // Old
    get_cap(client, Capability::RootAuthority, sender)

    // New
    get_root_authority_cap(client, owner, federation_id)

move_names module relocated

  • Moved from operations.rs to types/mod.rs for better organization.

Fixes

  • Package upgrade compatibility:
    • Capabilities are now found using find_object_for_address(), which searches across all package versions in history.
    • This fixes issues where capabilities created with older package versions could not be discovered.

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

- Introduced `RootAuthorityCap` and `AccreditCap` structs for better clarity and management of capabilities.
- Replaced existing capability retrieval methods with more specific methods: `get_root_authority_cap` and `get_accredit_cap`.
- Updated `Move.history.json` to maintain consistency in alias ordering.
@itsyaasir itsyaasir self-assigned this Dec 4, 2025
@itsyaasir itsyaasir requested a review from qrayven December 4, 2025 10:03
- Added a new `Generic` error variant to `CapabilityError` for improved error context.
- Updated `operations.rs` to utilize the new error handling mechanism and replaced hardcoded capability type strings with constants.
- Introduced constants for `RootAuthorityCap` and `AccreditCap` types in `cap.rs`.
- Adjusted `Move.history.json` to maintain alias consistency.
@itsyaasir itsyaasir requested a review from qrayven December 5, 2025 05:21
- Replaced the `Generic` error variant in `CapabilityError` with a more specific `Rpc` variant for improved clarity in error reporting.
- Updated error handling in `operations.rs` to utilize the new `Rpc` error variant for better context during capability retrieval failures.
- Adjusted the order of entries in `Move.history.json` for consistency.
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