Skip to content

fix: resolve issues #705 #706 #707 #708 - #721

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
Malik6828:fix/issues-705-706-707-708
Aug 30, 2026
Merged

fix: resolve issues #705 #706 #707 #708#721
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
Malik6828:fix/issues-705-706-707-708

Conversation

@Malik6828

@Malik6828 Malik6828 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves four cleanup issues: typed storage key for event counter, named stats struct, Default impl for invoice options, and extracted funding_bps helper.


#705 — Extract funding_bps helper into calc.rs

  • Added pub fn funding_bps(funded: i128, total: i128) -> u32 to calc.rs
    • Returns 0 when total <= 0 or funded <= 0
    • Clamps result to [0, 10_000] (overfunded invoices report exactly 10_000)
  • Added pub fn calc_platform_fee(funded: i128, fee_bps: u32) to calc.rs
  • Declared mod calc and use calc::{calc_platform_fee, funding_bps} in lib.rs
  • Replaced three inline funded * 10_000 / total computations in lib.rs
  • Unit tests: partial/full/overfunded/zero/negative cases

#706 — Refactor get_stats to return ProtocolStats struct

  • Added pub struct ProtocolStats { total_invoices, total_volume, total_recipients_paid }
  • Removed Stats type alias
  • Updated all return types; declared mod stats in lib.rs
  • Unit tests verify named-field access

#707 — Add Default impl for InvoiceOptions2

  • Manual impl Default: Cap policy, 10_000 denominator, all Options None
  • Updated 3 test sites to InvoiceOptions2::default() / ..Default::default()

#708 — Refactor next_seq to use typed storage key

  • Added EvSeq(u64) to InvoiceKey enum; added ev_seq_key() helper
  • Updated next_seq in events.rs — old inline tuple fully removed
  • Added EvSeq to uniqueness test; added per-invoice independence unit tests

Migration note

InvoiceKey::EvSeq replaces the inline (symbol_short!("ev_seq"), invoice_id) tuple. The old key was never in the storage snapshot baseline, so no snapshot migration is needed.

Closes

closes #705
closes #706
closes #707
closes #708

…it#707, Stellar-split#708

Issue Stellar-split#705 — Extract funding_bps helper into calc.rs
- Add pub fn funding_bps(funded: i128, total: i128) -> u32 to calc.rs
  (returns 0 for total<=0, clamps result to [0,10_000])
- Add pub fn calc_platform_fee(funded: i128, fee_bps: u32) to calc.rs
- Declare mod calc and use calc::{calc_platform_fee, funding_bps} in lib.rs
- Replace three inline funded*10_000/total computations in lib.rs with
  calls to funding_bps(): check_and_emit_funding_checkpoints,
  get_invoice_stats, auto_resolve
- Add unit tests: partial funding, full, overfunded, zero cases

Issue Stellar-split#706 — Refactor get_stats to return ProtocolStats struct
- Add pub struct ProtocolStats { total_invoices, total_volume,
  total_recipients_paid } to stats.rs; remove Stats type alias
- Update get_stats return type to ProtocolStats
- Update increment, invoice_created, volume_added, recipients_paid
  signatures to return Result<ProtocolStats, ContractError>
- Declare mod stats in lib.rs
- Add unit tests for named-field access on ProtocolStats

Issue Stellar-split#707 — Add Default impl for InvoiceOptions2
- Add manual impl Default for InvoiceOptions2 in types.rs
  (overfunding_policy: OverfundingPolicy::Cap, ratio_denominator: 10_000,
   all Option fields: None, booleans: false, numerics: 0)
- Update three test sites in test.rs to use InvoiceOptions2::default()
  and struct-update syntax (..Default::default()) for field overrides

Issue Stellar-split#708 — Refactor next_seq event counter to use typed storage key
- Add EvSeq(u64) variant to InvoiceKey enum in storage_keys.rs
- Add pub fn ev_seq_key(invoice_id: u64) -> InvoiceKey helper
- Update next_seq in events.rs to use ev_seq_key() instead of the
  old inline (symbol_short!("ev_seq"), invoice_id) tuple
- Add EvSeq(id) to the invoice_keys_differ_by_variant uniqueness test
- Add unit tests verifying per-invoice sequence independence
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

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

@Kingsman-99
Kingsman-99 merged commit 36b5cb9 into Stellar-split:main Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants