feat(iota-types)!: update to MoveStruct with contents checked#11471
Merged
thibault-martinez merged 3 commits intodevelopfrom May 8, 2026
Merged
feat(iota-types)!: update to MoveStruct with contents checked#11471thibault-martinez merged 3 commits intodevelopfrom
thibault-martinez merged 3 commits intodevelopfrom
Conversation
4bd1244 to
242e8e7
Compare
42ac591 to
77e52fa
Compare
valeriyr
reviewed
May 8, 2026
muXxer
approved these changes
May 8, 2026
valeriyr
approved these changes
May 8, 2026
semenov-vladyslav
approved these changes
May 8, 2026
kodemartin
approved these changes
May 8, 2026
filipdulic
approved these changes
May 8, 2026
6966288 to
90176d8
Compare
77e52fa to
ebfec8b
Compare
thibault-martinez
approved these changes
May 8, 2026
Alex6323
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR follows up on the
MoveObjectType/MoveStructmigration iniota-rust-sdk. The SDK'sMoveStruct(re-exported iniota-typesasMoveObject) has been hardened: its fields are now private, constructiongoes through a fallible
MoveStruct::newconstructor, and replacing thecontents goes through a fallible
set_contentssetter — both of whichvalidate that
contentsis at leastObjectId::LENGTH(32) bytes, sinceevery Move object must carry its
ObjectIdas the leading bytes of itsBCS payload. This PR adapts the
iota-typesand execution call sites tothe new API.
Description of change
iota-types::object(MoveObjectExt) no longer reaches intoMoveObjectfields directly. Allself.object_type/self.version/
self.contentsaccesses are replaced with the correspondingobject_type()/version()/contents()getters; mutations gothrough
set_version()and the fallibleset_contents()(returningMoveStructContentsError, mapped toExecutionError::invariant_violationon the production path).
MoveObjectExt::set_coin_value_uncheckedandset_clock_timestamp_ms_uncheckedno longer mutate the contents bufferin place via
Vec::splice— they now copy the buffer(
self.contents().to_vec()), patch the trailing 8 bytes, and pass itback through
set_contents(...).unwrap()(the length is unchanged, sothe length check cannot fail).
MoveObject { object_type, version, contents }struct-literalconstructions in
Object::*_for_testinghelpers and inMoveObjectExt::new_from_execution_with_limitare replaced withMoveObject::new(...). Test helpers.unwrap()the result; theexecution path maps the error to
ExecutionError::invariant_violation.MoveObject::id_opt(&bytes)(which extracted anObjectIdfrom the leading bytes of a raw payload) was removed in theSDK now that the same invariant is upheld by the constructor. The two
call sites in
iota-adapter::programmable_transactions::contextareupdated to call
ObjectID::from_bytes(&bytes[..ObjectID::LENGTH])directly, with the missing-bytes case turning into an
ExecutionError::invariant_violation.iota-open-rpc::exampleshad aMoveObject::new_from_execution_with_limitcall that built an example object with an empty
contents: Vec::new()and an empty
MoveStructLayout. Empty contents now fail the newlength check, so the example is updated to construct a 32-byte payload
via
UID::new(parent_object_id).to_bcs_bytes()and a matching layoutwith a single
id: UIDfield. Generatedopenrpc.jsonsnapshots areregenerated to reflect the new example payload.
Release Notes
MoveStruct(re-exported asiota-types::object::MoveObject)now has private fields. Construction must go through
MoveStruct::new(object_type, version, contents)and content updatesthrough
set_contents(...); both are fallible and rejectcontentsshorter than
ObjectId::LENGTH(32 bytes), since every Move objectmust carry its
ObjectIdas the leading bytes. The associated helperMoveObject::id_opt(&bytes)has been removed — callObjectID::from_bytes(&bytes[..ObjectID::LENGTH])directly. Directfield access (
.object_type,.version,.contents) is replaced bythe equivalent getter methods. Wire formats (BCS and JSON) are
unchanged.