-
Notifications
You must be signed in to change notification settings - Fork 112
Add NFT contract and token metadata handling #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c2dfed1
Add token URI and owner only setter method
stevieraykatz 844b1fd
lint
stevieraykatz 6a97655
Add reverting logic for expired and unowned names
stevieraykatz e7ca19f
Lint
stevieraykatz 89e670e
Add ERC-4906 support
stevieraykatz 9701fdc
Add support for ERC-7572
stevieraykatz fa7532c
Address PR comments
stevieraykatz a660021
Remove revert for expired tokens, use NonexistentToken error
stevieraykatz de5cf7b
Fix natspec
stevieraykatz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| //SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.23; | ||
|
|
||
| import {Test} from "forge-std/Test.sol"; | ||
| import {BaseRegistrarBase} from "./BaseRegistrarBase.t.sol"; | ||
|
|
||
| contract ContractURI is BaseRegistrarBase { | ||
| function test_contractURI_isReturnedAsExpected() public view { | ||
| assertEq(keccak256(bytes(baseRegistrar.contractURI())), keccak256(bytes(collectionURI))); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| //SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.23; | ||
|
|
||
| import {BaseRegistrar} from "src/L2/BaseRegistrar.sol"; | ||
| import {BaseRegistrarBase} from "./BaseRegistrarBase.t.sol"; | ||
| import {Ownable} from "solady/auth/Ownable.sol"; | ||
| import {LibString} from "solady/utils/LibString.sol"; | ||
|
|
||
| contract SetBaseTokenURI is BaseRegistrarBase { | ||
| using LibString for uint256; | ||
|
|
||
| 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); | ||
|
|
||
| _registrationSetup(); | ||
| vm.warp(blockTimestamp); | ||
| vm.prank(controller); | ||
| baseRegistrar.register(id, user, duration); | ||
|
|
||
| string memory returnedURI = baseRegistrar.tokenURI(id); | ||
| string memory expectedURI = string.concat(newBaseURI, id.toString()); | ||
| assertEq(keccak256(bytes(returnedURI)), keccak256(bytes(expectedURI))); | ||
| } | ||
|
|
||
| function test_reverts_whenCalledByNonOwner(address caller) public { | ||
| vm.assume(caller != owner); | ||
| vm.prank(caller); | ||
| vm.expectRevert(Ownable.Unauthorized.selector); | ||
| baseRegistrar.setBaseTokenURI(newBaseURI); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.23; | ||
|
|
||
| import {Test} from "forge-std/Test.sol"; | ||
| import {BaseRegistrarBase} from "./BaseRegistrarBase.t.sol"; | ||
| import {BaseRegistrar} from "src/L2/BaseRegistrar.sol"; | ||
| import {Ownable} from "solady/auth/Ownable.sol"; | ||
|
|
||
| contract SetContractURI is BaseRegistrarBase { | ||
| string newContractURI = "NewURI"; | ||
|
|
||
| function test_allowsTheOwnerToSetTheContractURI() public { | ||
| vm.expectEmit(address(baseRegistrar)); | ||
| emit BaseRegistrar.ContractURIUpdated(); | ||
|
|
||
| vm.prank(owner); | ||
| baseRegistrar.setContractURI(newContractURI); | ||
| assertEq(keccak256(bytes(baseRegistrar.contractURI())), keccak256(bytes(newContractURI))); | ||
| } | ||
|
|
||
| function test_reverts_whenCalledByNonOwner(address caller) public { | ||
| vm.assume(caller != owner); | ||
| vm.prank(caller); | ||
| vm.expectRevert(Ownable.Unauthorized.selector); | ||
| baseRegistrar.setBaseTokenURI(newContractURI); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.