Skip to content

Commit

Permalink
Add ERC-4906 support
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieraykatz committed Jul 21, 2024
1 parent e7ca19f commit 89e670e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/L2/BaseRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ contract BaseRegistrar is ERC721, Ownable {
uint256 indexed id, address indexed owner, uint256 expires, address resolver, uint64 ttl
);

/// @notice Emitted when metadata for a token range is updated.
///
/// @dev Useful for third-party platforms such as NFT marketplaces who can update
/// the images and related attributes of the NFTs in a timely fashion.
/// To refresh a whole collection, emit `_toTokenId` with `type(uint256).max`
/// ERC-4906: https://eip.tools/eip/4906
///
/// @param _fromTokenId The starting range of `tokenId` for which metadata has been updated.
/// @param _toTokenId The ending range of `tokenId` for which metadata has been updated.
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* MODIFIERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
Expand Down Expand Up @@ -343,6 +354,7 @@ contract BaseRegistrar is ERC721, Ownable {
/// @dev Allows the owner to set the the base Uniform Resource Identifier (URI)`.
function setBaseTokenURI(string memory baseURI_) public onlyOwner {
baseURI = baseURI_;
emit BatchMetadataUpdate(1, type(uint256).max);
}

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
Expand Down
2 changes: 2 additions & 0 deletions test/BaseRegistrar/SetBaseTokenURI.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ contract SetBaseTokenURI is BaseRegistrarBase {
string public newBaseURI = "https://newurl.org/";

function test_allowsTheOwnerToSetTheBaseURI() public {
vm.expectEmit(address(baseRegistrar));
emit BaseRegistrar.BatchMetadataUpdate(1, type(uint256).max);
vm.prank(owner);
baseRegistrar.setBaseTokenURI(newBaseURI);

Expand Down

0 comments on commit 89e670e

Please sign in to comment.