Skip to content

Commit bc32764

Browse files
Merge pull request #122 from ayomideadeniran/fix/issue-34-and-35-payments
Fix: Payment transfers in atomic swap (#34 and #35)
2 parents 8caf393 + ab4b421 commit bc32764

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
@@ -303,6 +303,13 @@ impl AtomicSwap {
303303
.persistent()
304304
.extend_ttl(&DataKey::Swap(swap_id), 50000, 50000);
305305

306+
// Transfer escrowed payment to seller (Issue #34)
307+
token::Client::new(&env, &swap.token).transfer(
308+
&env.current_contract_address(),
309+
&swap.seller,
310+
&swap.price,
311+
);
312+
306313
env.events().publish(
307314
(soroban_sdk::symbol_short!("key_rev"),),
308315
KeyRevealedEvent {
@@ -427,6 +434,13 @@ impl AtomicSwap {
427434
env.storage()
428435
.persistent()
429436
.remove(&DataKey::ActiveSwap(swap.ip_id));
437+
438+
// Refund buyer's escrowed payment (Issue #35)
439+
token::Client::new(&env, &swap.token).transfer(
440+
&env.current_contract_address(),
441+
&swap.buyer,
442+
&swap.price,
443+
);
430444
}
431445

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

0 commit comments

Comments
 (0)