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

fix issues based on scanner reports #52

Merged
merged 1 commit into from
Jun 17, 2024
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
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