Skip to content

list_pools does not validate start_id is within range #245

Description

@ritaifeoluwa

Description

The Factory contract's list_pools function does not validate that start_id is less than pool_count. A caller can pass any u32 value, which could cause unexpected behavior.

Current behavior

pub fn list_pools(
    env: Env,
    start_id: u32,
    limit: u32,
) -> Result<ListPoolsResponse, FactoryError> {
    // No validation on start_id
}

Expected behavior

Add validation:

if start_id >= count {
    return Ok(ListPoolsResponse {
        records: vec![&env],
        next_start_id: count,
        total: count,
    });
}

Why this matters

Invalid start_id values could cause confusing behavior or wasted gas.

Labels

enhancement, factory, good first issue

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions