Skip to content
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

add baseURI view function #16

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/BaseGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ contract BaseGen is ERC721, ERC721Burnable, ERC721Royalty, Ownable {
return _generatorURI;
}

function baseURI() external view returns (string memory) {
return _baseURI();
}

// or e.g. "https://external-link-url.com/my-contract-metadata.json";

function contractURI() external view returns (string memory) {
Expand Down
7 changes: 7 additions & 0 deletions test/BaseGen.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ contract BaseGenTest is Test {
string memory baseUri = "https://data.kodadot.xyz/base/";
string memory scAddress = Strings.toHexString(uint160(address(instance)), 20);
string memory expected = string.concat(baseUri, scAddress, "/");
assertEq(instance.baseURI(), expected);
}

function testTokenUri() public view {
string memory baseUri = "https://data.kodadot.xyz/base/";
string memory scAddress = Strings.toHexString(uint160(address(instance)), 20);
string memory expected = string.concat(baseUri, scAddress, "/");

assertEq(instance.tokenURI(0), string.concat(expected, "0"));
}
Expand Down
Loading