Skip to content

Commit

Permalink
finally fixed my nft error
Browse files Browse the repository at this point in the history
  • Loading branch information
michojekunle committed Sep 23, 2024
1 parent 4ac7480 commit 83981b9
Show file tree
Hide file tree
Showing 6 changed files with 61,456 additions and 49 deletions.
49 changes: 19 additions & 30 deletions contracts/CaveParty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract CaveParty is ERC721, Ownable(msg.sender) {
uint256 public mintPrice = 0.0001 ether;
uint256 public maxPerWallet = 1;
string public assetMetadata =
"ipfs://QmeXnyhrkEGfKzQRtusyWNFKcjyZxLcU1puRvxLkK2kTeS";
"https://gateway.pinata.cloud/ipfs/Qmcs26b4ph4xqNyweWciq8H6gTkhESd4yZtECVmESMWPBo";

// mappings
mapping(address => uint256) public walletMints;
Expand All @@ -26,6 +26,12 @@ contract CaveParty is ERC721, Ownable(msg.sender) {
return assetMetadata;
}

function tokenURI(
uint256 tokenId
) public view virtual override returns (string memory) {
return assetMetadata;
}

function safeMint(address to) internal {
uint256 tokenId = totalMints;
totalMints++;
Expand All @@ -34,9 +40,9 @@ contract CaveParty is ERC721, Ownable(msg.sender) {
}

function mintToken() external payable {
require(mintPrice == msg.value, "0.0001 ether required to mint");
require(mintPrice >= msg.value, "0.0001 ether required to mint");
require(
walletMints[msg.sender] <= maxPerWallet,
walletMints[msg.sender] < maxPerWallet,
"mints per wallet exceeded"
);

Expand All @@ -53,35 +59,18 @@ contract CaveParty is ERC721, Ownable(msg.sender) {
require(sent, "withdrawal failed");
}

function updateMetadata(string memory _newAssetMetadata) external onlyOwner {
require(checkMetadata(_newAssetMetadata), "Invalid asset metadata: must include 'ipfs://'");

function updateMetadata(
string memory _newAssetMetadata
) external onlyOwner {
assetMetadata = _newAssetMetadata;
}

function getAssetMetadata() external view onlyOwner returns(string memory) {
function getAssetMetadata()
external
view
onlyOwner
returns (string memory)
{
return assetMetadata;
}

function checkMetadata(string memory _newAssetMetadata) private pure returns (bool) {
bytes memory metadataBytes = bytes(_newAssetMetadata);
bytes memory ipfsBytes = bytes("ipfs://");

if (metadataBytes.length < ipfsBytes.length) return false;

for (uint256 i = 0; i <= metadataBytes.length - ipfsBytes.length; i++) {
bool check = true;
for (uint256 j = 0; j < ipfsBytes.length; j++) {
if (metadataBytes[i + j] != ipfsBytes[j]) {
check = false;
break;
}
}
if (check) {
return true;
}
}

return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "..\\build-info\\7061738f0af9aa002156ebd51161033d.json"
"buildInfo": "..\\build-info\\680447ab84804c0f234a257e2e2b6563.json"
}

Large diffs are not rendered by default.

61,428 changes: 61,428 additions & 0 deletions ignition/deployments/chain-4202/build-info/680447ab84804c0f234a257e2e2b6563.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ignition/deployments/chain-4202/deployed_addresses.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"FluffyFuryModule#FluffyFury": "0x8d62Cdd85BF63acD648c06b0766b33e381686DF0",
"CavePartyModule#CaveParty": "0x8613BFbd4A1c460a88E6ea15cCCD7dBEa67A882d",
"NFTGatedEventManagerModule#NFTGatedEventManager": "0xDbeaeb362f2889255b81f0d3E77F92Ee220D24Dc"
"NFTGatedEventManagerModule#NFTGatedEventManager": "0xDbeaeb362f2889255b81f0d3E77F92Ee220D24Dc",
"CavePartyModule#CaveParty": "0xacbF6c2f45D22D7814cE2469B8654211e3499296"
}
18 changes: 4 additions & 14 deletions ignition/deployments/chain-4202/journal.jsonl

Large diffs are not rendered by default.

0 comments on commit 83981b9

Please sign in to comment.