feat: implement WASM upgradeable contract pattern#58
Merged
Kingsman-99 merged 2 commits intoMay 28, 2026
Conversation
- Import BytesN from soroban_sdk - Add admin_key() storage helper (instance storage) - Add initialize(admin) — sets admin once, panics if called again - Add upgrade(new_wasm_hash) — requires admin auth, calls update_current_contract_wasm - Tests: initialize_twice_panics, upgrade_preserves_storage, upgrade_requires_admin_auth - All 10 tests pass, clippy clean Closes Stellar-split#34
|
@marvs8 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! 🚀 |
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
Implements the Soroban upgradeable contract pattern using
env.deployer().update_current_contract_wasm(), as described in issue #34.Changes
lib.rs:
BytesNto importsadmin_key()— instance storage key for the admin addressinitialize(admin)— sets the admin once; panics with"already initialized"on repeat callsupgrade(new_wasm_hash)— loads admin from storage, callsadmin.require_auth(), then callsenv.deployer().update_current_contract_wasm(new_wasm_hash)test.rs:
test_initialize_twice_panics— verifies double-init panicstest_upgrade_preserves_storage— creates an invoice, upgrades, then asserts the invoice storage key still exists in persistent storagetest_upgrade_requires_admin_auth— disables mock auths viaenv.set_auths(&[]), verifies upgrade panics without admin authAcceptance Criteria
upgrade()requires admin authupgrade()callsupdate_current_contract_wasmwith provided hashenv.storage().persistent().has())cargo testpass (10/10)cargo clippypasses with zero warningsCloses #34