Skip to content

feat(escrow): add read-only EscrowSummary view#225

Open
Mikkelnice wants to merge 1 commit into
DelegoLabs:mainfrom
Mikkelnice:feat/escrow-summary-view
Open

feat(escrow): add read-only EscrowSummary view#225
Mikkelnice wants to merge 1 commit into
DelegoLabs:mainfrom
Mikkelnice:feat/escrow-summary-view

Conversation

@Mikkelnice

@Mikkelnice Mikkelnice commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Adds a compact getter for API/indexer consumers that need all escrow display fields in one call.

Changes

  • EscrowSummary contracttype: escrow_id, buyer, seller, amount, status
  • get_escrow_summary(escrow_id)Result<EscrowSummary, EscrowError> — returns NotFound for missing escrows
  • Tests: missing escrow id returns NotFound; existing escrow returns correct summary fields

Files Changed

  • contracts/escrow/src/lib.rs
  • contracts/escrow/src/test.rs

Closes #90

Summary by CodeRabbit

  • New Features

    • Added a compact escrow summary view for quickly checking key escrow details.
    • Introduced a safer lookup that returns an error when an escrow record is missing instead of failing unexpectedly.
  • Tests

    • Added coverage for missing escrow lookups.
    • Added coverage for retrieving an existing escrow summary and verifying the returned details.

- Add EscrowSummary contracttype with escrow_id, buyer, seller, amount, status
- Add get_escrow_summary() returning Result<EscrowSummary, EscrowError::NotFound>
- Add unit tests for missing and existing escrow ids

Closes DelegoLabs#90
@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@Mikkelnice 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

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a compact EscrowSummary type and a get_escrow_summary getter that returns NotFound for missing escrow ids. Tests cover both the missing-escrow case and a funded escrow returned through the new summary view.

Changes

Escrow summary view

Layer / File(s) Summary
Summary API and coverage
contracts/escrow/src/lib.rs, contracts/escrow/src/test.rs
Adds EscrowSummary, a get_escrow_summary getter that returns Err(EscrowError::NotFound) when storage has no record, and tests for missing and funded escrows.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • DelegoLabs/Delego#41 — Shares the same EscrowError::NotFound path and read-only escrow error handling in contracts/escrow/src/lib.rs.
  • DelegoLabs/Delego#144 — Establishes the escrow record shape that get_escrow_summary reads from and maps into a compact return type.

Suggested labels

size/S

Poem

🐇 I hopped to storage, quick and keen,
A tidy escrow summary now can be seen.
If none is there, NotFound sings,
If funds are set, it shows the things.
Carrots for contracts, crisp and clean! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds the summary getter and tests, but the required EscrowSummary type in #90 specifies a BytesN<32> escrow_id and merchant field, while the implementation uses u64 and seller. Align EscrowSummary with the linked issue's required shape, especially the escrow_id type and field naming, then retest missing and existing escrow IDs.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the new read-only escrow summary view added by the PR.
Out of Scope Changes check ✅ Passed The changes stay within contracts/escrow/src/lib.rs and contracts/escrow/src/test.rs and match the stated feature scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contracts/escrow/src/test.rs`:
- Around line 50-52: The test setup still uses the deprecated
register_stellar_asset_contract API when creating the Stellar asset token.
Update the token registration in the escrow test to use
register_stellar_asset_contract_v2 instead, and obtain the contract address from
the returned handle before calling StellarAssetClient::new and minting to the
buyer.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: acc318cf-c62b-438b-8807-5212c3b99a0d

📥 Commits

Reviewing files that changed from the base of the PR and between c6dd0d9 and 35ebf7f.

📒 Files selected for processing (2)
  • contracts/escrow/src/lib.rs
  • contracts/escrow/src/test.rs

Comment on lines +50 to +52
let token_admin = Address::generate(&env);
let token_id = env.register_stellar_asset_contract(token_admin.clone());
soroban_sdk::token::StellarAssetClient::new(&env, &token_id).mint(&buyer, &10000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Is Env::register_stellar_asset_contract deprecated in soroban-sdk 22.0.0, and what is the recommended replacement?

💡 Result:

Yes, the function register_stellar_asset_contract is deprecated in soroban-sdk version 22.0.0 (and later versions) [1]. It is marked as deprecated within the testutils module of the Env struct [1]. The recommended replacement is register_stellar_asset_contract_v2 [1][2]. Unlike the original version, which returned only the contract ID [1], register_stellar_asset_contract_v2 returns a utility struct that includes the contract ID and provides additional methods for reading and updating issuer flags (such as AUTH_REVOCABLE and AUTH_REQUIRED) [1][2]. This updated function is specifically designed to facilitate testing scenarios that require interaction with Stellar Asset Contract (SAC) configuration [1][2][3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the test file and dependency declarations related to soroban-sdk.
git ls-files | rg '(^|/)Cargo\.toml$|contracts/escrow/src/test\.rs$'
echo '---'
for f in $(git ls-files | rg '(^|/)Cargo\.toml$|contracts/escrow/src/test\.rs$'); do
  echo "### $f"
  sed -n '1,220p' "$f"
  echo
done

Repository: DelegoLabs/Delego

Length of output: 4743


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the test file around the reported lines.
sed -n '1,120p' contracts/escrow/src/test.rs

Repository: DelegoLabs/Delego

Length of output: 2774


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the test file and dependency declarations related to soroban-sdk.
git ls-files | rg '(^|/)Cargo\.toml$|contracts/escrow/src/test\.rs$'
echo '---'
for f in $(git ls-files | rg '(^|/)Cargo\.toml$|contracts/escrow/src/test\.rs$'); do
  echo "### $f"
  sed -n '1,220p' "$f"
  echo
done

Repository: DelegoLabs/Delego

Length of output: 4743


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the test file around the reported lines.
sed -n '1,120p' contracts/escrow/src/test.rs

Repository: DelegoLabs/Delego

Length of output: 2774


Use register_stellar_asset_contract_v2 here
register_stellar_asset_contract is deprecated in soroban-sdk 22.0.0. Switch this test to register_stellar_asset_contract_v2 and take the address from the returned contract handle.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/escrow/src/test.rs` around lines 50 - 52, The test setup still uses
the deprecated register_stellar_asset_contract API when creating the Stellar
asset token. Update the token registration in the escrow test to use
register_stellar_asset_contract_v2 instead, and obtain the contract address from
the returned handle before calling StellarAssetClient::new and minting to the
buyer.

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.

[Soroban/Escrow] Add Read-Only Escrow Summary View

1 participant