Skip to content

Fix migrate() bug and clarify ExtendRef requirements in documentation#10

Draft
Copilot wants to merge 2 commits intomigrate-protocolfrom
copilot/sub-pr-9
Draft

Fix migrate() bug and clarify ExtendRef requirements in documentation#10
Copilot wants to merge 2 commits intomigrate-protocolfrom
copilot/sub-pr-9

Conversation

Copy link

Copilot AI commented Nov 20, 2025

Addresses review feedback from PR #9 identifying a bug in migrate() functions and unclear documentation about ExtendRef requirements.

Bug Fix

  • Move object_signer call inside existence check: Previously called before checking if Capability<OldProtocol, R> exists, causing abort even when migrating capabilities that don't exist, breaking the intended silent no-op behavior.
// Before: aborts if R doesn't exist but ExtendRef is missing
let object_signer = object_signer(old_protocol, object_address);
if (exists<Capability<OldProtocol, R>>(object_address)) { ... }

// After: only calls object_signer when R actually exists
if (exists<Capability<OldProtocol, R>>(object_address)) {
    let object_signer = object_signer(old_protocol, object_address);
    ...
}

Documentation Improvements

  • migrate() functions: Clarify that ExtendRef under OldProtocol is required for all migrations, not just when migrating ExtendRef itself
  • migrate_all() functions: Document that capabilities must be in storage (not extracted) and missing capabilities are silently skipped
  • Inline comment: Expand explanation of why ExtendRef must be migrated last in migrate_all()

Applied to both protocol_object and protocol_fungible_asset modules.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: yeap-oneke <213803782+yeap-oneke@users.noreply.github.com>
Copilot AI changed the title [WIP] Add capability migration functionality for protocol objects Fix migrate() bug and clarify ExtendRef requirements in documentation Nov 20, 2025
Copilot AI requested a review from yeap-oneke November 20, 2025 00: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.

2 participants