diff --git a/.gitpod.yml b/.gitpod.yml index 7738b6f..cf44b83 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -57,6 +57,7 @@ vscode: - naumovs.color-highlight - ngryman.codesandbox-theme - njzy.stats-bar + - oderwat.indent-rainbow - pflannery.vscode-versionlens - PKief.material-icon-theme - Prisma.prisma-insider diff --git a/advanced-redux/.env b/advanced-redux/.env new file mode 100755 index 0000000..04db6c2 --- /dev/null +++ b/advanced-redux/.env @@ -0,0 +1,3 @@ +PORT = 1035 +BROWSER = none +REACT_APP_API_ENDPOINT = https://reduxcart-e24dc-default-rtdb.firebaseio.com \ No newline at end of file diff --git a/blockchain-nft-app/content/fetcherTotalSales.js b/airbnb-clone-2/.env similarity index 100% rename from blockchain-nft-app/content/fetcherTotalSales.js rename to airbnb-clone-2/.env diff --git a/airbnb-clone/.env b/airbnb-clone/.env new file mode 100644 index 0000000..b99908d --- /dev/null +++ b/airbnb-clone/.env @@ -0,0 +1,3 @@ +PORT = 3000 +HOST = 0.0.0.0 +BROWSER = none \ No newline at end of file diff --git a/amazon-clone/.env b/amazon-clone/.env new file mode 100755 index 0000000..0c593d7 --- /dev/null +++ b/amazon-clone/.env @@ -0,0 +1,3 @@ +PORT = 3000 +HOST = 0.0.0.0 +BROWSER = none diff --git a/blockchain-nft-app/.env.development b/blockchain-nft-app/.env.development deleted file mode 100644 index 77f86af..0000000 --- a/blockchain-nft-app/.env.development +++ /dev/null @@ -1,7 +0,0 @@ -// NEXT_PUBLIC_TARGET_CHAIN_ID=1337 -// NEXT_PUBLIC_NETWORK_ID=5777 -// NEXT_PUBLIC_TARGET_CHAIN_ID=80001 -// NEXT_PUBLIC_NETWORK_ID=80001 -NEXT_PUBLIC_TARGET_CHAIN_ID=5 -NEXT_PUBLIC_NETWORK_ID=5 -// polygon 137 \ No newline at end of file diff --git a/blockchain-nft-app/.env.production b/blockchain-nft-app/.env.production deleted file mode 100644 index 6e02ff8..0000000 --- a/blockchain-nft-app/.env.production +++ /dev/null @@ -1,3 +0,0 @@ -NEXT_PUBLIC_TARGET_CHAIN_ID=5 -NEXT_PUBLIC_NETWORK_ID=5 -// polygon 137 \ No newline at end of file diff --git a/blockchain-nft-app/.eslintrc.json b/blockchain-nft-app/.eslintrc.json deleted file mode 100644 index bffb357..0000000 --- a/blockchain-nft-app/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "next/core-web-vitals" -} diff --git a/blockchain-nft-app/.gitignore b/blockchain-nft-app/.gitignore deleted file mode 100644 index 55175ef..0000000 --- a/blockchain-nft-app/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# local env files -.env*.local - -# vercel -.vercel diff --git a/blockchain-nft-app/README.md b/blockchain-nft-app/README.md deleted file mode 100644 index 5a82cb7..0000000 --- a/blockchain-nft-app/README.md +++ /dev/null @@ -1,90 +0,0 @@ - -# ![favicon-32x32](https://user-images.githubusercontent.com/19762585/174510071-6758e22d-76c8-493e-a5fe-7f9aa8ae0648.png) This is a **8Chiq**, a 9gag clone using blockchain & NFT as a backend - - -## LIVE DEMO - -![Library _ Loom - 10 July 2022](https://user-images.githubusercontent.com/19762585/178131746-db744feb-5bcf-4636-a27e-b7ed94a71534.gif) - - - - -## Getting Started - -First, configure the network, in _truffle-config.js_ : - -```bash - # if you are using local Ganache, adjust port accordingly - networks: { - development: { - host: "127.0.0.1", // Localhost (default: none) - port: 7545, // Standard Ethereum port (default: none) - network_id: "*", // Any network (default: none) - } - } -``` - -if you are using test network, for example, you can adjust to the right setting, in this case Goerli Test Network is used. define _infuraProjectId_ and _mnemonic_ in _.env_ : - -```bash - //Goerli - goerli_infura_testnet: { - provider: () => new HDWalletProvider({ - mnemonic: { - phrase: mnemonic - }, - providerOrUrl: - "wss://goerli.infura.io/ws/v3/" + infuraProjectId - }), - network_id: 5, - confirmations: 2, - timeoutBlocks: 800, - skipDryRun: true, - chainId: 5, - gasPrice: 30000000000 - }, -``` - -then, migrate the contract using truffle: - -```bash -truffle migrate -# or do this if previously alredy run and do some modification to contract, just in case -truffle migrate --reset -#or migrate with spesific network configuration -truffle migrate --network= --reset -``` - -Install all dependencies: - -```bash -npm install -``` - -then, run the development server: - -```bash -npm run dev -# or -yarn dev -``` - -## Details Features - -| Features | Status | -| --- | :---: | -| Minting Meme NFT | DONE | -| Sell the Meme on the Marketplace | DONE | -| Buy the Meme on the Marketplace | DONE | -| Cancel listing on the Marketplace | DONE | -| Activate likes and dislikes button function | DONE | -| Activate comment function | DONE | -| Contract use Testnet | DONE | - -## Tools - -- Truffle -- Ganache -- Next JS -- Tailwind - diff --git a/blockchain-nft-app/components/hooks/useEthPrice.js b/blockchain-nft-app/components/hooks/useEthPrice.js deleted file mode 100644 index b030758..0000000 --- a/blockchain-nft-app/components/hooks/useEthPrice.js +++ /dev/null @@ -1,22 +0,0 @@ -import useSWR from "swr" - -const URL = "https://api.coingecko.com/api/v3/coins/ethereum?localization=false&tickers=false&community_data=false&developer_data=false&sparkline=false" -export const MEME_PRICE = 15 - - -const fetcher = async url => { - const res = await fetch(url) - const json = await res.json() - return json.market_data.current_price.usd ?? null -} - -export const useEthPrice = () => { - const {data, ...swrRes} = useSWR( - URL, - fetcher, - { refreshInterval: 10000 } - ) - const pricePerItem = (data && (MEME_PRICE / Number(data)).toFixed(5)) ?? null - - return { eth: {data, pricePerItem, ...swrRes}} -} \ No newline at end of file diff --git a/blockchain-nft-app/components/hooks/web3/index.js b/blockchain-nft-app/components/hooks/web3/index.js deleted file mode 100644 index da17b8c..0000000 --- a/blockchain-nft-app/components/hooks/web3/index.js +++ /dev/null @@ -1,34 +0,0 @@ -import { useHooks } from "@components/provider/web3" - -const enhanceHook = swrResponse => { - return { - ...swrResponse, - hasInitialResponse: swrResponse.data || swrResponse.error - } -} - - -export const useAccount = () => { - const swrRes = enhanceHook(useHooks(hooks => hooks.useAccount)()) - return { - account: swrRes - } -} - -export const useNetwork = () => { - const swrRes = enhanceHook(useHooks(hooks => hooks.useNetwork)()) - return { - network: swrRes - } -} - -export const useWalletInfo = () => { - const { account } = useAccount() - const { network } = useNetwork() - - return { - account, - network, - canPurchaseMeme: !!(account.data && network.isSupported) - } -} \ No newline at end of file diff --git a/blockchain-nft-app/components/provider/index.js b/blockchain-nft-app/components/provider/index.js deleted file mode 100644 index d648eed..0000000 --- a/blockchain-nft-app/components/provider/index.js +++ /dev/null @@ -1,4 +0,0 @@ - - -export {default as Web3Provider} from "./web3"; -export { useWeb3 } from "./web3"; \ No newline at end of file diff --git a/blockchain-nft-app/components/provider/web3/hooks/setupHooks.js b/blockchain-nft-app/components/provider/web3/hooks/setupHooks.js deleted file mode 100644 index 90310c9..0000000 --- a/blockchain-nft-app/components/provider/web3/hooks/setupHooks.js +++ /dev/null @@ -1,13 +0,0 @@ - -import { handler as createAcountHook } from "./useAccounts"; -import { handler as createNetworkHook } from "./useNetwork"; - - - -export const setupHooks = (web3, provider) => { - - return { - useAccount: createAcountHook(web3, provider), - useNetwork: createNetworkHook(web3, provider) - } -} \ No newline at end of file diff --git a/blockchain-nft-app/components/provider/web3/hooks/useAccounts.js b/blockchain-nft-app/components/provider/web3/hooks/useAccounts.js deleted file mode 100644 index d4cbd29..0000000 --- a/blockchain-nft-app/components/provider/web3/hooks/useAccounts.js +++ /dev/null @@ -1,30 +0,0 @@ -import { useState, useEffect } from "react" -import useSWR from "swr" - -export const handler = (web3, provider) => () => { - - const adminAddresses = { - "0xfa97c10735eeedd598dc2a7643f0dba24f4a1c02155120685d29832a1e84f1d6" : true - } - - const {data, mutate, ...rest} = useSWR(() => - web3 ? "web3/accounts" : null, - async () => { - const accounts = await web3.eth.getAccounts() - return accounts[0] - }) - - useEffect(() => { - provider && - provider.on("accountsChanged", - accounts => mutate(accounts[0] ?? null) - ) - }, [provider]) - - return { - data, - isAdmin: (data && adminAddresses[web3.utils.keccak256(data)]) ?? false, - mutate, - ...rest - } -} \ No newline at end of file diff --git a/blockchain-nft-app/components/provider/web3/hooks/useNetwork.js b/blockchain-nft-app/components/provider/web3/hooks/useNetwork.js deleted file mode 100644 index 2c77c29..0000000 --- a/blockchain-nft-app/components/provider/web3/hooks/useNetwork.js +++ /dev/null @@ -1,40 +0,0 @@ -import { useEffect } from "react" -import useSWR from "swr" - -const NETWORKS = { - 1: "Ethereum Network", - 2: "Ropsten Test Network", - 4: "Rinkeby Test Network", - 5: "Goerli Test Network", - 80001: "Polygon Mumbai Test Network", - 137: "Polygon Network", - 56: "Binance Smart Network", - 1337: "Ganache" -} - -const targetNetwork = NETWORKS[process.env.NEXT_PUBLIC_TARGET_CHAIN_ID] - - -export const handler = (web3, provider) => () => { - - const {data, error, mutate, ...swrResponse} = useSWR(() => - web3 ? "web3/network" : null, - async () => { - const chainId = await web3.eth.getChainId() - return NETWORKS[chainId] - } - ) - - useEffect(()=> { - provider && - provider.on("chainChanged", chainId => mutate(NETWORKS[parseInt(chainId, 16)])) - }, [web3]) - - return { - data, - mutate, - target: targetNetwork, - isSupported: data === targetNetwork, - ...swrResponse - } -} \ No newline at end of file diff --git a/blockchain-nft-app/components/provider/web3/index.js b/blockchain-nft-app/components/provider/web3/index.js deleted file mode 100644 index 8b5f356..0000000 --- a/blockchain-nft-app/components/provider/web3/index.js +++ /dev/null @@ -1,82 +0,0 @@ -const { createContext, useContext } = require("react"); -import detectEthereumProvider from "@metamask/detect-provider"; -import { useEffect, useState, useMemo } from "react"; -import { loadContract } from "@utils/loadContract"; -import Web3 from "web3"; -import { setupHooks } from "./hooks/setupHooks"; - -const Web3Context = createContext(null); - -export default function Web3Provider({children}) { - - const [web3Api, setWeb3Api] = useState({ - provider: null, - web3: null, - marketContract: null, - // nftContract: null, - isLoading: true, - hooks: setupHooks(), - }) - - useEffect(() => { - const loadProvider = async () => { - - const provider = await detectEthereumProvider() - if (provider) { - const web3 = new Web3(provider) - // const marketContract = await loadContract("MemeMarketplace", web3) - // const nftContract = await loadContract("NFT", web3) - const marketContract = await loadContract("MemeMarketplaceV2", web3) - // console.log(nftContract) - setWeb3Api({ - provider, - web3, - marketContract, - // nftContract, - isLoading: false, - hooks: setupHooks(web3, provider) - }) - } else { - setWeb3Api( api => ({...api, isLoading: false})) - console.error("Please, install Metamask.") - } - } - - loadProvider() - }, []) - - const _web3Api = useMemo(() => { - const { web3, provider, isLoading } = web3Api - return { - ...web3Api, - // isWeb3Loaded: web3 != null, - requireInstall: !isLoading && !web3, - connect: provider ? - async () => { - console.log("come here") - try { - await provider.request({method: "eth_requestAccounts"}) - } catch { - console.error("cannot retreive account!") - location.reload() - } - } : - () => console.error("Cannot connect to Metamask, try to reload your browser please"), - } - }, [web3Api]) - - return ( - - {children} - - ) -} - -export function useWeb3() { - return useContext(Web3Context) -} - -export function useHooks(cb) { - const { hooks } = useWeb3() - return cb(hooks) -} \ No newline at end of file diff --git a/blockchain-nft-app/components/searchbox.js b/blockchain-nft-app/components/searchbox.js deleted file mode 100644 index e50c21b..0000000 --- a/blockchain-nft-app/components/searchbox.js +++ /dev/null @@ -1,24 +0,0 @@ -import Image from "next/image"; - - -const SearchBox = (props) => { - return ( -
- - -
- - ) -} - -export default SearchBox; \ No newline at end of file diff --git a/blockchain-nft-app/components/ui/cards/index.js b/blockchain-nft-app/components/ui/cards/index.js deleted file mode 100644 index 9ab2224..0000000 --- a/blockchain-nft-app/components/ui/cards/index.js +++ /dev/null @@ -1,126 +0,0 @@ -import Image from "next/image" -import Link from "next/link" -import { useWeb3 } from '@components/provider' -import { useWalletInfo } from '@components/hooks/web3' -import {useEffect, useState} from 'react' -import { Loader } from "@components/ui/common" -import { - FacebookShareButton, - FacebookIcon, - TwitterShareButton, - TwitterIcon, -} from 'next-share' - - -const logoMap = { - "Funny" : "/static/images/icons8-crazy-96.png", - "Anime" : "/static/images/icons8-naruto-96.png", - "Blockchain" : "/static/images/icons8-blockchain-digital-64.png", - "Cat" : "/static/images/icons8-cat-64.png", - "Chiq" : "/static/images/android-chrome-192x192.png" -} - -export default function Card({meme, disabledButton, onClickButton, onClickDislikeButton, loadingStateButton}) { - - const { isLoading, marketContract } = useWeb3() - const { account, network, canPurchaseMeme } = useWalletInfo() - - - const [likeStatus, setLikeStatus] = useState(2) - - useEffect(()=> { - if (!isLoading) { - getLikeStatus(meme.id) - } - }, [isLoading, loadingStateButton]) - - async function getLikeStatus(tokenId) { - const status = await marketContract.methods.getLikeStatus(tokenId).call({from: account.data}) - setLikeStatus(status) - console.log("like status :") - console.log(status) - } - - - return ( -
-
- - -

{meme.category}

-
-

{meme.age}

-
-
-
{meme.title}
-
-
- - - - - -
-
-
- - - -
- -
-
- - - -
- -
- - - -
-
- -
- {/*
- { - meme.tags.map((tag, i) => {tag}) - } -
*/} - {/*
- -
*/} -
- ) - } \ No newline at end of file diff --git a/blockchain-nft-app/components/ui/common/breadcrumbs/index.js b/blockchain-nft-app/components/ui/common/breadcrumbs/index.js deleted file mode 100644 index 1f575c1..0000000 --- a/blockchain-nft-app/components/ui/common/breadcrumbs/index.js +++ /dev/null @@ -1,32 +0,0 @@ -import ActiveLink from "../link" - -export default function Breadcrumbs({items}) { - - return ( - - ) - } \ No newline at end of file diff --git a/blockchain-nft-app/components/ui/common/button/index.js b/blockchain-nft-app/components/ui/common/button/index.js deleted file mode 100644 index 3a79cbb..0000000 --- a/blockchain-nft-app/components/ui/common/button/index.js +++ /dev/null @@ -1,26 +0,0 @@ - - -export default function CustomeButton({ - onClick, - children, - disabled = false, - hoverable = true, - className, - variant = "purple" - }) { - - const variants = { - purple: `dark:bg-purple-600 ${hoverable && "dark:hover:bg-purple-700 hover:bg-purple-800"} dark:focus:ring-purple-800 focus:ring-purple-300 text-white bg-purple-700`, - blue: `dark:bg-blue-600 ${hoverable && "dark:hover:bg-blue-700 hover:bg-blue-800"} dark:focus:ring-blue-800 focus:ring-blue-300 text-white bg-blue-700`, - red: `dark:bg-red-600 ${hoverable && "dark:hover:bg-red-700 hover:bg-red-800"} dark:focus:ring-red-800 focus:ring-red-300 text-white bg-red-700`, - } - - return ( - - ) -} \ No newline at end of file diff --git a/blockchain-nft-app/components/ui/common/commenInput/index.js b/blockchain-nft-app/components/ui/common/commenInput/index.js deleted file mode 100644 index dda0b86..0000000 --- a/blockchain-nft-app/components/ui/common/commenInput/index.js +++ /dev/null @@ -1,93 +0,0 @@ -import Head from 'next/head' -import { getAllMemes } from "@content/fetcher" -import { BaseLayout } from '@components/ui/layout' -import { useWalletInfo } from '@components/hooks/web3' -import { MarketHeader} from '@components/ui/store' -import { useState } from 'react' -import { useEthPrice } from '@components/hooks/useEthPrice' -import {create as ipfsHttpClient} from 'ipfs-http-client' -import { useRouter } from 'next/router' -import { useWeb3 } from '@components/provider' -import { Loader } from "@components/ui/common" -import axios from 'axios' - -const client = ipfsHttpClient('https://ipfs.infura.io:5001/api/v0') - -export default function CommmentInput({tokenId, onFinish}) { - - const [isCommenting, setIsCommenting] = useState(false) - const [onSale, setOnSale] = useState(false) - const { account, network, canPurchaseMeme } = useWalletInfo() - const { web3, isLoading, nftContract, marketContract } = useWeb3() - console.log(marketContract) - console.log(nftContract) - - // file to upload - const [fileUrl, setFileUrl] = useState(null) - const [formInput, updateFormInput] = useState({address: account.data, - comment:'', - - }) - const router = useRouter() - - - async function createComment() { - const {address, comment } = formInput - - console.log("comment 1") - - if(!comment) return - - console.log(comment) - setIsCommenting(true) - console.log("masuk ke comment") - - // we want to create a comment - try { - const result = await marketContract.methods.commentMeme(tokenId, formInput.comment).send({from: account.data}) - } catch { - console.error("Purchase course: Operation has failed.") - } - - setIsCommenting(false) - updateFormInput({...formInput, comment:""}) - onFinish() - - - } - - - - return ( -
-
-
-
-