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 #129 from SweetmanTech/test
Test
- Loading branch information
Showing
9 changed files
with
181 additions
and
28 deletions.
There are no files selected for viewing
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,26 @@ | ||
import { toast } from "react-toastify" | ||
import useHydroCollect from "@/hooks/useHydroCollect" | ||
|
||
const CollectHydro = ({ className = "" }) => { | ||
const { collect, loading } = useHydroCollect() | ||
|
||
const handleClick = async () => { | ||
const response = await collect() | ||
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 CollectHydro |
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 CollectHydro from "./CollectHydro" | ||
|
||
export default CollectHydro |
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 CollectHydro from "@/components/CollectHydro" | ||
import data from "@/lib/zora-drops" | ||
|
||
const HydroplaningSection = ({ isPopup }) => ( | ||
<div className="w-full flex flex-col gap-1.5"> | ||
<video | ||
src="https://ipfs.decentralized-content.com/ipfs/bafybeibifnzka6oqs77ascf5fuhtxtv4mc56jc47rb4fqbjz644byzu72q" | ||
preload="auto" | ||
controls | ||
playsInline | ||
webkit-playsinline | ||
x5-playsinline | ||
muted | ||
className={`${isPopup ? "h-[200px]" : "h-[300px]"}`} | ||
/> | ||
<CollectHydro /> | ||
<span className={`uppercase text-[12px] ${isPopup ? "md:text-[14px]" : "md:text-[16px]"}`}> | ||
{data[11].title} By {data[11].artist} | ||
</span> | ||
</div> | ||
) | ||
|
||
export default HydroplaningSection |
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,74 @@ | ||
import { | ||
HYDROPLANING_DROP_ADDRESS, | ||
IS_TESTNET, | ||
ZORA_FEE, | ||
HYDROPLANING_REWARDS_RECIPIENT, | ||
} from "@/lib/consts" | ||
import handleTxError from "@/lib/handleTxError" | ||
import { useState } from "react" | ||
import { BigNumber } from "ethers" | ||
import { base, baseSepolia } from "viem/chains" | ||
import getEncodedMinterArgs from "@/lib/zora/getEncodedMinterArgs" | ||
import { | ||
zoraCreator1155ImplABI, | ||
zoraCreatorFixedPriceSaleStrategyAddress, | ||
} from "@zoralabs/protocol-deployments" | ||
import get1155SaleStatus from "@/lib/get1155SaleStatus" | ||
import usePrivySendTransaction from "./usePrivySendTransaction" | ||
import useConnectedWallet from "./useConnectedWallet" | ||
import usePreparePrivyWallet from "./usePreparePrivyWallet" | ||
|
||
const useHydroCollect = () => { | ||
const { prepare } = usePreparePrivyWallet() | ||
const { connectedWallet } = useConnectedWallet() | ||
const { sendTransaction } = usePrivySendTransaction() | ||
const [loading, setLoading] = useState(false) | ||
const chainId = IS_TESTNET ? baseSepolia.id : base.id | ||
|
||
const collect = async () => { | ||
try { | ||
if (!(await prepare(chainId))) return false | ||
if (!connectedWallet) return false | ||
|
||
setLoading(true) | ||
const saleDetails = await get1155SaleStatus(HYDROPLANING_DROP_ADDRESS, 1, chainId) | ||
const totalFee = BigNumber.from(saleDetails?.pricePerToken).add(ZORA_FEE).toHexString() | ||
|
||
const minterArguments = getEncodedMinterArgs(connectedWallet, "!!!") | ||
|
||
const response = await sendTransaction( | ||
HYDROPLANING_DROP_ADDRESS, | ||
chainId, | ||
zoraCreator1155ImplABI, | ||
"mint", | ||
[ | ||
zoraCreatorFixedPriceSaleStrategyAddress[chainId], | ||
1, | ||
1, | ||
[HYDROPLANING_REWARDS_RECIPIENT], | ||
minterArguments, | ||
], | ||
totalFee, | ||
"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 useHydroCollect |
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,25 @@ | ||
import { Contract } from "ethers" | ||
import { | ||
zoraCreatorFixedPriceSaleStrategyABI, | ||
zoraCreatorFixedPriceSaleStrategyAddress, | ||
} from "@zoralabs/protocol-deployments" | ||
import getDefaultProvider from "./getDefaultProvider" | ||
|
||
const get1155SaleStatus = async (collectionAddress, tokenId, chainId) => { | ||
try { | ||
const fixedPriceSaleStrategry = new Contract( | ||
zoraCreatorFixedPriceSaleStrategyAddress[chainId], | ||
zoraCreatorFixedPriceSaleStrategyABI, | ||
getDefaultProvider(chainId), | ||
) | ||
const saleDetails = await fixedPriceSaleStrategry.sale(collectionAddress, tokenId) | ||
|
||
return saleDetails | ||
} catch (err) { | ||
// eslint-disable-next-line no-console | ||
console.error(err) | ||
return null | ||
} | ||
} | ||
|
||
export default get1155SaleStatus |
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