Skip to content

Commit

Permalink
[Supplier] Scaffold the Claim type (#149)
Browse files Browse the repository at this point in the history
Ran the following command and nothing else:
```
ignite scaffold map claim --module supplier supplier_address session_id root_hash --no-message --yes
```


---

Co-authored-by: Bryan White <[email protected]>
Co-authored-by: harry <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2023
1 parent b3802b1 commit a4fa181
Show file tree
Hide file tree
Showing 20 changed files with 1,563 additions and 777 deletions.
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.
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

0 comments on commit a4fa181

Please sign in to comment.