Skip to content

Commit

Permalink
update nft builder (#124)
Browse files Browse the repository at this point in the history
* decode extesisble property from nft transfer packet data

* refactor

* fix lint
  • Loading branch information
harish551 authored Dec 20, 2023
1 parent a0406fc commit 9c492c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
4 changes: 0 additions & 4 deletions cmd/omniflixhubd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/types"
vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
Expand Down Expand Up @@ -94,9 +93,6 @@ func initTendermintConfig() *tmcfg.Config {
}

func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
cfg := sdk.GetConfig()
cfg.Seal()

ac := appCreator{encodingConfig}

rootCmd.AddCommand(
Expand Down
23 changes: 20 additions & 3 deletions x/onft/types/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ var (
nftKeyPreviewURI = fmt.Sprintf("%s%s", Namespace, "preview_uri")
nftKeyDescription = fmt.Sprintf("%s%s", Namespace, "description")
nftKeyCreatedAt = fmt.Sprintf("%s%s", Namespace, "created_at")
nftKeyTransferable = fmt.Sprintf("%s%s", Namespace, "transferable")
nftKeyExtensible = fmt.Sprintf("%s%s", Namespace, "extensible")
nftKeyNSFW = fmt.Sprintf("%s%s", Namespace, "nsfw")
nftKeyRoyaltyShare = fmt.Sprintf("%s%s", Namespace, "royalty_share")
Expand Down Expand Up @@ -275,7 +274,6 @@ func (nb NFTBuilder) BuildMetadata(_nft nft.NFT) (string, error) {
kvals[nftKeyName] = MediaField{Value: nftMetadata.Name}
kvals[nftKeyDescription] = MediaField{Value: nftMetadata.Description}
kvals[nftKeyPreviewURI] = MediaField{Value: nftMetadata.PreviewURI}
kvals[nftKeyTransferable] = MediaField{Value: nftMetadata.Transferable}
kvals[nftKeyExtensible] = MediaField{Value: nftMetadata.Extensible}
kvals[nftKeyNSFW] = MediaField{Value: nftMetadata.Nsfw}
kvals[nftKeyCreatedAt] = MediaField{Value: nftMetadata.CreatedAt}
Expand Down Expand Up @@ -319,6 +317,7 @@ func (nb NFTBuilder) Build(classId, nftID, nftURI, nftData string) (nft.NFT, err
description string
previewURI string
nsfw = false
extensible = true
createdAt string
royaltyShare string
uriHash string
Expand Down Expand Up @@ -367,6 +366,24 @@ func (nb NFTBuilder) Build(classId, nftID, nftURI, nftData string) (nft.NFT, err
}
}

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 {
if vBool, ok := vMap[KeyMediaFieldValue].(bool); ok {
nsfw = vBool
delete(dataMap, nftKeyNSFW)
}
}
}

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

0 comments on commit 9c492c0

Please sign in to comment.