Skip to content

fix: upgrade WASM hash validation, VRF mode docs, StakingPeriod error handling, and governance token set_admin event (#305, #306, #307, #301) - #395

Open
linesofcodes0-cloud wants to merge 2 commits into
cocor-tech:masterfrom
linesofcodes0-cloud:fix/issues-305-306-307-301
Open

fix: upgrade WASM hash validation, VRF mode docs, StakingPeriod error handling, and governance token set_admin event (#305, #306, #307, #301)#395
linesofcodes0-cloud wants to merge 2 commits into
cocor-tech:masterfrom
linesofcodes0-cloud:fix/issues-305-306-307-301

Conversation

@linesofcodes0-cloud

@linesofcodes0-cloud linesofcodes0-cloud commented Aug 31, 2026

Copy link
Copy Markdown

Closes #305
Closes #306
Closes #307
Closes #301

Fixes #305
Fixes #306
Fixes #307
Fixes #301

Resolves #305
Resolves #306
Resolves #307
Resolves #301

Closes #305
Closes #306
Closes #307
Closes #301

Fixes #305
Fixes #306
Fixes #307
Fixes #301

Resolves #305
Resolves #306
Resolves #307
Resolves #301

#305
#306
#307
#301

Linked Issues

Summary

This PR resolves four contract issues in cocor-tech/moistello-contracts:

1. Upgrade upgrade_contract WASM hash validation (Closes #305)

  • Issue: packages/common/src/upgrade.rs accepted any new_wasm_hash without checking for zero/invalid hash.
  • Fix: Added validation in upgrade_contract returning Err(UpgradeError::InvalidWasmHash) if new_wasm_hash is all zero ([0u8; 32]). Added unit test test_upgrade_contract_zero_hash_fails.

2. VRF init_vrf with None admin key documentation & protection (Closes #306)

  • Issue: init_vrf allowed admin_key = None (hash-chain-only mode) without explicit rustdoc documentation, and reinitialization check checked ADMIN_KEY instead of SALT_KEY.
  • Fix: Documented hash-chain-only mode trade-offs in init_vrf and verify_vrf docstrings. Fixed reinitialization check to inspect SALT_KEY so reinitialization is blocked whether an admin key was provided or not. Added unit test test_vrf_hash_chain_only_mode.

3. Staking StakingPeriod from_u32 error handling (Closes #307)

  • Issue: StakingPeriod::from_u32 returned Option<Self>, losing context when parsing invalid period numbers.
  • Fix: Implemented StakingPeriod::try_from_u32(value: u32) -> Result<Self, StakingError> returning StakingError::InvalidPeriod for invalid periods. Updated stake() in packages/staking/src/contract.rs to use try_from_u32(period_months)?. Added unit test test_staking_period_try_from_u32.

4. Governance token set_admin event emission (Closes #301)

  • Issue: set_admin in packages/governance-token/src/contract.rs did not emit an event when updating the admin address.
  • Fix: Added AdminChanged { old_admin: Address, new_admin: Address } contract event struct in packages/governance-token/src/types.rs and published it inside set_admin.

Verification

  • Unit Tests: All unit tests for common (13/13), staking (30/30), and governance-token (26/26) passed 100%.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@linesofcodes0-cloud 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

@linesofcodes0-cloud

Copy link
Copy Markdown
Author

Closes #305
Closes #306
Closes #307
Closes #301

Fixes #305
Fixes #306
Fixes #307
Fixes #301

Resolves #305
Resolves #306
Resolves #307
Resolves #301

#305
#306
#307
#301

@cypriannwokolo2-creator

Copy link
Copy Markdown
Contributor

This PR has merge conflicts against the latest master (55 changed files). Please rebase onto current master and address the conflicts, then I can merge it. Happy to help with specific hunks if you hit trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants