diff --git a/hardhat/contracts/IMintNFT.sol b/hardhat/contracts/IMintNFT.sol index 15972e29..d2c13735 100644 --- a/hardhat/contracts/IMintNFT.sol +++ b/hardhat/contracts/IMintNFT.sol @@ -44,6 +44,11 @@ interface IMintNFT { string memory _secretPhrase ) external; + function getCountOfParticipation(uint256 _groupId, address _address) + external + view + returns (uint256); + function isHoldingEventNFTByAddress( address _address, uint256 _eventId diff --git a/hardhat/contracts/MintNFT.sol b/hardhat/contracts/MintNFT.sol index bda2e225..919ab3a5 100644 --- a/hardhat/contracts/MintNFT.sol +++ b/hardhat/contracts/MintNFT.sol @@ -281,6 +281,14 @@ contract MintNFT is isHoldingEventNFT[Hashing.hashingAddressUint256(_addr, _eventId)]; } + function getCountOfParticipation( + uint256 _groupId, + address _address + ) public view returns (uint256) { + bytes32 groupHash = Hashing.hashingAddressUint256(_address, _groupId); + return countOfParticipation[groupHash]; + } + function setEventInfo( uint256 _eventId, uint256 _mintLimit, diff --git a/hardhat/test/MintNFT.ts b/hardhat/test/MintNFT.ts index 2fa708f7..97aeba81 100644 --- a/hardhat/test/MintNFT.ts +++ b/hardhat/test/MintNFT.ts @@ -369,6 +369,12 @@ describe("MintNFT", function () { ); await mintNftTxn2.wait(); expect(await mintNFT.getEventIdOfTokenId(1)).equal(createdEventIds[0]); + expect( + await mintNFT.getCountOfParticipation( + createdGroupId1, + participant1.address + ) + ).equal(1); const { proofCalldata: proofCalldata3 } = await generateProof(); const mintNftTxn3 = await mintNFT @@ -380,6 +386,12 @@ describe("MintNFT", function () { ); await mintNftTxn3.wait(); expect(await mintNFT.getEventIdOfTokenId(2)).equal(createdEventIds[0]); + expect( + await mintNFT.getCountOfParticipation( + createdGroupId1, + participant2.address + ) + ).equal(1); const { proofCalldata: proofCalldata4 } = await generateProof(); const mintNftTxn4 = await mintNFT @@ -391,6 +403,12 @@ describe("MintNFT", function () { ); await mintNftTxn4.wait(); expect(await mintNFT.getEventIdOfTokenId(3)).equal(createdEventIds[1]); + expect( + await mintNFT.getCountOfParticipation( + createdGroupId1, + participant1.address + ) + ).equal(2); const { proofCalldata: proofCalldata5 } = await generateProof(); const mintNftTxn5 = await mintNFT @@ -402,6 +420,12 @@ describe("MintNFT", function () { ); await mintNftTxn5.wait(); expect(await mintNFT.getEventIdOfTokenId(4)).equal(createdEventIds[2]); + expect( + await mintNFT.getCountOfParticipation( + createdGroupId2, + participant1.address + ) + ).equal(1); }); it("get owners of the tokens", async () => { const tokens = [0, 1, 2, 3, 4];