Skip to content

Implement upgrade contract logic#256

Open
whiteghost0001 wants to merge 2 commits intoWeb3Novalabs:mainfrom
whiteghost0001:Implement-upgrade_contract-logic
Open

Implement upgrade contract logic#256
whiteghost0001 wants to merge 2 commits intoWeb3Novalabs:mainfrom
whiteghost0001:Implement-upgrade_contract-logic

Conversation

@whiteghost0001
Copy link

@whiteghost0001 whiteghost0001 commented Mar 26, 2026

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.

- 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)
@drips-wave
Copy link

drips-wave bot commented Mar 26, 2026

@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! 🚀

Learn more about application limits

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.

Implement upgrade_contract logic

1 participant