Skip to content

Commit

Permalink
Added Reveal
Browse files Browse the repository at this point in the history
  • Loading branch information
soumalya340 committed Jun 25, 2024
1 parent dd076e9 commit 6a17a24
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
30 changes: 27 additions & 3 deletions contracts/phygital/PhygitalA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ contract PhygitalA is Context, ERC2981, ERC721A, ERC721ABurnable {
uint8 public constant version = 1;

// PUBLIC && PRIVATE VARIABLES
string private baseURI;
string private baseURL;
bool public isRevealed;
uint256 public nftPrice;
uint16 public maxMint; /// @notice how many can be minted by a wallet
address public tradeHub;
Expand Down Expand Up @@ -143,7 +144,7 @@ contract PhygitalA is Context, ERC2981, ERC721A, ERC721ABurnable {
_setDefaultRoyalty(_msgSender(), uint96(contractDetails[2]));
maxMint = uint16(contractDetails[3]);

baseURI = _baseUri;
baseURL = _baseUri;
accessMasterAddress = accessControlAddress;
}

Expand Down Expand Up @@ -286,6 +287,12 @@ contract PhygitalA is Context, ERC2981, ERC721A, ERC721ABurnable {
);
}

function reveal(string memory uri) external {
require(isRevealed == false, "Collection is already revealed!");
isRevealed = true;
baseURL = uri;
}

