Skip to content

Add settlement.simulate claim - #1019

Merged
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
gloskull:Add-settlement.simulate_claim
Jul 29, 2026
Merged

Add settlement.simulate claim#1019
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
gloskull:Add-settlement.simulate_claim

Conversation

@gloskull

Copy link
Copy Markdown
Contributor

Motivation

  • Provide a read-only preview of a developer claim so callers can inspect the outcome of withdraw_developer_balance without performing state changes or transfers.

Description

  • Add a typed return struct ClaimSimulation containing developer, recipient, token, current and remaining balances, contract liquidity, daily cap and same-day withdrawal state in contracts/settlement/src/lib.rs.
  • Implement simulate_claim(env, developer, amount, to) as a read-only view that reuses the same validation logic as withdraw_developer_balance but performs no auth, transfers, storage writes, TTL updates, or events in contracts/settlement/src/lib.rs.
  • Add focused unit tests exercising a successful preview, verifying no side effects, and asserting that validation errors (non-positive amount, overdraw, claim-window closed) are returned by the view in contracts/settlement/src/test.rs.
  • Document the new visible API in contracts/settlement/API.md describing the semantics and fields returned by simulate_claim.

Testing

  • Added unit tests for simulate_claim under contracts/settlement/src/test.rs but running the package test suite with cargo test -p callora-settlement --lib failed to complete because the build fails in an upstream dependency (soroban-env-host) with a ChaCha20Rng / ed25519_dalek::rand_core::CryptoRng trait mismatch error.
  • Ran rustfmt on the modified settlement files successfully, while cargo fmt of the whole repo reported pre-existing parse errors in unrelated tests (in contracts/vault/src/test.rs).
  • The new tests should pass once the environment/dependency compile issue and unrelated repo parse errors are resolved.

Closes #571

@greatest0fallt1me
greatest0fallt1me merged commit 0e8429e into CalloraOrg:main Jul 29, 2026
6 checks passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

LGTM ✅ merging. Thanks!

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.

Add settlement.simulate_claim read-only view

2 participants