diff --git a/components/Gameplay/Planets/PlanetCard.tsx b/components/Gameplay/Planets/PlanetCard.tsx index a4ad9a6f..fd4abf53 100644 --- a/components/Gameplay/Planets/PlanetCard.tsx +++ b/components/Gameplay/Planets/PlanetCard.tsx @@ -4,7 +4,7 @@ import Link from "next/link"; import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; import PlanetEditor, { PlanetEditorFromData } from "../../../pages/generator/planet-editor"; -import StakePlay from "../../../pages/stake/play"; +// import StakePlay from "../../../pages/stake/play"; import UtterancesComments from "../../Lens/Utterances"; import { useContract, useContractRead, useContractWrite, useLazyMint } from "@thirdweb-dev/react"; import { planetsImagesCdnAddress } from "../../../constants/cdn"; @@ -47,13 +47,13 @@ export function PlanetCard ({ activeTab, planetId }) { error, } = useLazyMint(contract); - function showNftMetadataUri (planet) { - const { contract } = useContract(`{planet?.contract}`); - const { data, isLoading } = useContractRead( contract, "uri", `{planet?.tokenId}`) - if ( data ) { - setPlanetUri( data ); - } - } + // function showNftMetadataUri (planet) { + // const { contract } = useContract(`{planet?.contract}`); + // const { data, isLoading } = useContractRead( contract, "uri", `{planet?.tokenId}`) + // if ( data ) { + // setPlanetUri( data ); + // } + // } const updatePlayerReputation = async () => { let newReputation = playerReputation + 1; diff --git a/components/Gameplay/Stake/ApproxRewards.tsx b/components/Gameplay/Stake/ApproxRewards.tsx deleted file mode 100644 index 29367a70..00000000 --- a/components/Gameplay/Stake/ApproxRewards.tsx +++ /dev/null @@ -1,49 +0,0 @@ -export default function ApproxRewards () { - return ( - "This currently doesn't do anything due to compilation errors" - ) -} - -/*import React, { useState, useEffect } from "react"; - -import { useAddress } from "@thirdweb-dev/react"; -import { SmartContract } from "@thirdweb-dev/sdk"; -import { ethers } from "ethers"; -import ContractMappingResponse from "../../../constants/contractMappingResponse"; - -type Props = { helperContract: SmartContract; }; - -export default function ApproxRewards ({ helperContract }: Props ) { // Calls contract to estimate the rewards owed to the authenticated player/user - const address = useAddress(); - const addressString = address - const everyMillisecondAmount = parseInt( - (10_000_000_000_000 / 2.1).toFixed(0) // Assumes each block (on EVM) takes ~2.1 seconds to be mined. Begins when component isMounted - ); - - const [amount, setAmount] = useState(0); - const [multiplier, setMultiplier] = useState(0); - - useEffect(() => { - (async () => { - if (!address) return; - const p = ( await helperContract.call( 'playerHelper', address, )) as ContractMappingResponse; - if (p.isData) { // If a multitool owned by the player IS staked/equipped - setMultiplier(p.value.toNumber() + 1); // A better multitool (derived as tokenId of multitool contract) gives better rewards - } else { setMultiplier(0); }; - })(); - }, [address, helperContract]); - - useEffect(() => { // Update the amount in state based on everyMillisecondAmount - const interval = setInterval(() => { setAmount( amount + everyMillisecondAmount ); }, 100); // update token amount (earned from staking) - return () => clearInterval(interval); // Clear when the component unmounts - }, [amount, everyMillisecondAmount]); - - return ( -

- Earned this session: {" "} - - {ethers.utils.formatEther((amount * multiplier).toFixed(0)) || "Error..."} - -

