Skip to content

Commit ab4b421

Browse files
author
Your Name
committed
Fix: Atomic swap payment issues #34 and #35
- Add payment transfer to seller in reveal_key (Issue #34) - Add buyer refund in cancel_expired_swap (Issue #35) - Document pre-existing fixes for #32 (key verification) and #44 (duplicate check)
1 parent 681d7bd commit ab4b421

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • contracts/atomic_swap/src

contracts/atomic_swap/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ impl AtomicSwap {
199199
.persistent()
200200
.extend_ttl(&DataKey::Swap(swap_id), 50000, 50000);
201201

202+
// Transfer escrowed payment to seller (Issue #34)
203+
token::Client::new(&env, &swap.token).transfer(
204+
&env.current_contract_address(),
205+
&swap.seller,
206+
&swap.price,
207+
);
208+
202209
env.events().publish(
203210
(soroban_sdk::symbol_short!("key_reveal"),),
204211
KeyRevealedEvent {
@@ -275,6 +282,13 @@ impl AtomicSwap {
275282
env.storage()
276283
.persistent()
277284
.remove(&DataKey::ActiveSwap(swap.ip_id));
285+
286+
// Refund buyer's escrowed payment (Issue #35)
287+
token::Client::new(&env, &swap.token).transfer(
288+
&env.current_contract_address(),
289+
&swap.buyer,
290+
&swap.price,
291+
);
278292
}
279293

280294
/// Read a swap record. Returns `None` if the swap_id does not exist.

0 commit comments

Comments
 (0)