feat(contracts): add contract upgradeability - #106
Merged
Smartdevs17 merged 1 commit intoMar 24, 2026
Conversation
|
@Itodo-S is attempting to deploy a commit to the smartdevs17's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Itodo-S 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! 🚀 |
Owner
|
fix merge confllicts |
Implement Soroban's built-in upgrade mechanism that replaces contract bytecode while preserving all storage (persistent + instance). Changes: - Add `upgrade(admin, new_wasm_hash)` function, admin-only, uses `env.deployer().update_current_contract_wasm()` - Add `version()` query returning current contract version (1) for tracking upgrades across deployments - Add tests: version query and non-admin upgrade rejection Closes Smartdevs17#42
Itodo-S
force-pushed
the
feat/contract-upgradeability
branch
from
March 24, 2026 13:43
2dfc690 to
123f3b2
Compare
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.
Summary
update_current_contract_wasmmechanismupgrade(admin, new_wasm_hash)function replaces bytecode while preserving all persistent and instance storageversion()query (returns1) for tracking contract versions across upgradesChanges
contracts/src/lib.rs:BytesNfor WASM hash parameterupgrade()— validates admin auth, callsenv.deployer().update_current_contract_wasm()version()— returns current contract version constanttest_version_returns_currentandtest_upgrade_rejects_non_adminUpgrade flow
Test plan
test_version_returns_current— version() returns 1test_upgrade_rejects_non_admin— non-admin upgrade panics with "Only admin can upgrade"Closes #42