Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: All functions in RewardFacet now accept and emit an activityType #110

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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