Skip to content

Commit 77c2e58

Browse files
author
yakuhito
committed
require(success) instead of manual state revert
1 parent 1c0a71a commit 77c2e58

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

contracts/yakuSwap.sol

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ contract yakuSwap is Ownable {
6363

6464
swap.status = SwapStatus.Completed;
6565
(bool success,) = swap.toAddress.call{value: swap.amount}("");
66-
if(!success) {
67-
swap.status = SwapStatus.Created;
68-
}
66+
67+
require(success);
6968
}
7069

7170
function cancelSwap(bytes32 _swapId) public {
@@ -76,17 +75,14 @@ contract yakuSwap is Ownable {
7675

7776
swap.status = SwapStatus.Cancelled;
7877
(bool success,) = swap.fromAddress.call{value: swap.amount}("");
79-
if(!success) {
80-
swap.status = SwapStatus.Created;
81-
}
78+
79+
require(success);
8280
}
8381

8482
function getFees() public onlyOwner {
85-
uint oldTotalFees = totalFees;
8683
totalFees = 0;
8784
(bool success,) = owner().call{value: totalFees}("");
88-
if(!success) {
89-
totalFees = oldTotalFees;
90-
}
85+
86+
require(success);
9187
}
9288
}

0 commit comments

Comments
 (0)