-
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 #3 from SweetmanTech/sweets/heno
Sweets/heno
- Loading branch information
Showing
9 changed files
with
1,232 additions
and
7,504 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
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,48 @@ | ||
import { useMemo } from "react"; | ||
import { BigNumber, Contract, utils } from "ethers"; | ||
import { useEthersSigner } from "./useEthersSigner"; | ||
import abi from "../lib/abi/Zora1155Drop.json"; | ||
import { useZoraFixedPriceSaleStrategy } from ".."; | ||
|
||
const use1155Collect = (zora1155Drop: string, minterAddress: string) => { | ||
const signer = useEthersSigner(); | ||
const zora1155DropContract = useMemo( | ||
() => new Contract(zora1155Drop, abi, signer), | ||
[zora1155Drop, signer] | ||
); | ||
const { sale } = useZoraFixedPriceSaleStrategy(minterAddress); | ||
|
||
const mintWithRewards = async ( | ||
tokenId: string, | ||
to: string, | ||
referral: string, | ||
comment = "🪄🪄🪄" | ||
) => { | ||
const response = await sale(zora1155Drop, "1"); | ||
const zoraFee = BigNumber.from("777000000000000"); | ||
const value = BigNumber.from(response.pricePerToken.toString()).add( | ||
zoraFee | ||
); | ||
const minterArguments = utils.defaultAbiCoder.encode( | ||
["address", "string"], | ||
[to, comment] | ||
); | ||
const tx = await zora1155DropContract.mintWithRewards( | ||
minterAddress, | ||
tokenId, | ||
1, | ||
minterArguments, | ||
referral, | ||
{ | ||
value, | ||
} | ||
); | ||
|
||
const receipt = await tx.wait(); | ||
return receipt; | ||
}; | ||
|
||
return { mintWithRewards }; | ||
}; | ||
|
||
export default use1155Collect; |
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 { useMemo } from "react"; | ||
import { useEthersSigner } from "./useEthersSigner"; | ||
import abi from "../lib/abi/ZoraCreatorFixedPriceSaleStrategy.json"; | ||
|
||
const useZoraFixedPriceSaleStrategy = (saleConfig: string) => { | ||
const signer = useEthersSigner(); | ||
const saleConfigContract = useMemo( | ||
() => new Contract(saleConfig, abi, signer), | ||
[saleConfig, signer] | ||
); | ||
|
||
const sale = async (tokenContract: string, tokenId: string) => { | ||
try { | ||
const response = await saleConfigContract.sale(tokenContract, tokenId); | ||
return response; | ||
} catch (error) { | ||
return error; | ||
} | ||
}; | ||
|
||
return { sale }; | ||
}; | ||
|
||
export default useZoraFixedPriceSaleStrategy; |
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
Oops, something went wrong.