fix: resolve issues #705 #706 #707 #708 - #721
Merged
Kingsman-99 merged 2 commits intoAug 30, 2026
Merged
Conversation
…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
|
@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! 🚀 |
6 tasks
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.
Summary
Resolves four cleanup issues: typed storage key for event counter, named stats struct,
Defaultimpl for invoice options, and extractedfunding_bpshelper.#705 — Extract
funding_bpshelper intocalc.rspub fn funding_bps(funded: i128, total: i128) -> u32tocalc.rs0whentotal <= 0orfunded <= 0[0, 10_000](overfunded invoices report exactly10_000)pub fn calc_platform_fee(funded: i128, fee_bps: u32)tocalc.rsmod calcanduse calc::{calc_platform_fee, funding_bps}inlib.rsfunded * 10_000 / totalcomputations in lib.rs#706 — Refactor
get_statsto returnProtocolStatsstructpub struct ProtocolStats { total_invoices, total_volume, total_recipients_paid }Statstype aliasmod statsinlib.rs#707 — Add
Defaultimpl forInvoiceOptions2impl Default: Cap policy, 10_000 denominator, all Options NoneInvoiceOptions2::default()/..Default::default()#708 — Refactor
next_seqto use typed storage keyEvSeq(u64)toInvoiceKeyenum; addedev_seq_key()helpernext_seqinevents.rs— old inline tuple fully removedEvSeqto uniqueness test; added per-invoice independence unit testsMigration note
InvoiceKey::EvSeqreplaces 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