Skip to content

Commit

Permalink
feat: emit event with platform recipient/fee changes (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR4N authored Aug 11, 2024
1 parent cbbade1 commit 4cf3121
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/SWAP2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ contract SWAP2Deployer is

function _setPlatformFee(address payable recipient, uint16 basisPoints) private {
feeConfig = PlatformFeeConfig({recipient: recipient, basisPoints: basisPoints});
emit PlatformFeeChanged(recipient, basisPoints);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/SwapperDeployerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ pragma solidity 0.8.25;
import {IEscrow} from "./Escrow.sol";
import {currentChainId} from "./TypesAndConstants.sol";

interface ISwapperDeployerEvents {
/// @dev SHOULD be emitted when the values to be returned by `_platformFeeConfig()` change.
event PlatformFeeChanged(address indexed recipient, uint16 basisPoints);
}

/// @dev Abstract base contract for all <T>SwapperDeployer implementations.
abstract contract SwapperDeployerBase {
abstract contract SwapperDeployerBase is ISwapperDeployerEvents {
/**
* @return recipient Address to which platform fees MUST be sent by swapper contracts.
* @return basisPoints One-hundredths of a percentage point of swap consideration that MUST be sent to `recipient`.
Expand Down
5 changes: 4 additions & 1 deletion test/SwapperTestBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {console2} from "forge-std/console2.sol";
import {SWAP2} from "../src/SWAP2.sol";
import {Disbursement, Consideration, ERC20Consideration} from "../src/ConsiderationLib.sol";
import {Escrow, IEscrowEvents} from "../src/Escrow.sol";
import {ISwapperDeployerEvents} from "../src/SwapperDeployerBase.sol";
import {Parties, PayableParties, ISwapperEvents, SwapStatus} from "../src/TypesAndConstants.sol";

import {ERC721, IERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
Expand Down Expand Up @@ -48,7 +49,7 @@ contract Token is ERC721 {
}
}

interface ITestEvents is ISwapperEvents, IEscrowEvents {
interface ITestEvents is ISwapperEvents, IEscrowEvents, ISwapperDeployerEvents {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
}

Expand Down Expand Up @@ -124,6 +125,8 @@ abstract contract SwapperTestBase is Test, ITestEvents {

/// @dev Sets the platform-fee config to the parameters provided in the test case.
function _setPlatformFee(TestCase memory t) internal {
vm.expectEmit(true, true, true, true, address(factory));
emit PlatformFeeChanged(t.platformFeeRecipient, t.platformFeeBasisPoints);
vm.prank(factory.owner());
factory.setPlatformFee(t.platformFeeRecipient, t.platformFeeBasisPoints);
}
Expand Down

0 comments on commit 4cf3121

Please sign in to comment.