Skip to content

implemented the contract WASM upgrade function with version tracking.#352

Merged
Pvsaint merged 1 commit into
MetroLogic:mainfrom
tecch-wiz:feat
Jun 2, 2026
Merged

implemented the contract WASM upgrade function with version tracking.#352
Pvsaint merged 1 commit into
MetroLogic:mainfrom
tecch-wiz:feat

Conversation

@tecch-wiz
Copy link
Copy Markdown

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::ContractVersion variant (line ~629)

Added a new storage key for persisting the contract version string.

2. New constant INITIAL_CONTRACT_VERSION (line ~633)

pub const INITIAL_CONTRACT_VERSION: &str = "1.0.0";

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 added get_version() in PaymentProcessor impl (line ~3651)

  • version() now returns a String from persistent storage (falling back to "1.0.0")
  • get_version() is an alias for version()

5. Updated upgrade_contract() in PaymentProcessor impl (line ~5762)

  • Requires admin role authorization
  • Captures the old version string
  • Calls env.deployer().update_current_contract_wasm(new_wasm_hash) to replace the WASM
  • Bumps the minor version (e.g., "1.0.0""1.0.1")
  • Persists the new version string to DataKey::ContractVersion
  • Emits CONTRACT/UPGRADED event with (old_version, new_version)

6. Added bump_version_string() helper function

Byte-level semver version bumping (no std string manipulation) that increments the patch number.

7. Added Error::UpgradeFailed = 48 variant

For host-level upgrade failures.

8. Added tests in fluxapay/src/test.rs

  • test_upgrade_contract_version_and_event - verifies initial version and upgrade attempt
  • test_upgrade_contract_unauthorized - verifies non-admin callers get rejected
  • test_version_after_init - verifies version and get_version return "1.0.0" after init

Note: The pre-existing compilation errors (top_up_stream duplicate, MetadataTooLarge discriminant clash, merchant_registry_test.rs unmatched brace) are all pre-existing issues in the repository and not related to these changes.

closes #281

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

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

Learn more about application limits

@Pvsaint Pvsaint merged commit 8342543 into MetroLogic:main Jun 2, 2026
1 check failed
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 contract WASM upgrade function with version tracking

3 participants