Skip to content

Add more flexibility to types of content and preview of useCreateNft hook #124

@NicolasMahe

Description

@NicolasMahe

Will be very good to bring flexibility to the type of content and preview. This will make frontend more flexible when creating NFTs.
Currently it's they are only File:

content: File
preview?: File

The codebase is actually already compatible with File | string as the uploadFile function is already compatible:

type UploadFn = (
file: File | string,
options?: { protected?: boolean },
) => Promise<string>
export default function useIPFSUploader(uploadUrl: string): [UploadFn] {
const upload = useCallback<UploadFn>(
async (file, options) => {
if (typeof file === 'string') {
const gatewayTools = new IPFSGatewayTools()
const { cid, containsCid } = gatewayTools.containsCID(file)
return containsCid ? cid : undefined
}

The hook useUpdateAccount already implement this logic:

type AccountInput = {
image?: File | string
cover?: File | string

For now, only a valid IPFS URI can be put as string, this should be expand to also https URL. The API already accept both ipfs and https URL.

To make the system more generic, the upload function in useIPFSUploader should return not only the CID but the CID with the ipfs prefix: ipfs://CID. This will simplify other part of the codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions