Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
feat: tagging module events
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubpark committed Jan 24, 2024
1 parent d0df7d4 commit a4287ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions contracts/interfaces/modules/ITaggingModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

interface ITaggingModule {
event TagSet(string tag, address ipId);

event TagRemoved(string tag, address ipId);
}
6 changes: 4 additions & 2 deletions contracts/modules/tagging/TaggingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { ShortStringOps } from "contracts/utils/ShortStringOps.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import { Errors } from "contracts/lib/Errors.sol";
import { IModule } from "contracts/interfaces/modules/base/IModule.sol";
import { ITaggingModule } from "contracts/interfaces/modules/ITaggingModule.sol";

contract TaggingModule is IModule {
contract TaggingModule is IModule, ITaggingModule {
using ShortStrings for *;
using EnumerableSet for EnumerableSet.Bytes32Set;
using EnumerableSet for EnumerableSet.AddressSet;
Expand All @@ -23,14 +24,15 @@ contract TaggingModule is IModule {
function setTag(string calldata tag, address ipId) external returns (bool added) {
// TODO: access control
// TODO: emit
emit TagSet(tag, ipId);
return _tagsForIpIds[ipId].add(ShortStringOps.stringToBytes32(tag));
}

function removeTag(string calldata tag, address ipId) external returns (bool removed) {
// TODO: access control
emit TagRemoved(tag, ipId);
return _tagsForIpIds[ipId].remove(ShortStringOps.stringToBytes32(tag));
}

function isTagged(string calldata tag, address ipId) external view returns (bool) {
return _tagsForIpIds[ipId].contains(ShortStringOps.stringToBytes32(tag));
}
Expand Down

0 comments on commit a4287ee

Please sign in to comment.