Skip to content

feat: delego build#272

Open
manasehstephen131-ops wants to merge 1 commit into
DelegoLabs:mainfrom
manasehstephen131-ops:manasehstephen131-ops
Open

feat: delego build#272
manasehstephen131-ops wants to merge 1 commit into
DelegoLabs:mainfrom
manasehstephen131-ops:manasehstephen131-ops

Conversation

@manasehstephen131-ops

@manasehstephen131-ops manasehstephen131-ops commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

closes #170

Summary by CodeRabbit

  • New Features
    • Added a read-only receipt view for escrows, showing key order details and current status.
  • Bug Fixes
    • Receipt lookups now return a clear “not found” result when an escrow doesn’t exist.
  • Tests
    • Added coverage for receipt states after funding, release, refund, dispute, and missing records.
    • Expanded snapshot coverage for escrow and refund-related scenarios.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new EscrowReceipt struct and get_receipt read-only method to the escrow contract. Five integration tests cover receipt retrieval across funded, released, refunded, disputed, and not-found states. Corresponding JSON test snapshots are added for all new and existing refund-eligibility/unit tests.

Changes

EscrowReceipt Getter

Layer / File(s) Summary
EscrowReceipt type and get_receipt method
contracts/escrow/src/lib.rs
Defines EscrowReceipt struct with escrow_id, buyer, seller, order_id, status fields. Adds get_receipt(env, escrow_id) that returns EscrowError::NotFound for missing records or maps EscrowRecord fields into EscrowReceipt.
Integration tests for get_receipt
contracts/escrow/src/integration_tests.rs
Adds five tests: funded state, released state, refunded state, disputed state, and not-found error case, each asserting receipt fields and expected EscrowStatus.
Test snapshots for get_receipt
contracts/escrow/test_snapshots/integration_tests/test_get_receipt_*.1.json
New JSON snapshots capturing full ledger/contract state for all five get_receipt test cases.
Test snapshots for refund-eligibility and unit tests
contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_*.1.json, contracts/escrow/test_snapshots/test/test/test_get_token_not_found.1.json, contracts/escrow/test_snapshots/test/test/test_set_create_paused_*.1.json
New JSON snapshots for refund-eligibility integration tests and unit tests for get_token_not_found and set_create_paused.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • #170 ([Soroban/Escrow] Add Buyer-Facing Escrow Receipt Getter): This PR directly implements the get_receipt getter, EscrowReceipt type, not-found error, and state-coverage tests described in the issue.
  • [Soroban/Escrow] Add Merchant-Facing Escrow Receipt Getter #171: Related issue also requesting an escrow receipt getter with matching integration tests for all status states.

Possibly related PRs

  • DelegoLabs/Delego#41: This PR's get_receipt returns EscrowError::NotFound for missing escrow records, directly depending on the typed error enum from that PR.
  • DelegoLabs/Delego#144: get_receipt constructs EscrowReceipt from the stored EscrowRecord/EscrowStatus types established in that escrow lifecycle PR.

Poem

🐇 Hop, hop! A receipt pops out,
The buyer sees what escrow's about—
Funded, released, refunded too,
Disputed states all tested through.
No escrow missing from our sight,
NotFound errors set things right!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is unrelated to the escrow receipt getter changes and does not describe the PR's main purpose. Rename the PR to describe the escrow receipt getter, e.g. "feat: add buyer-facing escrow receipt getter".
Linked Issues check ⚠️ Warning The getter shape and tests diverge from #170: it returns seller/order_id/status instead of merchant/amount/created_at_ledger and misses created-state coverage. Align EscrowReceipt with the required fields, add created-state coverage, and verify the getter and tests match the issue exactly.
Out of Scope Changes check ⚠️ Warning The PR adds many snapshot updates for refund eligibility and pause-state tests that are not required by the receipt getter issue. Remove unrelated snapshot/test changes and limit the diff to the receipt getter and the smallest adjacent test updates needed.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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: 2

🤖 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/lib.rs`:
- Around line 220-237: `EscrowReceipt` in the escrow contract does not match the
requested receipt shape, so `get_receipt` still returns the wrong public
contract. Update the receipt type and the related `deposit`/storage flow so the
contract persists enough creation metadata to return `escrow_id: BytesN<32>`,
`buyer`, `merchant`, `amount`, and `created_at_ledger`. Use the existing
`EscrowReceipt` and `get_receipt` symbols to align the getter output with issue
`#170`, and remove or replace fields like `seller`, `order_id`, and `status` if
they are not part of the wire contract.

In
`@contracts/escrow/test_snapshots/test/test/test_set_create_paused_success.1.json`:
- Around line 6-56: Regenerate the snapshot from the complete success flow
exercised by escrow test setup so it matches the actual behavior of
set_create_paused in contracts/escrow/src/test.rs. The fixture currently mixes
two separate executions by showing only one auth tree for the pair of calls
(true then false), and it must also include the escrow.paused event emitted by
contracts/escrow/src/lib.rs instead of ending with an empty events array. Use
the set_create_paused flow and the escrow.paused emission as the anchors when
updating the fixture so the auth and events reflect the full run.
🪄 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: 224f34db-a51d-41dc-a5c0-4b2fdfa6192b

