diff --git a/frontend/src/components/molecules/EventGroupTab.tsx b/frontend/src/components/molecules/EventGroupTab.tsx index c363995d..d4ccaeae 100644 --- a/frontend/src/components/molecules/EventGroupTab.tsx +++ b/frontend/src/components/molecules/EventGroupTab.tsx @@ -27,8 +27,6 @@ const EventGroupTab: FC = ({ group }) => { return 1; case router.asPath.includes("role"): return 2; - case router.asPath.includes("transfer"): - return 3; default: break; } @@ -83,21 +81,6 @@ const EventGroupTab: FC = ({ group }) => { {t.RBAC_EDIT_COLLABORATORS} )} - {(group.ownerAddress === address) && ( - - router.push(`/event-groups/${router.query.eventgroupid}/transfer`) - } - > - {t.EVENT_GROUP_TAB_TRANSFER} - - )} ); diff --git a/frontend/src/locales/en.ts b/frontend/src/locales/en.ts index 0a025962..927fc271 100644 --- a/frontend/src/locales/en.ts +++ b/frontend/src/locales/en.ts @@ -43,7 +43,6 @@ export default { // Event group tab EVENT_GROUP_TAB_EVENTS: "Event List", EVENT_GROUP_TAB_LEADERS: "Leader Board", - EVENT_GROUP_TAB_TRANSFER: "Transfer Owner", // Event group leaders EVENT_GROUP_LEADERS_RANK: "RANK", EVENT_GROUP_LEADERS_ADDRESS: "ADDRESS", diff --git a/frontend/src/locales/ja.ts b/frontend/src/locales/ja.ts index 6c6942dc..f39d40d9 100644 --- a/frontend/src/locales/ja.ts +++ b/frontend/src/locales/ja.ts @@ -43,7 +43,6 @@ export default { // Event group tab EVENT_GROUP_TAB_EVENTS: "イベント一覧", EVENT_GROUP_TAB_LEADERS: "リーダーボード", - EVENT_GROUP_TAB_TRANSFER: "権限譲与", // Event group leaders EVENT_GROUP_LEADERS_RANK: "ランク", EVENT_GROUP_LEADERS_ADDRESS: "アドレス", diff --git a/hardhat/contracts/Event.sol b/hardhat/contracts/Event.sol index 9c4a20cc..bf7dc1f2 100644 --- a/hardhat/contracts/Event.sol +++ b/hardhat/contracts/Event.sol @@ -61,11 +61,6 @@ contract EventManager is OwnableUpgradeable { private memberRolesByGroupId; mapping(uint256 => address[]) private memberAddressesByGroupId; - modifier onlyGroupOwner(uint256 _groupId) { - require(_isGroupOwner(_groupId, msg.sender), "You have no permission"); - _; - } - modifier onlyAdminAccess(uint256 _groupId) { require( _hasAdminAccess(_groupId, msg.sender), @@ -121,11 +116,6 @@ contract EventManager is OwnableUpgradeable { event CreateGroup(address indexed owner, uint256 groupId); event CreateEvent(address indexed owner, uint256 eventId); - event TransferGroupOwner( - address indexed prevOwner, - address indexed newOwner, - uint256 groupId - ); // Currently, reinitializer(3) was executed as constructor. function initialize( @@ -204,41 +194,6 @@ contract EventManager is OwnableUpgradeable { return _groups; } - function transferGroupOwner( - uint256 _groupId, - address _newOwnerAddress - ) external whenNotPaused onlyGroupOwner(_groupId) { - require(_newOwnerAddress != address(0), "New owner address is blank"); - - for (uint256 i = 0; i < groups.length; i++) { - if (groups[i].groupId == _groupId) { - groups[i].ownerAddress = _newOwnerAddress; - break; - } - } - - ownGroupIds[_newOwnerAddress].push(_groupId); - - for (uint256 i = 0; i < ownGroupIds[msg.sender].length; i++) { - if (ownGroupIds[msg.sender][i] == _groupId) { - ownGroupIds[msg.sender][i] = ownGroupIds[msg.sender][ - ownGroupIds[msg.sender].length - 1 - ]; - ownGroupIds[msg.sender].pop(); - break; - } - } - - emit TransferGroupOwner(msg.sender, _newOwnerAddress, _groupId); - } - - function _isGroupOwner( - uint256 _groupId, - address _address - ) private view returns (bool) { - return groups[_groupId - 1].ownerAddress == _address; - } - function createEventRecord( uint256 _groupId, string memory _name, @@ -442,7 +397,7 @@ contract EventManager is OwnableUpgradeable { require(_groupId > 0 && _groupId <= groups.length, "Invalid groupId"); return - _isGroupOwner(_groupId, _address) || + groups[_groupId - 1].ownerAddress == _address || _hasRole(_groupId, _address, ADMIN_ROLE); } diff --git a/hardhat/test/EventManager.ts b/hardhat/test/EventManager.ts index fe92030e..1066b3bd 100644 --- a/hardhat/test/EventManager.ts +++ b/hardhat/test/EventManager.ts @@ -39,10 +39,9 @@ describe("EventManager", function () { let participant1: SignerWithAddress; let participant2: SignerWithAddress; let relayer: SignerWithAddress; - let newOwner: SignerWithAddress; before(async () => { - [organizer, participant1, participant2, relayer, newOwner] = + [organizer, participant1, participant2, relayer] = await ethers.getSigners(); const SecretPhraseVerifierFactory = await ethers.getContractFactory( "SecretPhraseVerifier" @@ -88,8 +87,7 @@ describe("EventManager", function () { relayer.address, 250000, 1000000, - operationController.address, - ], + operationController.address], { initializer: "initialize", } @@ -489,7 +487,7 @@ describe("EventManager", function () { relayer.address, 500000, 1000000, - operationController.address, + operationController.address ], { initializer: "initialize", @@ -544,7 +542,7 @@ describe("EventManager", function () { relayer.address, 500000, 1000000, - operationController.address, + operationController.address ], { initializer: "initialize", @@ -619,7 +617,7 @@ describe("EventManager", function () { relayer.address, 250000, 1000000, - operationController.address, + operationController.address ], { initializer: "initialize", @@ -700,79 +698,6 @@ describe("EventManager", function () { }); }); - describe("Transfer Owner", function () { - let eventManager: EventManager; - before(async () => { - const eventManagerContractFactory = await ethers.getContractFactory( - "EventManager" - ); - const deployedEventManagerContract = await upgrades.deployProxy( - eventManagerContractFactory, - [ - organizer.address, - relayer.address, - 250000, - 1000000, - operationController.address, - ], - { initializer: "initialize" } - ); - eventManager = deployedEventManagerContract as EventManager; - await eventManager.deployed(); - await eventManager.setMintNFTAddr(mintNFT.address); - await mintNFT.setEventManagerAddr(eventManager.address); - - const createGroupTx = await eventManager - .connect(organizer) - .createGroup("transferGroup"); - await createGroupTx.wait(); - - const createdGroups = await eventManager.getGroups(); - expect(createdGroups.some((group) => group.name === "transferGroup")).to - .be.true; - }); - - it("Should transfer group ownership", async function () { - const groups = await eventManager.getGroups(); - const group = groups.find((group) => group.name === "transferGroup"); - const groupId = group!.groupId; - - const transferTx = await eventManager - .connect(organizer) - .transferGroupOwner(groupId, newOwner.address); - await transferTx.wait(); - expect(transferTx) - .to.emit(eventManager, "TransferOwner") - .withArgs(groupId, organizer.address, newOwner.address); - - const updatedGroups = await eventManager.getGroups(); - const updatedGroup = updatedGroups.find((group) => - group.groupId.eq(groupId) - ); - - expect(updatedGroup, "Updated group not found").to.exist; - expect(updatedGroup!.ownerAddress).to.equal(newOwner.address); - - const ownGroups = await eventManager.getOwnGroups(newOwner.address); - expect(ownGroups.some((group) => group.groupId.eq(groupId))).to.be.true; - const ownGroups2 = await eventManager.getOwnGroups(organizer.address); - expect(ownGroups2.every((group) => !group.groupId.eq(groupId))).to.be - .true; - }); - - it("Should revert if not group owner", async function () { - const groups = await eventManager.getGroups(); - const group = groups.find((group) => group.name === "transferGroup"); - const groupId = group!.groupId; - - await expect( - eventManager - .connect(participant1) - .transferGroupOwner(groupId, newOwner.address) - ).to.be.revertedWith("You have no permission"); - }); - }); - describe("Role", async () => { let eventManager: EventManager; @@ -787,7 +712,7 @@ describe("EventManager", function () { relayer.address, 250000, 1000000, - operationController.address, + operationController.address ], { initializer: "initialize",