Skip to content

fix: resolve issues #739 #740 #741 #742 - #840

Merged
nanaf6203-bit merged 2 commits into
MettaChain:mainfrom
Ummi-001:fix/issues-739-740-741-742
Jul 30, 2026
Merged

fix: resolve issues #739 #740 #741 #742#840
nanaf6203-bit merged 2 commits into
MettaChain:mainfrom
Ummi-001:fix/issues-739-740-741-742

Conversation

@Ummi-001

Copy link
Copy Markdown
Contributor

Summary

Resolves four issues in a single batch:

Closes #742
Closes #740
Closes #741
Closes #739


#742 – Replace production unwrap/expect with graceful error propagation

Files: contracts/staking/src/lib.rs, contracts/oracle/src/lib.rs, contracts/bridge/src/lib.rs, contracts/prediction-market/src/lib.rs

  • staking: 8 .unwrap() calls on validators.get / delegations.get replaced with .ok_or(Error::ValidatorNotFound | Unauthorized | DelegationNotFound)?
  • oracle (get_history_statistics): first()/last().unwrap() replaced with safe alternatives
  • bridge: route.last().unwrap().ok_or(Error::InvalidRequest)?
  • prediction-market: two winning_direction.as_ref().unwrap().ok_or(...)

#740 – Sweep #[allow(unused_*)] band-aids

Files: contracts/crowdfunding/src/lib.rs, contracts/prediction-market/src/lib.rs, contracts/identity/tests/identity_tests.rs

  • crowdfunding: removed #[allow(unused_assignments)] by deleting dead loop; removed #[allow(unused_imports)]
  • prediction-market: removed blanket #[allow(unused_variables)] from mod tests
  • identity: removed #![allow(unused_variables)] crate-level attr; prefixed genuinely-unused accounts bindings with _

#741 – Introduce offset/limit pagination on property-management view messages

File: contracts/property-management/src/lib.rs

Added MAX_PAGE = 50 bounded list views plus count helpers: get_leases_by_owner, count_leases_by_owner, get_disputes_paginated, count_disputes, get_expenses_paginated, count_expenses, get_maintenance_paginated, count_maintenance. All existing single-item getters unchanged — fully backwards-compatible.


#739 – Reuse price buffer allocations during oracle price ingestion

Files: contracts/oracle/src/slot_vec.rs (new), contracts/oracle/src/lib.rs

  • Added SlotVec<T>: a Vec<T> wrapper with reuse() (clears length, retains capacity) and into_vec()
  • collect_prices_batched: 4 intermediate buffers converted to SlotVec
  • collect_prices_sequential: output buffer converted to SlotVec

…aChain#742

MettaChain#742 – Replace production unwrap/expect with graceful error propagation
- staking: 8 .unwrap() calls on validators.get/delegations.get replaced
  with .ok_or(Error::ValidatorNotFound/Unauthorized/DelegationNotFound)?
- oracle: first/last().unwrap() in get_history_statistics replaced with
  .map(...).unwrap_or / .ok_or(OracleError::PropertyNotFound)?
- bridge: route.last().unwrap() replaced with .ok_or(Error::InvalidRequest)?
- prediction-market: winning_direction.as_ref().unwrap() replaced with
  .ok_or(Error::MarketNotActive/OracleMarketNotResolved)?

MettaChain#740 – Sweep workspace #[allow(unused_*)] band-aids
- crowdfunding: removed #[allow(unused_assignments)] by eliminating dead
  loop; removed #[allow(unused_imports)] (imports are used)
- prediction-market: removed blanket #[allow(unused_variables)] from mod tests
- identity: removed #![allow(unused_variables)] crate-level attr; prefixed
  two genuinely-unused 'accounts' bindings with '_'

MettaChain#741 – Introduce offset/limit pagination on property-management view messages
- Added MAX_PAGE = 50 constant
- get_leases_by_owner(owner, offset, limit) + count_leases_by_owner(owner)
- get_disputes_paginated(offset, limit) + count_disputes()
- get_expenses_paginated(offset, limit) + count_expenses()
- get_maintenance_paginated(offset, limit) + count_maintenance()
- Legacy single-item views unchanged (backwards-compatible)

MettaChain#739 – Reuse price buffer allocations during oracle price ingestion
- Added contracts/oracle/src/slot_vec.rs: SlotVec<T> wrapper that clears
  contents via reuse() while retaining heap allocation (capacity preserved)
- collect_prices_batched: 4 intermediate Vec buffers converted to SlotVec
- collect_prices_sequential: output Vec converted to SlotVec
- Docstring on each function notes the reuse pattern
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@Ummi-001 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

@nanaf6203-bit
nanaf6203-bit merged commit c15b3d0 into MettaChain:main Jul 30, 2026
1 of 2 checks passed
nanaf6203-bit added a commit that referenced this pull request Jul 30, 2026
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