-
Notifications
You must be signed in to change notification settings - Fork 1
Description
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:
liteflow-js/packages/hooks/src/useCreateNFT.ts
Lines 92 to 93 in 11668f0
| content: File | |
| preview?: File |
The codebase is actually already compatible with File | string as the uploadFile function is already compatible:
liteflow-js/packages/hooks/src/useIPFSUploader.ts
Lines 6 to 18 in 11668f0
| 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:
liteflow-js/packages/hooks/src/useUpdateAccount.ts
Lines 20 to 22 in 11668f0
| 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.