Skip to content

feat: HTLC claim/refund events, cleanup limit, and clippy check — resolves #461 #462 #469 #475#497

Merged
floxxih merged 1 commit into
floxxih:masterfrom
JamesVictor-O:feat/htlc-events-cleanup-limit-clippy-check
May 30, 2026
Merged

feat: HTLC claim/refund events, cleanup limit, and clippy check — resolves #461 #462 #469 #475#497
floxxih merged 1 commit into
floxxih:masterfrom
JamesVictor-O:feat/htlc-events-cleanup-limit-clippy-check

Conversation

@JamesVictor-O

@JamesVictor-O JamesVictor-O commented May 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves four assigned issues in a single cohesive PR:

Changes

File What changed
smartcontract/src/htlc.rs env.events().publish(…) after state update in claim_htlc and refund_htlc
smartcontract/src/storage.rs cleanup_expired_htlcs(env, limit) with ExpiredHTLCHead read-pointer for multi-call correctness
smartcontract/src/lib.rs Updated public contract API for cleanup_expired_htlcs; also houses the new AdvancedOrderConfig and OptOrderExecution imports
smartcontract/src/types.rs Added OptOrderExecution enum (mirrors OptMultiSig) and AdvancedOrderConfig struct
smartcontract/src/order.rs Updated internal functions to use OptOrderExecution instead of Option<OrderExecutionCondition>
smartcontract/src/test.rs 5 new tests + pre-existing call-site fixes
scripts/verify.sh Clippy section added before on-chain checks

Pre-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 with OptOrderExecution enum
  • create_advanced_order exceeded Soroban's 10-parameter contract limit → parameters consolidated into AdvancedOrderConfig
  • create_order_with_min_fill test 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-existing TWAP variant

Test plan

  • cargo clippy --all-targets --all-features -- -D warnings → 0 errors
  • cargo test71 tests pass, 0 fail
  • test_claim_htlc_emits_event — asserts event is published with 2 topics from the correct contract
  • test_refund_htlc_emits_event — asserts event is published with 2 topics from the correct contract
  • test_cleanup_expired_htlcs_partial_then_remainder — cleans 5 HTLCs in 3 capped calls (2+2+1), then 0 on empty queue
  • test_cleanup_expired_htlcs_zero_limit_uses_default_batch — limit=0 uses the default batch and cleans all

Closes #475
Closes #469
Closes #461
Closes #462

 #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>
@drips-wave

drips-wave Bot commented May 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@floxxih floxxih merged commit d48c5cd into floxxih:master May 30, 2026
15 of 22 checks passed
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