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

[Supplier] Scaffold the Claim type #149

Merged
merged 18 commits into from
Nov 8, 2023
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
1,654 changes: 892 additions & 762 deletions docs/static/openapi.yml

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions proto/pocket/application/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ service Query {
// Parameters queries the parameters of the module.
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/pocket/application/params";

}

// Queries a list of Application items.
rpc Application (QueryGetApplicationRequest) returns (QueryGetApplicationResponse) {
option (google.api.http).get = "/pocket/application/application/{address}";

}
rpc ApplicationAll (QueryAllApplicationRequest) returns (QueryAllApplicationResponse) {
option (google.api.http).get = "/pocket/application/application";

}
}
// QueryParamsRequest is request type for the Query/Params RPC method.
Expand Down
5 changes: 1 addition & 4 deletions proto/pocket/gateway/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ service Query {
// Parameters queries the parameters of the module.
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/pocket/gateway/params";

}

// Queries a list of Gateway items.
rpc Gateway (QueryGetGatewayRequest) returns (QueryGetGatewayResponse) {
rpc Gateway (QueryGetGatewayRequest) returns (QueryGetGatewayResponse) {
option (google.api.http).get = "/pocket/gateway/gateway/{address}";

}
rpc GatewayAll (QueryAllGatewayRequest) returns (QueryAllGatewayResponse) {
option (google.api.http).get = "/pocket/gateway/gateway";

}
}
// QueryParamsRequest is request type for the Query/Params RPC method.
Expand Down
2 changes: 0 additions & 2 deletions proto/pocket/session/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ service Query {
// Parameters queries the parameters of the module.
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/pocket/session/params";

}

// Queries a list of GetSession items.
rpc GetSession (QueryGetSessionRequest) returns (QueryGetSessionResponse) {
option (google.api.http).get = "/pocket/session/get_session";

}
}
// QueryParamsRequest is request type for the Query/Params RPC method.
Expand Down
14 changes: 14 additions & 0 deletions proto/pocket/supplier/claim.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package pocket.supplier;

option go_package = "github.com/pokt-network/poktroll/x/supplier/types";

// TODO_UPNEXT(@Olshansk): The structure below is the default (untouched) scaffolded type. Update
// and productionize it for our use case.
message Claim {
string index = 1;
string supplier_address = 2;
string session_id = 3;
string root_hash = 4;
}

5 changes: 4 additions & 1 deletion proto/pocket/supplier/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ package pocket.supplier;
import "gogoproto/gogo.proto";
import "pocket/supplier/params.proto";
import "pocket/shared/supplier.proto";
import "pocket/supplier/claim.proto";

option go_package = "github.com/pokt-network/poktroll/x/supplier/types";

// GenesisState defines the supplier module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
Params params = 1 [(gogoproto.nullable) = false];
repeated pocket.shared.Supplier supplierList = 2 [(gogoproto.nullable) = false];
// TODO_UPNEXT(@Olshansk): Delete `claimList` from the genesis state.
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
repeated Claim claimList = 3 [(gogoproto.nullable) = false];
}

31 changes: 26 additions & 5 deletions proto/pocket/supplier/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "pocket/supplier/params.proto";
import "pocket/shared/supplier.proto";
import "pocket/supplier/claim.proto";

option go_package = "github.com/pokt-network/poktroll/x/supplier/types";

Expand All @@ -16,25 +17,29 @@ service Query {
// Parameters queries the parameters of the module.
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/pocket/supplier/params";

}

// Queries a list of Supplier items.
rpc Supplier (QueryGetSupplierRequest) returns (QueryGetSupplierResponse) {
rpc Supplier (QueryGetSupplierRequest) returns (QueryGetSupplierResponse) {
option (google.api.http).get = "/pocket/supplier/supplier/{address}";

}
rpc SupplierAll (QueryAllSupplierRequest) returns (QueryAllSupplierResponse) {
option (google.api.http).get = "/pocket/supplier/supplier";
}

// Queries a list of Claim items.
rpc Claim (QueryGetClaimRequest) returns (QueryGetClaimResponse) {
option (google.api.http).get = "/pocket/supplier/claim/{index}";
}
rpc AllClaims (QueryAllClaimsRequest) returns (QueryAllClaimsResponse) {
option (google.api.http).get = "/pocket/supplier/claim";
}
}
// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {

// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}
Expand All @@ -52,7 +57,23 @@ message QueryAllSupplierRequest {
}

message QueryAllSupplierResponse {
repeated pocket.shared.Supplier supplier = 1 [(gogoproto.nullable) = false];
repeated pocket.shared.Supplier supplier = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

message QueryGetClaimRequest {
string index = 1;
}

message QueryGetClaimResponse {
Claim claim = 1 [(gogoproto.nullable) = false];
}

message QueryAllClaimsRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllClaimsResponse {
repeated Claim claim = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
2 changes: 2 additions & 0 deletions x/supplier/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
cmd.AddCommand(CmdQueryParams())
cmd.AddCommand(CmdListSupplier())
cmd.AddCommand(CmdShowSupplier())
cmd.AddCommand(CmdListClaim())
cmd.AddCommand(CmdShowClaim())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
84 changes: 84 additions & 0 deletions x/supplier/client/cli/query_claim.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package cli

import (
"strconv"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"

"github.com/pokt-network/poktroll/x/supplier/types"
)

// Prevent strconv unused error
var _ = strconv.IntSize

func CmdListClaim() *cobra.Command {
cmd := &cobra.Command{
Use: "list-claims",
Short: "list all claims",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryAllClaimsRequest{
Pagination: pageReq,
}

res, err := queryClient.AllClaims(cmd.Context(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
flags.AddQueryFlagsToCmd(cmd)

return cmd
}

func CmdShowClaim() *cobra.Command {
cmd := &cobra.Command{
Use: "show-claim <index>",
Short: "shows a claim",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

argIndex := args[0]

params := &types.QueryGetClaimRequest{
Index: argIndex,
}

res, err := queryClient.Claim(cmd.Context(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading