Skip to content

Commit

Permalink
Merge pull request #110 from open-format/feature/activity-type
Browse files Browse the repository at this point in the history
Feature: All functions in RewardFacet now accept and emit an activityType
  • Loading branch information
tinypell3ts authored Nov 8, 2023
2 parents 4c2bd6c + 429f688 commit b36f218
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions deployed/80001.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"address": "0x265A242Bcf4CFd9021A666B427e2d4dce2F5eF54"
},
"RewardFacet": {
"startBlock": 40828433,
"address": "0xaCC7A3782DFb20c0e08b58D3420662B9805D76AE"
"startBlock": 41305071,
"address": "0x3866CCBb73B96c4eA2c60CD513691382c91fFfe4"
}
}
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 b36f218

Please sign in to comment.