- ); -}*/ \ No newline at end of file diff --git a/components/Gameplay/Stake/CurrentGear.tsx b/components/Gameplay/Stake/CurrentGear.tsx deleted file mode 100644 index 1da75f6f..00000000 --- a/components/Gameplay/Stake/CurrentGear.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import React, { useState, useEffect } from "react"; -import styles from '../../../styles/Staking-P2E/planetInteraction.module.css'; - -import { ThirdwebNftMedia, useAddress, useNFT } from "@thirdweb-dev/react"; // https://www.notion.so/skinetics/February-Flow-Planets-8c864b66147c447f82136772336e9bc6?pvs=4#3f8fd072ce514882a1a05e89a6cf63db -import { EditionDrop, NFT, SmartContract } from "@thirdweb-dev/sdk"; -import ContractMappingResponse from "../../../constants/contractMappingResponse"; -import GameplayAnimation from "./GameplayAnimation"; -import { PLANETS_ADDRESS } from "../../../constants/contractAddresses"; - -type Props = { - helperContract: SmartContract; - planetContract: EditionDrop; - multitoolContract: EditionDrop; -}; - -export default function CurrentGear ({ // Shows the currently equipped planet character & currently equipped multitool - helperContract, - planetContract, - multitoolContract, -}: Props) { - const address = useAddress(); - const { data: planetNft } = useNFT(planetContract, 0); // Maps the data to the first planet nft (as for this version of the demo, we're only interacting with WASP-48b aka token id 1) - const [multitool, setMultitool] = useState(); // If user has any multitools staked onto the helper contract. Previously () - /*useEffect(() => { - (async () => { - if (!address) return; - const p = ( await helperContract.call( // Connect to the helper contract - 'playerHelper', // Referred on contract as `playerHelper`, in terms of the frontend/ux it's essentially the `playerMultitool` from `multitoolContract` - address, - )) as ContractMappingResponse; - if (p.isData) { // If there is an equipped (staked) multitool, fetch its metadata - const multitoolMetadata = await multitoolContract.get(p.value); - setMultitool(multitoolMetadata); - } - })(); - }, [address, helperContract, multitoolContract]); // Refresh this function if any of these values change. This component is reusable across multiple contracts (the contract addresses are defined in the page, not the component)*/ - - return ( -
-

Equipped items

