Skip to content

Commit

Permalink
Merge pull request #3792 from Jarsen136/issue-3765
Browse files Browse the repository at this point in the history
fix: Tags on RMRK NFTs
  • Loading branch information
yangwao authored Aug 25, 2022
2 parents b4c721c + 6e1d606 commit 170a269
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
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
4 changes: 4 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/shared/gallery/Properties.vue'),
DescriptionWrapper: () =>
import('@/components/shared/collapse/DescriptionWrapper.vue'),
Detail: () => import('@/components/unique/Gallery/Item/Detail.vue'),
Expand Down
11 changes: 9 additions & 2 deletions components/shared/gallery/Properties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
:key="attribute[fieldKey]"
class="column is-4">
<div class="notification is-primary is-light">
<div class="is-size-7 has-text-grey-lighter is-uppercase">
{{ attribute[fieldKey] }}
<div
class="is-size-7 has-text-grey-lighter is-uppercase properties-attribute-key">
{{ attribute[fieldKey] === 'undefined' ? '' : attribute[fieldKey] }}
</div>
<div class="is-size-5 has-text-white">{{ attribute.value }}</div>
</div>
Expand All @@ -33,3 +34,9 @@ export default class Properties extends Vue {
@Prop({ type: String, default: 'trait_type' }) public fieldKey!: string
}
</script>
<style>
.properties-attribute-key {
min-height: 18px;
}
</style>
>
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

0 comments on commit 170a269

Please sign in to comment.