Skip to content

Commit

Permalink
Merge pull request #143 from moonstream-to/public-private-at-bat-event
Browse files Browse the repository at this point in the history
Adding requiresSignature to the AtBat started event.
  • Loading branch information
kellan-simiotics authored Feb 7, 2024
2 parents 598011d + 63f49a9 commit b71b45d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/Fullcount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ contract Fullcount is EIP712 {
address indexed nftAddress,
uint256 indexed tokenID,
uint256 firstSessionID,
PlayerType role
PlayerType role,
bool requiresSignature
);

event AtBatJoined(
Expand Down Expand Up @@ -374,7 +375,7 @@ contract Fullcount is EIP712 {
AtBatSessions[NumAtBats] = [firstSessionID];
SessionAtBat[firstSessionID] = NumAtBats;

emit AtBatStarted(NumAtBats, nftAddress, tokenID, firstSessionID, role);
emit AtBatStarted(NumAtBats, nftAddress, tokenID, firstSessionID, role, requireSignature);

return NumAtBats;
}
Expand Down
27 changes: 15 additions & 12 deletions test/AtBats.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ contract FullcountAtBatTest is FullcountTestBase {
address indexed nftAddress,
uint256 indexed tokenID,
uint256 firstSessionID,
PlayerType role
PlayerType role,
bool requiresSignature
);
event AtBatJoined(
uint256 indexed atBatID,
Expand Down Expand Up @@ -57,9 +58,8 @@ contract FullcountTest_startAtBat is FullcountAtBatTest {
vm.startPrank(player1);

vm.expectEmit(address(game));
emit SessionStarted(initialNumSessions + 1, address(characterNFTs), tokenID, PlayerType.Pitcher);
emit AtBatStarted(
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Pitcher
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Pitcher, false
);
uint256 atBatID = game.startAtBat(address(characterNFTs), tokenID, PlayerType.Pitcher, false);

Expand Down Expand Up @@ -92,9 +92,8 @@ contract FullcountTest_startAtBat is FullcountAtBatTest {
vm.startPrank(player1);

vm.expectEmit(address(game));
emit SessionStarted(initialNumSessions + 1, address(characterNFTs), tokenID, PlayerType.Batter);
emit AtBatStarted(
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Batter
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Batter, false
);
uint256 atBatID = game.startAtBat(address(characterNFTs), tokenID, PlayerType.Batter, false);

Expand Down Expand Up @@ -134,9 +133,8 @@ contract FullcountTest_joinAtBatSession is FullcountAtBatTest {
vm.startPrank(player1);

vm.expectEmit(address(game));
emit SessionStarted(initialNumSessions + 1, address(characterNFTs), tokenID, PlayerType.Pitcher);
emit AtBatStarted(
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Pitcher
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Pitcher, false
);
uint256 atBatID = game.startAtBat(address(characterNFTs), tokenID, PlayerType.Pitcher, false);

Expand All @@ -152,7 +150,6 @@ contract FullcountTest_joinAtBatSession is FullcountAtBatTest {
vm.startPrank(player2);

vm.expectEmit(address(game));
emit SessionJoined(firstSessionID, address(otherCharacterNFTs), otherTokenID, PlayerType.Batter);
emit AtBatJoined(atBatID, address(otherCharacterNFTs), otherTokenID, firstSessionID, PlayerType.Batter);
game.joinSession(firstSessionID, address(otherCharacterNFTs), otherTokenID, "");

Expand Down Expand Up @@ -184,9 +181,8 @@ contract FullcountTest_joinAtBatSession is FullcountAtBatTest {
vm.startPrank(player1);

vm.expectEmit(address(game));
emit SessionStarted(initialNumSessions + 1, address(characterNFTs), tokenID, PlayerType.Batter);
emit AtBatStarted(
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Batter
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Batter, false
);
uint256 atBatID = game.startAtBat(address(characterNFTs), tokenID, PlayerType.Batter, false);

Expand All @@ -202,7 +198,6 @@ contract FullcountTest_joinAtBatSession is FullcountAtBatTest {
vm.startPrank(player2);

vm.expectEmit(address(game));
emit SessionJoined(firstSessionID, address(otherCharacterNFTs), otherTokenID, PlayerType.Pitcher);
emit AtBatJoined(atBatID, address(otherCharacterNFTs), otherTokenID, firstSessionID, PlayerType.Pitcher);
game.joinSession(firstSessionID, address(otherCharacterNFTs), otherTokenID, "");

Expand Down Expand Up @@ -1067,7 +1062,7 @@ contract FullcountTest_ballsAndStrikes is FullcountAtBatTest {
}
}

contract FullcountTest_atBatInviteOnly is FullcountTestBase {
contract FullcountTest_atBatInviteOnly is FullcountAtBatTest {
function test_as_batter() public {
charactersMinted++;
uint256 tokenID = charactersMinted;
Expand All @@ -1083,6 +1078,10 @@ contract FullcountTest_atBatInviteOnly is FullcountTestBase {

vm.startPrank(player1);

vm.expectEmit(address(game));
emit AtBatStarted(
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Batter, true
);
uint256 atBatID = game.startAtBat(address(characterNFTs), tokenID, PlayerType.Batter, true);

vm.stopPrank();
Expand Down Expand Up @@ -1125,6 +1124,10 @@ contract FullcountTest_atBatInviteOnly is FullcountTestBase {

vm.startPrank(player1);

vm.expectEmit(address(game));
emit AtBatStarted(
initialNumAtBats + 1, address(characterNFTs), tokenID, initialNumSessions + 1, PlayerType.Pitcher, true
);
uint256 atBatID = game.startAtBat(address(characterNFTs), tokenID, PlayerType.Pitcher, true);

vm.stopPrank();
Expand Down

0 comments on commit b71b45d

Please sign in to comment.