Skip to content

Commit

Permalink
mint: new drop.
Browse files Browse the repository at this point in the history
  • Loading branch information
techeng322 committed Oct 8, 2024
1 parent a3c9791 commit 3bd7c7e
Show file tree
Hide file tree
Showing 13 changed files with 1,962 additions and 8,190 deletions.
4,815 changes: 0 additions & 4,815 deletions package-lock.json

This file was deleted.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
"@pushprotocol/uiweb": "^1.3.8",
"@stackso/js-core": "^0.3.1",
"@vercel/analytics": "^1.0.1",
"@zoralabs/protocol-deployments": "^0.1.8",
"@zoralabs/universal-minter": "^0.2.16",
"@zoralabs/protocol-deployments": "^0.2.2",
"@zoralabs/protocol-sdk": "^0.9.0",
"@zoralabs/zorb": "^0.1.0",
"@zoralabs/zord": "^2.1.0",
"axios": "^1.2.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "5.0.0",
"firebase": "10.3.0",
"framer-motion": "^9.0.2",
"joi": "^17.12.0",
Expand Down Expand Up @@ -59,6 +60,7 @@
"eslint-config-next": "14.2.4",
"eslint-config-prettier": "^8.5.0",
"postcss": "^8",
"prettier": "3.3.3",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/CollectDropButton/CollectDropButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ 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, chainId)
const response = await collect(address, tokenId, chainId)
if (!response) return
toast.success("Collected!")
}
Expand All @@ -25,7 +27,6 @@ const CollectDropButton = ({
onTouchStart={handleClick}
onClick={handleClick}
className={`${className} bg-darkgray py-[3px] w-full`}
disabled={true}
>
{loading ? `Collecting...` : "Collect"}
</button>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Core/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ function Icon({
size <= 20
? styles.sizes.mini
: size < 25
? styles.sizes.small
: size < 40
? styles.sizes.medium
: styles.sizes.large
? styles.sizes.small
: size < 40
? styles.sizes.medium
: styles.sizes.large
}
${!noHighlights && styles?.variants?.[variant]?.highlight}
${className}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Core/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ function TextArea({
className={`text-gray_1 w-full border-[2px] !border-gray_1 bg-black
focus:ring-0 focus:border-gray_1
${className || ""} ${
hookToForm && fieldError && fieldError?.message ? clasNameError : ""
}`}
hookToForm && fieldError && fieldError?.message ? clasNameError : ""
}`}
{...(!hookToForm && {
value,
onChange,
Expand Down
1 change: 1 addition & 0 deletions src/components/Pages/Web3Page/BonasiSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const BonasiSection = ({ isPopup }) => (
>
<CollectDropButton
chainId={IS_TESTNET ? baseSepolia.id : base.id}
tokenId={3}
address={BONSAI_DROP_ADDRESS as Address}
/>
</DropCollect>
Expand Down
64 changes: 26 additions & 38 deletions src/hooks/useCollectDrop.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { HYDROPLANING_DROP_ADDRESS, ZORA_FEE, HYDROPLANING_REWARDS_RECIPIENT } from "@/lib/consts"
import handleTxError from "@/lib/handleTxError"
import { useState } from "react"
import { BigNumber } from "ethers"
import getEncodedMinterArgs from "@/lib/zora/getEncodedMinterArgs"
import {
zoraCreator1155ImplABI,
zoraCreatorFixedPriceSaleStrategyAddress,
} from "@zoralabs/protocol-deployments"
import get1155SaleStatus from "@/lib/get1155SaleStatus"
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"
import getCollectorClient from "@/lib/zora/getCollectorClient"
import getToken from "@/lib/zora/getToken"

const useCollectDrop = () => {
const { prepare } = usePreparePrivyWallet()
Expand All @@ -28,42 +20,38 @@ const useCollectDrop = () => {

setLoading(true)

const { token } = await getToken(dropAddress, '1155', tokenId, chainId)

console.log("ZIAD", token)
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',
mintType: "1155",
quantityToMint: 1,
minterAccount: connectedWallet,
minterAccount: connectedWallet as Address,
tokenId,
})

// 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
// }

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 true
return response
} catch (error) {
handleTxError(error)
return { error }
Expand Down
19 changes: 19 additions & 0 deletions src/lib/consts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,22 @@ export const COLLECTIONS = [
type: "ERC1155",
},
]

export const zoraUniversalMinterAddress = {
1: "0x308E190d70c7d1C6Ed569554bCe73Dc3F4ad359A",
5: "0x1Eb7Bf3a08784D7cB08CC2AE1448012C0c02bDa2",
10: "0x97eb05B8db496B12244BCcf17CF377d00a99b67a",
420: "0x39C51a7957651ea176733F19125BD9c253894D6F",
424: "0xF82286760a953D2Bad7D6F2F0da458Ac20f955D3",
999: "0xD9bC36841C259f07924e73cF08d5a2c92d53639B",
8453: "0x308E190d70c7d1C6Ed569554bCe73Dc3F4ad359A",
42161: "0xC6899816663891D7493939d74d83cb7f2BBcBB16",
58008: "0xE9BaDfb9a1658cDF67D8c4631a7f22610C013319",
81457: "0xC6899816663891D7493939d74d83cb7f2BBcBB16",
84531: "0x418B87c2C9579d27FC3D66605545AB9889737E60",
421614: "0x308E190d70c7d1C6Ed569554bCe73Dc3F4ad359A",
7777777: "0xF482C51346f3c77673dc619F243Eb8B09E9A954E",
11155111: "0x0ef82DaB14798E63F1B99479Ba689e3f6A6fEb6C",
168587773: "0xa718BD919eeA529ac75EEf2cf33363AF211f09f4",
999999999: "0xD662FB0fB00261C039441EF49Dbab154d7c533bD",
}
2 changes: 1 addition & 1 deletion src/lib/zora/getCollectorClient.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCollectorClient } from "@zoralabs/protocol-sdk"
import { getPublicClient } from "../clients"
import { createCollectorClient } from '@zoralabs/protocol-sdk'

const getCollectorClient = (chainId: number) => {
const publicClient = getPublicClient(chainId)
Expand Down
8 changes: 4 additions & 4 deletions src/lib/zora/getToken.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import getCollectorClient from './getCollectorClient'
import { Address } from 'viem'
import { Address } from "viem"
import getCollectorClient from "./getCollectorClient"

const getToken = async (
collectionAddress: Address,
mintType: any,
tokenId: any,
chainId: number
chainId: number,
) => {
const collectorClient = getCollectorClient(chainId)

Expand All @@ -14,7 +14,7 @@ const getToken = async (
mintType,
}

if (mintType === '1155') tokenInfo.tokenId = tokenId
if (mintType === "1155") tokenInfo.tokenId = tokenId

const { token, prepareMint } = await collectorClient.getToken(tokenInfo)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/zora/getUniversalMinter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { zoraUniversalMinterAddress } from "@zoralabs/universal-minter"
import { zoraUniversalMinterAddress } from "@/lib/consts"

const getUniversalMinter = (chainId) =>
zoraUniversalMinterAddress[chainId as keyof typeof zoraUniversalMinterAddress]
Expand Down
14 changes: 12 additions & 2 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@ body {
background-color: black;
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell,
Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
font-family:
-apple-system,
BlinkMacSystemFont,
Segoe UI,
Roboto,
Oxygen,
Ubuntu,
Cantarell,
Fira Sans,
Droid Sans,
Helvetica Neue,
sans-serif;
}

body::-webkit-scrollbar {
Expand Down
Loading

0 comments on commit 3bd7c7e

Please sign in to comment.