Implement upgrade contract logic#256
Open
whiteghost0001 wants to merge 2 commits intoWeb3Novalabs:mainfrom
Open
Implement upgrade contract logic#256whiteghost0001 wants to merge 2 commits intoWeb3Novalabs:mainfrom
whiteghost0001 wants to merge 2 commits intoWeb3Novalabs:mainfrom
Conversation
- Add EventMetrics struct with tickets_sold field (zero-initialized) - Add StorageKey::Event(BytesN<32>) and StorageKey::EventMetrics(BytesN<32>) - Update EventDetails: id changed to BytesN<32>, added token field - Implement create_event to persist EventDetails and EventMetrics in storage - Add state logic test verifying all fields saved correctly in env.storage()
- Replace weak auth-only test with a real integration test that uploads the contract's own compiled WASM via contractimport!, calls upgrade_contract, and verifies the contract remains functional after the upgrade (storage preserved) - Add test_upgrade_contract_not_initialized_fails test - Update CI workflow: install wasm32v1-none target and build WASM before running tests (contractimport! requires the file at compile time)
|
@whiteghost0001 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.
Closes #221
The upgrade_contract function already existed and was correctly calling env.deployer().update_current_contract_wasm(new_wasm_hash). The task was really about proving it works with a proper integration test.
The old test was weak — it just passed a zeroed-out hash, expected it to fail, and called that "success". I replaced it with a real integration test that:
Builds the contract's own WASM using contractimport!
Uploads it to get a valid on-ledger hash
Calls upgrade_contract and asserts it succeeds
Verifies the contract is still callable after the upgrade (storage intact)
I also updated the CI workflow to install the wasm32v1-none target and build the WASM before running tests, since contractimport! needs the file present at compile time.