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
Feature Request
Area: Smart Contract
File:
contracts/solar_grid/src/lib.rsDescription
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_LISTmaintained in instance storage on everyregister_metercallget_all_metersreturns full list of registered meter IDsGET /api/metersroute updated to callget_all_meters