Skip to content

Commit

Permalink
Merge pull request #53 from TogetherCrew/fix/scanner-issue-reports
Browse files Browse the repository at this point in the history
fix scanner reports
  • Loading branch information
cyri113 authored Jun 17, 2024
2 parents 1c7a4dd + 023074d commit 6507f2c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
26 changes: 18 additions & 8 deletions contracts/Engagement.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
pragma solidity 0.8.26;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import "./IEngagement.sol";

contract Engagement is IEngagement, ERC1155, AccessControl {
using ERC165Checker for address;

uint private _counter;
bytes32 public constant PROVIDER_ROLE = keccak256("PROVIDER_ROLE");

mapping(uint => string) private _tokenMetadata;
mapping(uint => string) private _scores;
mapping(uint tokenId => string metadata) private _tokenMetadata;
mapping(uint date => string cid) private _scores;

constructor() ERC1155("") {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
Expand All @@ -28,6 +31,13 @@ contract Engagement is IEngagement, ERC1155, AccessControl {
_;
}

modifier onlyTokenOwner(address account, uint tokenId) {
if (account != msg.sender) {
revert NotAllowed(account, tokenId);
}
_;
}

function counter() external view returns (uint) {
return _counter;
}
Expand Down Expand Up @@ -57,10 +67,7 @@ contract Engagement is IEngagement, ERC1155, AccessControl {
address account,
uint tokenId,
uint amount
) external override validTokenId(tokenId) {
if (account != msg.sender) {
revert NotAllowed(account, tokenId);
}
) external override validTokenId(tokenId) onlyTokenOwner(account, tokenId) {
_burn(account, tokenId, 1);
emit Burn(account, tokenId, 1);
}
Expand Down Expand Up @@ -95,7 +102,10 @@ contract Engagement is IEngagement, ERC1155, AccessControl {
function supportsInterface(
bytes4 interfaceId
) public view override(AccessControl, ERC1155) returns (bool) {
return super.supportsInterface(interfaceId);
if (address(this).supportsERC165()) {
return super.supportsInterface(interfaceId);
}
return false;
}

function uri(
Expand Down
3 changes: 2 additions & 1 deletion contracts/IEngagement.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.8.24;
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;

interface IEngagement {
event Issue(address indexed account, uint indexed tokenId);
Expand Down
6 changes: 4 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import "@nomicfoundation/hardhat-toolbox-viem";
import { vars } from "hardhat/config";

const ALCHEMY_SEPOLIA_ENDPOINT = vars.get("ALCHEMY_SEPOLIA_ENDPOINT", "");
const PRIVATE_KEYS = vars.has("PRIVATE_KEYS") ? vars.get("PRIVATE_KEYS").split(", ") : [];
const PRIVATE_KEYS = vars.has("PRIVATE_KEYS")
? vars.get("PRIVATE_KEYS").split(", ")
: [];
const ETHERSCAN_API_KEY = vars.get("ETHERSCAN_API_KEY", "");

const config: HardhatUserConfig = {
solidity: "0.8.24",
solidity: "0.8.26",
networks: {
sepolia: {
url: ALCHEMY_SEPOLIA_ENDPOINT,
Expand Down

0 comments on commit 6507f2c

Please sign in to comment.