refactor: rename oracle_address→condition_oracle, add assert_valid_bp… - #654
Open
ironclad-x wants to merge 1 commit into
Open
refactor: rename oracle_address→condition_oracle, add assert_valid_bp…#654ironclad-x wants to merge 1 commit into
ironclad-x wants to merge 1 commit into
Conversation
…s, Default for InvoiceExt/2, #[must_use] on distribute_with_remainder - Stellar-split#627: Rename InvoiceExt::oracle_address to condition_oracle across types.rs, lib.rs, test.rs, and fuzz/src/lib.rs to distinguish the release-condition oracle from price_oracle. - Stellar-split#628: Extract basis-points validation into validation.rs as assert_valid_bps(bps) -> Result<(), ContractError>. Wire it into _create_invoice for penalty_bps, tax_bps, and insurance_premium_bps. Add unit tests for valid (0, 5000, 10_000) and out-of-range (10_001) values. - Stellar-split#629: Implement InvoiceExt::default(env) and InvoiceExt2::default(env) in types.rs. Rewrite Invoice::from_legacy to start from those defaults and override only the fields LegacyInvoice carries, eliminating the long manual zero-fill block. - Stellar-split#630: Add #[must_use = "the distribution result must be applied to recipients"] to distribute_with_remainder in calc.rs so the compiler warns when the return value is silently dropped.
|
@ironclad-x 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: refactor: rename condition_oracle, assert_valid_bps, InvoiceExt defaults, #[must_use]
distribute_with_remainder
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Description:
This PR addresses four independent cleanup issues across the split contract.
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Changes
#627 — Rename oracle_address → condition_oracle in InvoiceExt
InvoiceExt had both oracle_address and price_oracle fields, which were easy to confuse. oracle_address is
specifically the release-condition oracle (gating condition_met), not the price oracle. Renamed to condition_oracle
across types.rs, lib.rs, test.rs, and fuzz/src/lib.rs.
Closes #627
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#628 — Extract penalty_bps validation into validation.rs as assert_valid_bps
Added pub fn assert_valid_bps(bps: u32) -> Result<(), ContractError> to contracts/split/src/validation.rs. Returns
Err(ContractError::InvalidAmount) when bps > 10_000. Replaced the three inline assert! guards for penalty_bps,
tax_bps, and insurance_premium_bps in _create_invoice with calls to this function. Added unit tests covering both
valid (0, 5000, 10_000) and out-of-range (10_001) values.
Closes #628
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#629 — Add Default impl to InvoiceExt and InvoiceExt2 to simplify from_legacy
Added InvoiceExt::default(env: &Env) and InvoiceExt2::default(env: &Env) factory methods in types.rs. Rewrote
Invoice::from_legacy to start from those defaults and override only the fields that LegacyInvoice actually carries,
replacing a ~70-line manual zero-fill block with a concise override pattern. No behaviour change.
Closes #629
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#630 — Add #[must_use] to distribute_with_remainder
Added #[must_use = "the distribution result must be applied to recipients"] to distribute_with_remainder in
calc.rs. The compiler will now emit a warning if a caller discards the return value, preventing silent
fund-distribution bugs. Documented the expected warning in a code comment per the acceptance criteria.
Closes #630
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────