From e1ea803dfc65349c7f86090dbefb47c2ec993f1c Mon Sep 17 00:00:00 2001 From: chengwenxi Date: Thu, 22 Apr 2021 15:30:37 +0800 Subject: [PATCH] initialize nft structure --- proto/cosmos/nft/v1beta1/genesis.proto | 13 ++++++++ proto/cosmos/nft/v1beta1/nft.proto | 19 +++++++++++ proto/cosmos/nft/v1beta1/query.proto | 46 ++++++++++++++++++++++++++ x/nft/types/nft.go | 11 ++++++ 4 files changed, 89 insertions(+) create mode 100644 proto/cosmos/nft/v1beta1/genesis.proto create mode 100644 proto/cosmos/nft/v1beta1/nft.proto create mode 100644 proto/cosmos/nft/v1beta1/query.proto create mode 100644 x/nft/types/nft.go diff --git a/proto/cosmos/nft/v1beta1/genesis.proto b/proto/cosmos/nft/v1beta1/genesis.proto new file mode 100644 index 00000000000..e0b70a87783 --- /dev/null +++ b/proto/cosmos/nft/v1beta1/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package cosmos.nft.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/nft/types"; + +// GenesisState defines the NFT module's genesis state +message GenesisState { + repeated google.protobuf.Any nfts = 1 [(cosmos_proto.accepts_interface) = "NFTI", (gogoproto.customname) = "NFTs"]; +} diff --git a/proto/cosmos/nft/v1beta1/nft.proto b/proto/cosmos/nft/v1beta1/nft.proto new file mode 100644 index 00000000000..f5fd58779ab --- /dev/null +++ b/proto/cosmos/nft/v1beta1/nft.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package cosmos.nft.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/nft/types"; +option (gogoproto.goproto_getters_all) = false; + +// BaseNFT defines a base NFT type. +message BaseNFT { + option (gogoproto.equal) = true; + + string id = 1; + string name = 2; + string uri = 3 [(gogoproto.customname) = "URI"]; + string data = 4; + string owner = 5; +} \ No newline at end of file diff --git a/proto/cosmos/nft/v1beta1/query.proto b/proto/cosmos/nft/v1beta1/query.proto new file mode 100644 index 00000000000..6ffe11f22fb --- /dev/null +++ b/proto/cosmos/nft/v1beta1/query.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; +package cosmos.nft.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/nft/types"; + +// Query defines the gRPC querier service for NFT module +service Query { + + // NFT queries NFT details based on id. + rpc NFT(QueryNFTRequest) returns (QueryNFTResponse) { + option (google.api.http).get = "/cosmos/nft/v1beta1/nfts/{id}"; + } + + // NFTs queries all proposals based on the optional onwer. + rpc NFTs(QueryNFTsRequest) returns (QueryNFTsResponse) { + option (google.api.http).get = "/cosmos/nft/v1beta1/nfts"; + } +} + +// QueryNFTRequest is the request type for the Query/NFT RPC method +message QueryNFTRequest { + string id = 1; +} + +// QueryNFTResponse is the response type for the Query/NFT RPC method +message QueryNFTResponse { + google.protobuf.Any nft = 1 [(cosmos_proto.accepts_interface) = "NFTI", (gogoproto.customname) = "NFT"]; +} + +// QueryNFTsRequest is the request type for the Query/NFTs RPC method +message QueryNFTsRequest { + string owner = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryNFTsResponse is the response type for the Query/NFTs RPC method +message QueryNFTsResponse { + repeated google.protobuf.Any nfts = 1 [(cosmos_proto.accepts_interface) = "NFTI", (gogoproto.customname) = "NFTs"]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} \ No newline at end of file diff --git a/x/nft/types/nft.go b/x/nft/types/nft.go new file mode 100644 index 00000000000..f184b61121e --- /dev/null +++ b/x/nft/types/nft.go @@ -0,0 +1,11 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// NFTI is an interface used to store NFTs at a given id and owner. +type NFTI interface { + GetId() string // can not return empty string. + GetOwner() sdk.AccAddress +}