Skip to content

refactor: consolidate SwapCompleted/SwapTimedOut into single branch#302

Open
Tet-9 wants to merge 1 commit intoentrius:testfrom
Tet-9:fix/76-consolidate-swap-event-handling
Open

refactor: consolidate SwapCompleted/SwapTimedOut into single branch#302
Tet-9 wants to merge 1 commit intoentrius:testfrom
Tet-9:fix/76-consolidate-swap-event-handling

Conversation

@Tet-9
Copy link
Copy Markdown

@Tet-9 Tet-9 commented May 10, 2026

Summary

ContractEventWatcher.apply_event() had two near-duplicate elif
branches for SwapCompleted and SwapTimedOut — identical extraction,
guard, insert_swap_outcome, apply_busy_delta,
bootstrapped_swap_ids.discard, and swap_tracker.resolve calls,
differing only in completed=True/False and
SwapStatus.COMPLETED/TIMED_OUT.

Fix

Merge into a single elif name in ('SwapCompleted', 'SwapTimedOut')
branch with completed = name == 'SwapCompleted' and
status = SwapStatus.COMPLETED if completed else SwapStatus.TIMED_OUT.

Future changes to the resolution path now only need to be applied once.

Fixes #76

The two elif branches for SwapCompleted and SwapTimedOut shared
identical extraction, guard, insert_swap_outcome, apply_busy_delta,
bootstrapped_swap_ids.discard, and swap_tracker.resolve calls —
differing only in completed=True/False and SwapStatus.COMPLETED/TIMED_OUT.

Merge into a single elif name in ('SwapCompleted', 'SwapTimedOut')
branch with completed=(name == 'SwapCompleted') so future changes
to the resolution path only need to be applied once.

Fixes entrius#76
@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Restructures code without changing behavior label May 10, 2026
@igeabdulrahmanikeoluwa-str
Copy link
Copy Markdown

@anderdc , on for review 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructures code without changing behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate SwapCompleted/SwapTimedOut handling in ContractEventWatcher.apply_event

2 participants