Skip to content

Commit bccb944

Browse files
authored
Merge pull request #3358 from kodadot/nft-storage
NFT Storage is here
2 parents 086bd3b + 92a2f73 commit bccb944

File tree

14 files changed

+170
-31
lines changed

14 files changed

+170
-31
lines changed

components/bsx/Create/CreateCollection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import ChainMixin from '@/utils/mixins/chainMixin'
4444
import MetaTransactionMixin from '@/utils/mixins/metaMixin'
4545
import PrefixMixin from '@/utils/mixins/prefixMixin'
4646
import { notificationTypes, showNotification } from '@/utils/notification'
47-
import { pinJson, PinningKey } from '@/utils/pinning'
47+
import { pinJson, PinningKey } from '@/utils/nftStorage'
4848
import resolveQueryPath from '@/utils/queryPathResolver'
4949
import { getImageTypeSafe, pinImageSafe } from '@/utils/safePin'
5050
import { estimate } from '@/utils/transactionExecutor'

components/bsx/Create/CreateToken.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import {
6363
} from '@/components/rmrk/Create/mintUtils'
6464
import ChainMixin from '@/utils/mixins/chainMixin'
6565
import { notificationTypes, showNotification } from '@/utils/notification'
66-
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/pinning'
66+
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/nftStorage'
6767
import shouldUpdate from '@/utils/shouldUpdate'
6868
import {
6969
Attribute,
@@ -80,14 +80,20 @@ import {
8080
} from '@/components/unique/apiConstants'
8181
import { createTokenId } from '@/components/unique/utils'
8282
import onApiConnect from '@/utils/api/general'
83-
import { IPFS_KODADOT_IMAGE_PLACEHOLDER } from '@/utils/constants'
83+
import {
84+
DETAIL_TIMEOUT,
85+
IPFS_KODADOT_IMAGE_PLACEHOLDER,
86+
} from '@/utils/constants'
8487
import AuthMixin from '@/utils/mixins/authMixin'
8588
import MetaTransactionMixin from '@/utils/mixins/metaMixin'
8689
import PrefixMixin from '@/utils/mixins/prefixMixin'
8790
import resolveQueryPath from '@/utils/queryPathResolver'
8891
import { unwrapSafe } from '@/utils/uniquery'
8992
import { isRoyaltyValid, Royalty } from '@/utils/royalty'
90-
import { fetchCollectionMetadata } from '~/components/rmrk/utils'
93+
import {
94+
fetchCollectionMetadata,
95+
preheatFileFromIPFS,
96+
} from '~/components/rmrk/utils'
9197
import { getMany, update } from 'idb-keyval'
9298
9399
type MintedCollection = BaseMintedCollection & {
@@ -337,18 +343,22 @@ export default class CreateToken extends mixins(
337343
file.type
338344
)
339345
346+
preheatFileFromIPFS(fileHash)
347+
// uploadDirect(file, this.accountId).catch(this.$consola.warn)
340348
const metaHash = await pinJson(meta, imageHash)
341349
return unSanitizeIpfsUrl(metaHash)
342350
}
343351
344352
protected navigateToDetail(collection: string, id: string): void {
345-
showNotification('You will go to the detail in 2 seconds')
353+
showNotification(
354+
`You will go to the detail in ${DETAIL_TIMEOUT / 1000} seconds`
355+
)
346356
const go = () =>
347357
this.$router.push({
348358
path: `/${this.urlPrefix}/gallery/${createTokenId(collection, id)}`,
349359
query: { message: 'congrats' },
350360
})
351-
setTimeout(go, 2000)
361+
setTimeout(go, DETAIL_TIMEOUT)
352362
}
353363
}
354364
</script>

