Skip to content

feat: ObjectData improvements#1125

Merged
thibault-martinez merged 3 commits intodevelopfrom
24-ObjectData
May 7, 2026
Merged

feat: ObjectData improvements#1125
thibault-martinez merged 3 commits intodevelopfrom
24-ObjectData

Conversation

@thibault-martinez
Copy link
Copy Markdown
Member

Summary

Continues the SDK replacement series, stacked on top of sdk-replacement/23-ProgrammableTransaction. Rounds out ObjectData with the accessors the monorepo expects (object id, type, struct tag) and extends the def_is_as_into_opt! macro with mutable-borrow accessors so enums generated via the macro support in-place mutation of their inner values.

Changes

ObjectData

New methods on ObjectData in crates/iota-sdk-types/src/object.rs:

  • id() — returns the inner ObjectId regardless of variant (Struct delegates to MoveStruct::id, Package delegates to MovePackage::id).
  • object_type() — returns Some(&MoveObjectType) for Struct, None for Package.
  • struct_tag() — returns Some(StructTag) (cloned) for Struct, None for Package.

def_is_as_into_opt! macro

Adds mutable-borrow accessors to the plain-$inner arm of the macro in crates/iota-sdk-types/src/lib.rs:

  • as_<rename>_mut(&mut self) -> &mut $inner — panicking variant.
  • as_<rename>_mut_opt(&mut self) -> Option<&mut $inner> — fallible variant.

These mirror the existing as_<rename> / as_<rename>_opt pair and let callers mutate the inner value of an enum variant without re-matching. The Box<$inner> arm is intentionally left unchanged.

@thibault-martinez thibault-martinez marked this pull request as ready for review May 7, 2026 07:49
@thibault-martinez thibault-martinez requested a review from a team as a code owner May 7, 2026 07:49
Comment thread crates/iota-sdk-types/src/object.rs
@DaughterOfMars DaughterOfMars changed the title feat: ObjectData improvements (#1045) feat: ObjectData improvements May 7, 2026
Base automatically changed from sdk-replacement/23-ProgrammableTransaction to develop May 7, 2026 08:54
* feat: `ObjectData` improvements

* remove methods

* add mut versions in macro
@thibault-martinez thibault-martinez merged commit c683e52 into develop May 7, 2026
20 checks passed
@thibault-martinez thibault-martinez deleted the 24-ObjectData branch May 7, 2026 11:11
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