feat(contract): clean up upgrade support and add admin query (#927) - #1011
Closed
xtep103 wants to merge 1 commit into
Closed
feat(contract): clean up upgrade support and add admin query (#927)#1011xtep103 wants to merge 1 commit into
xtep103 wants to merge 1 commit into
Conversation
…se#927) - Remove duplicate upgrade_contract function (kept well-documented upgrade function) - Add public admin() query to retrieve the current contract admin address - Add comprehensive tests for upgrade functionality: - admin() returns None before init, Some after init - initialize_admin rejects duplicate initialization - Version bumps correctly - Plan data preserved after upgrade - migrate is no-op when already current
|
@xtep103 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@xtep103 |
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.
Closes #927
Summary
Cleans up the contract upgrade infrastructure: removes a duplicate
upgrade_contractfunction, adds a publicadmin()query, and adds comprehensive tests for the upgrade path.Changes
contracts/inheritance-contract/src/lib.rsupgrade_contractfunction (line 5677) — kept the well-documentedupgradefunction (line 3798) which includes version bumping, audit-trail event emission, logging, andenv.deployer().update_current_contract_wasm()pub fn admin(env: Env) -> Option<Address>— public query to retrieve the current contract admin address (exposes the existing privateget_adminhelper)contracts/inheritance-contract/src/test.rsAdded 5 new tests:
test_admin_returns_none_before_initialization— verifiesadmin()returnsNonebefore setuptest_admin_returns_address_after_initialization— verifiesadmin()returns the correct addresstest_upgrade_contract_rejects_duplicate_admin_init— verifiesinitialize_adminrejects second calltest_upgrade_version_bumps_correctly— verifies version tracking through multiple bumpstest_upgrade_preserves_plan_data— verifies inheritance plan data survives a version bumptest_migrate_rejects_when_already_current— verifiesmigrateis a no-op when version is currentUpgrade Architecture (existing, unchanged)
upgrade(admin, new_wasm_hash)migrate(admin)admin()version()initialize_admin(admin)