Skip to content

feat(pool): add public getters for admin, invoice_contract, escrow_contract - #676

Merged
mergekeeper[bot] merged 4 commits into
TrusTrove:mainfrom
Bogunrot:issue-578
Sep 3, 2026
Merged

feat(pool): add public getters for admin, invoice_contract, escrow_contract#676
mergekeeper[bot] merged 4 commits into
TrusTrove:mainfrom
Bogunrot:issue-578

Conversation

@Bogunrot

Copy link
Copy Markdown
Contributor

Linked Issue

Closes #578

Problem Statement (The Bug)

The pool contract stores Admin, InvoiceContract, and EscrowContract addresses in instance storage and has private helpers (Self::admin, Self::invoice_contract, Self::escrow_contract) to read them, but only UsdcAsset is exposed via a public getter (get_usdc_asset). There is no way for an off-chain client, another contract, or a test to read the pool's configured admin/invoice/escrow addresses without inspecting raw storage.

Solution Comparison and Decision

  • Option A: Expose raw storage reads — Callers use env.storage().instance().get(&DataKey::Admin) directly. This leaks internal key names and breaks encapsulation.
  • Option B: Add thin public getters — Wrap existing private helpers, matching the exact pattern of get_usdc_asset. Consistent, simple, and safe.

Option B was chosen because it follows the established pattern and provides a clean public API.

The Change (Code modifications)

Change File Description
New getter contracts/pool/src/lib.rs get_admin(env) -> Address
New getter contracts/pool/src/lib.rs get_invoice_contract(env) -> Address
New getter contracts/pool/src/lib.rs get_escrow_contract(env) -> Address
Tests contracts/pool/src/test.rs 6 tests: 3 happy-path + 3 uninitialized-panic cases

Compatibility Note (On INTERFACE_VERSION)

No interface version change. This is a purely additive change — three new public read-only entry points are added. No existing interface is modified.

Incidental Fixes

  • None.

Testing (Proving it works)

  • test_get_admin_returns_correct_address: Verifies the admin address matches the one used in initialize().
  • test_get_invoice_contract_returns_correct_address: Verifies the invoice contract address matches the one used in initialize().
  • test_get_escrow_contract_returns_correct_address: Verifies the escrow contract address matches the one used in initialize().
  • test_get_admin_panics_when_uninitialized: Asserts panic for uninitialized contract.
  • test_get_invoice_contract_panics_when_uninitialized: Asserts panic for uninitialized contract.
  • test_get_escrow_contract_panics_when_uninitialized: Asserts panic for uninitialized contract.

All 6 new tests pass.

Additional Notes

These getters mirror the existing get_usdc_asset pattern and use the private helpers already present in the contract. No storage key changes are needed.

…ntract

Add get_admin(), get_invoice_contract(), and get_escrow_contract()
public read-only accessors, matching the symmetry already present for
get_usdc_asset(). These wrap the existing private helpers (admin,
invoice_contract, escrow_contract) and include rustdoc matching the
style of get_usdc_asset. Tests cover both happy-path and
uninitialized-panic cases.

Closes TrusTrove#578

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Bogunrot
Bogunrot requested a review from K1NGD4VID as a code owner August 27, 2026 05:30
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Bogunrot Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mergekeeper

mergekeeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Needs changes

Public getters for invoice and escrow contracts call private helpers directly without checking option unwrapping or panicking on uninitialized state, causing test failures on expected panic messages.

  • contracts/pool/src/lib.rs:202: get_invoice_contract calls Self::invoice_contract(&env) directly which returns Option instead of unwrapping or panicking when uninitialized, causing the corresponding test to fail.
  • contracts/pool/src/lib.rs:224: get_escrow_contract calls Self::escrow_contract(&env) directly which returns Option instead of unwrapping or panicking when uninitialized, causing the corresponding test to fail.

Reviewed commit: 3a113939203540033cd3ede908b51d270871f2c4.

@mergekeeper mergekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs changes

Private helper implementations for invoice and escrow contract getters do not unwrap or handle Option types properly compared to admin and usdc assets.

  • contracts/pool/src/lib.rs:206: Self::invoice_contract(&env) returns an Option<Address> (or raw helper return type), but lacks .expect(...) like get_admin and get_usdc_asset, causing a type mismatch or missing panic behavior required by the issue.
  • contracts/pool/src/lib.rs:228: Self::escrow_contract(&env) lacks .expect(...) to unwrap the Option and provide an uninitialized panic message, which is tested in test.rs expecting specific panic strings.

Reviewed commit: 458bbbad5e03142dc162558303368e41e56ad046.

…e#676)

Resolve the test.rs conflict by keeping main's checks-effects-interactions
tests alongside the new public-getter tests for admin, invoice contract,
and escrow contract. The getters delegate to private helpers that already
unwrap with clear panic messages, so no behavior change was needed.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>

@mergekeeper mergekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs changes

Public getters for invoice and escrow contracts call private helpers directly without checking option unwrapping or panicking on uninitialized state, causing test failures on expected panic messages.

  • contracts/pool/src/lib.rs:202: get_invoice_contract calls Self::invoice_contract(&env) directly which returns Option instead of unwrapping or panicking when uninitialized, causing the corresponding test to fail.
  • contracts/pool/src/lib.rs:224: get_escrow_contract calls Self::escrow_contract(&env) directly which returns Option instead of unwrapping or panicking when uninitialized, causing the corresponding test to fail.

Reviewed commit: 3a113939203540033cd3ede908b51d270871f2c4.

Bogunrot and others added 2 commits September 3, 2026 21:57
… pattern

Make the private invoice_contract/escrow_contract helpers return
Option<Address> (raw storage read) and move the .expect(...) into the
public getters, mirroring get_admin. Internal call sites unwrap with the
same messages, so panic behavior is unchanged.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@mergekeeper

mergekeeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

MergeKeeper review

Scope: in scope for linked issue #578.
Verdict: clean

The pull request correctly implements the public getters for admin, invoice contract, and escrow contract along with all required tests and documentation matching the issue requirements.

Reviewed commit: 077f45e331c7f784eb0ff01a20158708ca2f557c.
CI and merge eligibility are checked separately.

@mergekeeper mergekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

The pull request correctly implements the public getters for admin, invoice contract, and escrow contract along with all required tests and documentation matching the issue requirements.

@mergekeeper
mergekeeper Bot merged commit c6d5da2 into TrusTrove:main Sep 3, 2026
2 checks passed
@mergekeeper

mergekeeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Merged

Merged with squash.

Bogunrot added a commit to Bogunrot/TrusTrove-contract that referenced this pull request Sep 3, 2026
…e#674)

main now contains the merged public-getter work (TrusTrove#676), which touched
the same pool files. Keep both: main's getter tests alongside the
pool_initialized event test from this PR. All 109 pool tests pass.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement(pool): missing public getters for admin, invoice_contract, and escrow_contract addresses

1 participant