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 Ownable dependency to CrucibleFactory #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 28 additions & 2 deletions contracts/crucible/CrucibleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity 0.7.6;

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";

import {IFactory} from "../factory/IFactory.sol";
import {IInstanceRegistry} from "../factory/InstanceRegistry.sol";
Expand All @@ -10,12 +12,14 @@ import {ProxyFactory} from "../factory/ProxyFactory.sol";
import {IUniversalVault} from "./Crucible.sol";

/// @title CrucibleFactory
contract CrucibleFactory is IFactory, IInstanceRegistry, ERC721 {
contract CrucibleFactory is Ownable, IFactory, IInstanceRegistry, ERC721 {
address private immutable _template;
using Strings for uint256;

constructor(address template) ERC721("Alchemist Crucible v1", "CRUCIBLE-V1") {
constructor(address template) ERC721("Alchemist Crucible v1", "CRUCIBLE-V1") Ownable() {
require(template != address(0), "CrucibleFactory: invalid template");
_template = template;
_setBaseURI('https://crucible.alchemist.wtf/nft/');
}

/* registry functions */
Expand Down Expand Up @@ -82,4 +86,26 @@ contract CrucibleFactory is IFactory, IInstanceRegistry, ERC721 {
function getTemplate() external view returns (address template) {
return _template;
}

/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

string memory base = baseURI();

uint256 id;
assembly {
id := chainid()
}

// concatenate the tokenID and chain id to the baseURI
return string(abi.encodePacked(
base,
tokenId.toString(),
'?network=',
chainId.toString()
));
}
}