implemented the contract WASM upgrade function with version tracking.#352
Merged
Conversation
|
@tecch-wiz 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.
I've implemented the contract WASM upgrade function with version tracking. Here's a summary of all changes made to
fluxapay/src/lib.rs:Changes Made
1. New
DataKey::ContractVersionvariant (line ~629)Added a new storage key for persisting the contract version string.
2. New constant
INITIAL_CONTRACT_VERSION(line ~633)3. Updated
initialize_payment_processor(line ~3677)Now sets the initial contract version (
"1.0.0") in persistent storage during initialization.4. Updated
version()and addedget_version()inPaymentProcessorimpl (line ~3651)version()now returns aStringfrom persistent storage (falling back to"1.0.0")get_version()is an alias forversion()5. Updated
upgrade_contract()inPaymentProcessorimpl (line ~5762)env.deployer().update_current_contract_wasm(new_wasm_hash)to replace the WASM"1.0.0"→"1.0.1")DataKey::ContractVersionCONTRACT/UPGRADEDevent with(old_version, new_version)6. Added
bump_version_string()helper functionByte-level semver version bumping (no
stdstring manipulation) that increments the patch number.7. Added
Error::UpgradeFailed = 48variantFor host-level upgrade failures.
8. Added tests in
fluxapay/src/test.rstest_upgrade_contract_version_and_event- verifies initial version and upgrade attempttest_upgrade_contract_unauthorized- verifies non-admin callers get rejectedtest_version_after_init- verifies version and get_version return"1.0.0"after initNote: The pre-existing compilation errors (
top_up_streamduplicate,MetadataTooLargediscriminant clash,merchant_registry_test.rsunmatched brace) are all pre-existing issues in the repository and not related to these changes.closes #281