Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added pnft feature in x/pnft #673

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
golang.org/x/crypto v0.19.0
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
)

require (
Expand Down Expand Up @@ -171,7 +172,6 @@ require (
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
Expand Down
21 changes: 21 additions & 0 deletions proto/panacea/pnft/v2/denom.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";
package panacea.pnft.v2;

option go_package = "github.com/medibloc/panacea-core/x/pnft/types";
option java_multiple_files = true;

message Denom {
string id = 1;
string name = 2;
string symbol = 3;
string description = 4;
string uri = 5;
string uri_hash = 6;
string owner = 7;
string data = 8;
}

message DenomMeta {
string owner = 1;
string data = 2;
}
19 changes: 19 additions & 0 deletions proto/panacea/pnft/v2/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,23 @@ message EventTransferDenom {
string id = 1;
string sender = 2;
string receiver = 3;
}

message EventMintPNFT {
string denom_id = 1;
string id = 2;
string creator = 3;
}

message EventTransferPNFT {
string denom_id = 1;
string id = 2;
string sender = 3;
string receiver = 4;
}

message EventBurnPNFT {
string denom_id = 1;
string id = 2;
string burner = 3;
}
2 changes: 1 addition & 1 deletion proto/panacea/pnft/v2/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";
package panacea.pnft.v2;

import "panacea/pnft/v2/pnft.proto";
import "panacea/pnft/v2/denom.proto";

option go_package = "github.com/medibloc/panacea-core/x/pnft/types";
option java_multiple_files = true;
Expand Down
35 changes: 25 additions & 10 deletions proto/panacea/pnft/v2/pnft.proto
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
syntax = "proto3";
package panacea.pnft.v2;

import "google/protobuf/timestamp.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/medibloc/panacea-core/x/pnft/types";
option java_multiple_files = true;

message Denom {
string id = 1;
string name = 2;
string symbol = 3;

message PNFT {
string denom_id = 1;
string id = 2;
string name = 3;
string description = 4;
string uri = 5;
string uri_hash = 6;
string owner = 7;
string data = 8;
string data = 7;
string creator = 8;
string owner = 9;
google.protobuf.Timestamp created_at = 10[
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
}

message DenomMeta {
string owner = 1;
string data = 2;
}
message PNFTMeta {
string name = 1;
string description = 2;
string creator = 3;
google.protobuf.Timestamp created_at = 4[
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
string data = 5;
}
60 changes: 53 additions & 7 deletions proto/panacea/pnft/v2/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package panacea.pnft.v2;

import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "panacea/pnft/v2/denom.proto";
import "panacea/pnft/v2/pnft.proto";

option java_multiple_files = true;
Expand All @@ -16,16 +17,29 @@ service QueryService {
"/panacea/pnft/v2/denoms";
}

rpc DenomsByCreator(QueryServiceDenomsByCreatorRequest) returns (QueryServiceDenomsByCreatorResponse) {
rpc DenomsByOwner(QueryServiceDenomsByOwnerRequest) returns (QueryServiceDenomsByOwnerResponse) {
option (google.api.http).get =
"/panacea/pnft/v2/denoms/creators/{creator}";
"/panacea/pnft/v2/denoms/owners/{owner}";
}

// Denom returns denom detail.
rpc Denom(QueryServiceDenomRequest) returns (QueryServiceDenomResponse) {
option (google.api.http).get =
"/panacea/pnft/v2/denoms/{id}";
}

rpc PNFTs(QueryServicePNFTsRequest) returns (QueryServicePNFTsResponse) {
option (google.api.http).get = "/panacea/pnft/v2/denoms/{denom_id}/pnfts";
}

rpc PNFTsByDenomOwner(QueryServicePNFTsByDenomOwnerRequest) returns (QueryServicePNFTsByDenomOwnerResponse) {
option (google.api.http).get = "/panacea/pnft/v2/denoms/{denom_id}/owners/{owner}/pnfts";
}


rpc PNFT(QueryServicePNFTRequest) returns (QueryServicePNFTResponse) {
option (google.api.http).get = "/panacea/pnft/v2/denoms/{denom_id}/pnfts/{id}";
}
}

// QueryServiceDenomsRequest is the response type for the Query RPC method.
Expand All @@ -39,13 +53,13 @@ message QueryServiceDenomsResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryServiceDenomsByCreatorRequest is the response type for the Query RPC method.
message QueryServiceDenomsByCreatorRequest {
string creator = 1;
// QueryServiceDenomsByOwnerRequest is the response type for the Query RPC method.
message QueryServiceDenomsByOwnerRequest {
string owner = 1;
}

// QueryServiceDenomsByCreatorResponse is the response type for the Query RPC method.
message QueryServiceDenomsByCreatorResponse {
// QueryServiceDenomsByOwnerResponse is the response type for the Query RPC method.
message QueryServiceDenomsByOwnerResponse {
repeated panacea.pnft.v2.Denom denoms = 1;
}

Expand All @@ -57,4 +71,36 @@ message QueryServiceDenomRequest {
// QueryServiceDenomResponse is the response type for the Query RPC method.
message QueryServiceDenomResponse {
panacea.pnft.v2.Denom denom = 1;
}

// QueryServicePNFTsRequest is the response type for the Query RPC method.
message QueryServicePNFTsRequest {
string denom_id = 1;
}

// QueryServicePNFTsResponse is the response type for the Query RPC method.
message QueryServicePNFTsResponse {
repeated panacea.pnft.v2.PNFT pnfts = 1;
}

// QueryServicePNFTsRequest is the response type for the Query RPC method.
message QueryServicePNFTsByDenomOwnerRequest {
string denom_id = 1;
string owner = 2;
}

// QueryServicePNFTsResponse is the response type for the Query RPC method.
message QueryServicePNFTsByDenomOwnerResponse {
repeated panacea.pnft.v2.PNFT pnfts = 1;
}

// QueryServicePNFTRequest is the response type for the Query RPC method.
message QueryServicePNFTRequest {
string denom_id = 1;
string id = 2;
}

// QueryServicePNFTResponse is the response type for the Query RPC method.
message QueryServicePNFTResponse {
panacea.pnft.v2.PNFT pnft = 1;
}
38 changes: 37 additions & 1 deletion proto/panacea/pnft/v2/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ service MsgService {
rpc DeleteDenom(MsgServiceDeleteDenomRequest) returns (MsgServiceDeleteDenomResponse);

rpc TransferDenom(MsgServiceTransferDenomRequest) returns (MsgServiceTransferDenomResponse);

rpc MintPNFT(MsgServiceMintPNFTRequest) returns (MsgServiceMintPNFTResponse);

rpc TransferPNFT(MsgServiceTransferPNFTRequest) returns (MsgServiceTransferPNFTResponse);

rpc BurnPNFT(MsgServiceBurnPNFTRequest) returns (MsgServiceBurnPNFTResponse);
}

message MsgServiceCreateDenomRequest {
Expand Down Expand Up @@ -55,4 +61,34 @@ message MsgServiceTransferDenomRequest {
string receiver = 3;
}

message MsgServiceTransferDenomResponse {}
message MsgServiceTransferDenomResponse {}

message MsgServiceMintPNFTRequest {
string denom_id = 1;
string id = 2;
string name = 3;
string description = 4;
string uri = 5;
string uri_hash = 6;
string data = 7;
string creator = 8;
}

message MsgServiceMintPNFTResponse {}

message MsgServiceTransferPNFTRequest {
string denom_id = 1;
string id = 2;
string sender = 3;
string receiver = 4;
}

message MsgServiceTransferPNFTResponse {}

message MsgServiceBurnPNFTRequest {
string denom_id = 1;
string id = 2;
string burner = 3;
}

message MsgServiceBurnPNFTResponse {}
3 changes: 2 additions & 1 deletion proto/scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.16.0
# go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest
# go install github.com/cosmos/gogoproto/protoc-gen-gocosmos@latest
# go get github.com/regen-network/cosmos-proto@latest # doesn't work in install mode
# go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@v0.3.1


set -eo pipefail

Expand Down
5 changes: 5 additions & 0 deletions x/pnft/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ const (
FlagDenomData = "denom-data"
FlagDenomURI = "denom-uri"
FlagDenomURIHash = "denom-uri-hash"
flagPNFTName = "pnft-name"
flagPNFTDescription = "pnft-description"
flagPNFTData = "pnft-data"
flagPNFTUri = "pnft-uri"
flagPNFTUriHash = "pnft-uri-hash"
)
38 changes: 5 additions & 33 deletions x/pnft/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package cli

import (
"context"
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/medibloc/panacea-core/v2/x/pnft/types"
"github.com/spf13/cobra"
)
Expand All @@ -19,38 +17,12 @@ func NewGetQueryCmd() *cobra.Command {
}

cmd.AddCommand(NewCmdGetDenoms())
cmd.AddCommand(NewCmdGetDenomsByOwner())
cmd.AddCommand(NewCmdGetDenom())

return cmd
}

func NewCmdGetDenoms() *cobra.Command {
cmd := &cobra.Command{
Use: "list-denom",
Short: "List all denoms",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
pagination, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

queryClient := types.NewQueryServiceClient(clientCtx)

msg := &types.QueryServiceDenomsRequest{
Pagination: pagination,
}

res, err := queryClient.Denoms(context.Background(), msg)

if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
cmd.AddCommand(NewCmdGetPNFTs())
cmd.AddCommand(NewCmdGetPNFTsByOwner())
cmd.AddCommand(NewCmdGetPNFT())

return cmd
}
Loading
Loading