Skip to content

Commit

Permalink
fix unsupported data format issue (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 authored Dec 5, 2023
1 parent d04d607 commit e7c5be9
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions x/onft/types/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ func (nb NFTBuilder) Build(classId, nftID, nftURI, nftData string) (nft.NFT, err
dataMap := make(map[string]interface{})
if err := json.Unmarshal(nftDataBz, &dataMap); err != nil {
metadata, err := codectypes.NewAnyWithValue(&ONFTMetadata{
Data: string(nftDataBz),
Data: string(nftDataBz),
Transferable: true,
Extensible: true,
})
if err != nil {
return nft.NFT{}, err
Expand All @@ -316,13 +318,12 @@ func (nb NFTBuilder) Build(classId, nftID, nftURI, nftData string) (nft.NFT, err
name string
description string
previewURI string
transferable = true
extensible = true
nsfw = false
createdAt string
royaltyShare string
uriHash string
)

if v, ok := dataMap[nftKeyName]; ok {
if vMap, ok := v.(map[string]interface{}); ok {
if vStr, ok := vMap[KeyMediaFieldValue].(string); ok {
Expand Down Expand Up @@ -365,23 +366,6 @@ func (nb NFTBuilder) Build(classId, nftID, nftURI, nftData string) (nft.NFT, err
}
}
}
if v, ok := dataMap[nftKeyTransferable]; ok {
if vMap, ok := v.(map[string]interface{}); ok {
if vBool, ok := vMap[KeyMediaFieldValue].(bool); ok {
transferable = vBool
delete(dataMap, nftKeyTransferable)
}
}
}

if v, ok := dataMap[nftKeyExtensible]; ok {
if vMap, ok := v.(map[string]interface{}); ok {
if vBool, ok := vMap[KeyMediaFieldValue].(bool); ok {
extensible = vBool
delete(dataMap, nftKeyExtensible)
}
}
}

if v, ok := dataMap[nftKeyNSFW]; ok {
if vMap, ok := v.(map[string]interface{}); ok {
Expand Down Expand Up @@ -417,8 +401,8 @@ func (nb NFTBuilder) Build(classId, nftID, nftURI, nftData string) (nft.NFT, err
Description: description,
PreviewURI: previewURI,
Data: data,
Transferable: transferable,
Extensible: extensible,
Transferable: true,
Extensible: true,
Nsfw: nsfw,
CreatedAt: createdTime,
RoyaltyShare: royalty,
Expand Down

0 comments on commit e7c5be9

Please sign in to comment.