Skip to content

feat(repayment): idempotency and no-double-repay guards (#148) - #231

Open
bilhokista wants to merge 1 commit into
Stellar-VaultLink:masterfrom
bilhokista:feat/issue-148-repayment-idempotency-guards
Open

feat(repayment): idempotency and no-double-repay guards (#148)#231
bilhokista wants to merge 1 commit into
Stellar-VaultLink:masterfrom
bilhokista:feat/issue-148-repayment-idempotency-guards

Conversation

@bilhokista

Copy link
Copy Markdown

Summary

Adds explicit status-based idempotency and double-repay guards to repay_invoice in the repayment contract:

  • Reverts immediately with ContractError::InvalidTransition (Invoice-as-NFT tokenization #3) if invoice.status == InvoiceStatus::Repaid or offer.status == OfferStatus::Repaid.
  • Reverts with ContractError::InvalidTransition (Invoice-as-NFT tokenization #3) if remaining_principal <= 0, preventing redundant repayment executions against already settled loan principal.
  • Documents the guard in doc comments for repay_invoice.
  • Adds unit tests verifying duplicate full repayments and duplicate partial settlements revert with Error(Contract, #3).
  • Resolves a clippy::needless_borrow warning in test setup helpers.

Type of change

  • Bug fix
  • New contract function
  • Data type change
  • Test addition
  • Chore / docs

Checklist

  • cargo test passes
  • cargo clippy -- -D warnings passes (CI)
  • Soroban Scout security analysis passes (CI)
  • stellar contract build succeeds
  • New functions have corresponding tests
  • Breaking changes are documented

⚠️ CI checks are maintainer-managed. Do not add, remove, rename, or
reconfigure any CI check or workflow (including Soroban Scout detector
exclusions in docs/scout-detectors.md) in this PR. CI is part of the
audit story and changes to it go through the maintainers only. If you
believe a check needs changing, open an issue instead.

Related issues

Closes #148

…VaultLink#148)

Add explicit status guards rejecting repayment calls when an invoice or offer is already Repaid, and ensure settled obligations cannot be double-repaid. Add unit tests covering retry and duplicate partial settlement.
@bilhokista
bilhokista requested a review from samjay8 as a code owner September 12, 2026 16:42
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7c14e2b0-27fe-495f-b2ee-a4bb9e47bd05

📥 Commits

Reviewing files that changed from the base of the PR and between bf55bae and a1bc68f.

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

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "path_rules"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@samjay8 samjay8 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.

🤖 Auto-merge bot⚠️ You are not assigned to issue #148.

Please request assignment before opening a PR. Maintainers assign issues to avoid duplicate work and ensure quality review.

Once assigned, this PR will be re-evaluated automatically.

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.

feat(repayment): idempotency and no-double-repay guards

2 participants