+ { isAuthenticated && address ? (
+
@@ -249,7 +254,7 @@ const handleFilterButtonClick = (section: string) => {
handleFilterButtonClick('a')} show={currentSection !== 'a'} >nft's ({completedBounties.length})
- handleFilterButtonClick('b')} show={currentSection !== 'b'}>your bounties ({inProgressBounties.length + completedBounties.length })
+ handleFilterButtonClick('b')} show={currentSection !== 'b'}> {userAccount ? "your bounties" : "user bounties"} bounties ({inProgressBounties.length + completedBounties.length })
handleFilterButtonClick('c')} show={currentSection !== 'c'}>submitted claims ({submitedClaims.length})
{/* handleFilterButtonClick('c')} show={currentSection !== 'd'} >collab bounties (0) */}
@@ -274,13 +279,67 @@ const handleFilterButtonClick = (section: string) => {
-
+
) : (
-
-
start poidh journey!
-
-
- )
+
+
+
+
+ user
+ {userAddress}
+
+
+
+
completed bounties: {completedBounties.length}
+
total degen paid: {totalETHPaid}
+
in progress bounties: {inProgressBounties.length}
+
total degen in contract: {ETHinContract}
+
completed claims: {completedClaims.length}
+
total degen earned: {totalETHEarn}
+
+
+
+
+
+
+
+
+
+ poidh score:
+ 123456
+
+
+
+
+
+ handleFilterButtonClick('a')} show={currentSection !== 'a'} >nft's ({completedBounties.length})
+ handleFilterButtonClick('b')} show={currentSection !== 'b'}>{userAccount ? "your bounties" : "user bounties"} ({inProgressBounties.length + completedBounties.length })
+ handleFilterButtonClick('c')} show={currentSection !== 'c'}>submitted claims ({submitedClaims.length})
+ {/* handleFilterButtonClick('c')} show={currentSection !== 'd'} >collab bounties (0) */}
+
+
+
+ {currentSection === 'a' && (
+
+
+ {/* */}
+
+ )}
+ {currentSection === 'b' && (
+
+
+
+ )}
+ {currentSection === 'c' && (
+
+ )}
+
+
+
+
+ )
}
);
diff --git a/src/components/account/AccountInfoShare.tsx b/src/components/account/AccountInfoShare.tsx
new file mode 100644
index 00000000..1306ba46
--- /dev/null
+++ b/src/components/account/AccountInfoShare.tsx
@@ -0,0 +1,288 @@
+"use client"
+import {
+ useDynamicContext,
+} from '@dynamic-labs/sdk-react-core'
+import { ethers } from "ethers";
+import { useEffect, useState } from 'react';
+
+import ProofListAccount from '@/components/bounty/ProofListAccount';
+import BountyList from '@/components/ui/BountyList';
+import Button from '@/components/ui/Button';
+import FilterButton from '@/components/ui/FilterButton';
+
+import { getBountiesByUser, getClaimsByUser, getContract, getProvider, getSigner, getURI, fetchBountyById, getNftsOfOwner, getClaimById} from '@/app/context/web3';
+
+import { BountiesData, ClaimsData, NFTDetails } from '@/types/web3';
+
+import { usePathname } from 'next/navigation';
+import { publicClient, walletClient } from '../../app/context/client'
+import abiNFT from '../../app/context/abiNFT'
+
+import { formatEther } from 'viem'
+import NftList from '../bounty/NftList';
+
+
+
+
+
+
+
+const AccountInfo = () => {
+ const {isAuthenticated, primaryWallet } = useDynamicContext();
+ const [userAddress, setUserAddress] = useState("0x111...123456")
+ const [bountiesData, setBountiesData] = useState
([]);
+ const [claimsData, setClaimsData] = useState([]);
+
+ const [completedBounties, setCompletedBounties] = useState([]);
+ const [inProgressBounties, setInProgressBounties] = useState("");
+ const [ETHinContract, setETHinContract] = useState("");
+ const [completedClaims, setCompletedClaims] = useState([]);
+ const [submitedClaims, setSubmitedClaims] = useState([]);
+ const [currentSection, setCurrentSection] = useState('a');
+ const [totalETHPaid, setTotalETHPaid] = useState(0);
+ const [totalETHEarn, setTotalETHEarn] = useState(0);
+
+ const [nftDetails, setNftDetails] = useState([]);
+
+
+
+
+
+
+// user info
+useEffect(() => {
+ const userInformation = async () => {
+ const signer = await getSigner(primaryWallet);
+ const provider = await getProvider()
+ const contract = await getContract(signer)
+
+
+
+
+ const balanceNFT = await getNftsOfOwner(signer);
+ const nftDetailsPromises = balanceNFT.map(async (nftId) => {
+ const uri = await getURI(nftId);
+ const response = await fetch(uri);
+ const data = await response.json();
+ const claims = await getClaimById(nftId);
+ if (claims.length > 0) {
+ const { name, description } = claims[0];
+ return { name: data?.name, description: data?.description, nftId: claims[0].id, uri: data?.image } as NFTDetails;
+ }
+ return null;
+ });
+
+
+
+ const completedNFTs = (await Promise.all(nftDetailsPromises)).filter((nft): nft is NFTDetails => nft !== null);
+ setNftDetails(completedNFTs);
+
+
+
+
+ //VIEM
+ // const balance = await publicClient.getBalance({
+ // address: '0x2fe17A509032Ce9F0AEBA6f2c1B8Dd0EaB304aAc',
+ // })
+
+ // const balanceAsEther = formatEther(balance)
+ // console.log("balance")
+
+ // console.log(balanceAsEther)
+ // const success = await walletClient.watchAsset({
+ // type: 'ERC20',
+ // options: {
+ // address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
+ // decimals: 18,
+ // symbol: 'WETH',
+ // },
+ // })
+ // console.log("success")
+
+ // console.log(success)
+
+
+
+
+
+
+ const address = signer.address;
+
+
+ // useEffect(() => {
+ // if (address !== "0x111...123456") {
+ // const newUrl = `http://localhost:3000/account/${address}`;
+ // window.history.pushState({ path: newUrl }, '', newUrl);
+ // }
+ // }, [address]); // This effect depends on userAddress and runs whenever it changes
+
+
+ const formattedAddress = `${address.slice(0, 5)}...${address.slice(-6)}`;
+ setUserAddress(formattedAddress);
+
+ const contractBalance = await provider.getBalance(contract.getAddress())
+ const balanceETH = ethers.formatEther(contractBalance)
+ setETHinContract(balanceETH)
+
+ getBountiesByUser(address, 0, [])
+ .then((data: any) => {
+ setBountiesData(data)
+ const completedBounties = data.filter((bounty:any) => bounty.claimer !== '0x0000000000000000000000000000000000000000' && bounty.claimer.toLowerCase() !== address.toLowerCase());
+ const inProgressBounties = data.filter((bounty:any) => bounty.claimer === '0x0000000000000000000000000000000000000000');
+ setInProgressBounties(inProgressBounties);
+ setCompletedBounties(completedBounties);
+
+
+ })
+
+
+
+
+
+ getClaimsByUser(address)
+ .then((data: any) => {
+ setClaimsData(data);
+ const completedClaims = data.filter((claim: any) => claim.accepted === true);
+ const submitedClaims = data;
+
+ setCompletedClaims(completedClaims);
+ setSubmitedClaims(submitedClaims);
+ console.log(completedClaims)
+ });
+
+
+ return formattedAddress;
+ };
+
+ if (primaryWallet) {
+ userInformation().catch(console.error);
+ }
+
+
+ }, [primaryWallet]);
+
+useEffect(() => {
+ const fetchClaimInformation = async () => {
+ const claimInformationPromises = completedBounties.map(async (bounty) => {
+ const uri = await getURI(bounty.claimId);
+ const amount = bounty.amount;
+ return {
+ claimId: bounty.claimId,
+ claimURI: uri,
+ amount: amount
+ };
+ });
+ const claimInformation = await Promise.all(claimInformationPromises);
+ console.log("Claim Information:", claimInformation);
+ };
+
+ fetchClaimInformation();
+ }, [completedBounties]);
+
+useEffect(() => {
+ let totalAmount = BigInt(0);
+ completedBounties.forEach(bounty => {
+ totalAmount += BigInt(bounty.amount);
+ });
+ const totalAmountETH = ethers.formatEther(totalAmount);
+ setTotalETHPaid(Number(totalAmountETH));
+}, [completedBounties]);
+
+useEffect(() => {
+ console.log("claims:");
+ var bountyIds = completedClaims.map(claim => claim.bountyId);
+ let totalAmount = BigInt(0);
+ Promise.all(bountyIds.map(async bountyId => {
+ const bountyData = await fetchBountyById(bountyId);
+ const amountBigInt = BigInt(bountyData.amount);
+ totalAmount += amountBigInt;
+ const totalAmountEarnETH = ethers.formatEther(totalAmount);
+ setTotalETHEarn(Number(totalAmountEarnETH))
+ }))
+}, [completedClaims]);
+
+
+
+
+
+
+const handleFilterButtonClick = (section: string) => {
+ setCurrentSection(section);
+ };
+
+
+
+
+ return (
+
+ { isAuthenticated ? (
+
+
+
+
+ user
+ {userAddress}
+
+
+
+
completed bounties: {completedBounties.length}
+
total degen paid: {totalETHPaid}
+
in progress bounties: {inProgressBounties.length}
+
total degen in contract: {ETHinContract}
+
completed claims: {completedClaims.length}
+
total degen earned: {totalETHEarn}
+
+
+
+
+
+
+
+
+
+ poidh score:
+ 123456
+
+
+
+
+
+ handleFilterButtonClick('a')} show={currentSection !== 'a'} >nft's ({completedBounties.length})
+ handleFilterButtonClick('b')} show={currentSection !== 'b'}>your bounties ({inProgressBounties.length + completedBounties.length })
+ handleFilterButtonClick('c')} show={currentSection !== 'c'}>submitted claims ({submitedClaims.length})
+ {/* handleFilterButtonClick('c')} show={currentSection !== 'd'} >collab bounties (0) */}
+
+
+
+ {currentSection === 'a' && (
+
+
+ {/* */}
+
+ )}
+ {currentSection === 'b' && (
+
+
+
+ )}
+ {currentSection === 'c' && (
+
+ )}
+
+
+
+
+ ) : (
+
+
start poidh journey!
+
+
+ )
+ }
+
+ );
+};
+
+export default AccountInfo;
\ No newline at end of file
diff --git a/src/components/bounty/ProofItem.tsx b/src/components/bounty/ProofItem.tsx
index 1ca4bd9e..8f700164 100644
--- a/src/components/bounty/ProofItem.tsx
+++ b/src/components/bounty/ProofItem.tsx
@@ -133,7 +133,7 @@ const ProofItem: React.FC = ({
{title}
-
{description}
+
{description}
diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx
index 54c1562c..bbac2974 100644
--- a/src/components/layout/Header.tsx
+++ b/src/components/layout/Header.tsx
@@ -12,7 +12,7 @@ import { WalletContext } from '@/app/context/WalletProvider';
import Banner from '@/components/global/Banner';
const Header = () => {
- const { isAuthenticated } = useDynamicContext();
+ const { isAuthenticated, primaryWallet } = useDynamicContext();
const [isClient, setIsClient] = useState(false);
const [isOpen, setIsOpen] = useState(false);
@@ -29,7 +29,7 @@ const Header = () => {
};
const walletContext = useContext(WalletContext);
-
+
useEffect(() => {
setIsClient(true);
}, []);
@@ -50,7 +50,9 @@ const Header = () => {
- {isClient && isAuthenticated ?
my bounties : null}
+ {isClient && isAuthenticated ?
my bounties : null}
+
+
{isClient ? : null}
@@ -118,7 +120,12 @@ const Header = () => {
{isClient && isAuthenticated ?
-
my bounties
+
my bounties
+
+
+
+
+
diff --git a/src/components/ui/BountyItem.tsx b/src/components/ui/BountyItem.tsx
index bee30019..a03bd80b 100644
--- a/src/components/ui/BountyItem.tsx
+++ b/src/components/ui/BountyItem.tsx
@@ -17,10 +17,16 @@ const BountyItem: React.FC
= ({ id, title, description, amount
const amountETH = ethers.formatEther(amount);
+
+
+
return (
-
+ <>
+
+
+
{title}
-
{shortDescription}
+
{shortDescription}
{Number(amountETH)} degen
@@ -29,6 +35,10 @@ const BountyItem: React.FC
= ({ id, title, description, amount
+
+
+
+ >
);
};
diff --git a/src/components/ui/BountyList.tsx b/src/components/ui/BountyList.tsx
index 9a337aa5..084e0210 100644
--- a/src/components/ui/BountyList.tsx
+++ b/src/components/ui/BountyList.tsx
@@ -1,9 +1,25 @@
import { motion } from 'framer-motion';
-import React from 'react';
+import React, { useEffect, useState } from 'react';
-import BountyItem from '@/components/ui/BountyItem';
+import BountyItem from '@/components/ui/BountyItem';
-import { BountyListProps } from '../../types/web3';
+import { BountyListProps } from '../../types/web3';
+import { getClaimsByBountyId } from '@/app/context/web3';
+
+
+
+export interface EnhancedBounty {
+ canceledOrClaimed: boolean;
+ hasClaims: boolean;
+ id: string;
+ issuer: string;
+ name: string;
+ amount: string | number | bigint;
+ description: string;
+ claimer: string;
+ createdAt: bigint;
+ claimId: string;
+}
const container = {
@@ -17,7 +33,7 @@ const container = {
}
}
};
-
+
const item = {
hidden: { y: 20, opacity: 0 },
visible: {
@@ -26,36 +42,48 @@ const item = {
}
};
-
const BountyList: React.FC
= ({ bountiesData }) => {
-// const [showFilters, setShowFilters] = useState(false);
+ const [enhancedBounties, setEnhancedBounties] = useState([]);
+ useEffect(() => {
+ const fetchClaims = async () => {
+ const promises = bountiesData.map(async (bounty) => {
+ const hasClaims = await getClaimsByBountyId(bounty.id);
+ return {
+ ...bounty,
+ canceledOrClaimed: bounty.claimer !== "0x0000000000000000000000000000000000000000",
+ hasClaims: hasClaims.length > 0
+ };
+ });
+ const results = await Promise.all(promises);
+ setEnhancedBounties(results);
+ };
-
- // useEffect(() => {
- // if (window.location.pathname === '/account') {
- // setShowFilters(true);
- // } else {
- // setShowFilters(false);
- // }
- // }, []);
+ fetchClaims();
+ }, [bountiesData]);
return (
<>
-
-
-
-
- {bountiesData.map((bounty) => (
-
-
+
+ {enhancedBounties.map((bounty) => (
+
+
))}
-
-
>
);
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 0e50e915..2659766f 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -166,5 +166,52 @@ button {
}
.votingStarted .submitForVote{
+
display:none;
}
+
+.bountyItem.pendingClaims .bg-gradient {
+ background: linear-gradient(to right, #2582D9, #F15E5F);
+ transition: all 0.3s ease; /* Add transition property */
+}
+
+.bountyItem.pendingClaims:hover .bg-gradient {
+ background: linear-gradient(to left, #2582D9, #F15E5F);
+}
+
+
+.bg-whiteblue{
+ background:#80b4ebd8;
+
+}
+
+
+
+
+
+.bg-blur{
+ background-color: rgba(209, 236, 255, 0.2);
+ color:white;
+ border-radius: 0.75rem;
+ backdrop-filter: blur(4px);
+}
+
+.bountyItem.pendingClaims > div > div.borderBox {
+ border:1px solid #cf5d5d;
+}
+
+.bountyItem.pendingClaims:hover > div > div.borderBox {
+ border:1px solid #4f80c5;
+}
+
+.bountyItem.noClaims > div > div.borderBox {
+ border:1px solid white;
+}
+
+.bountyItem.canceled > div > div.borderBox {
+ border:1px solid white;
+}
+
+.bountyItem.pendingClaims.canceled:hover > div > div.borderBox {
+ border:1px solid white;
+}
\ No newline at end of file
diff --git a/src/types/web3.ts b/src/types/web3.ts
index 315187bf..09d968ab 100644
--- a/src/types/web3.ts
+++ b/src/types/web3.ts
@@ -1,7 +1,7 @@
import { Contract } from "ethers";
// Wallets and Signers
-interface Wallet {
+export interface Wallet {
address: string;
authenticated: boolean;
chain: string;
@@ -146,7 +146,7 @@ export type FetchBountiesFunction = (offset: number) => Promise;
export type FetchBountyByIdFunction = (id: string) => Promise;
export type GetBountiesByUserFunction = (user: string, offset: number, allBounties: Bounty[]) => Promise;
export type GetAllBountiesFunction = () => Promise;
-
+export type GetOpenBountiesByUserFunction = (primaryWallet: Wallet) => Promise;
export type GetParticipants = (id: string) => Promise;