feat: HTLC claim/refund events, cleanup limit, and clippy check — resolves #461 #462 #469 #475#497
Merged
floxxih merged 1 commit intoMay 30, 2026
Conversation
#475 ## Smart Contract ### #461 — Emit event for HTLC claim - `claim_htlc` now publishes a ("htlc", "claimed") event after the state update, carrying (htlc_id, receiver) as data. Secret is not emitted. - Test: `test_claim_htlc_emits_event` asserts the event is present and has the correct two-topic shape. ### #462 — Emit event for HTLC refund - `refund_htlc` now publishes a ("htlc", "refunded") event after the state update, carrying (htlc_id, sender) as data. - Test: `test_refund_htlc_emits_event` asserts the event is present and has the correct two-topic shape. ### #469 — Add cleanup limit for expired HTLC processing - `cleanup_expired_htlcs` now accepts a `limit: u32` parameter. Pass 0 to use the default batch size (backward-compatible). - Introduces a persistent read-head pointer (`ExpiredHTLCHead`) so successive partial calls resume from where they left off, enabling correct multi-call partial cleanup. - Tests: `test_cleanup_expired_htlcs_partial_then_remainder` verifies 5 HTLCs can be cleaned in three capped calls (2+2+1); zero-limit test confirms default-batch behavior. ## Operations ### #475 — Add smartcontract clippy check to verification script - `scripts/verify.sh` now runs `cargo clippy -- -D warnings` in the smartcontract directory before the Stellar on-chain checks. - Exits non-zero if clippy reports any lint; existing checks are unchanged. ## Pre-existing compilation fixes (required to make CI green) - `OptOrderExecution` enum added (mirrors `OptMultiSig`) to replace `Option<OrderExecutionCondition>` in `#[contracttype]` structs, which soroban-sdk v21.7.7 no longer supports for custom types. - `AdvancedOrderConfig` struct introduced to group min_fill_amount + order_type + execution, bringing `create_advanced_order` within Soroban's 10-parameter contract-function limit. - Removed two stale extra arguments from `create_order_with_min_fill` test calls that no longer matched the function signature. - Added `#![allow(clippy::too_many_arguments)]` crate-level to silence macro-generated client code; added `#[allow(clippy::upper_case_acronyms)]` for the pre-existing `TWAP` variant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@JamesVictor-O 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.
Summary
Resolves four assigned issues in a single cohesive PR:
claim_htlcemits a("htlc", "claimed")event (htlc_id + receiver; secret omitted)refund_htlcemits a("htlc", "refunded")event (htlc_id + sender)cleanup_expired_htlcs(limit)accepts a cap per call; a persistent read-head pointer enables correct partial cleanup over multiple calls; returns processed countscripts/verify.shrunscargo clippy -- -D warningsin the smartcontract directory before the Stellar on-chain checks; exits non-zero on failureChanges
smartcontract/src/htlc.rsenv.events().publish(…)after state update inclaim_htlcandrefund_htlcsmartcontract/src/storage.rscleanup_expired_htlcs(env, limit)withExpiredHTLCHeadread-pointer for multi-call correctnesssmartcontract/src/lib.rscleanup_expired_htlcs; also houses the newAdvancedOrderConfigandOptOrderExecutionimportssmartcontract/src/types.rsOptOrderExecutionenum (mirrorsOptMultiSig) andAdvancedOrderConfigstructsmartcontract/src/order.rsOptOrderExecutioninstead ofOption<OrderExecutionCondition>smartcontract/src/test.rsscripts/verify.shPre-existing fixes included
The smartcontract was failing to compile with soroban-sdk v21.7.7 (Cargo resolved to this from the
"21.0.0"constraint). Fixed:Option<OrderExecutionCondition>in#[contracttype]structs is not supported → replaced withOptOrderExecutionenumcreate_advanced_orderexceeded Soroban's 10-parameter contract limit → parameters consolidated intoAdvancedOrderConfigcreate_order_with_min_filltest calls had 2 stale extra arguments#![allow(clippy::too_many_arguments)]at crate level to silence macro-generated client code#[allow(clippy::upper_case_acronyms)]for the pre-existingTWAPvariantTest plan
cargo clippy --all-targets --all-features -- -D warnings→ 0 errorscargo test→ 71 tests pass, 0 failtest_claim_htlc_emits_event— asserts event is published with 2 topics from the correct contracttest_refund_htlc_emits_event— asserts event is published with 2 topics from the correct contracttest_cleanup_expired_htlcs_partial_then_remainder— cleans 5 HTLCs in 3 capped calls (2+2+1), then 0 on empty queuetest_cleanup_expired_htlcs_zero_limit_uses_default_batch— limit=0 uses the default batch and cleans allCloses #475
Closes #469
Closes #461
Closes #462