Skip to content

Commit

Permalink
Merge pull request #52 from TogetherCrew/fix/vulnerability
Browse files Browse the repository at this point in the history
fix issues based on scanner reports
  • Loading branch information
cyri113 authored Jun 17, 2024
2 parents db32f51 + 083285a commit 1c7a4dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 10 additions & 7 deletions contracts/Engagement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "@openzeppelin/contracts/utils/Strings.sol";
import "./IEngagement.sol";

contract Engagement is IEngagement, ERC1155, AccessControl {
uint private _counter = 0;
uint private _counter;
bytes32 public constant PROVIDER_ROLE = keccak256("PROVIDER_ROLE");

mapping(uint => string) private _tokenMetadata;
Expand All @@ -33,10 +33,11 @@ contract Engagement is IEngagement, ERC1155, AccessControl {
}

function issue(string memory hash_) external {
_tokenMetadata[_counter] = hash_;
_mint(msg.sender, _counter, 1, "");
emit Issue(msg.sender, _counter);
_counter++;
uint counterCache = _counter;
_tokenMetadata[counterCache] = hash_;
_mint(msg.sender, counterCache, 1, "");
emit Issue(msg.sender, counterCache);
_counter = counterCache + 1;
}

function mint(
Expand All @@ -45,7 +46,7 @@ contract Engagement is IEngagement, ERC1155, AccessControl {
uint amount,
bytes memory data
) external override validTokenId(tokenId) {
if (balanceOf(account, tokenId) > 0) {
if (balanceOf(account, tokenId) >= 1) {
revert MintLimit(account, tokenId);
}
_mint(account, tokenId, 1, data);
Expand Down Expand Up @@ -93,7 +94,9 @@ contract Engagement is IEngagement, ERC1155, AccessControl {

function supportsInterface(
bytes4 interfaceId
) public view override(AccessControl, ERC1155) returns (bool) {}
) public view override(AccessControl, ERC1155) returns (bool) {
return super.supportsInterface(interfaceId);
}

function uri(
uint tokenId
Expand Down
2 changes: 2 additions & 0 deletions contracts/IEngagement.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pragma solidity ^0.8.24;

interface IEngagement {
event Issue(address indexed account, uint indexed tokenId);
event Mint(address indexed account, uint indexed tokenId, uint amount);
Expand Down

0 comments on commit 1c7a4dd

Please sign in to comment.