* initial /publish * custom contract init (#27) * clean up customContract interface for the moment * upgrade sdk & make multi-uri publish work * upgraded dependencies and customContract workflow * more custom contract stuff * publish ui update * basic publish & deploy flow works * cleanup eslint * update sdk * add contract address to toast and log it out * integrate newer sdk version * upgrade deps * full deploy loop functional with updated sdk * upgrade sdk * upgrade deps * upgrade sdk to fix big contracts * full flow! * update deps * update to latest sdk, support custom contracts in contracts list * one more sdk update * cache keys // analytics mapping * make mr. typescript happy * try catch the resolve type (need to fix it in SDK) * fix type check * upgrade sdk & handle `ipfs=` from cli * fix yarn lock * publishBatch * add very basic code tab * fix build * init cleaning up code tab * fix zindex issue * update code segments * prep some more stuff * remove duplication * this wont build and that is ok * fix build * upgrade react package * add super basic mint button * update sdk * clean up some custom contract interfaces a bit * updated sdks all around * change minting to useNFTMint * append contract.functions to signatures so you can copy paste * add byoc page tracking * new publish page * slightly fix hook * custom deploy form update * completely overhauled deploy flow now * some improvements, empty states etc * only show coming soon on non-mumbai * tw-components * fix contract items table * upgrade deps * fix secondary cta * fix string * fixed things more * fix up code-block * small code tab improvements * Add mint drawer if ERC721 (#95) * Update thumbnail/title/desc * Add custom nft mint * Fix FormHelperText * Delete unused imports * Remove imports * fix build issues etc * Add token drop (#93) * Update thumbnail/title/desc * Merge * wip * Token drop page working * Add claim phases tab, add TokenDrop to conditionals * update font size * NFTs/token conditional * Add QuantityInputWithUnlimited * Update SDK * Fix unlimited * Remove fontSize Co-authored-by: Jonas Daniels <[email protected]> * set tokendrop back to coming soon * remove "@dev" tag for sdk installation * fix mappings file * fix indentation on custom code tab * ship central 🚢 * fix build Co-authored-by: Joaquim Verges <[email protected]> Co-authored-by: Jake Loo <[email protected]> Co-authored-by: Nacho Iacovino <[email protected]>
157 lines
4.7 KiB
TypeScript
157 lines
4.7 KiB
TypeScript
import { NFTDropKeys, editionDropKeys, tokenDropKeys } from "../cache-keys";
|
|
import {
|
|
useMutationWithInvalidate,
|
|
useQueryWithNetwork,
|
|
} from "./query/useQueryWithNetwork";
|
|
import { useEditionDropResetClaimEligibilityMutation } from "./useEditionDrop";
|
|
import { useNFTDropResetClaimEligibilityMutation } from "./useNFTDrop";
|
|
import {
|
|
useTokenDropData,
|
|
useTokenDropResetClaimEligibilityMutation,
|
|
} from "./useTokenDrop";
|
|
import {
|
|
ClaimConditionInput,
|
|
EditionDrop,
|
|
NFTDrop,
|
|
TokenDrop,
|
|
} from "@thirdweb-dev/sdk";
|
|
import invariant from "tiny-invariant";
|
|
|
|
export function useDecimals(contract?: NFTDrop | EditionDrop | TokenDrop) {
|
|
if (contract instanceof NFTDrop || contract instanceof EditionDrop) {
|
|
return 0;
|
|
} else {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useTokenDropData(contract?.getAddress()).data?.decimals;
|
|
}
|
|
}
|
|
|
|
export function useClaimPhases(
|
|
contract?: NFTDrop | EditionDrop | TokenDrop,
|
|
tokenId?: string,
|
|
) {
|
|
if (contract instanceof NFTDrop) {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useNFTDropClaimPhases(contract);
|
|
} else if (contract instanceof EditionDrop) {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useEditionDropClaimPhases(contract, tokenId);
|
|
} else {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useTokenDropClaimPhases(contract);
|
|
}
|
|
}
|
|
|
|
function useNFTDropClaimPhases(contract?: NFTDrop) {
|
|
return useQueryWithNetwork(
|
|
NFTDropKeys.claimPhases(contract?.getAddress()),
|
|
async () => await contract?.claimConditions.getAll(),
|
|
{
|
|
enabled: !!contract,
|
|
},
|
|
);
|
|
}
|
|
|
|
function useEditionDropClaimPhases(contract?: EditionDrop, tokenId?: string) {
|
|
return useQueryWithNetwork(
|
|
editionDropKeys.claimPhases(contract?.getAddress(), tokenId),
|
|
async () => await contract?.claimConditions.getAll(tokenId as string),
|
|
{
|
|
enabled: !!contract && !!tokenId,
|
|
},
|
|
);
|
|
}
|
|
|
|
function useTokenDropClaimPhases(contract?: TokenDrop) {
|
|
return useQueryWithNetwork(
|
|
tokenDropKeys.claimPhases(contract?.getAddress()),
|
|
async () => await contract?.claimConditions.getAll(),
|
|
{
|
|
enabled: !!contract,
|
|
},
|
|
);
|
|
}
|
|
|
|
export function useClaimPhasesMutation(
|
|
contract?: NFTDrop | EditionDrop | TokenDrop,
|
|
tokenId?: string,
|
|
) {
|
|
if (contract instanceof NFTDrop) {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useNFTDropPhasesMutation(contract);
|
|
} else if (contract instanceof EditionDrop) {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useEditionDropPhasesMutation(contract, tokenId);
|
|
} else {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useTokenDropPhasesMutation(contract);
|
|
}
|
|
}
|
|
|
|
export function useResetEligibilityMutation(
|
|
contract?: NFTDrop | EditionDrop | TokenDrop,
|
|
tokenId?: string,
|
|
) {
|
|
if (contract instanceof NFTDrop) {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useNFTDropResetClaimEligibilityMutation(contract);
|
|
} else if (contract instanceof EditionDrop) {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useEditionDropResetClaimEligibilityMutation(contract, tokenId);
|
|
} else {
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
return useTokenDropResetClaimEligibilityMutation(contract);
|
|
}
|
|
}
|
|
|
|
function useNFTDropPhasesMutation(contract?: NFTDrop) {
|
|
return useMutationWithInvalidate(
|
|
async (phases: ClaimConditionInput[]) => {
|
|
invariant(contract, "contract is required");
|
|
|
|
return await contract.claimConditions.set(phases);
|
|
},
|
|
{
|
|
onSuccess: (_data, _variables, _options, invalidate) => {
|
|
return invalidate([NFTDropKeys.claimPhases(contract?.getAddress())]);
|
|
},
|
|
},
|
|
);
|
|
}
|
|
|
|
function useEditionDropPhasesMutation(
|
|
contract?: EditionDrop,
|
|
tokenId?: string,
|
|
) {
|
|
return useMutationWithInvalidate(
|
|
async (phases: ClaimConditionInput[]) => {
|
|
invariant(contract, "contract is required");
|
|
invariant(tokenId, "tokenId is required");
|
|
|
|
return await contract.claimConditions.set(tokenId, phases);
|
|
},
|
|
{
|
|
onSuccess: (_data, _variables, _options, invalidate) => {
|
|
return invalidate([
|
|
editionDropKeys.claimPhases(contract?.getAddress(), tokenId),
|
|
]);
|
|
},
|
|
},
|
|
);
|
|
}
|
|
|
|
function useTokenDropPhasesMutation(contract?: TokenDrop) {
|
|
return useMutationWithInvalidate(
|
|
async (phases: ClaimConditionInput[]) => {
|
|
invariant(contract, "contract is required");
|
|
|
|
return await contract.claimConditions.set(phases);
|
|
},
|
|
{
|
|
onSuccess: (_data, _variables, _options, invalidate) => {
|
|
return invalidate([tokenDropKeys.claimPhases(contract?.getAddress())]);
|
|
},
|
|
},
|
|
);
|
|
}
|