Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tags on RMRK NFTs #3792

Merged
merged 9 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions components/bsx/Create/CreateCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ export default class CreateCollection extends mixins(

const imageHash = await pinImageSafe(file, pinningKey.token)
const type = getImageTypeSafe(file)
const attributes = this.attributes
.map((val) => ({
...val,
display_type: null,
}))
.filter((item) => item.trait_type || item.display_type)
const attributes = this.attributes.map((val) => ({
...val,
display_type: null,
}))

const meta = createMetadata(
name,
description,
Expand Down
2 changes: 1 addition & 1 deletion components/bsx/Create/CreateToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export default class CreateToken extends mixins(
...(this.attributes || []),
...nsfwAttribute(this.nsfw),
...offsetAttribute(this.hasCarbonOffset),
].filter((attribute) => attribute.display_type || attribute.trait_type)
]

const meta = createMetadata(
name,
Expand Down
2 changes: 1 addition & 1 deletion components/rmrk/Create/CreateToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export default class CreateToken extends mixins(
...(this.tags || []),
...nsfwAttribute(this.nsfw),
...offsetAttribute(this.hasCarbonOffset),
].filter((item) => item.trait_type || item.display_type)
]

const meta = createMetadata(
name,
Expand Down
6 changes: 6 additions & 0 deletions components/rmrk/Gallery/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
v-if="!isLoading"
:text="meta.description.replaceAll('\n', ' \n')" />
</div>
<div v-if="meta.attributes && meta.attributes.length" class="block">
<Properties :attributes="meta.attributes" field-key="trait_type" />
</div>
</div>

<div v-if="detailVisible" class="column is-6">
Expand Down Expand Up @@ -190,6 +193,7 @@ import AvailableActions from './AvailableActions.vue'
Appreciation: () => import('@/components/rmrk/Gallery/Appreciation.vue'),
MediaResolver: () => import('@/components/media/MediaResolver.vue'),
IndexerGuard: () => import('@/components/shared/wrapper/IndexerGuard.vue'),
Properties: () => import('@/components/unique/Gallery/Item/Properties.vue'),
DescriptionWrapper: () =>
import('@/components/shared/collapse/DescriptionWrapper.vue'),
Detail: () => import('@/components/unique/Gallery/Item/Detail.vue'),
Expand Down Expand Up @@ -368,6 +372,8 @@ export default class GalleryItem extends mixins(PrefixMixin) {
),
}

console.log('jarsen this', this.meta)

Jarsen136 marked this conversation as resolved.
Show resolved Hide resolved
if (this.meta.animation_url && !this.mimeType) {
const { mimeType, imageVisible } = await processMedia(
this.meta.animation_url
Expand Down
24 changes: 8 additions & 16 deletions components/unique/Create/CreateCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ export default class CreateCollection extends mixins(
? IPFS_KODADOT_IMAGE_PLACEHOLDER
: await pinFileToIPFS(file, pinningKey.token)
const type = !file ? 'image/png' : file.type
const attributes = this.attributes
.map((val) => ({
...val,
display_type: null,
}))
.filter((item) => item.trait_type || item.display_type)
const attributes = this.attributes.map((val) => ({
...val,
display_type: null,
}))

const meta = createMetadata(
name,
description,
Expand Down Expand Up @@ -162,16 +161,9 @@ export default class CreateCollection extends mixins(
const create = api.tx.uniques.create(randomId, this.accountId)
// Option to freeze metadata
const meta = api.tx.uniques.setClassMetadata(randomId, metadata, false)
const attributes = this.attributes
.filter((item) => item.trait_type || item.display_type)
.map((a) =>
api.tx.uniques.setAttribute(
randomId,
null,
a.trait_type,
String(a.value)
)
)
const attributes = this.attributes.map((a) =>
api.tx.uniques.setAttribute(randomId, null, a.trait_type, String(a.value))
)

return [create, meta, ...attributes]
}
Expand Down
16 changes: 7 additions & 9 deletions components/unique/Create/CreateToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,14 @@ export default class CreateToken extends mixins(
metadata,
false
)
const attributes = this.attributes
.filter((item) => item.trait_type || item.display_type)
.map((a) =>
api.tx.uniques.setAttribute(
collectionId,
String(nextId),
a.trait_type,
String(a.value)
)
const attributes = this.attributes.map((a) =>
api.tx.uniques.setAttribute(
collectionId,
String(nextId),
a.trait_type,
String(a.value)
)
)

const support = await canSupport(api, this.hasSupport)
//
Expand Down
9 changes: 8 additions & 1 deletion components/unique/Gallery/Item/Properties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export default class Properties extends Vue {
@Prop({ type: String, default: 'key' }) private fieldKey!: string

get displayAttributes() {
return this.attributes.filter((attribute) => attribute[this.fieldKey])
return this.attributes
.map((attr) => {
return {
[this.fieldKey]: '',
...attr,
}
})
.filter((attribute) => attribute[this.fieldKey] || attribute.value)
}

get columns() {
Expand Down