diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 1b653dc..8b93b73 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -32,17 +32,17 @@ jobs: - name: Install dependencies run: yarn install --immutable - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 + # - name: Install Foundry + # uses: foundry-rs/foundry-toolchain@v1 - - name: Run foundry node, deploy contracts (& generate contracts typescript output) - env: - ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} - run: yarn chain & yarn deploy - id: build + # - name: Run foundry node, deploy contracts (& generate contracts typescript output) + # env: + # ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} + # run: yarn chain & yarn deploy + # id: build - - name: Run tests - run: yarn test -vvv + # - name: Run tests + # run: yarn test -vvv - name: Run nextjs lint diff --git a/packages/foundry/script/Deploy.s.sol b/packages/foundry/script/Deploy.s.sol index d7423f1..069c688 100644 --- a/packages/foundry/script/Deploy.s.sol +++ b/packages/foundry/script/Deploy.s.sol @@ -7,7 +7,8 @@ import {ScaffoldETHDeploy} from "./DeployHelpers.s.sol"; import {Hats} from "../contracts/Hats/Hats.sol"; import {DeployDemoScript} from "./DeployDemo.s.sol"; -import {DeployFactoryScript} from "./DeployFactory.s.sol"; + +// import {DeployFactoryScript} from "./DeployFactory.s.sol"; contract DeployScript is ScaffoldETHDeploy { error InvalidPrivateKey(string); @@ -16,9 +17,8 @@ contract DeployScript is ScaffoldETHDeploy { DeployDemoScript deployer = new DeployDemoScript(); deployer.run(); - DeployFactoryScript factoryDeployer = new DeployFactoryScript(); - - factoryDeployer.run(); + // DeployFactoryScript factoryDeployer = new DeployFactoryScript(); + // factoryDeployer.run(); exportDeployments(); } diff --git a/packages/foundry/script/DeployFactory.s.sol b/packages/foundry/script/DeployFactory.s.sol index 0fd69b5..c9ac608 100644 --- a/packages/foundry/script/DeployFactory.s.sol +++ b/packages/foundry/script/DeployFactory.s.sol @@ -1,47 +1,47 @@ -//SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -import {console} from "forge-std/console.sol"; - -import {ScaffoldETHDeploy} from "./DeployHelpers.s.sol"; -import {ReputationTokensFactory} from "@atxdao/contracts/reputation/ReputationTokensFactory.sol"; -import {ReputationTokensUpgradeable} from "@atxdao/contracts/reputation/ReputationTokensUpgradeable.sol"; - -contract DeployFactoryScript is ScaffoldETHDeploy { - error InvalidPrivateKey(string); - - address controller = 0x2F15D4A66D22ecC6967928b6A76Ab06897b05676; //replace with burner or other address from wallet! - - function run() external { - uint256 deployerPrivateKey = setupLocalhostEnv(); - if (deployerPrivateKey == 0) { - revert InvalidPrivateKey( - "You don't have a deployer account. Make sure you have set DEPLOYER_PRIVATE_KEY in .env or use `yarn generate` to generate a new random account" - ); - } - address deployerPubKey = vm.createWallet(deployerPrivateKey).addr; - - vm.startBroadcast(deployerPrivateKey); - address[] memory admins = new address[](2); - admins[0] = deployerPubKey; - admins[1] = controller; - - address tokensAddr = address(0); - - uint256 chainId; - assembly { - chainId := chainid() - } - - if (chainId == 10) { - tokensAddr = 0x4200000000000000000000000000000000000042; - } - - ReputationTokensUpgradeable implementation = new ReputationTokensUpgradeable(); - ReputationTokensFactory factory = new ReputationTokensFactory( - admins, - address(implementation), - address(0) - ); - } -} +// //SPDX-License-Identifier: MIT +// pragma solidity ^0.8.19; + +// import {console} from "forge-std/console.sol"; + +// import {ScaffoldETHDeploy} from "./DeployHelpers.s.sol"; +// import {ReputationTokensFactory} from "@atxdao/contracts/reputation/ReputationTokensFactory.sol"; +// import {ReputationTokensUpgradeable} from "@atxdao/contracts/reputation/ReputationTokensUpgradeable.sol"; + +// contract DeployFactoryScript is ScaffoldETHDeploy { +// error InvalidPrivateKey(string); + +// address controller = 0x2F15D4A66D22ecC6967928b6A76Ab06897b05676; //replace with burner or other address from wallet! + +// function run() external { +// uint256 deployerPrivateKey = setupLocalhostEnv(); +// if (deployerPrivateKey == 0) { +// revert InvalidPrivateKey( +// "You don't have a deployer account. Make sure you have set DEPLOYER_PRIVATE_KEY in .env or use `yarn generate` to generate a new random account" +// ); +// } +// address deployerPubKey = vm.createWallet(deployerPrivateKey).addr; + +// vm.startBroadcast(deployerPrivateKey); +// address[] memory admins = new address[](2); +// admins[0] = deployerPubKey; +// admins[1] = controller; + +// address tokensAddr = address(0); + +// uint256 chainId; +// assembly { +// chainId := chainid() +// } + +// if (chainId == 10) { +// tokensAddr = 0x4200000000000000000000000000000000000042; +// } + +// ReputationTokensUpgradeable implementation = new ReputationTokensUpgradeable(); +// ReputationTokensFactory factory = new ReputationTokensFactory( +// admins, +// address(implementation), +// address(0) +// ); +// } +// } diff --git a/packages/nextjs/app/collections/[network]/[address]/[tokenId]/page.tsx b/packages/nextjs/app/collections/[network]/[address]/[tokenId]/page.tsx deleted file mode 100644 index 76af4eb..0000000 --- a/packages/nextjs/app/collections/[network]/[address]/[tokenId]/page.tsx +++ /dev/null @@ -1,11 +0,0 @@ -"use client"; - -export default function Token({ params }: { params: { id: string } }) { - console.log(params); - - return ( -
-

