Skip to content

Commit

Permalink
New deploy to sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi committed Oct 25, 2024
1 parent e3df664 commit 0d2cd54
Show file tree
Hide file tree
Showing 13 changed files with 530 additions and 177 deletions.
236 changes: 236 additions & 0 deletions packages/foundry/broadcast/Deploy.s.sol/11155111/run-1729818567.json

Large diffs are not rendered by default.

208 changes: 129 additions & 79 deletions packages/foundry/broadcast/Deploy.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions packages/foundry/contracts/PunkSociety.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ contract PunkSociety is Ownable {
function createPost(
string memory _tokenURI
) public payable {
require(msg.value == 3 ether, "Must send 3 USDC to create a post");
// require(msg.value == 3 ether, "Must send 3 USDC to create a post");
uint256 postId = postIds++;
postIdToUser[postId] = msg.sender;
userPosts[msg.sender].push(postId);

punkPosts.mint(_tokenURI);
payable(owner()).transfer(3 ether);
// payable(owner()).transfer(3 ether);

emit PostCreated(postId, msg.sender, _tokenURI, block.timestamp);
}
Expand All @@ -134,17 +134,17 @@ contract PunkSociety is Ownable {
require(
!userToPostLikes[msg.sender][_postID], "You have already liked this post"
);
require(msg.value == 1 ether, "Must send 1 USDC to like a post");
// require(msg.value == 1 ether, "Must send 1 USDC to like a post");

address postOwner = postIdToUser[_postID];
require(postOwner != address(0), "Post owner does not exist");

userToPostLikes[msg.sender][_postID] = true;
postToLikes[_postID]++;

// Transfer 0.1 ETH to the post owner
(bool sent,) = postOwner.call{ value: 1 ether }("");
require(sent, "Failed to send ETH to the post owner");
// Transfer 1 USDC to the post owner
// (bool sent,) = postOwner.call{ value: 1 ether }("");
// require(sent, "Failed to send USDC to the post owner");

emit PostLiked(_postID, msg.sender, block.timestamp);
}
Expand All @@ -156,17 +156,17 @@ contract PunkSociety is Ownable {
require(
userToPostLikes[msg.sender][_postID], "You have not liked this post yet"
);
require(msg.value == 0.5 ether, "Must send 0.5 USDC to unlike a post");
// require(msg.value == 0.5 ether, "Must send 0.5 USDC to unlike a post");

address postOwner = postIdToUser[_postID];
require(postOwner != address(0), "Post owner does not exist");

userToPostLikes[msg.sender][_postID] = false;
postToLikes[_postID]--;

// Transfer 0.1 ETH to the post owner
(bool sent,) = postOwner.call{ value: 0.5 ether }("");
require(sent, "Failed to send ETH to the post owner");
// Transfer 0.5 USDC to the post owner
// (bool sent,) = postOwner.call{ value: 0.5 ether }("");
// require(sent, "Failed to send USDC to the post owner");

emit PostUnliked(_postID, msg.sender, block.timestamp);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/foundry/contracts/SimpleFaucet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ contract SimpleFaucet {
// Mapping to track if an address has claimed ETH
mapping(address => bool) public hasClaimed;

// Ether to be dispensed (10 ETH in 18 decimals)
uint256 public constant AMOUNT = 10 ether;
// Ether to be dispensed (10 USDC in 18 decimals)
// uint256 public constant AMOUNT = 10 ether;
uint256 public constant AMOUNT = 0.01 ether;

// Only allow each address to claim once
modifier onlyOnce() {
Expand Down
5 changes: 3 additions & 2 deletions packages/foundry/script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ contract DeployScript is ScaffoldETHDeploy {
);

// Transfer 5000 USDC to the simpleFaucet
payable(address(simpleFaucet)).transfer(5000 * 1e18);
console.logString("5000 USDC transferred to SimpleFaucet");
// payable(address(simpleFaucet)).transfer(5000 * 1e18);
// payable(address(simpleFaucet)).transfer(0.5 * 1e18);
// console.logString("5000 USDC transferred to SimpleFaucet");

if (block.chainid == LOCAL_CHAIN_ID) { }

Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/app/create/_components/MintingButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import { parseEther } from "viem";
// import { parseEther } from "viem";
import { useAccount } from "wagmi";
import { useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
import { uploadToPinata } from "~~/utils/pinata-upload";
Expand Down Expand Up @@ -53,7 +53,7 @@ export const MintingButtons: React.FC<MintingFormProps> = ({ yourJSON, resetForm
const contractResponse = await writeContractAsync({
functionName: "createPost",
args: [ipfsPath],
value: parseEther("3"),
// value: parseEther("3"),
});

if (contractResponse) {
Expand Down
75 changes: 38 additions & 37 deletions packages/nextjs/app/explore/Explore.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use client";

import { useCallback, useEffect, useRef, useState } from "react";
import Image from "next/image";
// import Image from "next/image";
import { LoadingBars } from "../../components/punk-society/LoadingBars";
import { NewsFeed } from "../../components/punk-society/NewsFeed";
import { useAccount } from "wagmi";
import { useScaffoldEventHistory, useScaffoldReadContract, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
// import { useAccount } from "wagmi";
import { useScaffoldEventHistory } from "~~/hooks/scaffold-eth";
// import { useScaffoldEventHistory, useScaffoldReadContract, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";
import { getMetadataFromIPFS } from "~~/utils/simpleNFT/ipfs-fetch";
import { NFTMetaData } from "~~/utils/simpleNFT/nftsMetadata";
Expand All @@ -24,45 +25,45 @@ export const Explore = () => {
const [page, setPage] = useState(0);
const [activeTab, setActiveTab] = useState("Global");

const { address: connectedAddress } = useAccount();
const { writeContractAsync } = useScaffoldWriteContract("SimpleFaucet");
// const { address: connectedAddress } = useAccount();
// const { writeContractAsync } = useScaffoldWriteContract("SimpleFaucet");

const handleTabClick = (tab: any) => {
setActiveTab(tab);
};

const observer = useRef<IntersectionObserver | null>(null);

const { data: isClaimed } = useScaffoldReadContract({
contractName: "SimpleFaucet",
functionName: "hasClaimed",
args: [connectedAddress],
watch: true,
});

const handleClaimUSDC = async () => {
if (!connectedAddress) {
notification.error("Please connect your wallet");
return;
}

setLoading(true);

try {
const contractResponse = await writeContractAsync({
functionName: "claim",
// args: [],
});

if (contractResponse) {
notification.success("Claimed 10 USDC successfully!");
}
} catch (error) {
console.error("Error during claiming USDC:", error);
notification.error("Claiming USDC failed, please try again.");
} finally {
}
};
// const { data: isClaimed } = useScaffoldReadContract({
// contractName: "SimpleFaucet",
// functionName: "hasClaimed",
// args: [connectedAddress],
// watch: true,
// });

// const handleClaimUSDC = async () => {
// if (!connectedAddress) {
// notification.error("Please connect your wallet");
// return;
// }

// setLoading(true);

// try {
// const contractResponse = await writeContractAsync({
// functionName: "claim",
// // args: [],
// });

// if (contractResponse) {
// notification.success("Claimed 10 USDC successfully!");
// }
// } catch (error) {
// console.error("Error during claiming USDC:", error);
// notification.error("Claiming USDC failed, please try again.");
// } finally {
// }
// };

const {
data: createEvents,
Expand Down Expand Up @@ -149,15 +150,15 @@ export const Explore = () => {

return (
<div className="flex flex-col items-center justify-center">
{!isClaimed && (
{/* {!isClaimed && (
<button
onClick={handleClaimUSDC}
className="btn btn-primary text-white bg-[#2E79CC] hover:bg-blue-700 active:bg-blue-700 border-0 mt-2"
>
<Image src="/usdc-logo.png" alt="USDC logo" width={40} height={40} className="mr-2" />
<span>Claim 10 USDC from Faucet</span>
</button>
)}
)} */}
<div className="tabs-bar ">
<button className={`tab ${activeTab === "Global" ? "active" : ""}`} onClick={() => handleTabClick("Global")}>
Global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { KeyIcon as KeyIconOutline } from "@heroicons/react/24/outline";
import {
ArrowLeftOnRectangleIcon,
ArrowTopRightOnSquareIcon,
ArrowsRightLeftIcon,
QrCodeIcon,
ArrowsRightLeftIcon, // QrCodeIcon,
} from "@heroicons/react/24/outline";
import { KeyIcon as KeyIconSolid, LanguageIcon } from "@heroicons/react/24/solid";
import { SwitchTheme } from "~~/components/SwitchTheme";
Expand Down Expand Up @@ -51,30 +50,24 @@ export const AddressInfoDropdown = ({ blockExplorerAddressLink }: AddressInfoDro
>
<NetworkOptions hidden={!selectingNetwork} />

<li className={selectingNetwork ? "hidden" : ""}>
{/* <li className={selectingNetwork ? "hidden" : ""}>
<label
htmlFor="qrcode-modal"
className="text-white bg-orange-600 hover:bg-orange-500 active:bg-orange-500 btn-sm !rounded-xl flex gap-3 py-3"
>
<QrCodeIcon className="h-6 w-4 ml-2 sm:ml-0" />
<span className="whitespace-nowrap">View your address</span>
</label>
</li>
</li> */}
<li className={selectingNetwork ? "hidden" : ""}>
<label
htmlFor="private-key-modal"
className="btn-sm text-white bg-orange-600 hover:bg-orange-500 active:bg-orange-500 !rounded-xl flex gap-3 py-3"
>
<label htmlFor="private-key-modal" className="btn-sm !rounded-xl flex gap-3 py-3">
<KeyIconOutline className="h-6 w-4 ml-2 sm:ml-0" />
<span className="whitespace-nowrap">View Private Key</span>
</label>
</li>

<li className={selectingNetwork ? "hidden" : ""}>
<label
htmlFor="load-private-key-modal"
className="btn-sm text-white bg-orange-600 hover:bg-orange-500 active:bg-orange-500 !rounded-xl flex gap-3 py-3"
>
<label htmlFor="load-private-key-modal" className="btn-sm !rounded-xl flex gap-3 py-3">
<KeyIconSolid className="h-6 w-4 ml-2 sm:ml-0" />
<span className="whitespace-nowrap">Load Private Key</span>
</label>
Expand Down
6 changes: 3 additions & 3 deletions packages/nextjs/components/punk-society/LikedButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { parseEther } from "viem";
// import { parseEther } from "viem";
import { useAccount } from "wagmi";
import { useScaffoldReadContract, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";
Expand Down Expand Up @@ -42,7 +42,7 @@ const LikeButton: React.FC<LikeButtonProps> = ({ postId }) => {
await writeContractAsync({
functionName: "likePost",
args: [postId],
value: parseEther("1"),
// value: parseEther("1"),
});
notification.success("Liked successfully!");
} catch (error) {
Expand All @@ -60,7 +60,7 @@ const LikeButton: React.FC<LikeButtonProps> = ({ postId }) => {
await writeContractAsync({
functionName: "unlikePost",
args: [postId],
value: parseEther("0.5"),
// value: parseEther("0.5"),
});
notification.success("Unliked successfully!");
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion packages/nextjs/components/punk-society/PunkBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export const PunkBalance = ({ address, className = "", usdMode }: BalanceProps)
</>
) : (
<>
<span>{formattedBalance.toFixed(2)}</span>
<span>{formattedBalance.toFixed(4)}</span>
{/* <span>{formattedBalance.toFixed(2)}</span> */}
<span className="text-[0.8em] font-bold ml-1">{targetNetwork.nativeCurrency.symbol}</span>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { useRef, useState } from "react";
import Link from "next/link";
import { PunkBalance } from "../PunkBalance";
import { NetworkOptions } from "./NetworkOptions";
import { FundButton, getOnrampBuyUrl } from "@coinbase/onchainkit/fund";
// import { FundButton, getOnrampBuyUrl } from "@coinbase/onchainkit/fund";
import { getAddress } from "viem";
import { Address } from "viem";
import { useAccount } from "wagmi";
import { useAccount, useDisconnect } from "wagmi";
import { UserIcon } from "@heroicons/react/24/outline";
import { QrCodeIcon } from "@heroicons/react/24/outline";
import { ArrowUpLeftIcon, LinkIcon } from "@heroicons/react/24/solid";
import { ArrowLeftOnRectangleIcon, ArrowUpLeftIcon } from "@heroicons/react/24/solid";
import { useOutsideClick, useScaffoldReadContract } from "~~/hooks/scaffold-eth";

type AddressInfoDropdownProps = {
Expand All @@ -23,16 +23,17 @@ export const AddressInfoDropdown = ({ address }: AddressInfoDropdownProps) => {

const checkSumAddress = getAddress(address);
const { address: connectedAddress } = useAccount();
const { disconnect } = useDisconnect();

const projectId = process.env.NEXT_PUBLIC_CDP_PROJECT_ID || "";
// const projectId = process.env.NEXT_PUBLIC_CDP_PROJECT_ID || "";

const onrampBuyUrl = getOnrampBuyUrl({
projectId,
addresses: { connectedAddress: ["base", "avalanche"] },
assets: ["USDC"],
presetFiatAmount: 5,
fiatCurrency: "USD",
});
// const onrampBuyUrl = getOnrampBuyUrl({
// projectId,
// addresses: { connectedAddress: ["base", "avalanche"] },
// assets: ["USDC"],
// presetFiatAmount: 5,
// fiatCurrency: "USD",
// });

const { data: profileInfo } = useScaffoldReadContract({
contractName: "PunkProfile",
Expand Down Expand Up @@ -94,24 +95,18 @@ export const AddressInfoDropdown = ({ address }: AddressInfoDropdownProps) => {
</Link>
</li>
<li className={selectingNetwork ? "hidden" : ""}>
<label
htmlFor="qrcode-modal"
className="bg-[#4338CA] text-white hover:bg-[#4f46e5] active:bg-[#4f46e5] btn-sm !rounded-xl flex gap-3 py-3"
>
<label htmlFor="qrcode-modal" className="btn-sm !rounded-xl flex gap-3 py-3">
<QrCodeIcon className="h-6 w-4 ml-2 sm:ml-0" />
<span className="whitespace-nowrap">Receive USDC</span>
<span className="whitespace-nowrap">Receive ETH</span>
</label>
</li>
<li className={selectingNetwork ? "hidden" : ""}>
<label
htmlFor="send-usdc-modal"
className="bg-[#4338CA] text-white hover:bg-[#4f46e5] active:bg-[#4f46e5] btn-sm !rounded-xl flex gap-3 py-3"
>
<label htmlFor="send-usdc-modal" className=" btn-sm !rounded-xl flex gap-3 py-3">
<ArrowUpLeftIcon className="h-6 w-4 ml-2 sm:ml-0" />
<span className="whitespace-nowrap">Send USDC</span>
<span className="whitespace-nowrap">Send ETH</span>
</label>
</li>
<li className={selectingNetwork ? "hidden" : ""}>
{/* <li className={selectingNetwork ? "hidden" : ""}>
<label
htmlFor="bridge-usdc-modal"
className="bg-[#4338CA] text-white hover:bg-[#4f46e5] active:bg-[#4f46e5] btn-sm !rounded-xl flex gap-3 py-3"
Expand All @@ -126,17 +121,17 @@ export const AddressInfoDropdown = ({ address }: AddressInfoDropdownProps) => {
fundingUrl={onrampBuyUrl}
className="py-1 text-white px-6 md:px-3.5 gap-0.5 md:gap-1 text-md rounded-xl bg-[#4338CA] hover:bg-[#4f46e5] active:bg-[#4f46e5] justify-start font-normal "
/>
</li>
</li> */}

{/* <li className={selectingNetwork ? "hidden" : ""}>
<li className={selectingNetwork ? "hidden" : ""}>
<button
className="menu-item text-red-600 dark:text-red-500 btn-sm !rounded-xl flex gap-3 py-3"
type="button"
onClick={() => disconnect()}
>
<ArrowLeftOnRectangleIcon className="h-6 w-4 ml-2 sm:ml-0" /> <span>Disconnect</span>
</button>
</li> */}
</li>
</ul>
</details>
</>
Expand Down
Loading

0 comments on commit 0d2cd54

Please sign in to comment.