diff --git a/contracts/Swaplace.sol b/contracts/Swaplace.sol index 8e99cf1..26beb71 100644 --- a/contracts/Swaplace.sol +++ b/contracts/Swaplace.sol @@ -99,17 +99,15 @@ contract Swaplace is SwapFactory, ISwaplace, IERC165 { * @dev See {ISwaplace-cancelSwap}. */ function cancelSwap(uint256 swapId) public { - Swap memory swap = _swaps[swapId]; + if (_swaps[swapId].owner != msg.sender) revert InvalidAddress(msg.sender); - if (swap.owner != msg.sender) revert InvalidAddress(msg.sender); - - (address allowed, uint256 expiry) = parseData(swap.config); + (, uint256 expiry) = parseData(_swaps[swapId].config); if (expiry < block.timestamp) revert InvalidExpiry(expiry); - _swaps[swapId].config = packData(allowed, 0); + _swaps[swapId].config = 0; - emit SwapCanceled(swapId, msg.sender); + emit SwapCanceled(swapId); } /** diff --git a/contracts/interfaces/ISwaplace.sol b/contracts/interfaces/ISwaplace.sol index 44cfaa0..1304bd0 100644 --- a/contracts/interfaces/ISwaplace.sol +++ b/contracts/interfaces/ISwaplace.sol @@ -22,7 +22,7 @@ interface ISwaplace { /** * @dev Emitted when a Swap is canceled. */ - event SwapCanceled(uint256 indexed swapId, address indexed owner); + event SwapCanceled(uint256 indexed swapId); /** * @dev Allow users to create a Swap. Each new Swap self-increments its ID by one. diff --git a/test/TestSwaplace.test.ts b/test/TestSwaplace.test.ts index aefe987..d37f8e5 100644 --- a/test/TestSwaplace.test.ts +++ b/test/TestSwaplace.test.ts @@ -434,9 +434,9 @@ describe("Swaplace", async function () { it("Should be able to {cancelSwap} a Swap", async function () { const lastSwap = await Swaplace.totalSwaps(); - expect(await Swaplace.connect(owner).cancelSwap(lastSwap)) + await expect(await Swaplace.connect(owner).cancelSwap(lastSwap)) .to.emit(Swaplace, "SwapCanceled") - .withArgs(lastSwap, swap.owner); + .withArgs(lastSwap); }); it("Should not be able to {acceptSwap} a canceled a Swap", async function () {