Skip to content

Commit

Permalink
Merge pull request #6 from OmniFlix/onft-new-updates
Browse files Browse the repository at this point in the history
Updated onft module (#6)
  • Loading branch information
harish551 authored Nov 16, 2021
2 parents ed0bc90 + 82d54f4 commit bda7c33
Show file tree
Hide file tree
Showing 41 changed files with 6,302 additions and 1,226 deletions.
2 changes: 1 addition & 1 deletion app/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

const (
AccountAddressPrefix = "onft"
AccountAddressPrefix = "cosmos"
)

var (
Expand Down
74 changes: 43 additions & 31 deletions client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,60 @@ import (
)

const (
FlagONFTName = "name"
FlagONFTDescription = "description"
FlagONFTMediaURI = "media-uri"
FlagONFTPreviewURI = "preview-uri"
FlagONFTType = "type"
FlagName = "name"
FlagDescription = "description"
FlagMediaURI = "media-uri"
FlagPreviewURI = "preview-uri"
FlagData = "data"
FlagTransferable = "transferable"
FlagRecipient = "recipient"
FlagOwner = "owner"
FlagDenomName = "name"
FlagDenom = "denom"
FlagSchema = "schema"
FlagExtensible = "extensible"
FlagRecipient = "recipient"
FlagOwner = "owner"
FlagDenomID = "denom-id"
FlagSchema = "schema"
)

var (
FsCreateDenom = flag.NewFlagSet("", flag.ContinueOnError)
FsMintONFT = flag.NewFlagSet("", flag.ContinueOnError)
FsEditONFT = flag.NewFlagSet("", flag.ContinueOnError)
FsTransferONFT = flag.NewFlagSet("", flag.ContinueOnError)
FsQuerySupply = flag.NewFlagSet("", flag.ContinueOnError)
FsQueryOwner = flag.NewFlagSet("", flag.ContinueOnError)
FsCreateDenom = flag.NewFlagSet("", flag.ContinueOnError)
FsUpdateDenom = flag.NewFlagSet("", flag.ContinueOnError)
FsTransferDenom = flag.NewFlagSet("", flag.ContinueOnError)
FsMintONFT = flag.NewFlagSet("", flag.ContinueOnError)
FsEditONFT = flag.NewFlagSet("", flag.ContinueOnError)
FsTransferONFT = flag.NewFlagSet("", flag.ContinueOnError)
FsQuerySupply = flag.NewFlagSet("", flag.ContinueOnError)
FsQueryOwner = flag.NewFlagSet("", flag.ContinueOnError)
)

func init() {
FsCreateDenom.String(FlagSchema, "", "Denom schema")
FsCreateDenom.String(FlagDenomName, "", "Name of the denom")
FsCreateDenom.String(FlagName, "", "Name of the denom")
FsCreateDenom.String(FlagDescription, "", "Description for denom")
FsCreateDenom.String(FlagPreviewURI, "", "Preview image uri for denom")

FsMintONFT.String(FlagONFTMediaURI, "", "Media uri of onft")
FsUpdateDenom.String(FlagName, "[do-not-modify]", "Name of the denom")
FsUpdateDenom.String(FlagDescription, "[do-not-modify]", "Description for denom")
FsUpdateDenom.String(FlagPreviewURI, "[do-not-modify]", "Preview image uri for denom")

FsTransferDenom.String(FlagRecipient, "", "recipient of the denom")

FsMintONFT.String(FlagMediaURI, "", "Media uri of onft")
FsMintONFT.String(FlagRecipient, "", "Receiver of the onft. default value is sender address of transaction")
FsMintONFT.String(FlagONFTPreviewURI, "", "Preview uri of onft")
FsMintONFT.String(FlagONFTName, "", "Name of onft")
FsMintONFT.String(FlagONFTDescription, "", "Description of onft")
FsMintONFT.String(FlagONFTType, "video", "type of onft (artwork|audio|video)")
FsMintONFT.String(FlagTransferable, "yes", " transferability of onft (yes|no)")

FsEditONFT.String(FlagONFTMediaURI, "[do-not-modify]", "Media uri of onft")
FsEditONFT.String(FlagONFTPreviewURI, "[do-not-modify]", "Preview uri of onft")
FsEditONFT.String(FlagONFTName, "[do-not-modify]", "Name of nft")
FsEditONFT.String(FlagONFTDescription, "[do-not-modify]", "Description of onft")
FsEditONFT.String(FlagONFTType, "[do-not-modify]", "type of onft")
FsEditONFT.String(FlagTransferable, "[do-not-modify]", "transferability of onft")
FsMintONFT.String(FlagPreviewURI, "", "Preview uri of onft")
FsMintONFT.String(FlagName, "", "Name of onft")
FsMintONFT.String(FlagDescription, "", "Description of onft")
FsMintONFT.String(FlagData, "", "custom data of onft")

FsMintONFT.Bool(FlagTransferable, true, "transferability of onft (true | false)")
FsMintONFT.Bool(FlagExtensible, false, "extensisbility of onft (true | false)")

FsEditONFT.String(FlagMediaURI, "[do-not-modify]", "Media uri of onft")
FsEditONFT.String(FlagPreviewURI, "[do-not-modify]", "Preview uri of onft")
FsEditONFT.String(FlagName, "[do-not-modify]", "Name of nft")
FsEditONFT.String(FlagDescription, "[do-not-modify]", "Description of onft")
FsEditONFT.String(FlagTransferable, "[do-not-modify]", "transferability of onft")
FsEditONFT.String(FlagData, "[do-not-modify]", "custom data of onft")

FsTransferONFT.String(FlagRecipient, "", "Receiver of the onft. default value is sender address of transaction")
FsQuerySupply.String(FlagOwner, "", "The owner of a nft")
}
FsQueryOwner.String(FlagDenomID, "", "id of the denom")
}
76 changes: 64 additions & 12 deletions client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdQueryCollection(),
GetCmdQuerySupply(),
GetCmdQueryONFT(),
GetCmdQueryOwner(),
)

