Skip to content

Commit

Permalink
All functions in RewardFacet now accept and emit an activityType
Browse files Browse the repository at this point in the history
  • Loading branch information
tinypell3ts committed Oct 17, 2023
1 parent 4c2bd6c commit bee57f9
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/facet/RewardsFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,40 @@ bytes32 constant ADMIN_ROLE = bytes32(uint256(0));
bytes32 constant MINTER_ROLE = bytes32(uint256(1));

contract RewardsFacet is Multicall, SafeOwnable {
event TokenMinted(address token, address to, uint256 amount, bytes32 id, string uri);
event TokenTransferred(address token, address to, uint256 amount, bytes32 id, string uri);
event BadgeMinted(address token, uint256 quantity, address to, bytes32 id, string uri);
event BadgeTransferred(address token, address to, uint256 tokenId, bytes32 id, string uri);
event TokenMinted(address token, address to, uint256 amount, bytes32 id, bytes32 activityType, string uri);
event TokenTransferred(address token, address to, uint256 amount, bytes32 id, bytes32 activityType, string uri);
event BadgeMinted(address token, uint256 quantity, address to, bytes32 id, bytes32 activityType, string uri);
event BadgeTransferred(address token, address to, uint256 tokenId, bytes32 id, bytes32 activityType, string uri);

error RewardsFacet_NotAuthorized();
error RewardsFacet_InsufficientBalance();

function mintERC20(address _token, address _to, uint256 _amount, bytes32 _id, string calldata _uri) public {
function mintERC20(
address _token,
address _to,
uint256 _amount,
bytes32 _id,
bytes32 _activityType,
string calldata _uri
) public {
if (!_canMint(_token)) {
revert RewardsFacet_NotAuthorized();
}

Token(_token).mintTo(_to, _amount);
emit TokenMinted(_token, _to, _amount, _id, _uri);
emit TokenMinted(_token, _to, _amount, _id, _activityType, _uri);
}

function transferERC20(
address _holder,
address _token,
address _to,
uint256 _amount,
bytes32 _id,
bytes32 _activityType,
string calldata _uri
) public {
Token(_token).transferFrom(msg.sender, _to, _amount);
emit TokenTransferred(_token, _to, _amount, _id, _uri);
emit TokenTransferred(_token, _to, _amount, _id, _activityType, _uri);
}

function mintERC721(
Expand All @@ -61,26 +68,27 @@ contract RewardsFacet is Multicall, SafeOwnable {
uint256 _quantity,
string calldata _baseURI,
bytes32 _id,
bytes32 _activityType,
string calldata _uri
) public {
if (!_canMint(_token)) {
revert RewardsFacet_NotAuthorized();
}

NFT(_token).batchMintTo(_to, _quantity, _baseURI);
emit BadgeMinted(_token, _quantity, _to, _id, _uri);
emit BadgeMinted(_token, _quantity, _to, _id, _activityType, _uri);
}

function transferERC721(
address _token,
address _holder,
address _to,
uint256 _tokenId,
bytes32 _id,
bytes32 _activityType,
string calldata _uri
) public {
NFT(_token).transferFrom(msg.sender, _to, _tokenId);
emit BadgeTransferred(_token, _to, _tokenId, _id, _uri);
emit BadgeTransferred(_token, _to, _tokenId, _id, _activityType, _uri);
}

function _canMint(address _token) internal virtual returns (bool) {
Expand Down

0 comments on commit bee57f9

Please sign in to comment.