Skip to content

Commit ada843e

Browse files
committed
consolidated minter events
1 parent 98e8b5a commit ada843e

File tree

2 files changed

+63
-25
lines changed

2 files changed

+63
-25
lines changed

src/EFPListMinterV2.sol

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ contract EFPListMinterV2 is ENSReverseClaimer, Pausable {
2929
IEFPAccountMetadata public immutable accountMetadata;
3030
IEFPListRecords public listRecordsL1;
3131

32-
event Minted(address indexed to, bytes listStorageLocation);
33-
event MintedTo(address indexed to, bytes listStorageLocation);
34-
event MintedPrimaryListNoMeta(address indexed to, bytes listStorageLocation);
35-
event MintedNoMeta(address indexed to, bytes listStorageLocation);
36-
event MintedToNoMeta(address indexed to, bytes listStorageLocation);
32+
event Minted(string method, address indexed to, bytes listStorageLocation);
3733

3834
constructor(address _registryAddress, address _accountMetadataAddress, address _listRecordsL1) {
3935
registry = IEFPListRegistryERC721(_registryAddress);
@@ -136,7 +132,7 @@ contract EFPListMinterV2 is ENSReverseClaimer, Pausable {
136132
if (recordsContract == address(listRecordsL1) && currentChain == chain) {
137133
listRecordsL1.claimListManagerForAddress(slot, msg.sender);
138134
}
139-
emit Minted(msg.sender, listStorageLocation);
135+
emit Minted('easyMint', msg.sender, listStorageLocation);
140136
}
141137

142138
/**
@@ -155,7 +151,7 @@ contract EFPListMinterV2 is ENSReverseClaimer, Pausable {
155151
if (recordsContract == address(listRecordsL1) && currentChain == chain) {
156152
listRecordsL1.claimListManagerForAddress(slot, msg.sender);
157153
}
158-
emit MintedTo(to, listStorageLocation);
154+
emit Minted('easyMintTo', to, listStorageLocation);
159155
}
160156

161157
/**
@@ -168,7 +164,7 @@ contract EFPListMinterV2 is ENSReverseClaimer, Pausable {
168164
uint256 tokenId = registry.totalSupply();
169165
_setDefaultListForAccount(msg.sender, tokenId);
170166
registry.mintTo{value: msg.value}(msg.sender, listStorageLocation);
171-
emit MintedPrimaryListNoMeta(msg.sender, listStorageLocation);
167+
emit Minted('mintPrimaryListNoMeta', msg.sender, listStorageLocation);
172168
}
173169

174170
/**
@@ -180,7 +176,7 @@ contract EFPListMinterV2 is ENSReverseClaimer, Pausable {
180176
validateAndDecodeLSL(listStorageLocation);
181177

182178
registry.mintTo{value: msg.value}(msg.sender, listStorageLocation);
183-
emit MintedNoMeta(msg.sender, listStorageLocation);
179+
emit Minted('mintNoMeta', msg.sender, listStorageLocation);
184180
}
185181

186182
/**
@@ -193,7 +189,7 @@ contract EFPListMinterV2 is ENSReverseClaimer, Pausable {
193189
validateAndDecodeLSL(listStorageLocation);
194190

195191
registry.mintTo{value: msg.value}(to, listStorageLocation);
196-
emit MintedToNoMeta(to, listStorageLocation);
192+
emit Minted('mintToNoMeta', to, listStorageLocation);
197193
}
198194

199195
/**

test/EFPListMinter.t.sol

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -464,49 +464,49 @@ contract EFPListMinterTest is Test {
464464
bytes memory listStorageLocation = _makeListStorageLocation(address(listRecords), slot);
465465

466466
vm.expectEmit(true, false, false, true);
467-
emit EFPListMinterV2.Minted(address(this), listStorageLocation);
467+
emit EFPListMinterV2.Minted('easyMint', address(this), listStorageLocation);
468468

469469
minter.easyMint(listStorageLocation);
470470
}
471471

472-
function test_EasyMintTo_EmitsMintedToEvent() public {
472+
function test_EasyMintTo_EmitsMintedEvent() public {
473473
uint256 slot = _getSlot(address(this), 5678);
474474
bytes memory listStorageLocation = _makeListStorageLocation(address(listRecords), slot);
475475
address recipient = address(0x456);
476476

477477
vm.expectEmit(true, false, false, true);
478-
emit EFPListMinterV2.MintedTo(recipient, listStorageLocation);
478+
emit EFPListMinterV2.Minted('easyMintTo', recipient, listStorageLocation);
479479

480480
minter.easyMintTo(recipient, listStorageLocation);
481481
}
482482

483-
function test_MintPrimaryListNoMeta_EmitsMintedPrimaryListNoMetaEvent() public {
483+
function test_MintPrimaryListNoMeta_EmitsMintedEvent() public {
484484
uint256 slot = _getSlot(address(this), 9012);
485485
bytes memory listStorageLocation = _makeListStorageLocation(address(listRecords), slot);
486486

487487
vm.expectEmit(true, false, false, true);
488-
emit EFPListMinterV2.MintedPrimaryListNoMeta(address(this), listStorageLocation);
488+
emit EFPListMinterV2.Minted('mintPrimaryListNoMeta', address(this), listStorageLocation);
489489

490490
minter.mintPrimaryListNoMeta(listStorageLocation);
491491
}
492492

493-
function test_MintNoMeta_EmitsMintedNoMetaEvent() public {
493+
function test_MintNoMeta_EmitsMintedEvent() public {
494494
uint256 slot = _getSlot(address(this), 3456);
495495
bytes memory listStorageLocation = _makeListStorageLocation(address(listRecords), slot);
496496

497497
vm.expectEmit(true, false, false, true);
498-
emit EFPListMinterV2.MintedNoMeta(address(this), listStorageLocation);
498+
emit EFPListMinterV2.Minted('mintNoMeta', address(this), listStorageLocation);
499499

500500
minter.mintNoMeta(listStorageLocation);
501501
}
502502

503-
function test_MintToNoMeta_EmitsMintedToNoMetaEvent() public {
503+
function test_MintToNoMeta_EmitsMintedEvent() public {
504504
uint256 slot = _getSlot(address(this), 7890);
505505
bytes memory listStorageLocation = _makeListStorageLocation(address(listRecords), slot);
506506
address recipient = address(0x789);
507507

508508
vm.expectEmit(true, false, false, true);
509-
emit EFPListMinterV2.MintedToNoMeta(recipient, listStorageLocation);
509+
emit EFPListMinterV2.Minted('mintToNoMeta', recipient, listStorageLocation);
510510

511511
minter.mintToNoMeta(recipient, listStorageLocation);
512512
}
@@ -530,12 +530,12 @@ contract EFPListMinterTest is Test {
530530

531531
// Test easyMint with native location
532532
vm.expectEmit(true, false, false, true);
533-
emit EFPListMinterV2.Minted(address(this), nativeLocation);
533+
emit EFPListMinterV2.Minted('easyMint', address(this), nativeLocation);
534534
minter.easyMint(nativeLocation);
535535

536536
// Test easyMint with non-native location
537537
vm.expectEmit(true, false, false, true);
538-
emit EFPListMinterV2.Minted(address(this), nonNativeLocation);
538+
emit EFPListMinterV2.Minted('easyMint', address(this), nonNativeLocation);
539539
minter.easyMint(nonNativeLocation);
540540
}
541541

@@ -550,12 +550,53 @@ contract EFPListMinterTest is Test {
550550
bytes memory listStorageLocation = _makeListStorageLocation(address(listRecords), slot);
551551

552552
vm.expectEmit(true, false, false, true);
553-
emit EFPListMinterV2.MintedTo(recipients[i], listStorageLocation);
553+
emit EFPListMinterV2.Minted('easyMintTo', recipients[i], listStorageLocation);
554554

555555
minter.easyMintTo(recipients[i], listStorageLocation);
556556
}
557557
}
558558

559+
function test_Events_AllMintingMethods() public {
560+
// Test all minting methods emit the correct function names
561+
uint256 baseSlot = 10000;
562+
address recipient = address(0xabc);
563+
564+
// Test easyMint
565+
uint256 slot1 = _getSlot(address(this), uint96(baseSlot + 1));
566+
bytes memory lsl1 = _makeListStorageLocation(address(listRecords), slot1);
567+
vm.expectEmit(true, false, false, true);
568+
emit EFPListMinterV2.Minted('easyMint', address(this), lsl1);
569+
minter.easyMint(lsl1);
570+
571+
// Test easyMintTo
572+
uint256 slot2 = _getSlot(address(this), uint96(baseSlot + 2));
573+
bytes memory lsl2 = _makeListStorageLocation(address(listRecords), slot2);
574+
vm.expectEmit(true, false, false, true);
575+
emit EFPListMinterV2.Minted('easyMintTo', recipient, lsl2);
576+
minter.easyMintTo(recipient, lsl2);
577+
578+
// Test mintPrimaryListNoMeta
579+
uint256 slot3 = _getSlot(address(this), uint96(baseSlot + 3));
580+
bytes memory lsl3 = _makeListStorageLocation(address(listRecords), slot3);
581+
vm.expectEmit(true, false, false, true);
582+
emit EFPListMinterV2.Minted('mintPrimaryListNoMeta', address(this), lsl3);
583+
minter.mintPrimaryListNoMeta(lsl3);
584+
585+
// Test mintNoMeta
586+
uint256 slot4 = _getSlot(address(this), uint96(baseSlot + 4));
587+
bytes memory lsl4 = _makeListStorageLocation(address(listRecords), slot4);
588+
vm.expectEmit(true, false, false, true);
589+
emit EFPListMinterV2.Minted('mintNoMeta', address(this), lsl4);
590+
minter.mintNoMeta(lsl4);
591+
592+
// Test mintToNoMeta
593+
uint256 slot5 = _getSlot(address(this), uint96(baseSlot + 5));
594+
bytes memory lsl5 = _makeListStorageLocation(address(listRecords), slot5);
595+
vm.expectEmit(true, false, false, true);
596+
emit EFPListMinterV2.Minted('mintToNoMeta', recipient, lsl5);
597+
minter.mintToNoMeta(recipient, lsl5);
598+
}
599+
559600
function test_Events_CorrectEventDataEncoding() public {
560601
uint256 slot = _getSlot(address(this), 4321);
561602
bytes memory listStorageLocation = _makeListStorageLocation(address(listRecords), slot);
@@ -575,13 +616,14 @@ contract EFPListMinterTest is Test {
575616
}
576617

577618
// Verify event signature
578-
assertEq(mintedLog.topics[0], keccak256("Minted(address,bytes)"));
619+
assertEq(mintedLog.topics[0], keccak256("Minted(string,address,bytes)"));
579620

580621
// Verify indexed parameter (address)
581622
assertEq(mintedLog.topics[1], bytes32(uint256(uint160(address(this)))));
582623

583-
// Verify non-indexed parameter (bytes data)
584-
bytes memory decodedData = abi.decode(mintedLog.data, (bytes));
624+
// Verify non-indexed parameters (string method, bytes data)
625+
(string memory method, bytes memory decodedData) = abi.decode(mintedLog.data, (string, bytes));
626+
assertEq(method, 'easyMint');
585627
assertEq(decodedData, listStorageLocation);
586628
}
587629
}

0 commit comments

Comments
 (0)