Add multicall utility and metrics aggregation module#90
Add multicall utility and metrics aggregation module#90tahseen-ccprotocol merged 9 commits intodevelopfrom
Conversation
- Introduced a new `multicall` function to enable batching of multiple entity read calls into a single RPC request, improving efficiency. - Updated `provider.ts` to enable `batch.multicall` in the JSON RPC provider configuration. - Exported the new `multicall` function from the utils index for easy access.
- Implemented a new `multicall` method in the `OakContractsClient` interface to facilitate batching of multiple entity read calls into a single RPC request. - Updated the `create.ts` file to include the `multicall` function, enhancing the client’s functionality and efficiency in handling multiple asynchronous calls.
- Added `getCampaignSummary` function to aggregate financial data from the CampaignInfo contract, including total raised, refunded, and goal status. - Introduced `getTreasuryReport` function for per-treasury reporting, supporting AllOrNothing, KeepWhatsRaised, and PaymentTreasury contracts. - Updated types to reflect new options and return structures for campaign and treasury reports. - Enhanced documentation with examples for both functions to improve usability.
- Introduced tests for the `multicall` utility, verifying concurrent execution of closures and error propagation. - Expanded the `getPlatformStats`, `getCampaignSummary`, and `getTreasuryReport` functions with comprehensive tests to ensure accurate financial data aggregation and reporting. - Implemented mock client for testing contract interactions, improving test coverage and reliability.
- Introduced a new section on Multicall, detailing its usage for batching multiple entity read calls into a single RPC request, with examples for standalone utility and client convenience methods. - Added a Metrics section, outlining pre-built aggregation functions for platform statistics, campaign summaries, and treasury reports, complete with usage examples. - Updated the exported entry points to include the new multicall and metrics functionalities for improved accessibility.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a25636fb9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Introduced a constant for the canonical Multicall3 address, ensuring consistency across supported chains. - Updated Celo Mainnet and Celo Sepolia chain definitions to include the Multicall3 contract address and block creation details, enhancing interoperability for multicall functionalities.
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Summary
Multicall utility: Added an ergonomic
multicallfunction that batches multiple entity read calls into a single RPC round-trip via Multicall3. Accepts lazy closures (() => gp.getProtocolFeePercent()) instead of raw ABI descriptors, aligning with the existing entity read pattern. Enabled viem'sbatch.multicalltransport on the provider so all concurrentreadContractcalls are automatically aggregated. Exposed as both a standalone utility (multicall(...)) and a client convenience method (oak.multicall(...)).Metrics module: Implemented three aggregation functions —
getPlatformStats,getCampaignSummary, andgetTreasuryReport— that combine multiple on-chain reads into structured reports. Supports all three treasury types (all-or-nothing,keep-whats-raised,payment-treasury) with correct ABI resolution for each.Tests & docs: Added comprehensive unit tests for the multicall utility and all three metrics functions with 100% coverage. Updated
README.mdwith dedicated Multicall and Metrics sections, usage examples, doc links, and the exported entry points table.