Hello!

-
- ); -} diff --git a/packages/nextjs/app/collections/[network]/[address]/page.tsx b/packages/nextjs/app/collections/[network]/[address]/page.tsx deleted file mode 100644 index 619a51f..0000000 --- a/packages/nextjs/app/collections/[network]/[address]/page.tsx +++ /dev/null @@ -1,58 +0,0 @@ -"use client"; - -import React from "react"; -//, { useEffect } -import { useState } from "react"; -import { useAccount } from "wagmi"; -// import "react-dropdown/style.css"; -import { Collection } from "~~/components/scaffold-nft/collection/Collection"; -// import useAdvancedFiltering from "~~/hooks/scaffold-nft/useAdvancedFiltering"; -// import useCheckboxes from "~~/hooks/scaffold-nft/useCheckboxes"; -// import useTokenIds from "~~/hooks/scaffold-nft/useTokenIds"; -import { useTokens } from "~~/hooks/scaffold-nft/useTokens"; - -// import { renderInputOptions } from "~~/scaffold-nft-config"; - -export default function CollectionPage({ params }: { params: { network: string; address: string } }) { - // const { inputComponents, componentsToRender } = useCheckboxes(renderInputOptions); - - const userAccount = useAccount(); - - // const { tokenIds, setTokenIds } = useTokenIds(2); - // async function onSubmit(newIds: bigint[]) { - // setTokenIds([...newIds]); - // } - - // const tokenIds = [BigInt(0), BigInt(1)]; - - const [tokenIds] = useState([BigInt(0), BigInt(1)]); - - // const { - // chosenOption, - // // chosenOption2, - // output: advancedOutput, - // } = useAdvancedFiltering(inputComponents, onSubmit); - - const { collection, isLoading, isError } = useTokens( - params["network"], - params["address"], - userAccount.address, - tokenIds, - "nftstorage", - //chosenOption2, - ); - - console.log(collection); - - return ( -
- {/* {advancedOutput} */} - -
- ); -} diff --git a/packages/nextjs/app/factory/_components/Factory.tsx b/packages/nextjs/app/factory/_components/Factory.tsx deleted file mode 100644 index 29804c3..0000000 --- a/packages/nextjs/app/factory/_components/Factory.tsx +++ /dev/null @@ -1,217 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { abi as factoryAbi } from "../factoryAbi"; -import { abi as repAbi } from "../repAbi"; -import { UpdateTokenCard } from "./UpdateTokenCard"; -import { decodeEventLog } from "viem"; -import { useAccount, usePublicClient } from "wagmi"; -import { useWalletClient } from "wagmi"; -import { useScaffoldWriteContract } from "~~/hooks/scaffold-eth"; - -export function Factory() { - const account = useAccount(); - - // const { data: factoryContract } = useScaffoldContract({ contractName: "ReputationTokensFactory" }); - - const { writeContractAsync: writeFactoryAsync } = useScaffoldWriteContract("ReputationTokensFactory"); - - // const blockNum = useBlockNumber(); - // const initialBlock = useBlock(); - - const publicClient = usePublicClient(); - const { data: walletClient } = useWalletClient(); - - // const [block, setBlock] = useState(initialBlock); - - // useWatchContractEvent({ - // address: factoryContract?.address, - // abi: factoryContract?.abi, - // eventName: "CreatedNewInstance", - // onLogs: logs => { - // logs.map(log => { - // console.log("mapped"); - // console.log(log); - // // const { instance } = log.args; - // // console.log("📡 Factory create", instance); - // }); - // }, - // }); - - // const { - // data: events, - // isLoading: isLoadingEvents, - // error: errorReadingEvents, - // } = useScaffoldEventHistory({ - // contractName: "ReputationTokensFactory", - // eventName: "CreatedNewInstance", - // fromBlock: block?.number || BigInt(0), - // watch: true, - // blockData: true, - // transactionData: true, - // receiptData: true, - // }); - - // console.log(events); - - // const [deployedInstance, setDeployedInstance] = useState(); - - const [deployedInstance, setDeployedInstance] = useState(); - - // let deployedInstance; - // events?.map(event => { - // const { instance } = event.args; - // deployedInstance = instance; - // // setDeployedInstance(instance); - // }); - - // useScaffoldWatchContractEvent({ - // contractName: "ReputationTokensFactory", - // eventName: "CreatedNewInstance", - // watch: true, - // // The onLogs function is called whenever a GreetingChange event is emitted by the contract. - // // Parameters emitted by the event can be destructed using the below example - // // for this example: event GreetingChange(address greetingSetter, string newGreeting, bool premium, uint256 value); - // onLogs: logs => { - // logs.map(log => { - // const { instance } = log.args; - // console.log("📡 Factory create", instance); - // }); - // }, - // }); - - const [newTokens, setNewTokens] = useState([{ tokenType: 0, uri: "" }]); - - console.log(newTokens); - - async function onTypeChanged(index: number, res: any) { - const tokens = newTokens; - tokens[index].tokenType = res.value; - setNewTokens([...tokens]); - } - - async function onUriChanged(index: number, uri: any) { - const tokens = newTokens; - tokens[index].uri = uri.target.value; - setNewTokens([...tokens]); - } - - const updateCards = newTokens.map((token, index) => { - return ; - }); - - // console.log(tokens); - return ( - <> -
-
-
-
{updateCards}
- {/* */} - - - - -
-
- -

Reputation Tokens deployed at: {deployedInstance}

-
- - ); -} diff --git a/packages/nextjs/app/factory/_components/UpdateTokenCard.tsx b/packages/nextjs/app/factory/_components/UpdateTokenCard.tsx deleted file mode 100644 index 407698e..0000000 --- a/packages/nextjs/app/factory/_components/UpdateTokenCard.tsx +++ /dev/null @@ -1,61 +0,0 @@ -"use client"; - -import Select from "react-select"; - -type Props = { - index: number; - onTypeChanged: any; - onUriChanged: any; -}; - -const options = [ - { value: 0, label: "Transferable" }, - { value: 1, label: "Lifetime" }, - { value: 2, label: "Redeemable" }, -]; -export function UpdateTokenCard({ index, onTypeChanged, onUriChanged }: Props) { - const defaultOption = options[0]; - - // const [selectedDropdownOption, setSelectedDropdownOption] = useState(defaultOption); - - return ( -
-

Token {index}

-

Type

- { - onUriChanged(index, val); - }} - className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" - placeholder="John" - required - /> -
- ); -} diff --git a/packages/nextjs/app/factory/page.tsx b/packages/nextjs/app/factory/page.tsx deleted file mode 100644 index cd69165..0000000 --- a/packages/nextjs/app/factory/page.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { Factory } from "./_components/Factory"; -import type { NextPage } from "next"; -import { getMetadata } from "~~/utils/scaffold-eth/getMetadata"; - -export const metadata = getMetadata({ - title: "Factory", - description: "Factory", -}); - -const FactoryPage: NextPage = () => { - return ( - <> - - - ); -}; - -export default FactoryPage; diff --git a/packages/nextjs/components/Header.tsx b/packages/nextjs/components/Header.tsx index 1c96989..727e76c 100644 --- a/packages/nextjs/components/Header.tsx +++ b/packages/nextjs/components/Header.tsx @@ -77,14 +77,14 @@ export const Header = () => { args: [address, BigInt(claimableHatId2)], }); - useEffect(() => { - if (location?.hostname === "localhost" || location?.hostname === "127.0.0.1") { - setOutput( - , - ); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [tokens.length]); + // useEffect(() => { + // if (location?.hostname === "localhost" || location?.hostname === "127.0.0.1") { + // setOutput( + // , + // ); + // } + // // eslint-disable-next-line react-hooks/exhaustive-deps + // }, [tokens.length]); useEffect(() => { const linksToAdd: any = []; @@ -100,10 +100,10 @@ export const Header = () => { href: "/hats", }); - linksToAdd.push({ - label: "Factory", - href: "/factory", - }); + // linksToAdd.push({ + // label: "Factory", + // href: "/factory", + // }); linksToAdd.push({ label: "Debug Contracts", @@ -147,7 +147,7 @@ export const Header = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const [output, setOutput] = useState(); + // const [output, setOutput] = useState(); return (
@@ -188,8 +188,8 @@ export const Header = () => {
- {output} - {/* */} + {/* {output} */} + diff --git a/packages/nextjs/hooks/scaffold-nft/useTokens.ts b/packages/nextjs/hooks/scaffold-nft/useTokens.ts index 64ef721..8ad267e 100644 --- a/packages/nextjs/hooks/scaffold-nft/useTokens.ts +++ b/packages/nextjs/hooks/scaffold-nft/useTokens.ts @@ -1,7 +1,7 @@ import { useEffect } from "react"; import { useState } from "react"; // import erc1155Abi from "./erc1155Abi.json"; -import { abi as repAbi } from "../../app/factory/repAbi"; +import { abi as repAbi } from "../../z_app/factory/repAbi"; // import { erc721Abi } from "viem"; import * as allChains from "viem/chains"; import { usePublicClient } from "wagmi"; diff --git a/packages/nextjs/z_app/collections/[network]/[address]/[tokenId]/page.tsx b/packages/nextjs/z_app/collections/[network]/[address]/[tokenId]/page.tsx new file mode 100644 index 0000000..ce12c1e --- /dev/null +++ b/packages/nextjs/z_app/collections/[network]/[address]/[tokenId]/page.tsx @@ -0,0 +1,11 @@ +// "use client"; + +// export default function Token({ params }: { params: { id: string } }) { +// console.log(params); + +// return ( +//
+//

Hello!

+//
+// ); +// } diff --git a/packages/nextjs/z_app/collections/[network]/[address]/page.tsx b/packages/nextjs/z_app/collections/[network]/[address]/page.tsx new file mode 100644 index 0000000..71b5489 --- /dev/null +++ b/packages/nextjs/z_app/collections/[network]/[address]/page.tsx @@ -0,0 +1,58 @@ +// "use client"; + +// import React from "react"; +// //, { useEffect } +// import { useState } from "react"; +// import { useAccount } from "wagmi"; +// // import "react-dropdown/style.css"; +// import { Collection } from "~~/components/scaffold-nft/collection/Collection"; +// // import useAdvancedFiltering from "~~/hooks/scaffold-nft/useAdvancedFiltering"; +// // import useCheckboxes from "~~/hooks/scaffold-nft/useCheckboxes"; +// // import useTokenIds from "~~/hooks/scaffold-nft/useTokenIds"; +// import { useTokens } from "~~/hooks/scaffold-nft/useTokens"; + +// // import { renderInputOptions } from "~~/scaffold-nft-config"; + +// export default function CollectionPage({ params }: { params: { network: string; address: string } }) { +// // const { inputComponents, componentsToRender } = useCheckboxes(renderInputOptions); + +// const userAccount = useAccount(); + +// // const { tokenIds, setTokenIds } = useTokenIds(2); +// // async function onSubmit(newIds: bigint[]) { +// // setTokenIds([...newIds]); +// // } + +// // const tokenIds = [BigInt(0), BigInt(1)]; + +// const [tokenIds] = useState([BigInt(0), BigInt(1)]); + +// // const { +// // chosenOption, +// // // chosenOption2, +// // output: advancedOutput, +// // } = useAdvancedFiltering(inputComponents, onSubmit); + +// const { collection, isLoading, isError } = useTokens( +// params["network"], +// params["address"], +// userAccount.address, +// tokenIds, +// "nftstorage", +// //chosenOption2, +// ); + +// console.log(collection); + +// return ( +//
+// {/* {advancedOutput} */} +// +//
+// ); +// } diff --git a/packages/nextjs/z_app/factory/_components/Factory.tsx b/packages/nextjs/z_app/factory/_components/Factory.tsx new file mode 100644 index 0000000..0d419ed --- /dev/null +++ b/packages/nextjs/z_app/factory/_components/Factory.tsx @@ -0,0 +1,217 @@ +// "use client"; + +// import { useState } from "react"; +// import { abi as factoryAbi } from "../factoryAbi"; +// import { abi as repAbi } from "../repAbi"; +// import { UpdateTokenCard } from "./UpdateTokenCard"; +// import { decodeEventLog } from "viem"; +// import { useAccount, usePublicClient } from "wagmi"; +// import { useWalletClient } from "wagmi"; +// import { useScaffoldWriteContract } from "~~/hooks/scaffold-eth"; + +// export function Factory() { +// const account = useAccount(); + +// // const { data: factoryContract } = useScaffoldContract({ contractName: "ReputationTokensFactory" }); + +// const { writeContractAsync: writeFactoryAsync } = useScaffoldWriteContract("ReputationTokensFactory"); + +// // const blockNum = useBlockNumber(); +// // const initialBlock = useBlock(); + +// const publicClient = usePublicClient(); +// const { data: walletClient } = useWalletClient(); + +// // const [block, setBlock] = useState(initialBlock); + +// // useWatchContractEvent({ +// // address: factoryContract?.address, +// // abi: factoryContract?.abi, +// // eventName: "CreatedNewInstance", +// // onLogs: logs => { +// // logs.map(log => { +// // console.log("mapped"); +// // console.log(log); +// // // const { instance } = log.args; +// // // console.log("📡 Factory create", instance); +// // }); +// // }, +// // }); + +// // const { +// // data: events, +// // isLoading: isLoadingEvents, +// // error: errorReadingEvents, +// // } = useScaffoldEventHistory({ +// // contractName: "ReputationTokensFactory", +// // eventName: "CreatedNewInstance", +// // fromBlock: block?.number || BigInt(0), +// // watch: true, +// // blockData: true, +// // transactionData: true, +// // receiptData: true, +// // }); + +// // console.log(events); + +// // const [deployedInstance, setDeployedInstance] = useState(); + +// const [deployedInstance, setDeployedInstance] = useState(); + +// // let deployedInstance; +// // events?.map(event => { +// // const { instance } = event.args; +// // deployedInstance = instance; +// // // setDeployedInstance(instance); +// // }); + +// // useScaffoldWatchContractEvent({ +// // contractName: "ReputationTokensFactory", +// // eventName: "CreatedNewInstance", +// // watch: true, +// // // The onLogs function is called whenever a GreetingChange event is emitted by the contract. +// // // Parameters emitted by the event can be destructed using the below example +// // // for this example: event GreetingChange(address greetingSetter, string newGreeting, bool premium, uint256 value); +// // onLogs: logs => { +// // logs.map(log => { +// // const { instance } = log.args; +// // console.log("📡 Factory create", instance); +// // }); +// // }, +// // }); + +// const [newTokens, setNewTokens] = useState([{ tokenType: 0, uri: "" }]); + +// console.log(newTokens); + +// async function onTypeChanged(index: number, res: any) { +// const tokens = newTokens; +// tokens[index].tokenType = res.value; +// setNewTokens([...tokens]); +// } + +// async function onUriChanged(index: number, uri: any) { +// const tokens = newTokens; +// tokens[index].uri = uri.target.value; +// setNewTokens([...tokens]); +// } + +// const updateCards = newTokens.map((token, index) => { +// return ; +// }); + +// // console.log(tokens); +// return ( +// <> +//
+//
+//
+//
{updateCards}
+// {/* */} + +// + +// +//
+//
+ +//

Reputation Tokens deployed at: {deployedInstance}

+//
+// +// ); +// } diff --git a/packages/nextjs/z_app/factory/_components/UpdateTokenCard.tsx b/packages/nextjs/z_app/factory/_components/UpdateTokenCard.tsx new file mode 100644 index 0000000..da50cce --- /dev/null +++ b/packages/nextjs/z_app/factory/_components/UpdateTokenCard.tsx @@ -0,0 +1,61 @@ +// "use client"; + +// import Select from "react-select"; + +// type Props = { +// index: number; +// onTypeChanged: any; +// onUriChanged: any; +// }; + +// const options = [ +// { value: 0, label: "Transferable" }, +// { value: 1, label: "Lifetime" }, +// { value: 2, label: "Redeemable" }, +// ]; +// export function UpdateTokenCard({ index, onTypeChanged, onUriChanged }: Props) { +// const defaultOption = options[0]; + +// // const [selectedDropdownOption, setSelectedDropdownOption] = useState(defaultOption); + +// return ( +//
+//

Token {index}

+//

Type

+// { +// onUriChanged(index, val); +// }} +// className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" +// placeholder="John" +// required +// /> +//
+// ); +// } diff --git a/packages/nextjs/app/factory/factoryAbi.ts b/packages/nextjs/z_app/factory/factoryAbi.ts similarity index 100% rename from packages/nextjs/app/factory/factoryAbi.ts rename to packages/nextjs/z_app/factory/factoryAbi.ts diff --git a/packages/nextjs/z_app/factory/page.tsx b/packages/nextjs/z_app/factory/page.tsx new file mode 100644 index 0000000..ab747a4 --- /dev/null +++ b/packages/nextjs/z_app/factory/page.tsx @@ -0,0 +1,18 @@ +// import { Factory } from "./_components/Factory"; +// import type { NextPage } from "next"; +// import { getMetadata } from "~~/utils/scaffold-eth/getMetadata"; + +// export const metadata = getMetadata({ +// title: "Factory", +// description: "Factory", +// }); + +// const FactoryPage: NextPage = () => { +// return ( +// <> +// +// +// ); +// }; + +// export default FactoryPage; diff --git a/packages/nextjs/app/factory/repAbi.ts b/packages/nextjs/z_app/factory/repAbi.ts similarity index 100% rename from packages/nextjs/app/factory/repAbi.ts rename to packages/nextjs/z_app/factory/repAbi.ts