generated from sweetmantech/DACIRKUS_PERFORMERS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from SweetmanTech/test
Test
- Loading branch information
Showing
23 changed files
with
2,176 additions
and
8,158 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { toast } from "react-toastify" | ||
import { Address } from "viem" | ||
import useCollectDrop from "@/hooks/useCollectDrop" | ||
|
||
const CollectDropButton = ({ | ||
className = "", | ||
address, | ||
tokenId, | ||
chainId, | ||
}: { | ||
className?: string | ||
address: Address | ||
tokenId: number | ||
chainId: number | ||
}) => { | ||
const { collect, loading } = useCollectDrop() | ||
|
||
const handleClick = async () => { | ||
const response = await collect(address, tokenId, chainId) | ||
if (!response) return | ||
toast.success("Collected!") | ||
} | ||
|
||
return ( | ||
<button | ||
type="button" | ||
onTouchStart={handleClick} | ||
onClick={handleClick} | ||
className={`${className} bg-darkgray py-[3px] w-full`} | ||
disabled={loading} | ||
> | ||
{loading ? `Collecting...` : "Collect"} | ||
</button> | ||
) | ||
} | ||
|
||
export default CollectDropButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import CollectDropButton from "./CollectDropButton" | ||
|
||
export default CollectDropButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const DropCollect = ({ isPopup, children, title, artist, animationUrl }) => ( | ||
<div className="w-full flex flex-col gap-1.5"> | ||
<video | ||
src={animationUrl} | ||
preload="auto" | ||
controls | ||
playsInline | ||
webkit-playsinline | ||
x5-playsinline | ||
muted | ||
className={`${isPopup ? "h-[200px]" : "h-[300px]"}`} | ||
/> | ||
{children} | ||
<span className={`uppercase text-[12px] ${isPopup ? "md:text-[14px]" : "md:text-[16px]"}`}> | ||
{title} By {artist} | ||
</span> | ||
</div> | ||
) | ||
|
||
export default DropCollect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import getIpfsLink from "@/lib/getIpfsLink" | ||
import { BONSAI } from "@/lib/consts" | ||
import RecBar from "../../RecBar" | ||
import useIsMobile from "../../../hooks/useIsMobile" | ||
|
||
const BonsaiContent = () => { | ||
const isMobile = useIsMobile() | ||
|
||
return ( | ||
<div className="p-[5px] md:p-[10px] border-[2px] border-gray_1 h-full"> | ||
<div | ||
className="border-[1px] border-darkgray text-gray_1 font-dresden | ||
py-[25px] text-center | ||
flex items-center justify-center text-[16px] relative h-full | ||
text-[12px] md:text-[16px] relative" | ||
> | ||
<div | ||
className="h-fit max-h-full overflow-y-auto text-[12px] md:text-[16px] | ||
px-[15px] md:px-[20px] flex flex-col gap-y-[5px] md:gap-y-[20px]" | ||
> | ||
{/* eslint-disable-next-line jsx-a11y/media-has-caption */} | ||
<video | ||
src={getIpfsLink(BONSAI)} | ||
width={isMobile ? 180 : 200} | ||
height={isMobile ? 125 : 230} | ||
controls | ||
autoPlay | ||
/> | ||
</div> | ||
<RecBar /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default BonsaiContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import BonsaiContent from "./BonsaiContent" | ||
|
||
export default BonsaiContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import CollectDropButton from "@/components/CollectDropButton" | ||
import DropCollect from "@/components/DropCollect" | ||
import { BONSAI_DROP_ADDRESS, IS_TESTNET } from "@/lib/consts" | ||
import data from "@/lib/zora-drops" | ||
import { Address } from "viem" | ||
import { base, baseSepolia } from "viem/chains" | ||
|
||
const BonsaiSection = ({ isPopup }) => ( | ||
<DropCollect | ||
title={data[12].title} | ||
artist={data[12].artist} | ||
isPopup={isPopup} | ||
animationUrl={data[12].ipfs} | ||
> | ||
<CollectDropButton | ||
chainId={IS_TESTNET ? baseSepolia.id : base.id} | ||
tokenId={3} | ||
address={BONSAI_DROP_ADDRESS as Address} | ||
/> | ||
</DropCollect> | ||
) | ||
|
||
export default BonsaiSection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import handleTxError from "@/lib/handleTxError" | ||
import { useState } from "react" | ||
import { Address } from "viem" | ||
import getCollectorClient from "@/lib/zora/getCollectorClient" | ||
import getToken from "@/lib/zora/getToken" | ||
import usePrivySendTransaction from "./usePrivySendTransaction" | ||
import useConnectedWallet from "./useConnectedWallet" | ||
import usePreparePrivyWallet from "./usePreparePrivyWallet" | ||
|
||
const useCollectDrop = () => { | ||
const { prepare } = usePreparePrivyWallet() | ||
const { connectedWallet } = useConnectedWallet() | ||
const { sendTransaction } = usePrivySendTransaction() | ||
const [loading, setLoading] = useState(false) | ||
|
||
const collect = async (dropAddress: Address, tokenId: number, chainId: number) => { | ||
try { | ||
if (!(await prepare(chainId))) return false | ||
setLoading(true) | ||
|
||
const { token }: any = await getToken(dropAddress, "1155", tokenId, chainId) | ||
const { salesConfig } = token | ||
const { mintFee } = salesConfig | ||
|
||
const collectorClient = getCollectorClient(chainId) | ||
const { parameters } = await collectorClient.mint({ | ||
tokenContract: dropAddress, | ||
mintType: "1155", | ||
quantityToMint: 1, | ||
minterAccount: connectedWallet as Address, | ||
tokenId, | ||
}) | ||
|
||
const { abi, functionName, args, address: minter } = parameters | ||
|
||
const response = await sendTransaction( | ||
minter, | ||
chainId, | ||
abi, | ||
functionName, | ||
args, | ||
mintFee, | ||
"HENO.WEB3", | ||
"COLLECT", | ||
) | ||
const { error } = response as any | ||
if (error) { | ||
setLoading(false) | ||
return false | ||
} | ||
setLoading(false) | ||
return response | ||
} catch (error) { | ||
handleTxError(error) | ||
return { error } | ||
} | ||
} | ||
|
||
return { | ||
collect, | ||
loading, | ||
} | ||
} | ||
|
||
export default useCollectDrop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const getIpfsLink = (hash: string) => | ||
hash?.indexOf?.("ipfs://") > -1 | ||
? hash.replace("ipfs://", "https://cloudflare-ipfs.com/ipfs/") | ||
? hash.replace("ipfs://", "https://ipfs.decentralized-content.com/ipfs/") | ||
: hash | ||
|
||
export default getIpfsLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createCollectorClient } from "@zoralabs/protocol-sdk" | ||
import { getPublicClient } from "../clients" | ||
|
||
const getCollectorClient = (chainId: number) => { | ||
const publicClient = getPublicClient(chainId) as any | ||
const collectorClient = createCollectorClient({ | ||
chainId, | ||
publicClient, | ||
}) | ||
|
||
return collectorClient | ||
} | ||
|
||
export default getCollectorClient |
Oops, something went wrong.