* Rename hooks * Rename mint forms * Rename cache keys * Rename table columns * Widgets to embeds * Update expansion * Fix errors * Rename pages * Rename some variables * Fix dropzone issue * Redeploy * Fix edition drop caching * Fix name Co-authored-by: Jonas Daniels <[email protected]>
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { useMutationWithInvalidate } from "./query/useQueryWithNetwork";
|
|
import { getAllQueryKey } from "./useGetAll";
|
|
import {
|
|
Edition,
|
|
EditionMetadata,
|
|
EditionMetadataInput,
|
|
} from "@thirdweb-dev/sdk";
|
|
import invariant from "tiny-invariant";
|
|
|
|
export interface EditionMetadataWithOwner extends EditionMetadata {
|
|
owner: string | undefined;
|
|
}
|
|
// ----------------------------------------------------------------
|
|
// Mutations
|
|
// ----------------------------------------------------------------
|
|
|
|
type Input = EditionMetadataInput["metadata"] & {
|
|
supply: EditionMetadataInput["supply"];
|
|
};
|
|
|
|
export function useEditionCreateAndMintMutation(contract?: Edition) {
|
|
return useMutationWithInvalidate(
|
|
async (metadataWithSupply: Input) => {
|
|
invariant(contract, "contract is required");
|
|
|
|
const { supply, ...metadata } = metadataWithSupply;
|
|
|
|
return await contract.mint({ metadata, supply });
|
|
},
|
|
{
|
|
onSuccess: (_data, _variables, _options, invalidate) => {
|
|
return invalidate([getAllQueryKey(contract)]);
|
|
},
|
|
},
|
|
);
|
|
}
|