Skip to content

feat(contract): add get_all_meters admin function to list all registered meter IDs #181

@Dev-AdeTutu

Description

@Dev-AdeTutu

Feature Request

Area: Smart Contract
File: contracts/solar_grid/src/lib.rs

Description

There is currently no way to enumerate all registered meters from the contract. The provider dashboard and backend need a way to list all meter IDs to display the registry and run batch operations.

Implementation Guide

Maintain a Vec<Symbol> of meter IDs in instance storage:

`
ust
const METER_LIST: Symbol = symbol_short!("MTRLIST");

// In register_meter, after storing the meter:
let mut list: Vec = env.storage().instance()
.get(&METER_LIST).unwrap_or(Vec::new(&env));
list.push_back(meter_id.clone());
env.storage().instance().set(&METER_LIST, &list);

// New function:
pub fn get_all_meters(env: Env) -> Vec {
env.storage().instance().get(&METER_LIST).unwrap_or(Vec::new(&env))
}
`

Definition of Done

  • METER_LIST maintained in instance storage on every register_meter call
  • get_all_meters returns full list of registered meter IDs
  • Unit test verifies list grows correctly as meters are registered
  • Backend GET /api/meters route updated to call get_all_meters
  • Provider dashboard fetches live meter list from contract

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions