Skip to content

Commit

Permalink
feat: update contract address & component
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruv1238 committed Dec 7, 2024
1 parent d044602 commit 20b8511
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
10 changes: 5 additions & 5 deletions packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import { Address } from "~~/components/scaffold-eth";

const Home: NextPage = () => {
const { address: connectedAddress } = useAccount();
const contractAddress = "0x0000000000000000000000000000000000000000" as `0x${string}`;
const contractAddress = "0x52dE6508FECCA4d712b75b0bD018a621EaF2d734" as `0x${string}`;
const contractABI = StakingABI;

return (
<>
{/* Floating Stake Button - Always visible */}
{/* <div className="fixed right-0 bottom-8 z-50 flex items-center">
<div className="fixed right-0 bottom-8 z-50 flex items-center">
<StakeButton contractAddress={contractAddress} contractABI={contractABI} />
</div> */}
</div>

<div className="flex items-center flex-col flex-grow pt-10">
<div className="px-5">
Expand All @@ -37,11 +37,11 @@ const Home: NextPage = () => {
</h1>

<div className="flex justify-center my-4">
<StatsComponent stepsGoal={8000} />
<StatsComponent stepsGoal={6000} />
</div>

<div className="flex justify-center my-4">
<StepComponent totalSteps={8000} />
<StepComponent totalSteps={6000} />
</div>

{/* Stake Card with CTA Arrow */}
Expand Down
28 changes: 6 additions & 22 deletions packages/nextjs/components/StakeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,13 @@ const StakeCard: React.FC<StakeCardProps> = ({ contractAddress, contractABI }) =
const currentChainId = useChainId();
const { writeContract, isPending, isSuccess, isError, error } = useWriteContract();

const BASE_SEPOLIA = {
id: 84532,
name: "Base Sepolia",
network: "base-sepolia",
nativeCurrency: { decimals: 18, name: "Base Sepolia Ether", symbol: "ETH" },
rpcUrls: {
default: { http: ["https://sepolia.base.org"] },
public: { http: ["https://sepolia.base.org"] },
},
blockExplorers: {
default: { name: "BaseScan", url: "https://sepolia.basescan.org" },
},
testnet: true,
};

const { data: balance } = useBalance({
address,
chainId: BASE_SEPOLIA.id,
chainId: baseSepolia.id,
});

useEffect(() => {
if (isConnected && currentChainId !== BASE_SEPOLIA.id) {
if (isConnected && currentChainId !== baseSepolia.id) {
setNetworkError("Please switch to Base Sepolia network");
} else {
setNetworkError("");
Expand All @@ -55,8 +40,8 @@ const StakeCard: React.FC<StakeCardProps> = ({ contractAddress, contractABI }) =
return;
}

if (currentChainId !== BASE_SEPOLIA.id) {
await switchChain({ chainId: BASE_SEPOLIA.id });
if (currentChainId !== baseSepolia.id) {
await switchChain({ chainId: baseSepolia.id });
return;
}

Expand Down Expand Up @@ -87,7 +72,7 @@ const StakeCard: React.FC<StakeCardProps> = ({ contractAddress, contractABI }) =
<h2 className="card-title text-neon-green mb-4">Stake ETH</h2>

{/* Network Warning */}
{currentChainId !== BASE_SEPOLIA.id && isConnected && (
{currentChainId !== baseSepolia.id && isConnected && (
<div className="alert alert-warning text-sm mb-4">
Wrong network. Please switch to Base Sepolia
</div>
Expand Down Expand Up @@ -125,13 +110,12 @@ const StakeCard: React.FC<StakeCardProps> = ({ contractAddress, contractABI }) =
>
{!isConnected
? "Connect Wallet"
: currentChainId !== BASE_SEPOLIA.id
: currentChainId !== baseSepolia.id
? "Switch Network"
: isPending
? "Staking..."
: "Stake ETH"}
</button>

{/* Status Messages */}
{isSuccess && (
<div className="alert alert-success text-sm mt-4">
Expand Down

0 comments on commit 20b8511

Please sign in to comment.