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

fix minter #122

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions minter/src/hooks/useMint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useMbWallet } from "@mintbase-js/react";

import { zodResolver } from "@hookform/resolvers/zod";

import { ArweaveResponse, uploadReference } from "@mintbase-js/storage"
import { ArweaveResponse, uploadFile, uploadReference } from "@mintbase-js/storage"
import { formSchema } from "./formSchema";
import { MintbaseWalletSetup, proxyAddress } from "@/config/setup";
import { Wallet } from "@near-wallet-selector/core"
Expand Down Expand Up @@ -50,16 +50,19 @@ const useMintImage = () => {
media: data?.media as unknown as File
})

const file = uploadFile(data?.media as unknown as File
);

await handleMint(reference, activeAccountId as string, wallet);
await handleMint(reference.id, file, activeAccountId as string, wallet);
};

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema)
});

async function handleMint(
reference: ArweaveResponse,
reference: string,
media: Promise<ArweaveResponse>,
activeAccountId: string,
wallet: Wallet
) {
Expand All @@ -73,8 +76,8 @@ const useMintImage = () => {
params: {
methodName: "mint",
args: {
metadata: JSON.stringify({ media: reference }),
nft_contract_id: MintbaseWalletSetup.contractAddress,
metadata: JSON.stringify({ reference, media: (await media).id }),
nft_contract_id: MintbaseWalletSetup.contractAddress,
},
gas: "200000000000000",
deposit: "10000000000000000000000",
Expand Down
Loading