📥 Commits

Reviewing files that changed from the base of the PR and between 4e7161b and b23a58c.

📒 Files selected for processing (19)
  • contracts/escrow/src/integration_tests.rs
  • contracts/escrow/src/lib.rs
  • contracts/escrow/test_snapshots/integration_tests/test_get_receipt_disputed_state.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_get_receipt_funded_state.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_get_receipt_not_found.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_get_receipt_refunded_state.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_get_receipt_released_state.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_admin_always_eligible.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_already_refunded.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_already_released.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_buyer_after_timeout.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_buyer_before_timeout.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_disputed.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_not_found.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_seller_always_eligible.1.json
  • contracts/escrow/test_snapshots/integration_tests/test_refund_eligibility_unauthorized_stranger.1.json
  • contracts/escrow/test_snapshots/test/test/test_get_token_not_found.1.json
  • contracts/escrow/test_snapshots/test/test/test_set_create_paused_success.1.json
  • contracts/escrow/test_snapshots/test/test/test_set_create_paused_unauthorized.1.json

Comment on lines +220 to +237
/// Compact receipt returned to buyers after escrow creation via `get_receipt`.
///
/// Fields are a purposeful subset of `EscrowRecord` — callers that need the
/// full record (amount, token, timeout, …) should use `get_escrow` instead.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct EscrowReceipt {
/// Numeric escrow identifier (matches the value returned by `deposit`).
pub escrow_id: u64,
/// Address of the buyer who funded the escrow.
pub buyer: Address,
/// Address of the seller (merchant) who will receive the released funds.
pub seller: Address,
/// Merchant-facing order reference embedded at deposit time.
pub order_id: BytesN<32>,
/// Current lifecycle status of the escrow.
pub status: EscrowStatus,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Align EscrowReceipt with the requested wire contract.

The linked requirement calls for EscrowReceipt { escrow_id: BytesN<32>, buyer, merchant, amount, created_at_ledger }, but this adds { escrow_id: u64, buyer, seller, order_id, status } instead. That means the new public getter still cannot serve the buyer/backend receipt shape requested by issue #170, and deposit only persists created_at as a timestamp, so get_receipt has no way to populate created_at_ledger later. Please adjust the stored creation metadata and return the requested fields here.

Also applies to: 942-965

🤖 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/lib.rs` around lines 220 - 237, `EscrowReceipt` in the
escrow contract does not match the requested receipt shape, so `get_receipt`
still returns the wrong public contract. Update the receipt type and the related
`deposit`/storage flow so the contract persists enough creation metadata to
return `escrow_id: BytesN<32>`, `buyer`, `merchant`, `amount`, and
`created_at_ledger`. Use the existing `EscrowReceipt` and `get_receipt` symbols
to align the getter output with issue `#170`, and remove or replace fields like
`seller`, `order_id`, and `status` if they are not part of the wire contract.

Comment on lines +6 to +56
"auth": [
[],
[],
[],
[
[
"CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4",
{
"function": {
"contract_fn": {
"contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"function_name": "set_create_paused",
"args": [
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4"
},
{
"bool": true
}
]
}
},
"sub_invocations": []
}
]
],
[],
[
[
"CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4",
{
"function": {
"contract_fn": {
"contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"function_name": "set_create_paused",
"args": [
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4"
},
{
"bool": false
}
]
}
},
"sub_invocations": []
}
]
],
[]
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Regenerate this fixture from the full success flow.

contracts/escrow/src/test.rs calls set_create_paused twice (true, then false), but this snapshot only records one auth tree and still ends with "events": [] even though contracts/escrow/src/lib.rs emits escrow.paused on success. The fixture is mixing two executions and no longer matches the exercised behavior.

Also applies to: 314-315

🤖 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/test_snapshots/test/test/test_set_create_paused_success.1.json`
around lines 6 - 56, Regenerate the snapshot from the complete success flow
exercised by escrow test setup so it matches the actual behavior of
set_create_paused in contracts/escrow/src/test.rs. The fixture currently mixes
two separate executions by showing only one auth tree for the pair of calls
(true then false), and it must also include the escrow.paused event emitted by
contracts/escrow/src/lib.rs instead of ending with an empty events array. Use
the set_create_paused flow and the escrow.paused emission as the anchors when
updating the fixture so the auth and events reflect the full run.

@ScriptedBro

Copy link
Copy Markdown
Contributor

Fix failing ci

@ScriptedBro

Copy link
Copy Markdown
Contributor

Please resolve conflicts

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 Buyer-Facing Escrow Receipt Getter

2 participants