Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Change naming of tokenURI to simply URI
Browse files Browse the repository at this point in the history
  • Loading branch information
leeren committed Jan 20, 2024
1 parent dba4d74 commit 0b3cc8a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions contracts/interfaces/resolvers/IIPMetadataResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ interface IIPMetadataResolver is IResolver {
/// @param ipId The canonical ID of the specified IP.
function owner(address ipId) external view returns (address);

/// @notice Fetches the token URI associated with the IP.
/// @notice Fetches an IP owner defined URI associated with the IP.
/// @param ipId The canonical ID of the specified IP.
function tokenURI(address ipId) external view returns (string memory);
function uri(address ipId) external view returns (string memory);

/// @notice Sets the core metadata associated with an IP.
/// @param ipId The canonical ID of the specified IP.
Expand All @@ -61,8 +61,8 @@ interface IIPMetadataResolver is IResolver {
/// @param hash The keccak-256 hash to associate with the IP.
function setHash(address ipId, bytes32 hash) external;

/// @notice Sets a token URI to associated with the IP.
/// @notice Sets an IP owner defined URI to associate with the IP.
/// @param ipId The canonical ID of the specified IP.
function setTokenURI(address ipId, string calldata tokenURI) external;
function setURI(address ipId, string calldata uri) external;

}
20 changes: 10 additions & 10 deletions contracts/resolvers/IPMetadataResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract IPMetadataResolver is IIPMetadataResolver, ResolverBase {
hash: record.hash,
registrationDate: record.registrationDate,
registrant: record.registrant,
uri: tokenURI(ipId)
uri: uri(ipId)
});
}

Expand Down Expand Up @@ -86,18 +86,18 @@ contract IPMetadataResolver is IIPMetadataResolver, ResolverBase {
return IIPAccount(payable(ipId)).owner();
}

/// @notice Fetches the token URI associated with the IP.
/// @notice Fetches an IP owner defined URI associated with the IP.
/// @param ipId The canonical ID of the specified IP.
function tokenURI(address ipId) public view returns (string memory) {
function uri(address ipId) public view returns (string memory) {
if (!IP_RECORD_REGISTRY.isRegistered(ipId)) {
return "";
}

IP.MetadataRecord memory record = _records[ipId];
string memory uri = record.uri;
string memory ipUri = record.uri;

if (bytes(uri).length > 0) {
return uri;
if (bytes(ipUri).length > 0) {
return ipUri;
}

return _defaultTokenURI(ipId, record);
Expand Down Expand Up @@ -131,11 +131,11 @@ contract IPMetadataResolver is IIPMetadataResolver, ResolverBase {
_records[ipId].hash = newHash;
}

/// @notice Sets a token URI to associated with the IP.
/// @notice Sets an IP owner defined URI to associate with the IP.
/// @param ipId The canonical ID of the specified IP.
/// @param newTokenURI The new token URI to set for the IP.
function setTokenURI(address ipId, string calldata newTokenURI) external onlyAuthorized(ipId) {
_records[ipId].uri = newTokenURI;
/// @param newURI The new token URI to set for the IP.
function setURI(address ipId, string calldata newURI) external onlyAuthorized(ipId) {
_records[ipId].uri = newURI;
}

/// @notice Checks whether the resolver interface is supported.
Expand Down
12 changes: 6 additions & 6 deletions test/foundry/resolvers/IPMetadataResolver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ contract IPMetadataResolverTest is ResolverBaseTest {
assertEq(ipResolver.registrationDate(ipId), RECORD_REGISTRATION_DATE);
assertEq(ipResolver.registrant(ipId), alice);
assertEq(ipResolver.owner(ipId), alice);
assertEq(ipResolver.tokenURI(ipId), RECORD_URI);
assertEq(ipResolver.uri(ipId), RECORD_URI);

// Also check the metadata getter returns as expected.
IP.Metadata memory metadata = ipResolver.metadata(ipId);
Expand Down Expand Up @@ -178,16 +178,16 @@ contract IPMetadataResolverTest is ResolverBaseTest {

/// @notice Checks setting token URI works as expected.
function test_IPMetadataResolver_SetTokenURI() public {
accessController.setPermission(ipId, alice, address(ipResolver), IIPMetadataResolver.setTokenURI.selector, 1);
accessController.setPermission(ipId, alice, address(ipResolver), IIPMetadataResolver.setURI.selector, 1);
vm.prank(alice);
ipResolver.setTokenURI(ipId, RECORD_URI);
assertEq(ipResolver.tokenURI(ipId), RECORD_URI);
ipResolver.setURI(ipId, RECORD_URI);
assertEq(ipResolver.uri(ipId), RECORD_URI);
}

/// @notice Checks the default token URI renders as expected.
function test_IPMetadataResolver_TokenURI_DefaultRender() public {
// Check default empty string value for unregistered IP.
assertEq(ipResolver.tokenURI(address(0)), "");
assertEq(ipResolver.uri(address(0)), "");

// Check default string value for registered IP.
assertTrue(accessController.checkPermission(ipId, alice, address(ipResolver), IIPMetadataResolver.setMetadata.selector));
Expand Down Expand Up @@ -218,7 +218,7 @@ contract IPMetadataResolverTest is ResolverBaseTest {
"data:application/json;base64,",
Base64.encode(bytes(string(abi.encodePacked(uriEncoding))))
));
assertEq(expectedURI, ipResolver.tokenURI(ipId));
assertEq(expectedURI, ipResolver.uri(ipId));
}

/// @dev Deploys a new IP Metadata Resolver.
Expand Down

0 comments on commit 0b3cc8a

Please sign in to comment.