/**
* @notice Burns `tokenId`. See {ERC721-_burn}.
*
Expand Down Expand Up @@ -317,8 +324,25 @@ contract PhygitalA is Context, ERC2981, ERC721A, ERC721ABurnable {
amount = quantity * nftPrice;
}

/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(
uint256 tokenId
) public view override(IERC721A, ERC721A) returns (string memory) {
if (!_exists(tokenId)) _revert(URIQueryForNonexistentToken.selector);
string memory baseURI = _baseURI();
if (isRevealed) {
return _baseURI();
}
return
bytes(baseURI).length != 0
? string(abi.encodePacked(baseURI, _toString(tokenId)))
: "";
}

function _baseURI() internal view override returns (string memory) {
return baseURI;
return baseURL;
}

function supportsInterface(
Expand Down
41 changes: 41 additions & 0 deletions typechain-types/PhygitalA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface PhygitalAInterface extends utils.Interface {
"delegateMint(address,uint256)": FunctionFragment;
"getApproved(uint256)": FunctionFragment;
"isApprovedForAll(address,address)": FunctionFragment;
"isRevealed()": FunctionFragment;
"maxMint()": FunctionFragment;
"maxSupply()": FunctionFragment;
"mint(uint256)": FunctionFragment;
Expand All @@ -40,6 +41,7 @@ export interface PhygitalAInterface extends utils.Interface {
"phygitalIdCheck(bytes)": FunctionFragment;
"registerAssetId(uint256,bytes)": FunctionFragment;
"rentables(uint256)": FunctionFragment;
"reveal(string)": FunctionFragment;
"royaltyInfo(uint256,uint256)": FunctionFragment;
"safeTransferFrom(address,address,uint256)": FunctionFragment;
"setApprovalForAll(address,bool)": FunctionFragment;
Expand Down Expand Up @@ -86,6 +88,10 @@ export interface PhygitalAInterface extends utils.Interface {
functionFragment: "isApprovedForAll",
values: [string, string]
): string;
encodeFunctionData(
functionFragment: "isRevealed",
values?: undefined
): string;
encodeFunctionData(functionFragment: "maxMint", values?: undefined): string;
encodeFunctionData(functionFragment: "maxSupply", values?: undefined): string;
encodeFunctionData(functionFragment: "mint", values: [BigNumberish]): string;
Expand All @@ -111,6 +117,7 @@ export interface PhygitalAInterface extends utils.Interface {
functionFragment: "rentables",
values: [BigNumberish]
): string;
encodeFunctionData(functionFragment: "reveal", values: [string]): string;
encodeFunctionData(
functionFragment: "royaltyInfo",
values: [BigNumberish, BigNumberish]
Expand Down Expand Up @@ -180,6 +187,7 @@ export interface PhygitalAInterface extends utils.Interface {
functionFragment: "isApprovedForAll",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "isRevealed", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "maxMint", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "maxSupply", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "mint", data: BytesLike): Result;
Expand All @@ -199,6 +207,7 @@ export interface PhygitalAInterface extends utils.Interface {
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "rentables", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "reveal", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "royaltyInfo",
data: BytesLike
Expand Down Expand Up @@ -421,6 +430,8 @@ export interface PhygitalA extends BaseContract {
overrides?: CallOverrides
): Promise<[boolean]>;

isRevealed(overrides?: CallOverrides): Promise<[boolean]>;

maxMint(overrides?: CallOverrides): Promise<[number]>;

maxSupply(overrides?: CallOverrides): Promise<[BigNumber]>;
Expand Down Expand Up @@ -473,6 +484,11 @@ export interface PhygitalA extends BaseContract {
}
>;

reveal(
uri: string,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;

royaltyInfo(
tokenId: BigNumberish,
salePrice: BigNumberish,
Expand Down Expand Up @@ -586,6 +602,8 @@ export interface PhygitalA extends BaseContract {
overrides?: CallOverrides
): Promise<boolean>;

isRevealed(overrides?: CallOverrides): Promise<boolean>;

maxMint(overrides?: CallOverrides): Promise<number>;

maxSupply(overrides?: CallOverrides): Promise<BigNumber>;
Expand Down Expand Up @@ -632,6 +650,11 @@ export interface PhygitalA extends BaseContract {
}
>;

reveal(
uri: string,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;

royaltyInfo(
tokenId: BigNumberish,
salePrice: BigNumberish,
Expand Down Expand Up @@ -736,6 +759,8 @@ export interface PhygitalA extends BaseContract {
overrides?: CallOverrides
): Promise<boolean>;

isRevealed(overrides?: CallOverrides): Promise<boolean>;

maxMint(overrides?: CallOverrides): Promise<number>;

maxSupply(overrides?: CallOverrides): Promise<BigNumber>;
Expand Down Expand Up @@ -785,6 +810,8 @@ export interface PhygitalA extends BaseContract {
}
>;

reveal(uri: string, overrides?: CallOverrides): Promise<void>;

royaltyInfo(
tokenId: BigNumberish,
salePrice: BigNumberish,
Expand Down Expand Up @@ -1013,6 +1040,8 @@ export interface PhygitalA extends BaseContract {
overrides?: CallOverrides
): Promise<BigNumber>;

isRevealed(overrides?: CallOverrides): Promise<BigNumber>;

maxMint(overrides?: CallOverrides): Promise<BigNumber>;

maxSupply(overrides?: CallOverrides): Promise<BigNumber>;
Expand Down Expand Up @@ -1052,6 +1081,11 @@ export interface PhygitalA extends BaseContract {
overrides?: CallOverrides
): Promise<BigNumber>;

reveal(
uri: string,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>;

royaltyInfo(
tokenId: BigNumberish,
salePrice: BigNumberish,
Expand Down Expand Up @@ -1171,6 +1205,8 @@ export interface PhygitalA extends BaseContract {
overrides?: CallOverrides
): Promise<PopulatedTransaction>;

isRevealed(overrides?: CallOverrides): Promise<PopulatedTransaction>;

maxMint(overrides?: CallOverrides): Promise<PopulatedTransaction>;

maxSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>;
Expand Down Expand Up @@ -1210,6 +1246,11 @@ export interface PhygitalA extends BaseContract {
overrides?: CallOverrides
): Promise<PopulatedTransaction>;

reveal(
uri: string,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;

royaltyInfo(
tokenId: BigNumberish,
salePrice: BigNumberish,
Expand Down
Loading

0 comments on commit 6a17a24

Please sign in to comment.