fix(events): add event_seq to delegate_set, revoker to delegate_revoked - #655
Merged
Kingsman-99 merged 2 commits intoAug 29, 2026
Conversation
- Stellar-split#619: call next_seq inside delegate_set and publish (delegate, event_seq) so indexers can order multiple delegate changes within the same tx - Stellar-split#620: add revoker: &Address param to delegate_revoked and publish (revoker, ledger_sequence) for complete audit trails - Stellar-split#621: extract assert_invoice_pending helper to replace repeated if status != Pending { return Err(InvalidStatus) } inline checks - Stellar-split#622: add pub fn calc_platform_fee(funded, fee_bps) to calc.rs with checked_mul / ArithmeticOverflow guard; replace all three inline fee expressions in lib.rs with calls to the new helper; add unit tests covering normal, zero-bps, 100%-bps and overflow cases
|
@kulkan-IV 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: fix(events): add event_seq to delegate_set, revoker to delegate_revoked; extract pending guard and platform fee helper
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Description:
This PR resolves four issues from the Wave backlog. No behaviour changes — only bug fixes, audit improvements, and internal refactors.
Changes
#619 — delegate_set missing event_seq for ordering
delegate_set now calls next_seq(env, invoice_id) and publishes (delegate, event_seq) instead of the bare address. Indexers can now determine the final delegate state when a delegate is set and then
changed within the same transaction.
#620 — delegate_revoked event data was empty
delegate_revoked now accepts a revoker: &Address parameter and publishes (revoker, ledger_sequence). The revoke_delegate call site in lib.rs passes &invoice.creator as the revoker. Audit logs are now
complete.
#621 — Extract assert_invoice_pending guard
Added fn assert_invoice_pending(invoice: &Invoice) -> Result<(), ContractError> immediately after load_invoice in lib.rs. The repeated inline pattern:
if invoice.status != InvoiceStatus::Pending {
return Err(ContractError::InvalidStatus);
}
is replaced with assert_invoice_pending(&invoice)?. The idempotent silent-return in claim_refund was intentionally left unchanged — it has different semantics.
#622 — Extract calc_platform_fee into calc.rs
Added pub fn calc_platform_fee(funded: i128, fee_bps: u32) -> Result<i128, ContractError> to calc.rs. Uses checked_mul and returns ContractError::ArithmeticOverflow on overflow. All three inline
(funded as u128 * platform_fee_bps as u128 / 10_000u128) as i128 expressions in lib.rs are replaced with calls to this helper. Unit tests added covering: normal case, zero bps, 100% bps, and
overflow.
Testing
Migration note
delegate_set and delegate_revoked event data shapes have changed. Indexers consuming these events must update their decoders:
Closes #619
Closes #620
Closes #621
Closes #622