return queryCmd
Expand Down Expand Up @@ -64,8 +65,8 @@ $ %s query onft supply [denom-id]`, version.AppName)),

queryClient := types.NewQueryClient(clientCtx)
resp, err := queryClient.Supply(context.Background(), &types.QuerySupplyRequest{
Denom: denomId,
Owner: owner.String(),
DenomId: denomId,
Owner: owner.String(),
})
if err != nil {
return err
Expand All @@ -79,6 +80,48 @@ $ %s query onft supply [denom-id]`, version.AppName)),
return cmd
}

func GetCmdQueryOwner() *cobra.Command {
cmd := &cobra.Command{
Use: "owner [address]",
Long: "Get the oNFTs owned by an account address.",
Example: fmt.Sprintf("$ %s query onft owner <addr> --denom-id=<denom-id>", version.AppName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

if _, err := sdk.AccAddressFromBech32(args[0]); err != nil {
return err
}
pagination, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}
denomID, err := cmd.Flags().GetString(FlagDenomID)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
resp, err := queryClient.OwnerONFTs(context.Background(), &types.QueryOwnerONFTsRequest{
DenomId: denomID,
Owner: args[0],
Pagination: pagination,
})
if err != nil {
return err
}
return clientCtx.PrintProto(resp)
},
}
cmd.Flags().AddFlagSet(FsQueryOwner)
flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "owner onfts")

return cmd
}

func GetCmdQueryCollection() *cobra.Command {
cmd := &cobra.Command{
Use: "collection [denom-id]",
Expand All @@ -94,11 +137,16 @@ $ %s query onft collection <denom-id>`, version.AppName)),
return err
}

denomId := strings.ToLower(strings.TrimSpace(args[0]))
denomId := args[0]
pagination, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
resp, err := queryClient.Collection(context.Background(), &types.QueryCollectionRequest{
Denom: denomId,
DenomId: denomId,
Pagination: pagination,
})
if err != nil {
return err
Expand All @@ -107,7 +155,7 @@ $ %s query onft collection <denom-id>`, version.AppName)),
},
}
flags.AddQueryFlagsToCmd(cmd)

flags.AddPaginationFlagsToCmd(cmd, "onfts")
return cmd
}

Expand All @@ -124,17 +172,21 @@ $ %s query onft denoms`, version.AppName)),
if err != nil {
return err
}
pagination, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
resp, err := queryClient.Denoms(context.Background(), &types.QueryDenomsRequest{})
resp, err := queryClient.Denoms(context.Background(), &types.QueryDenomsRequest{Pagination: pagination})
if err != nil {
return err
}
return clientCtx.PrintProto(resp)
},
}
flags.AddQueryFlagsToCmd(cmd)

flags.AddPaginationFlagsToCmd(cmd, "denoms")
return cmd
}

Expand All @@ -160,7 +212,7 @@ $ %s query onft denom <denom-id>`, version.AppName)),

queryClient := types.NewQueryClient(clientCtx)
resp, err := queryClient.Denom(context.Background(), &types.QueryDenomRequest{
Denom: denomId,
DenomId: denomId,
})
if err != nil {
return err
Expand Down Expand Up @@ -188,13 +240,13 @@ $ %s query onft asset <denom> <onft-id>`, version.AppName)),
return err
}

denomId := strings.ToLower(strings.TrimSpace(args[0]))
onftId := strings.ToLower(strings.TrimSpace(args[1]))
denomId := args[0]
onftId := args[1]

queryClient := types.NewQueryClient(clientCtx)
resp, err := queryClient.ONFT(context.Background(), &types.QueryONFTRequest{
Denom: denomId,
Id: onftId,
DenomId: denomId,
Id: onftId,
})
if err != nil {
return err
Expand Down
Loading

0 comments on commit bda7c33

Please sign in to comment.