Skip to content

Commit

Permalink
Merge pull request #9800 from kodadot/fix-massmint-preheat
Browse files Browse the repository at this point in the history
fix: preheat on massmint
  • Loading branch information
prury authored Mar 18, 2024
2 parents bc15017 + cfa67c8 commit a5d8874
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
1 change: 0 additions & 1 deletion composables/drop/massmint/useDropMassMintUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
} from '@/composables/transaction/mintToken/constructDirectoryMeta'
import { makeUnlockableMetadata } from '@/components/collection/unlockable/utils'
import { useCollectionEntity } from '@/composables/drop/useGenerativeDropMint'
import { GenerativePreviewItem } from '../useGenerativePreview'

export default () => {
const { toMintNFTs, drop } = storeToRefs(useDropStore())
Expand Down
19 changes: 3 additions & 16 deletions composables/transaction/mintToken/constructDirectoryMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ export const uploadMediaAndMetadataDirectories = async (
const metaDirectoryCid = await pinDirectory(metadataFiles)

// Preheat and upload files
await Promise.all(
mediaFiles.map((media, index) =>
preheatAndDirectUpload(media, imageHashes[index]),
),
mediaFiles.map((_, index) =>
preheatFileFromIPFS(extractCid(imageHashes[index])),
)

return metadataFiles.map((_, index) =>
Expand Down Expand Up @@ -125,18 +123,7 @@ const createTokenMetadata = (
return makeJsonFile(meta, String(index))
}

export const makeJsonFile = (data: any, name: string) =>
export const makeJsonFile = (data: unknown, name: string) =>
new File([JSON.stringify(data, null, 2)], `${name}.json`, {
type: 'application/json',
})

const preheatAndDirectUpload = async (
media: File,
primaryHash: string,
): Promise<void> => {
const { $consola } = useNuxtApp()
preheatFileFromIPFS(primaryHash)
const filePair: [File, File | null] = [media, null]
const hashPair: [string, string | undefined] = [primaryHash, undefined]
await uploadDirectWhenMultiple(filePair, hashPair).catch($consola.warn)
}

0 comments on commit a5d8874

Please sign in to comment.