components/rmrk/Create/CreateCollection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { unSanitizeIpfsUrl } from '@kodadot1/minimark'
5353
import { generateId } from '@/components/rmrk/service/Consolidator'
5454
import { canSupport } from '@/utils/support'
5555
import MetaTransactionMixin from '@/utils/mixins/metaMixin'
56-
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/pinning'
56+
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/nftStorage'
5757
import { uploadDirect } from '@/utils/directUpload'
5858
import AuthMixin from '@/utils/mixins/authMixin'
5959
import {

components/rmrk/Create/CreateToken.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import ChainMixin from '@/utils/mixins/chainMixin'
5454
import MetaTransactionMixin from '@/utils/mixins/metaMixin'
5555
import RmrkVersionMixin from '@/utils/mixins/rmrkVersionMixin'
5656
import { notificationTypes, showNotification } from '@/utils/notification'
57-
import { pinFileToIPFS, PinningKey, pinJson } from '@/utils/pinning'
57+
import { pinFileToIPFS, PinningKey, pinJson } from '@/utils/nftStorage'
5858
import shouldUpdate from '@/utils/shouldUpdate'
5959
import { canSupport } from '@/utils/support'
6060
import {
@@ -71,7 +71,10 @@ import { formatBalance } from '@polkadot/util'
7171
import Connector from '@kodadot1/sub-api'
7272
import { Component, mixins, Watch } from 'nuxt-property-decorator'
7373
import { BaseMintedCollection, BaseTokenType } from '~/components/base/types'
74-
import { IPFS_KODADOT_IMAGE_PLACEHOLDER } from '~/utils/constants'
74+
import {
75+
DETAIL_TIMEOUT,
76+
IPFS_KODADOT_IMAGE_PLACEHOLDER,
77+
} from '~/utils/constants'
7578
import AuthMixin from '~/utils/mixins/authMixin'
7679
import PrefixMixin from '~/utils/mixins/prefixMixin'
7780
import { basicUpdateFunction } from '../service/NftUtils'
@@ -82,6 +85,7 @@ import {
8285
secondaryFileVisible,
8386
} from './mintUtils'
8487
import { uploadDirect } from '~/utils/directUpload'
88+
import { preheatFileFromIPFS } from '../utils'
8589
8690
type MintedCollection = BaseMintedCollection & {
8791
name: string
@@ -288,6 +292,7 @@ export default class CreateToken extends mixins(
288292
)
289293
290294
const metaHash = await pinJson(meta, imageHash)
295+
preheatFileFromIPFS(fileHash)
291296
uploadDirect(file, metaHash).catch(this.$consola.warn)
292297
return unSanitizeIpfsUrl(metaHash)
293298
}
@@ -340,13 +345,15 @@ export default class CreateToken extends mixins(
340345
}
341346
342347
protected navigateToDetail(nft: CreatedNFT, blockNumber: string) {
343-
showNotification('You will go to the detail in 2 seconds')
348+
showNotification(
349+
`You will go to the detail in ${DETAIL_TIMEOUT / 1000} seconds`
350+
)
344351
const go = () =>
345352
this.$router.push({
346353
path: `/rmrk/detail/${toNFTId(nft, blockNumber)}`,
347354
query: { message: 'congrats' },
348355
})
349-
setTimeout(go, 2000)
356+
setTimeout(go, DETAIL_TIMEOUT)
350357
}
351358
}
352359
</script>

components/rmrk/Create/CreativeMint.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import { emptyObject } from '@/utils/empty'
6363
import ChainMixin from '@/utils/mixins/chainMixin'
6464
import RmrkVersionMixin from '@/utils/mixins/rmrkVersionMixin'
6565
import { notificationTypes, showNotification } from '@/utils/notification'
66-
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/pinning'
66+
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/nftStorage'
6767
import {
6868
basicUpdateNameFunction,
6969
createCollection,
@@ -85,6 +85,7 @@ import { getNftId, NFT, NFTMetadata, SimpleNFT } from '../service/scheme'
8585
import { MediaType } from '../types'
8686
import { resolveMedia, sanitizeIpfsUrl } from '../utils'
8787
import { askGpt } from '@/utils/gpt'
88+
import { DETAIL_TIMEOUT } from '~/utils/constants'
8889
8990
const components = {
9091
AuthField: () => import('@/components/shared/form/AuthField.vue'),
@@ -242,13 +243,15 @@ export default class CreativeMint extends mixins(
242243
}
243244
244245
protected navigateToDetail(nft: NFT, blockNumber: string) {
245-
showNotification('You will go to the detail in 2 seconds')
246+
showNotification(
247+
`You will go to the detail in ${DETAIL_TIMEOUT / 1000} seconds`
248+
)
246249
const go = () =>
247250
this.$router.push({
248251
path: `/rmrk/detail/${getNftId(nft, blockNumber)}`,
249252
query: { message: 'congrats' },
250253
})
251-
setTimeout(go, 2000)
254+
setTimeout(go, DETAIL_TIMEOUT)
252255
}
253256
254257
@Watch('file')

components/rmrk/Create/SimpleMint.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,12 @@ import {
193193
shuffleFunction,
194194
toDistribute,
195195
} from '@/components/accounts/utils'
196-
import { PinningKey, pinFileToIPFS, pinJson } from '@/utils/pinning'
196+
import { PinningKey, pinFileToIPFS, pinJson } from '@/utils/nftStorage'
197197
import { uploadDirect } from '@/utils/directUpload'
198-
import { IPFS_KODADOT_IMAGE_PLACEHOLDER } from '~/utils/constants'
198+
import {
199+
DETAIL_TIMEOUT,
200+
IPFS_KODADOT_IMAGE_PLACEHOLDER,
201+
} from '~/utils/constants'
199202
import { createMetadata, findUniqueSymbol } from '@kodadot1/minimark'
200203
import Vue from 'vue'
201204
import PrefixMixin from '~/utils/mixins/prefixMixin'
@@ -783,13 +786,15 @@ export default class SimpleMint extends mixins(
783786
}
784787
785788
protected navigateToDetail(nft: NFT, blockNumber: string) {
786-
showNotification('You will go to the detail in 2 seconds')
789+
showNotification(
790+
`You will go to the detail in ${DETAIL_TIMEOUT / 1000} seconds`
791+
)
787792
const go = () =>
788793
this.$router.push({
789794
path: `/rmrk/detail/${getNftId(nft, blockNumber)}`,
790795
query: { message: 'congrats' },
791796
})
792-
setTimeout(go, 2000)
797+
setTimeout(go, DETAIL_TIMEOUT)
793798
}
794799
795800
protected getUsdFromKsm() {

components/rmrk/utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { NFTMetadata, Collection, NFT, NFTWithMeta } from './service/scheme'
99
import { before } from '@/utils/math'
1010
import { justHash, Interaction } from '@kodadot1/minimark'
1111
import { logError } from '@/utils/mappers'
12+
import consola from 'consola'
13+
import { fastExtract } from '~/utils/ipfs'
1214

1315
export const SQUARE = '::'
1416
export const DEFAULT_IPFS_PROVIDER = 'https://ipfs.io/'
@@ -101,6 +103,15 @@ export const fetchMetadata = async <T>(
101103
return emptyObject<T>()
102104
}
103105

106+
export const preheatFileFromIPFS = async (ipfsUrl: string) => {
107+
const url = sanitizeIpfsUrl(ipfsUrl, 'pinata')
108+
const hash = fastExtract(url)
109+
api
110+
.get(url)
111+
.then(() => consola.log(`[PREHEAT] ${hash}`))
112+
.catch((err) => consola.warn(`[PREHEAT] ${hash} ${err.message}`))
113+
}
114+
104115
export const unSanitizeArweaveId = (url: string): string => {
105116
return unSanitizeUrl(url, 'ar://')
106117
}

components/unique/Create/CreateCollection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { unSanitizeIpfsUrl } from '@kodadot1/minimark'
3434
import AuthMixin from '@/utils/mixins/authMixin'
3535
import MetaTransactionMixin from '@/utils/mixins/metaMixin'
3636
import { notificationTypes, showNotification } from '@/utils/notification'
37-
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/pinning'
37+
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/nftStorage'
3838
import { canSupport } from '@/utils/support'
3939
import { estimate, Extrinsic } from '@/utils/transactionExecutor'
4040
import { createMetadata } from '@kodadot1/minimark'

components/unique/Create/CreateToken.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import collectionForMint from '@/queries/unique/collectionForMint.graphql'
5757
import { unSanitizeIpfsUrl } from '@kodadot1/minimark'
5858
import ChainMixin from '@/utils/mixins/chainMixin'
5959
import { notificationTypes, showNotification } from '@/utils/notification'
60-
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/pinning'
60+
import { pinFileToIPFS, pinJson, PinningKey } from '@/utils/nftStorage'
6161
import shouldUpdate from '@/utils/shouldUpdate'
6262
import { canSupport } from '@/utils/support'
6363
import { createMetadata } from '@kodadot1/minimark'
@@ -67,7 +67,10 @@ import { getMany, update } from 'idb-keyval'
6767
import { BaseMintedCollection, BaseTokenType } from '~/components/base/types'
6868
import { fetchCollectionMetadata } from '~/components/rmrk/utils'
6969
import onApiConnect from '~/utils/api/general'
70-
import { IPFS_KODADOT_IMAGE_PLACEHOLDER } from '~/utils/constants'
70+
import {
71+
DETAIL_TIMEOUT,
72+
IPFS_KODADOT_IMAGE_PLACEHOLDER,
73+
} from '~/utils/constants'
7174
import AuthMixin from '~/utils/mixins/authMixin'
7275
import MetaTransactionMixin from '~/utils/mixins/metaMixin'
7376
import PrefixMixin from '~/utils/mixins/prefixMixin'
@@ -310,13 +313,15 @@ export default class CreateToken extends mixins(
310313
}
311314
312315
protected navigateToDetail(collection: string, id: string): void {
313-
showNotification('You will go to the detail in 2 seconds')
316+
showNotification(
317+
`You will go to the detail in ${DETAIL_TIMEOUT / 1000} seconds`
318+
)
314319
const go = () =>
315320
this.$router.push({
316321
path: `/${this.urlPrefix}/gallery/${createTokenId(collection, id)}`,
317322
query: { message: 'congrats' },
318323
})
319-
setTimeout(go, 2000)
324+
setTimeout(go, DETAIL_TIMEOUT)
320325
}
321326
}
322327
</script>

langDir/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@
502502
"submit": "Submit {0}"
503503
},
504504
"properties": {
505-
"label": "Properties"
505+
"label": "Traits"
506506
},
507507
"offer": {
508508
"label": "Offers ({0})",

0 commit comments

Comments
 (0)