Skip to content

Add a batch contribution read view returning many investors' funded amounts in one call #553

Description

@mikewheeleer

Add a batch contribution read view returning many investors' funded amounts in one call

Description

get_contribution(investor) returns a single investor's funded principal, and get_investors(start, limit) paginates addresses. To render a cap table, an integrator must call get_contribution once per address — N round-trips for N investors. There is no way to fetch a page of (address, amount) pairs together, which is wasteful for indexers reconstructing the book.

This issue adds get_contributions(addresses: Vec<Address>) -> Vec<i128> that resolves each supplied address to its recorded contribution (zero for non-funders) in a single read call, mirroring the input order.

Requirements and context

  • Repository scope: Liquifact/Liquifact-contracts only.
  • Add get_contributions(addresses: Vec<Address>) -> Vec<i128> returning one amount per input address, in order, reusing the same storage path as get_contribution.
  • Return 0 for any address with no recorded contribution (never panic on unknown addresses).
  • Bound the input length with a constant (e.g. reuse the existing pagination ceiling) and reject oversized batches with a typed error to avoid unbounded reads.
  • Pure read-only: no auth, no writes, no TTL bump.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feature/contracts-batch-contribution-view
  • Implement changes
    • Write code in: escrow/src/lib.rsget_contributions.
    • Write comprehensive tests in: escrow/src/tests/funding.rs — assert order preservation, zero for unknown addresses, equivalence with per-address get_contribution, the empty-input case, and the over-cap rejection.
    • Add documentation: extend the integrator view-surface reference with the batch read.
    • Include NatSpec-style doc comments (///) on the new view.
    • Validate security assumptions: bounded reads, no mutation, no panic on unknown input.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases and failure paths: empty vector, mix of funders and non-funders, duplicate addresses, batch at and above the cap.
  • Include the full cargo test output and a short security notes section in the PR description.

Example commit message

feat: add bounded batch contribution read view with order and equivalence tests

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the Liquifact community on Discord for questions, reviews, and faster merges: https://discord.gg/JrGPH4V3
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions