Skip to content

Commit

Permalink
Merge pull request #11245 from kodadot/chore/minimark-out-utils
Browse files Browse the repository at this point in the history
chore/minimark out utils
  • Loading branch information
vikiival authored Dec 16, 2024
2 parents e34df97 + 636c150 commit ff567e3
Show file tree
Hide file tree
Showing 16 changed files with 843 additions and 150 deletions.
2 changes: 1 addition & 1 deletion components/collection/unlockable/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMetadata } from '@kodadot1/minimark/utils'
import { createOpenSeaMetadata as createMetadata } from '@kodadot1/hyperdata'

export const UNLOCKABLE_CAMPAIGN = 'bbw2023'
export const UNLOCKABLE_NAME = 'Berlin (Blockchain) Waifus'
Expand Down
3 changes: 2 additions & 1 deletion components/common/EditNftModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@

<script setup lang="ts">
import { NeoButton, NeoField, NeoInput, NeoModal } from '@kodadot1/brick'
import type { Metadata, Attribute } from '@kodadot1/minimark/common'
import type { OpenSeaAttribute as Attribute } from '@kodadot1/hyperdata'
import type { ActionMetadataSetMetadata } from '@/composables/transaction/types'
import ModalBody from '@/components/shared/modals/ModalBody.vue'
import CustomAttributeInput from '@/components/rmrk/Create/CustomAttributeInput.vue'
import type { Metadata } from '@/services/nftStorage'
const emit = defineEmits(['submit'])
const props = defineProps<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

<script setup lang="ts">
import { NeoDropdownItem } from '@kodadot1/brick'
import type { Metadata } from '@kodadot1/minimark/common'
import { useQuery } from '@tanstack/vue-query'
import { refreshOdaTokenMetadata } from '@/services/oda'
import { type ActionMetadataSetMetadata, NFTs } from '@/composables/transaction/types'
import type { NFT } from '@/types'
import type { Metadata } from '@/services/nftStorage'
const props = defineProps<{
nft?: NFT
Expand Down
2 changes: 1 addition & 1 deletion components/rmrk/Create/CustomAttributeInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</template>

<script lang="ts" setup>
import type { Attribute } from '@kodadot1/minimark/common'
import type { OpenSeaAttribute as Attribute } from '@kodadot1/hyperdata'
import { NeoButton } from '@kodadot1/brick'
import AttributeInput from './AttributeInput.vue'
Expand Down
2 changes: 1 addition & 1 deletion components/shared/gallery/Properties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</template>

<script lang="ts" setup>
import type { Attribute } from '@kodadot1/minimark/common'
import type { OpenSeaAttribute as Attribute } from '@kodadot1/hyperdata'
import { emptyArray } from '~/utils/empty'
import CollapseCardWrapper from '@/components/shared/collapse/CollapseCardWrapper.vue'
Expand Down
4 changes: 2 additions & 2 deletions composables/transaction/mintCollection/constructMeta.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMetadata, unSanitizeIpfsUrl } from '@kodadot1/minimark/utils'
import { createOpenSeaMetadata as createMetadata, protocolize } from '@kodadot1/hyperdata'
import type { ActionMintCollection } from '../types'
import { pinJson } from '@/services/nftStorage'
import { uploadDirect } from '@/utils/directUpload'
Expand Down Expand Up @@ -28,5 +28,5 @@ export async function constructMeta(item: ActionMintCollection) {
uploadDirect(file, imageHash).catch($consola.warn)
}

return unSanitizeIpfsUrl(metaHash)
return protocolize(metaHash)
}
4 changes: 2 additions & 2 deletions composables/transaction/mintToken/constructDirectoryMeta.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMetadata, unSanitizeIpfsUrl } from '@kodadot1/minimark/utils'
import { createOpenSeaMetadata as createMetadata, protocolize } from '@kodadot1/hyperdata'
import type { TokenToMint } from '../types'
import { pinDirectory } from '@/services/nftStorage'

Expand Down Expand Up @@ -40,7 +40,7 @@ export const uploadMediaAndMetadataDirectories = async (
)

return metadataFiles.map((_, index) =>
unSanitizeIpfsUrl(`ipfs://${metaDirectoryCid}/${index}.json`),
protocolize(`ipfs://${metaDirectoryCid}/${index}.json`),
)
}