-
-
{/* Currently equipped player */} - {planetNft && ( - - )} -
-
{/* Currently equipped multitool */} - {multitool && ( - // @ts-ignore - - )} -
-
-
- planet-mining - -
-
- ); -}; \ No newline at end of file diff --git a/components/Gameplay/Stake/GameplayAnimation.tsx b/components/Gameplay/Stake/GameplayAnimation.tsx deleted file mode 100644 index c0d88f74..00000000 --- a/components/Gameplay/Stake/GameplayAnimation.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from "react"; -import styles from '../../../styles/Staking-P2E/Gameplay.module.css'; -import { NFT } from "@thirdweb-dev/sdk"; - -//const Minerals = (
mineral
) // This should be changed to the collection picture (via Thirdweb) -const Minerals = (
mineral
) -type Props = { multitool: NFT | undefined; }; - -export default function GameplayAnimation ({ multitool }: Props ) { - if (!multitool) { return
I need a multitool!
; }; - return ( -
-
- {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} - {Minerals} -
-
- ); -}; \ No newline at end of file diff --git a/components/Gameplay/Stake/LoadingSection.tsx b/components/Gameplay/Stake/LoadingSection.tsx deleted file mode 100644 index c6253825..00000000 --- a/components/Gameplay/Stake/LoadingSection.tsx +++ /dev/null @@ -1,4 +0,0 @@ -import React from "react"; -import styles from '../../../styles/Staking-P2E/planetInteraction.module.css'; - -export default function LoadingSection () { return
Loading...
; }; \ No newline at end of file diff --git a/components/Gameplay/Stake/MintContainer.tsx b/components/Gameplay/Stake/MintContainer.tsx deleted file mode 100644 index d3a34395..00000000 --- a/components/Gameplay/Stake/MintContainer.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import React from "react"; -import styles from '../../../styles/Staking-P2E/Home.module.css'; - -import { useAddress, useClaimNFT, useEditionDrop, Web3Button } from "@thirdweb-dev/react"; -import { PLANETS_ADDRESS } from "../../../constants/contractAddresses"; - -export default function MintContainer () { - const editionDrop = useEditionDrop(PLANETS_ADDRESS); - const { mutate: claim } = useClaimNFT(editionDrop); - const address = useAddress(); - - return ( -
-

Edition drop

-

Claim your planet NFT to start playing

-
- -
- { - claim({ - quantity: 1, - to: address!, - tokenId: 0, // Claim the first nft/planet in the collection. This mutate function will be updated, with the specific value being generated from our Flask API - }); - }} - accentColor="#f5f" - colorMode='dark' - >Claim the first planet! -
- ); -} \ No newline at end of file diff --git a/components/Gameplay/Stake/OwnedGear.tsx b/components/Gameplay/Stake/OwnedGear.tsx deleted file mode 100644 index f8197036..00000000 --- a/components/Gameplay/Stake/OwnedGear.tsx +++ /dev/null @@ -1,66 +0,0 @@ -export default function OwnedGear () { - return "This export is a stub for the original ownedGear component" -} - -/*import React from "react"; -import styles from '../../../styles/Staking-P2E/planetInteraction.module.css'; - -import { ThirdwebNftMedia, useAddress, useOwnedNFTs, Web3Button } from "@thirdweb-dev/react"; -import { EditionDrop, SmartContract } from "@thirdweb-dev/sdk"; - -import LoadingSection from "./LoadingSection"; -import { HELPER_ADDRESS } from "../../../constants/contractAddresses"; - -type Props = { multitoolContract: EditionDrop, helperContract: SmartContract; }; - -export default function OwnedGear ({ multitoolContract, helperContract }: Props) { // Shows the multitools in a user's wallet and allows them to stake/equip said multitools - const address = useAddress(); - const { data: ownedMultitools, isLoading } = useOwnedNFTs( // Which nfts does the user hold from the multitools contract - multitoolContract, - address, - ); - - if (isLoading) { - return - } - - async function equip(id: string) { - if (!address) return; - const hasApproval = await multitoolContract.isApproved( // Is the contract approved by the account to be able to transfer the multitool? - address, - HELPER_ADDRESS - ); - - if (!hasApproval) { - await multitoolContract.setApprovalForAll(HELPER_ADDRESS, true); - }; - - await helperContract.call("stake", id); - - window.location.reload(); - } - - return ( - <> -
- {ownedMultitools?.map((p) => ( -
- -

{p.metadata.name}

- - equip(p.metadata.id)} - > - Equip - -
- ))} -
- -); -}*/ \ No newline at end of file diff --git a/components/Gameplay/Stake/Rewards.tsx b/components/Gameplay/Stake/Rewards.tsx deleted file mode 100644 index 14222d01..00000000 --- a/components/Gameplay/Stake/Rewards.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import React from "react"; -import styles from '../../../styles/Staking-P2E/planetInteraction.module.css'; - -import { ThirdwebNftMedia, useAddress, useMetadata, useContractRead, useTokenBalance, Web3Button } from "@thirdweb-dev/react"; -import { SmartContract, Token } from "@thirdweb-dev/sdk"; -import { ethers } from "ethers"; -import { HELPER_ADDRESS } from "../../../constants/contractAddresses"; // Create a param/argument so that the helper contract can be changed per page like the rewards/planet (aka character) contracts - -import ApproxRewards from "./ApproxRewards"; - -type Props = { helperContract: SmartContract; rewardsContract: Token; }; - -export default function Rewards({ helperContract, rewardsContract }: Props ) { // Shows the token metadata, amount of tokens in wlalet, claimable amount (reward) - const address = useAddress(); - const { data: tokenMetadata } = useMetadata(rewardsContract); - const { data: currentBalance } = useTokenBalance(rewardsContract, address); - const { data: unclaimedAmount } = useContractRead( - helperContract, - 'calculateRewards', - address - ); - - return ( -
-

Your Minerals

- {tokenMetadata && ( // If exists/loaded - - )} -

- Balance: {currentBalance?.displayValue} -

-

- Unclaimed: {" "} - {unclaimedAmount && ethers.utils.formatUnits(unclaimedAmount)} -

-

Approx rewards would go here

- {/**/} -
- contract.call('claim')} - >Claim Rewards -
-
- ); -} \ No newline at end of file diff --git a/components/Gameplay/Stake/Shop.tsx b/components/Gameplay/Stake/Shop.tsx deleted file mode 100644 index d41f7d26..00000000 --- a/components/Gameplay/Stake/Shop.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React, { useEffect } from "react"; -import styles from '../../../styles/Staking-P2E/planetInteraction.module.css'; - -import { ThirdwebNftMedia, useNFTs } from "@thirdweb-dev/react"; -import { EditionDrop } from "@thirdweb-dev/sdk"; - -import { ShopItem } from "."; - -type Props = { multitoolContract: EditionDrop; }; - -export default function Shop ({ multitoolContract }: Props ) { // Shows all available multitools, their price, and a button to purchase them - const { data: availableMultitools } = useNFTs(multitoolContract); - return ( - <> -
- {availableMultitools?.map((p) => ( - - ))} -
- - ) -} \ No newline at end of file diff --git a/components/Gameplay/Stake/ShopItem.tsx b/components/Gameplay/Stake/ShopItem.tsx deleted file mode 100644 index ce7b8b7b..00000000 --- a/components/Gameplay/Stake/ShopItem.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from "react"; -import styles from '../../../styles/Staking-P2E/planetInteraction.module.css'; - -import { ThirdwebNftMedia, useActiveClaimCondition, Web3Button } from "@thirdweb-dev/react"; -import { ethers } from "ethers"; -import { NFT, EditionDrop } from "@thirdweb-dev/sdk"; - -import { MULTITOOLS_ADDRESS } from "../../../constants/contractAddresses"; - -type Props = { multitoolContract: EditionDrop; item: NFT; }; - -export default function ShopItem ({ item, multitoolContract }: Props ) { - const { data: claimCondition } = useActiveClaimCondition( - multitoolContract, - item.metadata.id, - ); - - return ( -
- -

{item.metadata.name}

-

- Price:{" "} - - {claimCondition && ethers.utils.formatUnits(claimCondition?.price)}{" "} - Minerals - -

- -
- contract.erc1155.claim(item.metadata.id, 1)} - onSuccess={() => alert("Purchased!")} - onError={(error) => alert(error)} - >Buy -
-
- ); -}; \ No newline at end of file diff --git a/components/Gameplay/Stake/index.ts b/components/Gameplay/Stake/index.ts deleted file mode 100644 index 82d7c311..00000000 --- a/components/Gameplay/Stake/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { default as ApproxRewards } from './ApproxRewards'; -export { default as CurrentGear } from './CurrentGear'; -export { default as GameplayAnimation } from './GameplayAnimation'; -export { default as LoadingSection } from './LoadingSection'; -export { default as OwnedGear } from './OwnedGear'; -export { default as Rewards } from './Rewards'; -export { default as Shop } from './Shop'; -export { default as ShopItem } from './ShopItem'; \ No newline at end of file diff --git a/components/Planet/PlanetCard.tsx b/components/Planet/PlanetCard.tsx index 9e224d7c..affdbb2a 100644 --- a/components/Planet/PlanetCard.tsx +++ b/components/Planet/PlanetCard.tsx @@ -19,19 +19,6 @@ export default function PlanetContent ({ activeTab, planetId }) { // } - async function getPlanetPosts ( planetId ) { - const { data, error } = await supabase.from('posts_duplicate') - .select('*') - .order('created_at', { ascending: false }) - .eq('planets2', planetId) - return data; - - if (error) { - console.error(error); - return []; - } - }; - async function getPlanetData ( planetId ) { const { data } = await supabase.from('planetsss') .select() diff --git a/components/Tests/Planet/PlanetCard.tsx b/components/Tests/Planet/PlanetCard.tsx index 67d42a9a..88f0386b 100644 --- a/components/Tests/Planet/PlanetCard.tsx +++ b/components/Tests/Planet/PlanetCard.tsx @@ -19,19 +19,6 @@ export default function PlanetContent ({ activeTab, planetId }) { // } - async function getPlanetPosts ( planetId ) { - const { data, error } = await supabase.from('posts_duplicate') - .select('*') - .order('created_at', { ascending: false }) - .eq('planets2', planetId) - return data; - - if (error) { - console.error(error); - return []; - } - }; - async function getPlanetData ( planetId ) { const { data } = await supabase.from('planetsss') .select() diff --git a/package.json b/package.json index b8506c48..be046d81 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,6 @@ "test-api": "cd server && venv/bin/activate && flask test" }, "dependencies": { - "@3rdweb/hooks": "1.9.2", - "@3rdweb/sdk": "1.42.1", "@chakra-ui/react": "2.4.9", "@emotion/react": "11.10.5", "@emotion/styled": "11.10.5", @@ -35,10 +33,6 @@ "@supabase/supabase-js": "^2.13.1", "@supabase/ui": "^0.36.5", "@tanstack/react-query": "^4.24.4", - "@thirdweb-dev/auth": "3.0.11", - "@thirdweb-dev/react": "3.9.0", - "@thirdweb-dev/sdk": "3.9.0", - "@thirdweb-dev/storage": "1.0.8", "@types/rc-slider": "^9.3.1", "@types/rc-tooltip": "^3.7.7", "@types/react-color": "^3.0.6", @@ -109,11 +103,6 @@ "@tailwindcss/forms": "0.5.3", "@tailwindcss/line-clamp": "0.4.2", "@tailwindcss/typography": "0.5.9", - "@thirdweb-dev/auth": "3.0.11", - "@thirdweb-dev/contracts": "3.3.0", - "@thirdweb-dev/react": "3.6.0", - "@thirdweb-dev/sdk": "3.10.7", - "@thirdweb-dev/storage": "1.0.8", "@typechain/ethers-v5": "10.2.0", "@typechain/hardhat": "6.1.5", "@types/chai": "4.3.4", diff --git a/pages/governance/Authenticate.tsx b/pages/governance/Authenticate.tsx deleted file mode 100644 index ba0adb32..00000000 --- a/pages/governance/Authenticate.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { useState, useEffect } from "react"; -import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; -import { ConnectWallet, useAddress } from "@thirdweb-dev/react"; -import { Database } from "../../utils/database.types"; - -type Profiles = Database['public']['Tables']['profiles']['Row']; - -export default function AuthenticateWalletToDb () { - const session = useSession(); - const supabase = useSupabaseClient(); - const address = useAddress(); - - const [loading, setLoading] = useState(false); - const [userAddress, setUserAddress] = useState(); - const [username, setUsername] = useState(''); - const [updated_at, setUpdate_at] = useState(); - - async function getProfile () { - try { - setLoading(true); - if (!session) throw new Error('No user authenticated'); - let { data, error, status } = await supabase - .from('profiles') - .select(`username, website, avatar_url, address`) - .eq('id', session?.user?.id) - .single() - - if (error && status !== 406) { - throw error; - } - - if (data) { - setUsername(data.username); - setUserAddress(data.address); - } - } catch (error) { - //alert('Error loading your user data'); - console.log(error); - } finally { - setLoading(false); - } - } - - useEffect(() => { - getProfile(); - }, [session]); - - async function updateProfile({ - userAddress, - } : { - userAddress: Profiles['address'] - }) { - try { - setLoading(true); - if (!session?.user) throw new Error('No user authenticated'); - const updates = { - id: session?.user?.id, - address2: address, - updated_at: new Date().toISOString(), - } - let { error } = await supabase.from('profiles').upsert(updates); - if (error) throw error; - alert('Off-chain PROFILE updated') - } catch (error) { - alert('Error updating your off-chain profile data'); - console.log(error); - } finally { - setLoading(false); - } - } - - if (loading) { - return ( - "Loading" - ); - } - - if (!userAddress) { - return ( - "Please authenticate via Metamask" - ) - } - - function updateProfileButton() { - updateProfile(userAddress); - } - - return ( -
- - {address} - -
- ) -} \ No newline at end of file diff --git a/pages/governance/[id].tsx b/pages/governance/[id].tsx deleted file mode 100644 index 36ad3610..00000000 --- a/pages/governance/[id].tsx +++ /dev/null @@ -1,5 +0,0 @@ -import React from "react"; - -export default function VotePageForId () { - -} \ No newline at end of file diff --git a/pages/governance/index.tsx b/pages/governance/index.tsx deleted file mode 100644 index 78eb07f2..00000000 --- a/pages/governance/index.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import React, { useEffect } from "react"; -//import { useMetamaskState } from "../../components/Governance/Connections/ConnectWallet"; -//import styles from '../../styles/governance/governance.module.css'; -import styles from '../../styles/Staking-P2E/planetInteraction.module.css'; -import { ConnectWallet, useAddress, useContract, useContractRead, Web3Button } from "@thirdweb-dev/react"; -import CoreLayout from "../../components/Core/Layout"; - -export default function GovernanceDAOIndex () { - //const { isConnected, account, signer, connectToMetamask } = useMetamaskState(); - const address = useAddress(); - const contractAddress = '0xd606dead5014AfCc5678EeF3EB1C7bEc64718b34'; - const { contract } = useContract("0xd606dead5014AfCc5678EeF3EB1C7bEc64718b34"); - const { data, isLoading } = useContractRead(contract, "proposals"); - const { data: proposal, isLoading: proposalLoading } = useContractRead(contract, 'proposals', 0); // Set the index to the specific planet id, map the planet id to the dao id - const { data: hasVoted, isLoading: hasVotedLoading } = useContractRead(contract, 'hasVoted', 0, address); - - return ( - <> -
-
-
- -

Proposal Voting

-
- {address ? ( -
- {proposalLoading ? ( -
-

{proposal/*[0]*/}

- {/* contract.call("vote", 0, true)} - >Yes*/} -
- {/* contract.call("vote", 0, false)} - >No*/} -
- ) : ( -

Loading

- )} -
- ) : ( -
-

Connect your wallet to get started

-
- )} -
-
-
-
- {/*
- -