Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update zora contract #12

Merged
merged 14 commits into from
Aug 8, 2024
1 change: 1 addition & 0 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function Footer() {
target="_blank"
rel="noreferrer"
title="OnchainKit"
className="font-semibold hover:text-indigo-600"
>
OnchainKit
</a>
Expand Down
49 changes: 37 additions & 12 deletions src/components/TransactionWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import {
TransactionStatusAction,
TransactionStatusLabel,
} from '@coinbase/onchainkit/transaction';
import { clickContractAbi, clickContractAddress } from 'src/constants';
import type { TransactionError } from '@coinbase/onchainkit/transaction';
import { mintABI, mintContractAddress } from 'src/constants';
import type { Address, ContractFunctionParameters } from 'viem';
import { parseEther } from 'viem';

const BASE_SEPOLIA_CHAIN_ID = 84532;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move this to constant file


const collectionAddress = '0xd6915560d3bb24aec04dc42ef409921ed1931510';
const tokenId = '1';
const quantity = '1';
const mintReferral = '0x0000000000000000000000000000000000000000';
const comment = 'testing';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, let's use more polish constant.


type TransactionWrapperParams = {
address: Address;
Expand All @@ -16,27 +26,42 @@ type TransactionWrapperParams = {
export default function TransactionWrapper({
address,
}: TransactionWrapperParams) {
const mintTo = address;

const contracts = [
{
address: clickContractAddress,
abi: clickContractAbi,
functionName: 'click',
args: [],
address: mintContractAddress,
abi: mintABI,
functionName: 'mint',
args: [
mintTo,
BigInt(quantity),
collectionAddress,
BigInt(tokenId),
mintReferral,
comment,
],
value: parseEther('0.000111'),
},
{
address: clickContractAddress,
abi: clickContractAbi,
functionName: 'click',
args: [],
},
] as ContractFunctionParameters[];
] as unknown as ContractFunctionParameters[];

const handleError = (err: TransactionError) => {
console.error('Transaction error:', err);
};

const handleSuccess = (response: any) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to export TransactionResponse from onchainkit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log('Transaction successful', response);
};

return (
<div className="flex w-[450px]">
<Transaction
address={address}
contracts={contracts}
className="w-[450px]"
chainId={BASE_SEPOLIA_CHAIN_ID}
onError={handleError}
onSuccess={handleSuccess}
>
<TransactionButton
className="mt-0 mr-auto ml-auto w-[450px] text-[white]"
Expand Down
19 changes: 19 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,22 @@ export const clickContractAbi = [
stateMutability: 'nonpayable',
},
];

export const mintContractAddress = '0x777777722D078c97c6ad07d9f36801e653E356Ae';

export const mintABI = [
{
inputs: [
{ internalType: 'address', name: 'mintTo', type: 'address' },
{ internalType: 'uint256', name: 'quantity', type: 'uint256' },
{ internalType: 'address', name: 'collection', type: 'address' },
{ internalType: 'uint256', name: 'tokenId', type: 'uint256' },
{ internalType: 'address', name: 'mintReferral', type: 'address' },
{ internalType: 'string', name: 'comment', type: 'string' },
],
name: 'mint',
outputs: [],
stateMutability: 'payable',
type: 'function',
},
] as const;
Loading