Expand Down
4 changes: 2 additions & 2 deletions composables/transaction/mintToken/constructMeta.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMetadata, unSanitizeIpfsUrl } from '@kodadot1/minimark/utils'
import { createOpenSeaMetadata as createMetadata, protocolize } from '@kodadot1/hyperdata'
import type { TokenToMint } from '../types'
import {
nsfwAttribute,
Expand Down Expand Up @@ -63,5 +63,5 @@ export async function constructMeta(
[file, secondFile],
[fileHash, secondFileHash],
).catch($consola.warn)
return unSanitizeIpfsUrl(metaHash)
return protocolize(metaHash)
}
8 changes: 4 additions & 4 deletions composables/transaction/transactionSetNftMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { unSanitizeIpfsUrl } from '@kodadot1/minimark/utils'
import { type Metadata } from '@kodadot1/minimark/common'
import { protocolize } from '@kodadot1/hyperdata'
import type { SetNftMetadataParams, ActionSetNftMetadata } from './types'
import type { Metadata } from '@/services/nftStorage'
import { pinJson, rateLimitedPinFileToIPFS } from '@/services/nftStorage'

const constructMeta = async (item: ActionSetNftMetadata) => {
Expand All @@ -10,7 +10,7 @@ const constructMeta = async (item: ActionSetNftMetadata) => {
let type: string | undefined

if (image instanceof File) {
imageHash = unSanitizeIpfsUrl(await rateLimitedPinFileToIPFS(image))
imageHash = protocolize(await rateLimitedPinFileToIPFS(image))
type = getImageTypeSafe(image)
}
else {
Expand All @@ -29,7 +29,7 @@ const constructMeta = async (item: ActionSetNftMetadata) => {

const metaHash = await pinJson(meta)

return unSanitizeIpfsUrl(metaHash)
return protocolize(metaHash)
}

async function execSetNftMetadataStatmine({ item, api, executeTransaction, isLoading, status }: SetNftMetadataParams) {
Expand Down
6 changes: 3 additions & 3 deletions composables/transaction/transactionUpdateCollection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMetadata, unSanitizeIpfsUrl } from '@kodadot1/minimark/utils'
import { createOpenSeaMetadata as createMetadata, protocolize } from '@kodadot1/hyperdata'
import type { SubmittableExtrinsic } from '@polkadot/api-base/types'
import { uploadMediaFiles } from './mintToken/constructDirectoryMeta'
import type { ActionUpdateCollection, UpdateCollectionParams } from './types'
Expand Down Expand Up @@ -53,11 +53,11 @@ const constructMeta = async (item: ActionUpdateCollection) => {
)

// TODO: add banner field to minimark https://github.com/kodadot/packages/blob/main/minimark/src/utils/metadata.ts#L4
Object.assign(meta, { banner: banner ? unSanitizeIpfsUrl(banner) : '' })
Object.assign(meta, { banner: banner ? protocolize(banner) : '' })

const metaHash = await pinJson(meta as any)

return unSanitizeIpfsUrl(metaHash)
return protocolize(metaHash)
}

async function execUpdateCollectionStatmine({ item, api, executeTransaction, isLoading, status }: UpdateCollectionParams) {
Expand Down
3 changes: 2 additions & 1 deletion composables/transaction/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Attribute, Metadata } from '@kodadot1/minimark/common'
import type { OpenSeaAttribute as Attribute } from '@kodadot1/hyperdata'
import type { Interaction } from '@kodadot1/minimark/v1'
import type { ApiPromise } from '@polkadot/api'
import type { Prefix } from '@kodadot1/static'
Expand All @@ -8,6 +8,7 @@ import type { BaseTokenType } from '@/components/base/types'
import type { Royalty } from '@/utils/royalty'
import type { ShoppingActions } from '@/utils/shoppingActions'
import type { Extrinsic } from '@/utils/transactionExecutor'
import type { Metadata } from '@/services/nftStorage'

type SuccessFunctionMessage = (blockNumber: string) => string
export type ObjectMessage = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/vue-fontawesome": "^3.0.8",
"@kodadot1/brick": "workspace:*",
"@kodadot1/hyperdata": "0.0.1-rc.6",
"@kodadot1/hyperdata": "0.0.2-rc.1",
"@kodadot1/minimark": "^0.1.14-rc.0",
"@kodadot1/minipfs": "0.4.3-rc.1",
"@kodadot1/static": "workspace:*",
Expand Down
Loading

0 comments on commit ff567e3

Please sign in to comment.